1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
25 #include "MEDFileFieldOverView.hxx"
27 #include "MEDCouplingFieldDouble.hxx"
28 #include "MEDCouplingFieldDiscretization.hxx"
30 #include "InterpKernelAutoPtr.hxx"
31 #include "CellModel.hxx"
36 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
37 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
38 extern med_geometry_type typmainoeud[1];
39 extern med_geometry_type typmai3[34];
41 using namespace ParaMEDMEM;
43 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
44 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
46 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
48 return new MEDFileFieldLoc(fid,locName);
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
53 return new MEDFileFieldLoc(fid,id);
56 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
58 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
61 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
63 med_geometry_type geotype;
64 med_geometry_type sectiongeotype;
66 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
67 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
68 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
69 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
70 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
71 _nb_node_per_cell=cm.getNumberOfNodes();
72 _ref_coo.resize(_dim*_nb_node_per_cell);
73 _gs_coo.resize(_dim*_nb_gauss_pt);
74 _w.resize(_nb_gauss_pt);
75 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
78 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
80 med_geometry_type geotype;
81 med_geometry_type sectiongeotype;
83 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
84 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
88 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
89 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
90 _nb_node_per_cell=cm.getNumberOfNodes();
91 _ref_coo.resize(_dim*_nb_node_per_cell);
92 _gs_coo.resize(_dim*_nb_gauss_pt);
93 _w.resize(_nb_gauss_pt);
94 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
97 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
98 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),
101 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
102 _dim=cm.getDimension();
103 _nb_node_per_cell=cm.getNumberOfNodes();
104 _nb_gauss_pt=_w.size();
107 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
109 return new MEDFileFieldLoc(*this);
112 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
114 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
117 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildren() const
119 return std::vector<const BigMemoryObject *>();
122 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
124 static const char OFF7[]="\n ";
125 oss << "\"" << _name << "\"" << OFF7;
126 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
127 oss << "Dimension=" << _dim << OFF7;
128 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
129 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
130 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
131 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
132 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
135 void MEDFileFieldLoc::setName(const std::string& name)
140 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
142 if(_name!=other._name)
146 if(_nb_gauss_pt!=other._nb_gauss_pt)
148 if(_nb_node_per_cell!=other._nb_node_per_cell)
150 if(_geo_type!=other._geo_type)
152 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
154 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
156 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
162 void MEDFileFieldLoc::writeLL(med_idt fid) const
164 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);
167 std::string MEDFileFieldLoc::repr() const
169 std::ostringstream oss; oss.precision(15);
170 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
171 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
172 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
173 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
174 oss << "\n - Ref coords are : ";
175 int sz=_ref_coo.size();
178 int nbOfTuples=sz/_dim;
179 for(int i=0;i<nbOfTuples;i++)
182 for(int j=0;j<_dim;j++)
183 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
188 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
189 oss << "\n - Gauss coords in reference element : ";
193 int nbOfTuples=sz/_dim;
194 for(int i=0;i<nbOfTuples;i++)
197 for(int j=0;j<_dim;j++)
198 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
203 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
204 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
208 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
210 _type=field->getTypeOfField();
216 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
217 _end=_start+nbOfCells;
223 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
224 const int *arrPtr=arr->getConstPointer();
225 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
226 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
232 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
233 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
234 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
236 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
237 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
238 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
239 const int *dai2Ptr=dai2->getConstPointer();
240 int nbi=gsLoc.getWeights().size();
241 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
242 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
243 const int *da3Ptr=da3->getConstPointer();
244 if(da3->getNumberOfTuples()!=nbOfCells)
245 {//profile : for gauss even in NoProfile !!!
246 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
248 da3->setName(_profile.c_str());
249 glob.appendProfile(da3);
251 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
252 _nval=da3->getNbOfElems();
253 da4->alloc(_nval*nbi,1);
254 int *da4Ptr=da4->getPointer();
255 for(int i=0;i<_nval;i++)
257 int ref=dai2Ptr[offset+da3Ptr[i]];
258 for(int j=0;j<nbi;j++)
261 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
262 _localization=oss2.str();
263 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
264 _end=_start+_nval*nbi;
265 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
269 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
275 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
276 * \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).
277 * \param [in] multiTypePfl is the end user profile specified in high level API
278 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
279 * \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.
280 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
281 * \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.
283 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
286 _type=field->getTypeOfField();
287 std::string pflName(multiTypePfl->getName());
288 std::ostringstream oss; oss << pflName;
292 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
299 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
300 if(_type!=ON_GAUSS_PT)
302 locIds->setName(oss.str().c_str());
303 glob.appendProfile(locIds);
312 _nval=idsInPfl->getNumberOfTuples();
313 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
319 _nval=idsInPfl->getNumberOfTuples();
320 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
326 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
327 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
328 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
329 arr3->computeOffsets2();
330 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
331 int trueNval=tmp->getNumberOfTuples();
332 _nval=idsInPfl->getNumberOfTuples();
333 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
334 _end=_start+trueNval;
339 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
341 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
342 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
343 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
344 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
345 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
346 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
348 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
349 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
351 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
353 for(const int *pt=da4->begin();pt!=da4->end();pt++)
354 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
355 tmp->alloc(trueNval,1);
356 int *tmpPtr=tmp->getPointer();
357 for(const int *pt=da4->begin();pt!=da4->end();pt++)
358 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
361 _nval=da4->getNumberOfTuples();
362 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
363 _end=_start+trueNval;
364 oss << "_loc_" << _loc_id;
367 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
368 da5->setName(oss.str().c_str());
369 glob.appendProfile(da5);
374 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
376 da3->setName(oss.str().c_str());
377 glob.appendProfile(da3);
381 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
382 _localization=oss2.str();
383 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
387 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
392 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
395 _nval=arrr->getNumberOfTuples();
396 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
401 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt)
403 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
408 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
413 return new MEDFileFieldPerMeshPerTypePerDisc(other);
416 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
418 return _profile.capacity()+_localization.capacity()+5*sizeof(int);
421 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildren() const
423 return std::vector<const BigMemoryObject *>();
426 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const
428 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
433 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt)
434 try:_type(atype),_father(fath),_profile_it(profileIt)
437 catch(INTERP_KERNEL::Exception& e)
442 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
446 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_tmp_work1(other._tmp_work1)
450 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
451 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
455 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
460 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
462 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
463 INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
464 std::string fieldName=nasc.getName();
465 std::string meshName=getMeshName();
466 int iteration=getIteration();
467 int order=getOrder();
468 TypeOfField type=getType();
469 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
471 med_geometry_type mgeoti;
472 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
473 _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it,MED_COMPACT_PFLMODE,
474 pflname,&profilesize,locname,&nbi);
475 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
476 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
478 _end=start+_nval*nbi;
480 if(type==ON_CELLS && !_localization.empty())
482 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
483 setType(ON_GAUSS_PT);
486 setType(ON_GAUSS_NE);
487 _localization.clear();
492 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
494 std::string fieldName=nasc.getName();
495 std::string meshName=getMeshName();
496 int iteration=getIteration();
497 int order=getOrder();
498 TypeOfField type=getType();
499 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
500 med_geometry_type mgeoti;
501 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
503 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
506 DataArray *arr=getOrCreateAndGetArray();//arr is not null due to the spec of getOrCreateAndGetArray
507 if(_start<0 || _start>=arr->getNumberOfTuples())
509 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
510 throw INTERP_KERNEL::Exception(oss.str().c_str());
512 if(_end<0 || _end>arr->getNumberOfTuples())
514 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
515 throw INTERP_KERNEL::Exception(oss.str().c_str());
518 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
519 med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
520 int nbOfCompo=arr->getNumberOfComponents();
521 if(_end-_start!=nbValsInFile*nbi)
523 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 !";
524 throw INTERP_KERNEL::Exception(oss.str().c_str());
526 DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
529 double *startFeeding=arrD->getPointer()+_start*nbOfCompo;
530 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
531 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
534 DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
537 int *startFeeding=arrI->getPointer()+_start*nbOfCompo;
538 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
539 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
542 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
546 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
548 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
550 int delta=_end-_start;
551 _start=newValueOfStart;
555 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
557 return _father->getIteration();
560 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
562 return _father->getOrder();
565 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
567 return _father->getTime();
570 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
572 return _father->getMeshName();
575 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
577 const char startLine[]=" ## ";
578 std::string startLine2(bkOffset,' ');
579 startLine2+=startLine;
580 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
581 oss << startLine2 << "Localization #" << id << "." << std::endl;
582 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
584 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
585 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
586 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
589 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
594 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
599 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
604 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
606 return _father->getGeoType();
609 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
611 return _father->getNumberOfComponents();
614 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
619 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
621 return _father->getOrCreateAndGetArray();
624 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
626 const MEDFileFieldPerMeshPerType *fath=_father;
627 return fath->getOrCreateAndGetArray();
630 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
632 return _father->getInfo();
635 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
640 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
645 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
647 return _localization;
650 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
652 _localization=newLocName;
655 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
657 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
659 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
661 _profile=(*it2).second;
667 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
669 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
671 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
673 _localization=(*it2).second;
679 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
683 dads.push_back(std::pair<int,int>(_start,_end));
684 geoTypes.push_back(getGeoType());
689 pfls.push_back(glob->getProfile(_profile.c_str()));
691 if(_localization.empty())
695 locs.push_back(glob->getLocalizationId(_localization.c_str()));
699 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
701 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));
705 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
707 TypeOfField type=getType();
708 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
709 med_geometry_type mgeoti;
710 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
711 const DataArray *arr=getOrCreateAndGetArray();
713 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
714 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
715 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
716 const unsigned char *locToWrite=0;
718 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
720 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
722 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
723 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
724 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
728 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
733 dad.first=_start; dad.second=_end;
737 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
738 * This code corresponds to the distribution of types in the corresponding mesh.
739 * \param [out] ptToFill memory zone where the output will be stored.
740 * \return the size of data pushed into output param \a ptToFill
742 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
745 std::ostringstream oss;
746 std::size_t nbOfType=codeOfMesh.size()/3;
748 for(std::size_t i=0;i<nbOfType && found==-1;i++)
749 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
753 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
754 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
755 throw INTERP_KERNEL::Exception(oss.str().c_str());
760 if(_nval!=codeOfMesh[3*found+1])
762 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
763 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
764 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
765 throw INTERP_KERNEL::Exception(oss.str().c_str());
767 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
772 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
773 if(pfl->getNumberOfTuples()!=_nval)
775 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
776 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
778 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
779 throw INTERP_KERNEL::Exception(oss.str().c_str());
781 int offset2=codeOfMesh[3*found+2];
782 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
784 if(*pflId<codeOfMesh[3*found+1])
785 *work++=offset2+*pflId;
791 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
793 for(int i=_start;i<_end;i++)
798 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
809 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
813 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
816 std::map<std::pair<std::string,TypeOfField>,int> m;
817 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
818 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
819 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
820 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
822 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
823 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
828 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
830 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
831 * \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.
832 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
833 * \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)
834 * \param [in,out] glob if necessary by the method, new profiles can be added to it
835 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
836 * \param [out] result All new entries will be appended on it.
837 * \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 !)
839 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
840 const DataArrayInt *explicitIdsInMesh,
841 const std::vector<int>& newCode,
842 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
843 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
845 if(entriesOnSameDisc.empty())
847 TypeOfField type=entriesOnSameDisc[0]->getType();
848 int szEntities=0,szTuples=0;
849 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
850 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
851 int nbi=szTuples/szEntities;
852 if(szTuples%szEntities!=0)
853 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
854 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
855 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
856 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
857 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
858 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
859 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
860 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
862 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
864 int startOfEltIdOfChunk=(*it)->_start;
865 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
866 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
867 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
869 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
870 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
872 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
873 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
875 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
876 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
877 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
878 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
880 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
882 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
883 arrPart->renumberInPlace(renumTupleIds->begin());
884 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
886 const int *idIt=diffVals->begin();
887 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
889 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
891 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
892 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
893 int nbEntityElts=subIds->getNumberOfTuples();
895 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
896 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
900 result.push_back(eltToAdd);
901 offset2+=nbEntityElts*nbi;
903 ret=ret || li.empty();
908 * \param [in] typeF type of field of new chunk
909 * \param [in] geoType the geometric type of the chunk
910 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
911 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
912 * \param [in] nbi number of integration points
913 * \param [in] offset The offset in the **global array of data**.
914 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
915 * to the new chunk to create.
916 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
917 * \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
918 * and corresponding entry erased from \a entriesOnSameDisc.
919 * \return a newly allocated chunk
921 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
922 bool isPfl, int nbi, int offset,
923 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
924 MEDFileFieldGlobsReal& glob,
927 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
928 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
929 for(;it!=entriesOnSameDisc.end();it++)
931 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
935 if((*it)->_profile.empty())
938 if(!(*it)->_profile.empty())
940 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
941 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
947 if(it==entriesOnSameDisc.end())
950 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
952 ret->_loc_id=(int)geoType;
953 ret->_nval=nbMeshEntities;
955 ret->_end=ret->_start+ret->_nval*nbi;
958 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
959 glob.appendProfile(idsOfMeshElt);
960 ret->_profile=idsOfMeshElt->getName();
962 //tony treatment of localization
968 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
969 ret->_loc_id=(int)geoType;
970 ret->setNewStart(offset);
971 entriesOnSameDisc.erase(it);
977 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc)
979 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
982 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
984 return new MEDFileFieldPerMeshPerType(fath,geoType);
987 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
989 return _field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
992 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildren() const
994 std::vector<const BigMemoryObject *> ret;
995 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
997 const MEDFileFieldPerMeshPerTypePerDisc *cur(*it);
1004 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const
1006 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1007 ret->_father=father;
1009 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1011 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1012 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
1017 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1019 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1020 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1021 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1025 * This method is the most general one. No optimization is done here.
1026 * \param [in] multiTypePfl is the end user profile specified in high level API
1027 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1028 * \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.
1029 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1030 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1031 * \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.
1033 void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1035 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1036 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1037 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1040 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1042 _field_pm_pt_pd.resize(1);
1043 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1044 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1047 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1049 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1050 if(!arr || !arr->isAllocated())
1051 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1052 _field_pm_pt_pd.resize(1);
1053 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1054 _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1057 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1059 TypeOfField type=field->getTypeOfField();
1060 if(type!=ON_GAUSS_PT)
1062 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1063 int sz=_field_pm_pt_pd.size();
1065 for(int j=0;j<sz && !found;j++)
1067 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1069 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1075 _field_pm_pt_pd.resize(sz+1);
1076 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1078 std::vector<int> ret(1,(int)sz);
1083 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1084 int sz2=ret2.size();
1085 std::vector<int> ret3(sz2);
1087 for(int i=0;i<sz2;i++)
1089 int sz=_field_pm_pt_pd.size();
1090 int locIdToFind=ret2[i];
1092 for(int j=0;j<sz && !found;j++)
1094 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1096 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1103 _field_pm_pt_pd.resize(sz+1);
1104 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1112 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1114 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1115 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1117 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1118 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1120 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1121 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1122 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1123 if(retTmp->presenceOfValue(-1))
1124 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1125 std::vector<int> ret(retTmp->begin(),retTmp->end());
1129 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1131 TypeOfField type=field->getTypeOfField();
1132 if(type!=ON_GAUSS_PT)
1134 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1135 int sz=_field_pm_pt_pd.size();
1137 for(int j=0;j<sz && !found;j++)
1139 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1141 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1147 _field_pm_pt_pd.resize(sz+1);
1148 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1150 std::vector<int> ret(1,0);
1155 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1156 int sz2=ret2.size();
1157 std::vector<int> ret3(sz2);
1159 for(int i=0;i<sz2;i++)
1161 int sz=_field_pm_pt_pd.size();
1162 int locIdToFind=ret2[i];
1164 for(int j=0;j<sz && !found;j++)
1166 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1168 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1175 _field_pm_pt_pd.resize(sz+1);
1176 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1184 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1186 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1187 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1189 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1190 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1192 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1193 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1194 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1195 if(retTmp->presenceOfValue(-1))
1196 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1197 std::vector<int> ret(retTmp->begin(),retTmp->end());
1201 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1206 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1208 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1209 int curDim=(int)cm.getDimension();
1210 dim=std::max(dim,curDim);
1213 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1215 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1217 (*it)->fillTypesOfFieldAvailable(types);
1221 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
1223 int sz=_field_pm_pt_pd.size();
1224 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1225 for(int i=0;i<sz;i++)
1227 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1231 int MEDFileFieldPerMeshPerType::getIteration() const
1233 return _father->getIteration();
1236 int MEDFileFieldPerMeshPerType::getOrder() const
1238 return _father->getOrder();
1241 double MEDFileFieldPerMeshPerType::getTime() const
1243 return _father->getTime();
1246 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1248 return _father->getMeshName();
1251 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1253 const char startLine[]=" ## ";
1254 std::string startLine2(bkOffset,' ');
1255 std::string startLine3(startLine2);
1256 startLine3+=startLine;
1257 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1259 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1260 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1263 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1264 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1266 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1268 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1270 cur->simpleRepr(bkOffset,oss,i);
1273 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1278 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1280 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1282 globalSz+=(*it)->getNumberOfTuples();
1284 nbOfEntries+=(int)_field_pm_pt_pd.size();
1287 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1293 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1295 return _father->getNumberOfComponents();
1298 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1300 return _father->getOrCreateAndGetArray();
1303 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1305 const MEDFileFieldPerMesh *fath=_father;
1306 return fath->getOrCreateAndGetArray();
1309 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1311 return _father->getInfo();
1314 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1316 std::vector<std::string> ret;
1317 std::set<std::string> ret2;
1318 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1320 std::string tmp=(*it1)->getProfile();
1322 if(ret2.find(tmp)==ret2.end())
1331 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1333 std::vector<std::string> ret;
1334 std::set<std::string> ret2;
1335 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1337 std::string tmp=(*it1)->getLocalization();
1338 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1339 if(ret2.find(tmp)==ret2.end())
1348 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1350 std::vector<std::string> ret;
1351 std::set<std::string> ret2;
1352 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1354 std::string tmp=(*it1)->getProfile();
1361 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1363 std::vector<std::string> ret;
1364 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1366 std::string tmp=(*it1)->getLocalization();
1367 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1373 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1375 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1376 (*it1)->changePflsRefsNamesGen(mapOfModif);
1379 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1381 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1382 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1385 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1387 if(_field_pm_pt_pd.empty())
1389 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1390 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1391 throw INTERP_KERNEL::Exception(oss.str().c_str());
1393 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1394 return _field_pm_pt_pd[locId];
1395 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1396 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1397 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1398 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1399 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1402 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1404 if(_field_pm_pt_pd.empty())
1406 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1407 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1408 throw INTERP_KERNEL::Exception(oss.str().c_str());
1410 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1411 return _field_pm_pt_pd[locId];
1412 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1413 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1414 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1415 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1416 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1419 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
1421 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1423 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1424 if(meshDim!=(int)cm.getDimension())
1427 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1428 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1431 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1434 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1436 (*it)->fillValues(i,startEntryId,entries);
1440 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1442 _field_pm_pt_pd=leaves;
1443 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1444 (*it)->setFather(this);
1448 * \param [in,out] globalNum a global numbering counter for the renumbering.
1449 * \param [out] its - list of pair (start,stop) kept
1450 * \return bool - false if the type of field \a tof is not contained in \a this.
1452 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1455 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1456 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1457 if((*it)->getType()==tof)
1459 newPmPtPd.push_back(*it);
1460 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1461 (*it)->setNewStart(globalNum);
1462 globalNum=(*it)->getEnd();
1463 its.push_back(bgEnd);
1467 _field_pm_pt_pd=newPmPtPd;
1471 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1475 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc):_father(fath),_geo_type(geoType)
1477 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1478 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1479 med_geometry_type mgeoti;
1480 med_entity_type menti;
1481 menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1482 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1483 _field_pm_pt_pd.resize(nbProfiles);
1484 for(int i=0;i<nbProfiles;i++)
1486 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1490 int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1491 for(int i=0;i<nbProfiles2;i++)
1492 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i+1));
1496 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1498 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1499 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1502 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1504 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1505 (*it)->loadBigArray(fid,nasc);
1508 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1510 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1512 (*it)->copyOptionsFrom(*this);
1513 (*it)->writeLL(fid,nasc);
1517 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1522 medfGeoType=typmai3[(int)ikGeoType];
1525 medfGeoType=MED_NONE;
1528 medfGeoType=typmai3[(int)ikGeoType];
1529 return MED_NODE_ELEMENT;
1531 medfGeoType=typmai3[(int)ikGeoType];
1534 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1536 return MED_UNDEF_ENTITY_TYPE;
1539 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc)
1541 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1544 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1546 return new MEDFileFieldPerMesh(fath,mesh);
1549 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1551 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1554 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildren() const
1556 std::vector<const BigMemoryObject *> ret;
1557 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1559 const MEDFileFieldPerMeshPerType *cur(*it);
1566 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1568 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1569 ret->_father=father;
1571 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1573 if((const MEDFileFieldPerMeshPerType *)*it)
1574 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1579 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1581 std::string startLine(bkOffset,' ');
1582 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1583 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1585 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1587 const MEDFileFieldPerMeshPerType *cur=*it;
1589 cur->simpleRepr(bkOffset,oss,i);
1592 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1597 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1599 _mesh_name=mesh->getName();
1600 mesh->getTime(_mesh_iteration,_mesh_order);
1603 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1605 int nbOfTypes=code.size()/3;
1607 for(int i=0;i<nbOfTypes;i++)
1609 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1610 int nbOfCells=code[3*i+1];
1611 int pos=addNewEntryIfNecessary(type);
1612 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1618 * This method is the most general one. No optimization is done here.
1619 * \param [in] multiTypePfl is the end user profile specified in high level API
1620 * \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].
1621 * \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.
1622 * \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.
1623 * \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.
1624 * \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.
1626 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)
1628 int nbOfTypes(code.size()/3);
1629 for(int i=0;i<nbOfTypes;i++)
1631 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1632 int pos=addNewEntryIfNecessary(type);
1633 DataArrayInt *pfl=0;
1635 pfl=idsPerType[code[3*i+2]];
1636 int nbOfTupes2=code2.size()/3;
1638 for(;found<nbOfTupes2;found++)
1639 if(code[3*i]==code2[3*found])
1641 if(found==nbOfTupes2)
1642 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1643 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1647 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1649 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1650 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1653 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1655 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1656 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1659 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1661 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1662 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1665 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1667 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1668 (*it)->loadBigArraysRecursively(fid,nasc);
1671 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1673 int nbOfTypes=_field_pm_pt.size();
1674 for(int i=0;i<nbOfTypes;i++)
1676 _field_pm_pt[i]->copyOptionsFrom(*this);
1677 _field_pm_pt[i]->writeLL(fid,nasc);
1681 void MEDFileFieldPerMesh::getDimension(int& dim) const
1683 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1684 (*it)->getDimension(dim);
1687 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1689 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1690 (*it)->fillTypesOfFieldAvailable(types);
1693 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
1695 int sz=_field_pm_pt.size();
1696 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1697 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1698 for(int i=0;i<sz;i++)
1700 types[i]=_field_pm_pt[i]->getGeoType();
1701 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1706 double MEDFileFieldPerMesh::getTime() const
1709 return _father->getTime(tmp1,tmp2);
1712 int MEDFileFieldPerMesh::getIteration() const
1714 return _father->getIteration();
1717 int MEDFileFieldPerMesh::getOrder() const
1719 return _father->getOrder();
1722 int MEDFileFieldPerMesh::getNumberOfComponents() const
1724 return _father->getNumberOfComponents();
1727 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1730 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1731 return _father->getOrCreateAndGetArray();
1734 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1737 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1738 return _father->getOrCreateAndGetArray();
1741 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1743 return _father->getInfo();
1747 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1748 * 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.
1749 * It returns 2 output vectors :
1750 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1751 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1752 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1754 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)
1756 int notNullPflsSz=0;
1757 int nbOfArrs=geoTypes.size();
1758 for(int i=0;i<nbOfArrs;i++)
1761 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1762 int nbOfDiffGeoTypes=geoTypes3.size();
1763 code.resize(3*nbOfDiffGeoTypes);
1764 notNullPfls.resize(notNullPflsSz);
1767 for(int i=0;i<nbOfDiffGeoTypes;i++)
1770 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1771 std::vector<const DataArrayInt *> notNullTmp;
1773 notNullTmp.push_back(pfls[j]);
1775 for(;j<nbOfArrs;j++)
1776 if(geoTypes[j]==refType)
1779 notNullTmp.push_back(pfls[j]);
1783 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1784 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1785 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1786 code[3*i]=(int)refType;
1787 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1788 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1789 if(notNullTmp.empty())
1793 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1794 code[3*i+2]=notNullPflsSz++;
1800 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1802 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)
1806 for(int i=0;i<sz;i++)
1810 if(type!=ON_GAUSS_NE)
1811 ret+=dads[i].second-dads[i].first;
1814 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1815 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1820 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1821 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1827 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1829 std::vector<std::string> ret;
1830 std::set<std::string> ret2;
1831 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1833 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1834 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1835 if(ret2.find(*it2)==ret2.end())
1837 ret.push_back(*it2);
1844 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1846 std::vector<std::string> ret;
1847 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1849 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1850 ret.insert(ret.end(),tmp.begin(),tmp.end());
1855 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1857 std::vector<std::string> ret;
1858 std::set<std::string> ret2;
1859 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1861 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1862 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1863 if(ret2.find(*it2)==ret2.end())
1865 ret.push_back(*it2);
1872 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1874 std::vector<std::string> ret;
1875 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1877 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1878 ret.insert(ret.end(),tmp.begin(),tmp.end());
1883 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1885 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1887 if((*it).first==_mesh_name)
1889 _mesh_name=(*it).second;
1896 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1897 MEDFileFieldGlobsReal& glob)
1899 if(_mesh_name!=meshName)
1901 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1902 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1903 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1904 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1905 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1906 getUndergroundDataArrayExt(entries);
1907 DataArray *arr0=getOrCreateAndGetArray();//tony
1909 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1910 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1912 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1915 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1916 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1918 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1920 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1921 sz+=(*it).second.second-(*it).second.first;
1924 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1926 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1927 ////////////////////
1928 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1929 int *workI2=explicitIdsOldInMesh->getPointer();
1930 int sz1=0,sz2=0,sid=1;
1931 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1932 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1933 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1935 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1936 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1937 int *workI=explicitIdsOldInArr->getPointer();
1938 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1940 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1941 (*itL2)->setLocId(sz2);
1942 (*itL2)->_tmp_work1=(*itL2)->getStart();
1943 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1945 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1947 explicitIdsOldInMesh->reAlloc(sz2);
1948 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1949 ////////////////////
1950 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1951 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1952 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1953 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1955 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1956 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1957 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1959 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1960 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1961 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1963 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1964 int newStart=elt->getLocId();
1965 elt->setLocId((*it)->getGeoType());
1966 elt->setNewStart(newStart);
1967 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1968 entriesKeptNew.push_back(elt);
1969 entriesKeptNew2.push_back(elt);
1971 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1972 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1973 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1974 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1976 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1979 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1981 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1982 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1984 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1985 glob,arr2,otherEntriesNew) || ret;
1989 // Assign new dispatching
1990 assignNewLeaves(otherEntriesNew);
1991 arr->cpyFrom(*arr2);
1996 * \param [in,out] globalNum a global numbering counter for the renumbering.
1997 * \param [out] its - list of pair (start,stop) kept
1999 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2001 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2002 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2004 std::vector< std::pair<int,int> > its2;
2005 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2008 its.insert(its.end(),its2.begin(),its2.end());
2014 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2016 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2017 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2018 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2020 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2021 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2022 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2023 for(;it1!=types.end();it1++,it2++)
2025 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2026 elt->setLeaves((*it1).second);
2029 _field_pm_pt=fieldPmPt;
2032 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2034 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2035 (*it)->changePflsRefsNamesGen(mapOfModif);
2038 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2040 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2041 (*it)->changeLocsRefsNamesGen(mapOfModif);
2045 * \param [in] mesh is the whole mesh
2047 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2049 if(_field_pm_pt.empty())
2050 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2052 std::vector< std::pair<int,int> > dads;
2053 std::vector<const DataArrayInt *> pfls;
2054 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2055 std::vector<int> locs,code;
2056 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2057 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2058 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2060 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2063 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2064 throw INTERP_KERNEL::Exception(oss.str().c_str());
2067 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2068 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2071 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2073 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2076 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2077 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2083 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2087 if(nb!=mesh->getNumberOfNodes())
2089 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2090 oss << " nodes in mesh !";
2091 throw INTERP_KERNEL::Exception(oss.str().c_str());
2093 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2096 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2100 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2102 if(_field_pm_pt.empty())
2103 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2105 std::vector<std::pair<int,int> > dads;
2106 std::vector<const DataArrayInt *> pfls;
2107 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2108 std::vector<int> locs,code;
2109 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2110 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2111 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2113 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2116 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2117 throw INTERP_KERNEL::Exception(oss.str().c_str());
2119 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2120 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2123 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2124 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2129 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2133 if(nb!=mesh->getNumberOfNodes())
2135 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2136 oss << " nodes in mesh !";
2137 throw INTERP_KERNEL::Exception(oss.str().c_str());
2140 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2146 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2150 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2152 (*it)->getSizes(globalSz,nbOfEntries);
2154 entries.resize(nbOfEntries);
2156 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2158 (*it)->fillValues(nbOfEntries,entries);
2162 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2164 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2166 if((*it)->getGeoType()==typ)
2167 return (*it)->getLeafGivenLocId(locId);
2169 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2170 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2171 oss << "Possiblities are : ";
2172 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2174 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2175 oss << "\"" << cm2.getRepr() << "\", ";
2177 throw INTERP_KERNEL::Exception(oss.str().c_str());
2180 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2182 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2184 if((*it)->getGeoType()==typ)
2185 return (*it)->getLeafGivenLocId(locId);
2187 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2188 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2189 oss << "Possiblities are : ";
2190 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2192 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2193 oss << "\"" << cm2.getRepr() << "\", ";
2195 throw INTERP_KERNEL::Exception(oss.str().c_str());
2198 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2201 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2202 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2203 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2205 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2210 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2215 int ret=std::distance(_field_pm_pt.begin(),it2);
2216 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2221 * 'dads' and 'locs' input parameters have the same number of elements
2222 * \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
2224 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2225 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2226 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2229 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2230 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2231 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2232 const std::vector<std::string>& infos=getInfo();
2233 da->setInfoOnComponents(infos);
2235 if(type==ON_GAUSS_PT)
2238 int nbOfArrs=dads.size();
2239 for(int i=0;i<nbOfArrs;i++)
2241 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2242 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2243 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2244 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2245 di->alloc(nbOfElems,1);
2247 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2248 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2257 * 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.
2258 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2259 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2260 * The order of cells in the returned field is those imposed by the profile.
2261 * \param [in] mesh is the global mesh.
2263 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2264 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2265 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2266 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2268 if(da->isIdentity())
2270 int nbOfTuples=da->getNumberOfTuples();
2271 if(nbOfTuples==mesh->getNumberOfCells())
2272 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2274 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2275 m2->setName(mesh->getName().c_str());
2276 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2282 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2284 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2285 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2286 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2288 if(da->isIdentity())
2290 int nbOfTuples=da->getNumberOfTuples();
2291 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2292 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2294 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2295 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2298 if(meshu->getNodalConnectivity()==0)
2300 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2301 int nb=da->getNbOfElems();
2302 const int *ptr=da->getConstPointer();
2303 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2304 meshuc->allocateCells(nb);
2305 for(int i=0;i<nb;i++)
2306 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2307 meshuc->finishInsertingCells();
2308 ret->setMesh(meshuc);
2309 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2310 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2311 disc->checkCoherencyBetween(meshuc,arrOut);
2316 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2318 DataArrayInt *arr2=0;
2319 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2320 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2321 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2322 int nnodes=mesh2->getNumberOfNodes();
2323 if(nnodes==(int)da->getNbOfElems())
2325 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2326 arrOut->renumberInPlace(da3->getConstPointer());
2327 mesh2->setName(mesh->getName().c_str());
2328 ret->setMesh(mesh2);
2333 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 !!!";
2334 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2335 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2336 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2337 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2338 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2339 throw INTERP_KERNEL::Exception(oss.str().c_str());
2345 * This method is the most light method of field retrieving.
2347 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2351 pflOut=DataArrayInt::New();
2352 pflOut->alloc(nbOfElems,1);
2357 pflOut=const_cast<DataArrayInt*>(pflIn);
2360 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2361 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2362 const std::vector<std::string>& infos=getInfo();
2363 int nbOfComp=infos.size();
2364 for(int i=0;i<nbOfComp;i++)
2365 da->setInfoOnComponent(i,infos[i].c_str());
2370 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2371 _mesh_csit(meshCsit),_father(fath)
2373 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2374 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2375 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2376 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2378 int nbProfile =MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[i],_mesh_csit,meshName,pflName,locName);
2379 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2380 int nbProfile2=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2381 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2382 if(nbProfile>0 || nbProfile2>0)
2384 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2391 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2394 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2395 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2399 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2401 copyTinyInfoFrom(mesh);
2404 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2406 if(id>=(int)_pfls.size())
2408 _pfls[id]=DataArrayInt::New();
2409 int lgth=MEDprofileSizeByName(fid,pflName.c_str());
2410 _pfls[id]->setName(pflName);
2411 _pfls[id]->alloc(lgth,1);
2412 MEDprofileRd(fid,pflName.c_str(),_pfls[id]->getPointer());
2413 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2416 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2418 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2420 MEDprofileInfo(fid,i+1,pflName,&sz);
2421 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2422 if(i>=(int)_pfls.size())
2424 _pfls[i]=DataArrayInt::New();
2425 _pfls[i]->alloc(sz,1);
2426 _pfls[i]->setName(pflCpp.c_str());
2427 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2428 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2431 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2433 int nbOfPfls=_pfls.size();
2434 for(int i=0;i<nbOfPfls;i++)
2436 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2437 cpy->applyLin(1,1,0);
2438 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2439 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2440 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2443 int nbOfLocs=_locs.size();
2444 for(int i=0;i<nbOfLocs;i++)
2445 _locs[i]->writeLL(fid);
2448 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2450 std::vector<std::string> pfls=getPfls();
2451 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2453 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2456 _pfls.push_back(*it);
2460 int id=std::distance(pfls.begin(),it2);
2461 if(!(*it)->isEqual(*_pfls[id]))
2463 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2464 throw INTERP_KERNEL::Exception(oss.str().c_str());
2468 std::vector<std::string> locs=getLocs();
2469 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2471 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2474 _locs.push_back(*it);
2478 int id=std::distance(locs.begin(),it2);
2479 if(!(*it)->isEqual(*_locs[id],eps))
2481 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2482 throw INTERP_KERNEL::Exception(oss.str().c_str());
2488 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2490 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2491 getProfile((*it).c_str());
2494 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2496 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2497 getLocalization((*it).c_str());
2500 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2502 std::vector<std::string> profiles=real.getPflsReallyUsed();
2503 int sz=profiles.size();
2505 for(int i=0;i<sz;i++)
2506 loadProfileInFile(fid,i,profiles[i].c_str());
2508 std::vector<std::string> locs=real.getLocsReallyUsed();
2511 for(int i=0;i<sz;i++)
2512 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2515 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2517 int nProfil=MEDnProfile(fid);
2518 for(int i=0;i<nProfil;i++)
2519 loadProfileInFile(fid,i);
2520 int sz=MEDnLocalization(fid);
2522 for(int i=0;i<sz;i++)
2524 _locs[i]=MEDFileFieldLoc::New(fid,i);
2528 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2530 return new MEDFileFieldGlobs(fname);
2533 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2535 return new MEDFileFieldGlobs;
2538 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2540 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2543 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildren() const
2545 std::vector<const BigMemoryObject *> ret;
2546 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2548 const DataArrayInt *cur(*it);
2552 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2554 const MEDFileFieldLoc *cur(*it);
2561 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2563 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2565 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2567 if((const DataArrayInt *)*it)
2568 ret->_pfls[i]=(*it)->deepCpy();
2571 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2573 if((const MEDFileFieldLoc*)*it)
2574 ret->_locs[i]=(*it)->deepCpy();
2580 * \throw if a profile in \a pfls in not in \a this.
2581 * \throw if a localization in \a locs in not in \a this.
2582 * \sa MEDFileFieldGlobs::deepCpyPart
2584 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2586 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2587 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2589 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2591 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2593 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2594 ret->_pfls.push_back(pfl2);
2596 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2598 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2600 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2602 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2603 ret->_locs.push_back(loc2);
2605 ret->setFileName(getFileName());
2610 * \throw if a profile in \a pfls in not in \a this.
2611 * \throw if a localization in \a locs in not in \a this.
2612 * \sa MEDFileFieldGlobs::shallowCpyPart
2614 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2616 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2617 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2619 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2621 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2622 ret->_pfls.push_back(pfl->deepCpy());
2624 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2626 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2628 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2629 ret->_locs.push_back(loc->deepCpy());
2631 ret->setFileName(getFileName());
2635 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2639 MEDFileFieldGlobs::MEDFileFieldGlobs()
2643 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2647 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2649 oss << "Profiles :\n";
2650 std::size_t n=_pfls.size();
2651 for(std::size_t i=0;i<n;i++)
2653 oss << " - #" << i << " ";
2654 const DataArrayInt *pfl=_pfls[i];
2656 oss << "\"" << pfl->getName() << "\"\n";
2661 oss << "Localizations :\n";
2662 for(std::size_t i=0;i<n;i++)
2664 oss << " - #" << i << " ";
2665 const MEDFileFieldLoc *loc=_locs[i];
2667 loc->simpleRepr(oss);
2673 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2675 _file_name=fileName;
2678 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2680 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2682 DataArrayInt *elt(*it);
2685 std::string name(elt->getName());
2686 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2688 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2690 elt->setName((*it2).second.c_str());
2698 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2700 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2702 MEDFileFieldLoc *elt(*it);
2705 std::string name(elt->getName());
2706 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2708 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2710 elt->setName((*it2).second.c_str());
2718 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2720 if(locId<0 || locId>=(int)_locs.size())
2721 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2722 return _locs[locId]->getNbOfGaussPtPerCell();
2725 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2727 return getLocalizationFromId(getLocalizationId(locName));
2730 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2732 if(locId<0 || locId>=(int)_locs.size())
2733 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2734 return *_locs[locId];
2737 namespace ParaMEDMEMImpl
2742 LocFinder(const std::string& loc):_loc(loc) { }
2743 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2745 const std::string &_loc;
2751 PflFinder(const std::string& pfl):_pfl(pfl) { }
2752 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2754 const std::string& _pfl;
2758 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2760 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2763 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2764 for(it=_locs.begin();it!=_locs.end();it++)
2765 oss << "\"" << (*it)->getName() << "\", ";
2766 throw INTERP_KERNEL::Exception(oss.str().c_str());
2768 return std::distance(_locs.begin(),it);
2772 * The returned value is never null.
2774 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2776 std::string pflNameCpp(pflName);
2777 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2780 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2781 for(it=_pfls.begin();it!=_pfls.end();it++)
2782 oss << "\"" << (*it)->getName() << "\", ";
2783 throw INTERP_KERNEL::Exception(oss.str().c_str());
2788 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2790 if(pflId<0 || pflId>=(int)_pfls.size())
2791 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2792 return _pfls[pflId];
2795 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
2797 if(locId<0 || locId>=(int)_locs.size())
2798 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2799 return *_locs[locId];
2802 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
2804 return getLocalizationFromId(getLocalizationId(locName));
2808 * The returned value is never null.
2810 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
2812 std::string pflNameCpp(pflName);
2813 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2816 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2817 for(it=_pfls.begin();it!=_pfls.end();it++)
2818 oss << "\"" << (*it)->getName() << "\", ";
2819 throw INTERP_KERNEL::Exception(oss.str().c_str());
2824 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
2826 if(pflId<0 || pflId>=(int)_pfls.size())
2827 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2828 return _pfls[pflId];
2831 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
2833 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2835 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2837 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2838 newPfls.push_back(*it);
2843 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
2845 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2847 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2849 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2850 newLocs.push_back(*it);
2855 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2857 int sz=_pfls.size();
2858 std::vector<std::string> ret(sz);
2859 for(int i=0;i<sz;i++)
2860 ret[i]=_pfls[i]->getName();
2864 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2866 int sz=_locs.size();
2867 std::vector<std::string> ret(sz);
2868 for(int i=0;i<sz;i++)
2869 ret[i]=_locs[i]->getName();
2873 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
2875 std::vector<std::string> v=getPfls();
2876 std::string s(pflName);
2877 return std::find(v.begin(),v.end(),s)!=v.end();
2880 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
2882 std::vector<std::string> v=getLocs();
2883 std::string s(locName);
2884 return std::find(v.begin(),v.end(),s)!=v.end();
2887 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2889 std::map<int,std::vector<int> > m;
2891 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2893 const DataArrayInt *tmp=(*it);
2896 m[tmp->getHashCode()].push_back(i);
2899 std::vector< std::vector<int> > ret;
2900 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2902 if((*it2).second.size()>1)
2904 std::vector<int> ret0;
2905 bool equalityOrNot=false;
2906 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2908 std::vector<int>::const_iterator it4=it3; it4++;
2909 for(;it4!=(*it2).second.end();it4++)
2911 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2914 ret0.push_back(*it3);
2915 ret0.push_back(*it4);
2921 ret.push_back(ret0);
2927 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2929 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2932 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
2934 std::string name(pfl->getName());
2936 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2937 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2938 if(name==(*it)->getName())
2940 if(!pfl->isEqual(*(*it)))
2942 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2943 throw INTERP_KERNEL::Exception(oss.str().c_str());
2947 _pfls.push_back(pfl);
2950 void MEDFileFieldGlobs::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
2952 std::string name(locName);
2954 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2955 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2956 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2957 if((*it)->isName(locName))
2959 if(!(*it)->isEqual(*obj,1e-12))
2961 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2962 throw INTERP_KERNEL::Exception(oss.str().c_str());
2965 _locs.push_back(obj);
2968 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
2970 std::vector<std::string> names=getPfls();
2971 return CreateNewNameNotIn("NewPfl_",names);
2974 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
2976 std::vector<std::string> names=getLocs();
2977 return CreateNewNameNotIn("NewLoc_",names);
2980 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
2982 for(std::size_t sz=0;sz<100000;sz++)
2984 std::ostringstream tryName;
2985 tryName << prefix << sz;
2986 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2987 return tryName.str();
2989 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2993 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2994 * \param [in] fname - the file name.
2996 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3001 * Creates an empty MEDFileFieldGlobsReal.
3003 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3007 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3012 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildren() const
3014 std::vector<const BigMemoryObject *> ret;
3015 if((const MEDFileFieldGlobs *)_globals)
3016 ret.push_back((const MEDFileFieldGlobs *)_globals);
3021 * Returns a string describing profiles and Gauss points held in \a this.
3022 * \return std::string - the description string.
3024 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3026 const MEDFileFieldGlobs *glob=_globals;
3027 std::ostringstream oss2; oss2 << glob;
3028 std::string stars(oss2.str().length(),'*');
3029 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3031 glob->simpleRepr(oss);
3033 oss << "NO GLOBAL INFORMATION !\n";
3036 void MEDFileFieldGlobsReal::resetContent()
3038 _globals=MEDFileFieldGlobs::New();
3041 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3046 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3047 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3049 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3051 _globals=other._globals;
3055 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3056 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3058 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3060 const MEDFileFieldGlobs *otherg(other._globals);
3063 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3067 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3068 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3070 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3072 const MEDFileFieldGlobs *otherg(other._globals);
3075 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3078 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3080 _globals=other._globals;
3081 if((const MEDFileFieldGlobs *)_globals)
3082 _globals=other._globals->deepCpy();
3086 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3087 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3088 * \param [in] eps - a precision used to compare Gauss points with same name held by
3089 * \a this and \a other MEDFileFieldGlobsReal.
3090 * \throw If \a this and \a other hold profiles with equal names but different ids.
3091 * \throw If \a this and \a other hold different Gauss points with equal names.
3093 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3095 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3096 if(thisGlobals==otherGlobals)
3100 _globals=other._globals;
3103 _globals->appendGlobs(*other._globals,eps);
3106 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3108 checkGlobsPflsPartCoherency();
3109 checkGlobsLocsPartCoherency();
3112 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3114 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3117 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3119 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3122 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3124 contentNotNull()->loadProfileInFile(fid,id,pflName);
3127 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3129 contentNotNull()->loadProfileInFile(fid,id);
3132 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3134 contentNotNull()->loadGlobals(fid,*this);
3137 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3139 contentNotNull()->loadAllGlobals(fid);
3142 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3144 contentNotNull()->writeGlobals(fid,opt);
3148 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3149 * or getPflsReallyUsedMulti().
3150 * \return std::vector<std::string> - a sequence of names of all profiles.
3152 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3154 return contentNotNull()->getPfls();
3158 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3159 * or getLocsReallyUsedMulti().
3160 * \return std::vector<std::string> - a sequence of names of all localizations.
3162 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3164 return contentNotNull()->getLocs();
3168 * Checks if the profile with a given name exists.
3169 * \param [in] pflName - the profile name of interest.
3170 * \return bool - \c true if the profile named \a pflName exists.
3172 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3174 return contentNotNull()->existsPfl(pflName);
3178 * Checks if the localization with a given name exists.
3179 * \param [in] locName - the localization name of interest.
3180 * \return bool - \c true if the localization named \a locName exists.
3182 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3184 return contentNotNull()->existsLoc(locName);
3187 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3189 return contentNotNull()->createNewNameOfPfl();
3192 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3194 return contentNotNull()->createNewNameOfLoc();
3198 * Sets the name of a MED file.
3199 * \param [inout] fileName - the file name.
3201 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3203 contentNotNull()->setFileName(fileName);
3207 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3208 * in the same order.
3209 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3210 * Each item of this sequence is a vector containing ids of equal profiles.
3212 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3214 return contentNotNull()->whichAreEqualProfiles();
3218 * Finds equal localizations.
3219 * \param [in] eps - a precision used to compare real values of the localizations.
3220 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3221 * Each item of this sequence is a vector containing ids of equal localizations.
3223 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3225 return contentNotNull()->whichAreEqualLocs(eps);
3229 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3230 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3231 * this sequence is a pair whose
3232 * - the first item is a vector of profile names to replace by the second item,
3233 * - the second item is a profile name to replace every profile name of the first item.
3235 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3237 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3241 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3242 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3243 * this sequence is a pair whose
3244 * - the first item is a vector of localization names to replace by the second item,
3245 * - the second item is a localization name to replace every localization name of the first item.
3247 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3249 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3253 * Replaces references to some profiles (a reference is a profile name) by references
3254 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3255 * them-selves accordingly. <br>
3256 * This method is a generalization of changePflName().
3257 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3258 * this sequence is a pair whose
3259 * - the first item is a vector of profile names to replace by the second item,
3260 * - the second item is a profile name to replace every profile of the first item.
3261 * \sa changePflsRefsNamesGen()
3262 * \sa changePflName()
3264 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3266 changePflsRefsNamesGen(mapOfModif);
3267 changePflsNamesInStruct(mapOfModif);
3271 * Replaces references to some localizations (a reference is a localization name) by references
3272 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3273 * them-selves accordingly. <br>
3274 * This method is a generalization of changeLocName().
3275 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3276 * this sequence is a pair whose
3277 * - the first item is a vector of localization names to replace by the second item,
3278 * - the second item is a localization name to replace every localization of the first item.
3279 * \sa changeLocsRefsNamesGen()
3280 * \sa changeLocName()
3282 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3284 changeLocsRefsNamesGen(mapOfModif);
3285 changeLocsNamesInStruct(mapOfModif);
3289 * Renames the profile having a given name and updates references to this profile.
3290 * \param [in] oldName - the name of the profile to rename.
3291 * \param [in] newName - a new name of the profile.
3292 * \sa changePflsNames().
3294 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3296 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3297 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3299 changePflsNames(mapOfModif);
3303 * Renames the localization having a given name and updates references to this localization.
3304 * \param [in] oldName - the name of the localization to rename.
3305 * \param [in] newName - a new name of the localization.
3306 * \sa changeLocsNames().
3308 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3310 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3311 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3313 changeLocsNames(mapOfModif);
3317 * Removes duplicated profiles. Returns a map used to update references to removed
3318 * profiles via changePflsRefsNamesGen().
3319 * Equal profiles are found using whichAreEqualProfiles().
3320 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3321 * a sequence describing the performed replacements of profiles. Each element of
3322 * this sequence is a pair whose
3323 * - the first item is a vector of profile names replaced by the second item,
3324 * - the second item is a profile name replacing every profile of the first item.
3326 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3328 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3329 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3331 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3333 std::vector< std::string > tmp((*it).size());
3335 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3336 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3337 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3339 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3340 killProfileIds(tmp2);
3342 changePflsRefsNamesGen(ret);
3347 * Removes duplicated localizations. Returns a map used to update references to removed
3348 * localizations via changeLocsRefsNamesGen().
3349 * Equal localizations are found using whichAreEqualLocs().
3350 * \param [in] eps - a precision used to compare real values of the localizations.
3351 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3352 * a sequence describing the performed replacements of localizations. Each element of
3353 * this sequence is a pair whose
3354 * - the first item is a vector of localization names replaced by the second item,
3355 * - the second item is a localization name replacing every localization of the first item.
3357 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3359 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3360 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3362 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3364 std::vector< std::string > tmp((*it).size());
3366 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3367 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3368 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3370 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3371 killLocalizationIds(tmp2);
3373 changeLocsRefsNamesGen(ret);
3378 * Returns number of Gauss points per cell in a given localization.
3379 * \param [in] locId - an id of the localization of interest.
3380 * \return int - the number of the Gauss points per cell.
3382 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3384 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3388 * Returns an id of a localization by its name.
3389 * \param [in] loc - the localization name of interest.
3390 * \return int - the id of the localization.
3391 * \throw If there is no a localization named \a loc.
3393 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3395 return contentNotNull()->getLocalizationId(loc);
3399 * Returns the name of the MED file.
3400 * \return const std::string& - the MED file name.
3402 std::string MEDFileFieldGlobsReal::getFileName() const
3404 return contentNotNull()->getFileName();
3408 * Returns a localization object by its name.
3409 * \param [in] locName - the name of the localization of interest.
3410 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3411 * \throw If there is no a localization named \a locName.
3413 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3415 return contentNotNull()->getLocalization(locName);
3419 * Returns a localization object by its id.
3420 * \param [in] locId - the id of the localization of interest.
3421 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3422 * \throw If there is no a localization with id \a locId.
3424 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3426 return contentNotNull()->getLocalizationFromId(locId);
3430 * Returns a profile array by its name.
3431 * \param [in] pflName - the name of the profile of interest.
3432 * \return const DataArrayInt * - the profile array having the name \a pflName.
3433 * \throw If there is no a profile named \a pflName.
3435 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3437 return contentNotNull()->getProfile(pflName);
3441 * Returns a profile array by its id.
3442 * \param [in] pflId - the id of the profile of interest.
3443 * \return const DataArrayInt * - the profile array having the id \a pflId.
3444 * \throw If there is no a profile with id \a pflId.
3446 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3448 return contentNotNull()->getProfileFromId(pflId);
3452 * Returns a localization object, apt for modification, by its id.
3453 * \param [in] locId - the id of the localization of interest.
3454 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3455 * having the id \a locId.
3456 * \throw If there is no a localization with id \a locId.
3458 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3460 return contentNotNull()->getLocalizationFromId(locId);
3464 * Returns a localization object, apt for modification, by its name.
3465 * \param [in] locName - the name of the localization of interest.
3466 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3467 * having the name \a locName.
3468 * \throw If there is no a localization named \a locName.
3470 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3472 return contentNotNull()->getLocalization(locName);
3476 * Returns a profile array, apt for modification, by its name.
3477 * \param [in] pflName - the name of the profile of interest.
3478 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3479 * \throw If there is no a profile named \a pflName.
3481 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3483 return contentNotNull()->getProfile(pflName);
3487 * Returns a profile array, apt for modification, by its id.
3488 * \param [in] pflId - the id of the profile of interest.
3489 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3490 * \throw If there is no a profile with id \a pflId.
3492 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3494 return contentNotNull()->getProfileFromId(pflId);
3498 * Removes profiles given by their ids. No data is updated to track this removal.
3499 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3501 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3503 contentNotNull()->killProfileIds(pflIds);
3507 * Removes localizations given by their ids. No data is updated to track this removal.
3508 * \param [in] locIds - a sequence of ids of the localizations to remove.
3510 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3512 contentNotNull()->killLocalizationIds(locIds);
3516 * Stores a profile array.
3517 * \param [in] pfl - the profile array to store.
3518 * \throw If the name of \a pfl is empty.
3519 * \throw If a profile with the same name as that of \a pfl already exists but contains
3522 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3524 contentNotNull()->appendProfile(pfl);
3528 * Adds a new localization of Gauss points.
3529 * \param [in] locName - the name of the new localization.
3530 * \param [in] geoType - a geometrical type of the reference cell.
3531 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3532 * must be \c nbOfNodesPerCell * \c dimOfType.
3533 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3534 * must be _wg_.size() * \c dimOfType.
3535 * \param [in] w - the weights of Gauss points.
3536 * \throw If \a locName is empty.
3537 * \throw If a localization with the name \a locName already exists but is
3538 * different form the new one.
3540 void MEDFileFieldGlobsReal::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
3542 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3545 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3547 MEDFileFieldGlobs *g(_globals);
3549 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3553 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3555 const MEDFileFieldGlobs *g(_globals);
3557 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3561 //= MEDFileFieldNameScope
3563 MEDFileFieldNameScope::MEDFileFieldNameScope()
3567 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3572 * Returns the name of \a this field.
3573 * \return std::string - a string containing the field name.
3575 std::string MEDFileFieldNameScope::getName() const
3581 * Sets name of \a this field
3582 * \param [in] name - the new field name.
3584 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3589 std::string MEDFileFieldNameScope::getDtUnit() const
3594 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3599 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3602 _dt_unit=other._dt_unit;
3605 //= MEDFileAnyTypeField1TSWithoutSDA
3607 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3609 _field_per_mesh.resize(other._field_per_mesh.size());
3611 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3613 if((const MEDFileFieldPerMesh *)*it)
3614 _field_per_mesh[i]=(*it)->deepCpy(this);
3619 * Prints a string describing \a this field into a stream. This string is outputted
3620 * by \c print Python command.
3621 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3622 * \param [in,out] oss - the out stream.
3623 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3624 * info id printed, else, not.
3626 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3628 std::string startOfLine(bkOffset,' ');
3629 oss << startOfLine << "Field ";
3631 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3632 oss << "on one time Step ";
3634 oss << "(" << f1tsId << ") ";
3635 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3636 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3637 const DataArray *arr=getUndergroundDataArray();
3640 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3643 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3644 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3645 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3647 if(arr->isAllocated())
3649 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3652 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3656 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3658 oss << startOfLine << "----------------------" << std::endl;
3659 if(!_field_per_mesh.empty())
3662 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3664 const MEDFileFieldPerMesh *cur=(*it2);
3666 cur->simpleRepr(bkOffset,oss,i);
3668 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3673 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3675 oss << startOfLine << "----------------------" << std::endl;
3678 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3680 const DataArray *arr(getUndergroundDataArray());
3682 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3683 int nbOfCompo=arr->getNumberOfComponents();
3684 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3685 for(int i=0;i<nbOfCompo;i++)
3688 std::vector<int> v(1,i);
3689 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3690 ret[i]->setArray(arr2);
3695 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
3699 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3704 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3705 * empty. Returns -1 if this in on nodes.
3706 * \return int - the dimension of \a this.
3708 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3711 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3712 (*it)->getDimension(ret);
3717 * Returns the mesh name.
3718 * \return std::string - a string holding the mesh name.
3719 * \throw If \c _field_per_mesh.empty()
3721 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3723 if(_field_per_mesh.empty())
3724 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3725 return _field_per_mesh[0]->getMeshName();
3728 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3730 std::string oldName(getMeshName());
3731 std::vector< std::pair<std::string,std::string> > v(1);
3732 v[0].first=oldName; v[0].second=newMeshName;
3736 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3739 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3741 MEDFileFieldPerMesh *cur(*it);
3743 ret=cur->changeMeshNames(modifTab) || ret;
3749 * Returns the number of iteration of the state of underlying mesh.
3750 * \return int - the iteration number.
3751 * \throw If \c _field_per_mesh.empty()
3753 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3755 if(_field_per_mesh.empty())
3756 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3757 return _field_per_mesh[0]->getMeshIteration();
3761 * Returns the order number of iteration of the state of underlying mesh.
3762 * \return int - the order number.
3763 * \throw If \c _field_per_mesh.empty()
3765 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3767 if(_field_per_mesh.empty())
3768 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3769 return _field_per_mesh[0]->getMeshOrder();
3773 * Checks if \a this field is tagged by a given iteration number and a given
3774 * iteration order number.
3775 * \param [in] iteration - the iteration number of interest.
3776 * \param [in] order - the iteration order number of interest.
3777 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3778 * \a this->getOrder() == \a order.
3780 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3782 return iteration==_iteration && order==_order;
3786 * Returns number of iteration and order number of iteration when
3787 * \a this field has been calculated.
3788 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3791 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3793 std::pair<int,int> p;
3799 * Returns number of iteration and order number of iteration when
3800 * \a this field has been calculated.
3801 * \param [in,out] p - a pair returning the iteration number and the iteration
3804 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3811 * Returns all types of spatial discretization of \a this field.
3812 * \param [in,out] types - a sequence of types of \a this field.
3814 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
3816 std::set<TypeOfField> types2;
3817 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3819 (*it)->fillTypesOfFieldAvailable(types2);
3821 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3822 std::copy(types2.begin(),types2.end(),bi);
3826 * Returns all types of spatial discretization of \a this field.
3827 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3830 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
3832 std::vector<TypeOfField> ret;
3833 fillTypesOfFieldAvailable(ret);
3837 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3839 std::vector<std::string> ret;
3840 std::set<std::string> ret2;
3841 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3843 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3844 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3845 if(ret2.find(*it2)==ret2.end())
3847 ret.push_back(*it2);
3854 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3856 std::vector<std::string> ret;
3857 std::set<std::string> ret2;
3858 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3860 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
3861 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3862 if(ret2.find(*it2)==ret2.end())
3864 ret.push_back(*it2);
3871 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3873 std::vector<std::string> ret;
3874 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3876 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3877 ret.insert(ret.end(),tmp.begin(),tmp.end());
3882 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3884 std::vector<std::string> ret;
3885 std::set<std::string> ret2;
3886 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3888 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3889 ret.insert(ret.end(),tmp.begin(),tmp.end());
3894 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3896 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3897 (*it)->changePflsRefsNamesGen(mapOfModif);
3900 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3902 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3903 (*it)->changeLocsRefsNamesGen(mapOfModif);
3907 * Returns all attributes of parts of \a this field lying on a given mesh.
3908 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3909 * item of every of returned sequences refers to the _i_-th part of \a this field.
3910 * Thus all sequences returned by this method are of the same length equal to number
3911 * of different types of supporting entities.<br>
3912 * A field part can include sub-parts with several different spatial discretizations,
3913 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3914 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3915 * of a nested sequence corresponds to a type of spatial discretization.<br>
3916 * This method allows for iteration over MEDFile DataStructure without any overhead.
3917 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3918 * for the case with only one underlying mesh. (Actually, the number of meshes is
3919 * not checked if \a mname == \c NULL).
3920 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3921 * a field part is returned.
3922 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3923 * This sequence is of the same length as \a types.
3924 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3925 * discretization. A profile name can be empty.
3926 * Length of this and of nested sequences is the same as that of \a typesF.
3927 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3928 * discretization. A localization name can be empty.
3929 * Length of this and of nested sequences is the same as that of \a typesF.
3930 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3931 * of ids of tuples within the data array, per each type of spatial
3932 * discretization within one mesh entity type.
3933 * Length of this and of nested sequences is the same as that of \a typesF.
3934 * \throw If no field is lying on \a mname.
3936 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
3940 meshId=getMeshIdFromMeshName(mname);
3942 if(_field_per_mesh.empty())
3943 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3944 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3948 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3949 * maximal absolute dimension and values returned via the out parameter \a levs are
3950 * dimensions relative to the maximal absolute dimension. <br>
3951 * This method is designed for MEDFileField1TS instances that have a discretization
3952 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3953 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3954 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3955 * Only these 3 discretizations will be taken into account here. If \a this is
3956 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3957 * This method is useful to make the link between the dimension of the underlying mesh
3958 * and the levels of \a this, because it is possible that the highest dimension of \a this
3959 * field is not equal to the dimension of the underlying mesh.
3961 * Let's consider the following case:
3962 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3963 * TETRA4, HEXA8, TRI3 and SEG2.
3964 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3965 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3967 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3968 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3969 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3970 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3971 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3972 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3974 * to retrieve the highest level of
3975 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3976 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3977 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3978 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3979 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3980 * for the case with only one underlying mesh. (Actually, the number of meshes is
3981 * not checked if \a mname == \c NULL).
3982 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3983 * absolute one. They are in decreasing order. This sequence is cleared before
3985 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3986 * \throw If no field is lying on \a mname.
3988 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
3991 int meshId=getMeshIdFromMeshName(mname);
3992 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3993 std::vector< std::vector<TypeOfField> > typesF;
3994 std::vector< std::vector<std::string> > pfls, locs;
3995 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3997 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3998 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3999 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4001 st.erase(INTERP_KERNEL::NORM_ERROR);
4003 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4005 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4006 ret1.insert((int)cm.getDimension());
4008 int ret=*std::max_element(ret1.begin(),ret1.end());
4009 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4010 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4015 * \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.
4016 * \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.
4017 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4018 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4020 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4022 int mid=getMeshIdFromMeshName(mName);
4023 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4027 * \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.
4028 * \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.
4029 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4030 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4032 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4034 int mid=getMeshIdFromMeshName(mName);
4035 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4039 * \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.
4041 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4043 if(_field_per_mesh.empty())
4044 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4047 std::string mName2(mName);
4049 std::vector<std::string> msg;
4050 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4051 if(mName2==(*it)->getMeshName())
4054 msg.push_back((*it)->getMeshName());
4055 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4056 oss << "Possible meshes are : ";
4057 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4058 oss << "\"" << (*it2) << "\" ";
4059 throw INTERP_KERNEL::Exception(oss.str().c_str());
4062 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4065 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4066 std::string tmp(mesh->getName());
4068 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4069 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4071 for(;it!=_field_per_mesh.end();it++,i++)
4073 if((*it)->getMeshName()==tmp)
4076 int sz=_field_per_mesh.size();
4077 _field_per_mesh.resize(sz+1);
4078 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4082 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4083 MEDFileFieldGlobsReal& glob)
4086 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4088 MEDFileFieldPerMesh *fpm(*it);
4090 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4095 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4097 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4098 std::vector< std::vector<TypeOfField> > typesF;
4099 std::vector< std::vector<std::string> > pfls,locs;
4100 std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4101 std::set<TypeOfField> allEnt;
4102 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4103 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4104 allEnt.insert(*it2);
4105 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4106 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4107 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4109 std::vector< std::pair<int,int> > its;
4110 ret[i]=shallowCpy();
4111 int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4112 ret[i]->updateData(newLgth,its);
4117 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4119 int globalCounter=0;
4120 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4121 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4122 return globalCounter;
4125 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4127 if(_nb_of_tuples_to_be_allocated>=0)
4129 _nb_of_tuples_to_be_allocated=newLgth;
4130 const DataArray *oldArr(getUndergroundDataArray());
4133 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4134 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4136 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4140 if(_nb_of_tuples_to_be_allocated==-1)
4142 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4144 const DataArray *oldArr(getUndergroundDataArray());
4145 if(!oldArr || !oldArr->isAllocated())
4146 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4147 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4148 newArr->alloc(newLgth,getNumberOfComponents());
4150 newArr->copyStringInfoFrom(*oldArr);
4152 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4154 if((*it).second<(*it).first)
4155 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4156 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4157 pos+=(*it).second-(*it).first;
4162 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4165 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4167 if(_field_per_mesh.empty())
4168 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4169 if(_field_per_mesh.size()>1)
4170 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4171 _field_per_mesh[0]->copyOptionsFrom(opts);
4172 _field_per_mesh[0]->writeLL(fid,nasc);
4176 * 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.
4177 * If false is returned the memory allocation is not required.
4179 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4181 if(_nb_of_tuples_to_be_allocated>=0)
4183 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4184 _nb_of_tuples_to_be_allocated=-2;
4187 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4189 if(_nb_of_tuples_to_be_allocated==-1)
4190 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4191 if(_nb_of_tuples_to_be_allocated<-3)
4192 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4193 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4196 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4198 med_int numdt,numit;
4202 med_int meshnumdt,meshnumit;
4203 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4204 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4205 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4206 if(_iteration!=numdt || _order!=numit)
4207 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4208 _field_per_mesh.resize(nmesh);
4209 for(int i=0;i<nmesh;i++)
4210 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4211 _nb_of_tuples_to_be_allocated=0;
4212 for(int i=0;i<nmesh;i++)
4213 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4216 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4218 allocIfNecessaryTheArrayToReceiveDataFromFile();
4219 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4220 (*it)->loadBigArraysRecursively(fid,nasc);
4223 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4225 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4226 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4227 (*it)->loadBigArraysRecursively(fid,nasc);
4230 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4232 loadOnlyStructureOfDataRecursively(fid,nasc);
4233 loadBigArraysRecursively(fid,nasc);
4236 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4238 DataArray *thisArr(getUndergroundDataArray());
4239 if(thisArr && thisArr->isAllocated())
4241 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4242 thisArr->desallocate();
4246 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4248 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4251 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildren() const
4253 std::vector<const BigMemoryObject *> ret;
4254 if(getUndergroundDataArray())
4255 ret.push_back(getUndergroundDataArray());
4256 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4258 const MEDFileFieldPerMesh *cur(*it);
4266 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4267 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4268 * "Sort By Type"), if not, an exception is thrown.
4269 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4270 * \param [in] arr - the array of values.
4271 * \param [in,out] glob - the global data where profiles and localization present in
4272 * \a field, if any, are added.
4273 * \throw If the name of \a field is empty.
4274 * \throw If the data array of \a field is not set.
4275 * \throw If \a this->_arr is already allocated but has different number of components
4277 * \throw If the underlying mesh of \a field has no name.
4278 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4280 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4282 const MEDCouplingMesh *mesh=field->getMesh();
4284 TypeOfField type=field->getTypeOfField();
4285 std::vector<DataArrayInt *> dummy;
4286 int start=copyTinyInfoFrom(field,arr);
4287 int pos=addNewEntryIfNecessary(mesh);
4290 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4291 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4294 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4298 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4299 * of a given mesh are used as the support of the given field (a real support is not used).
4300 * Elements of the given mesh must be sorted suitable for writing to MED file.
4301 * Order of underlying mesh entities of the given field specified by \a profile parameter
4302 * is not prescribed; this method permutes field values to have them sorted by element
4303 * type as required for writing to MED file. A new profile is added only if no equal
4304 * profile is missing.
4305 * \param [in] field - the field to add to \a this. The field double values are ignored.
4306 * \param [in] arrOfVals - the values of the field \a field used.
4307 * \param [in] mesh - the supporting mesh of \a field.
4308 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4309 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4310 * \param [in,out] glob - the global data where profiles and localization present in
4311 * \a field, if any, are added.
4312 * \throw If either \a field or \a mesh or \a profile has an empty name.
4313 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4314 * \throw If the data array of \a field is not set.
4315 * \throw If \a this->_arr is already allocated but has different number of components
4317 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4318 * \sa setFieldNoProfileSBT()
4320 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4323 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4324 if(!arrOfVals || !arrOfVals->isAllocated())
4325 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4326 TypeOfField type=field->getTypeOfField();
4327 std::vector<DataArrayInt *> idsInPflPerType;
4328 std::vector<DataArrayInt *> idsPerType;
4329 std::vector<int> code,code2;
4330 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4333 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4334 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4335 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4336 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4338 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4339 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4340 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4342 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4343 throw INTERP_KERNEL::Exception(oss.str().c_str());
4346 int start=copyTinyInfoFrom(field,arrOfVals);
4347 code2=m->getDistributionOfTypes();
4349 int pos=addNewEntryIfNecessary(m);
4350 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4354 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4355 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4356 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4357 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4358 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4359 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4361 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4362 throw INTERP_KERNEL::Exception(oss.str().c_str());
4364 int start=copyTinyInfoFrom(field,arrOfVals);
4365 int pos=addNewEntryIfNecessary(m);
4366 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4371 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4373 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4375 if(_nb_of_tuples_to_be_allocated>=0)
4376 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 !");
4377 DataArray *arr(getOrCreateAndGetArray());
4378 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4379 _nb_of_tuples_to_be_allocated=-3;
4383 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4384 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4385 * larger by the size of \a field. Returns an id of the first not filled
4386 * tuple of \a this->_arr.
4387 * \param [in] field - the field to copy the info on components and the name from.
4388 * \return int - the id of first not initialized tuple of \a this->_arr.
4389 * \throw If the name of \a field is empty.
4390 * \throw If the data array of \a field is not set.
4391 * \throw If \a this->_arr is already allocated but has different number of components
4394 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4397 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4398 std::string name(field->getName());
4399 setName(name.c_str());
4400 setDtUnit(field->getTimeUnit());
4402 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4404 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4405 if(!arr->isAllocated())
4406 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4407 _dt=field->getTime(_iteration,_order);
4408 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4409 if(!getOrCreateAndGetArray()->isAllocated())
4411 allocNotFromFile(arr->getNumberOfTuples());
4416 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4417 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4418 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4419 _nb_of_tuples_to_be_allocated=-3;
4420 return oldNbOfTuples;
4425 * Returns number of components in \a this field
4426 * \return int - the number of components.
4428 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4430 return getOrCreateAndGetArray()->getNumberOfComponents();
4434 * Change info on components in \a this.
4435 * \throw If size of \a infos is not equal to the number of components already in \a this.
4437 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4439 DataArray *arr=getOrCreateAndGetArray();
4440 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4444 * Returns info on components of \a this field.
4445 * \return const std::vector<std::string>& - a sequence of strings each being an
4446 * information on _i_-th component.
4448 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4450 const DataArray *arr=getOrCreateAndGetArray();
4451 return arr->getInfoOnComponents();
4455 * Returns a mutable info on components of \a this field.
4456 * \return std::vector<std::string>& - a sequence of strings each being an
4457 * information on _i_-th component.
4459 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4461 DataArray *arr=getOrCreateAndGetArray();
4462 return arr->getInfoOnComponents();
4466 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4467 * \param [in] type - a spatial discretization of the new field.
4468 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
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 of \a meshDimRelToMax dimension in the mesh.
4483 * \throw If no field of \a this is lying on the mesh \a mName.
4484 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4486 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4488 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4490 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4492 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4493 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4497 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4498 * \param [in] type - a spatial discretization of the new field.
4499 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
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 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4510 * caller is to delete this field using decrRef() as it is no more needed.
4511 * \throw If the MED file is not readable.
4512 * \throw If no field of \a this is lying on \a mesh.
4513 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4514 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4516 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4518 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4519 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4520 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4521 if(meshDimRelToMax==1)
4522 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4523 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4527 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4529 * \param [in] type - a spatial discretization of the new field.
4530 * \param [in] mName - a name of the supporting mesh.
4531 * \param [in] renumPol - specifies how to permute values of the result field according to
4532 * the optional numbers of cells and nodes, if any. The valid values are
4533 * - 0 - do not permute.
4534 * - 1 - permute cells.
4535 * - 2 - permute nodes.
4536 * - 3 - permute cells and nodes.
4538 * \param [in] glob - the global data storing profiles and localization.
4539 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4540 * caller is to delete this field using decrRef() as it is no more needed.
4541 * \throw If the MED file is not readable.
4542 * \throw If there is no mesh named \a mName in the MED file.
4543 * \throw If there are no mesh entities in the mesh.
4544 * \throw If no field values of the given \a type are available.
4546 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4548 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4550 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4552 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4553 int absDim=getDimension();
4554 int meshDimRelToMax=absDim-mm->getMeshDimension();
4555 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4559 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4560 * \param [in] type - a spatial discretization of the new field.
4561 * \param [in] renumPol - specifies how to permute values of the result field according to
4562 * the optional numbers of cells and nodes, if any. The valid values are
4563 * - 0 - do not permute.
4564 * - 1 - permute cells.
4565 * - 2 - permute nodes.
4566 * - 3 - permute cells and nodes.
4568 * \param [in] glob - the global data storing profiles and localization.
4569 * \param [in] mesh - the supporting mesh.
4570 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4571 * field according to \a renumPol.
4572 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4573 * field according to \a renumPol.
4574 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4575 * caller is to delete this field using decrRef() as it is no more needed.
4576 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4577 * \throw If no field of \a this is lying on \a mesh.
4578 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4580 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
4582 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4583 int meshId=getMeshIdFromMeshName(mesh->getName());
4585 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4590 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4597 throw INTERP_KERNEL::Exception(msg1);
4598 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4601 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4603 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4604 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4605 throw INTERP_KERNEL::Exception(oss.str().c_str());
4607 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4608 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4609 std::vector<DataArray *> arrOut2(1,arrOut);
4610 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4611 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4612 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4619 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4621 throw INTERP_KERNEL::Exception(msg1);
4624 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4626 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4627 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4628 throw INTERP_KERNEL::Exception(oss.str().c_str());
4630 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4631 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4632 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4633 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4638 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4643 * Returns values and a profile of the field of a given type lying on a given support.
4644 * \param [in] type - a spatial discretization of the field.
4645 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4646 * \param [in] mesh - the supporting mesh.
4647 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4648 * field of interest lies on. If the field lies on all entities of the given
4649 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4650 * using decrRef() as it is no more needed.
4651 * \param [in] glob - the global data storing profiles and localization.
4652 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4653 * field. The caller is to delete this array using decrRef() as it is no more needed.
4654 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4655 * \throw If no field of \a this is lying on \a mesh.
4656 * \throw If no field values of the given \a type are available.
4658 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4660 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4661 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4662 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4663 ret->setName(nasc.getName().c_str());
4667 //= MEDFileField1TSWithoutSDA
4670 * Throws if a given value is not a valid (non-extended) relative dimension.
4671 * \param [in] meshDimRelToMax - the relative dimension value.
4672 * \throw If \a meshDimRelToMax > 0.
4674 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4676 if(meshDimRelToMax>0)
4677 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4681 * Checks if elements of a given mesh are in the order suitable for writing
4682 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4683 * vector describing types of elements and their number.
4684 * \param [in] mesh - the mesh to check.
4685 * \return std::vector<int> - a vector holding for each element type (1) item of
4686 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4687 * These values are in full-interlace mode.
4688 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4690 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4693 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4694 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4695 int nbOfTypes=geoTypes.size();
4696 std::vector<int> code(3*nbOfTypes);
4697 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4698 arr1->alloc(nbOfTypes,1);
4699 int *arrPtr=arr1->getPointer();
4700 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4701 for(int i=0;i<nbOfTypes;i++,it++)
4702 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4703 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4704 const int *arrPtr2=arr2->getConstPointer();
4706 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4709 int nbCells=mesh->getNumberOfCellsWithType(*it);
4710 code[3*pos]=(int)(*it);
4711 code[3*pos+1]=nbCells;
4712 code[3*pos+2]=-1;//no profiles
4714 std::vector<const DataArrayInt *> idsPerType;//no profiles
4715 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4719 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4724 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4726 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4730 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4731 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4732 * item of every of returned sequences refers to the _i_-th part of \a this field.
4733 * Thus all sequences returned by this method are of the same length equal to number
4734 * of different types of supporting entities.<br>
4735 * A field part can include sub-parts with several different spatial discretizations,
4736 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4737 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4738 * of a nested sequence corresponds to a type of spatial discretization.<br>
4739 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4740 * The overhead is due to selecting values into new instances of DataArrayDouble.
4741 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4742 * for the case with only one underlying mesh. (Actually, the number of meshes is
4743 * not checked if \a mname == \c NULL).
4744 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4745 * a field part is returned.
4746 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4747 * A field part can include sub-parts with several different spatial discretizations,
4748 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4749 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4750 * This sequence is of the same length as \a types.
4751 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4752 * discretization. A profile name can be empty.
4753 * Length of this and of nested sequences is the same as that of \a typesF.
4754 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4755 * discretization. A localization name can be empty.
4756 * Length of this and of nested sequences is the same as that of \a typesF.
4757 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4758 * per each type of spatial discretization within one mesh entity type.
4759 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4760 * Length of this and of nested sequences is the same as that of \a typesF.
4761 * \throw If no field is lying on \a mname.
4763 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
4767 meshId=getMeshIdFromMeshName(mname);
4769 if(_field_per_mesh.empty())
4770 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4771 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4772 int nbOfRet=ret0.size();
4773 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4774 for(int i=0;i<nbOfRet;i++)
4776 const std::vector< std::pair<int,int> >& p=ret0[i];
4777 int nbOfRet1=p.size();
4778 ret[i].resize(nbOfRet1);
4779 for(int j=0;j<nbOfRet1;j++)
4781 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4789 * Returns a pointer to the underground DataArrayDouble instance. So the
4790 * caller should not decrRef() it. This method allows for a direct access to the field
4791 * values. This method is quite unusable if there is more than a nodal field or a cell
4792 * field on single geometric cell type.
4793 * \return DataArrayDouble * - the pointer to the field values array.
4795 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
4797 const DataArrayDouble *ret=_arr;
4799 return const_cast<DataArrayDouble *>(ret);
4804 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
4809 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
4811 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4812 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4813 ret->deepCpyLeavesFrom(*this);
4814 const DataArrayDouble *arr(_arr);
4817 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4818 ret->setArray(arr2);
4824 * Returns a pointer to the underground DataArrayDouble instance. So the
4825 * caller should not decrRef() it. This method allows for a direct access to the field
4826 * values. This method is quite unusable if there is more than a nodal field or a cell
4827 * field on single geometric cell type.
4828 * \return DataArrayDouble * - the pointer to the field values array.
4830 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
4832 return getUndergroundDataArrayDouble();
4836 * Returns a pointer to the underground DataArrayDouble instance and a
4837 * sequence describing parameters of a support of each part of \a this field. The
4838 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4839 * direct access to the field values. This method is intended for the field lying on one
4841 * \param [in,out] entries - the sequence describing parameters of a support of each
4842 * part of \a this field. Each item of this sequence consists of two parts. The
4843 * first part describes a type of mesh entity and an id of discretization of a
4844 * current field part. The second part describes a range of values [begin,end)
4845 * within the returned array relating to the current field part.
4846 * \return DataArrayDouble * - the pointer to the field values array.
4847 * \throw If the number of underlying meshes is not equal to 1.
4848 * \throw If no field values are available.
4849 * \sa getUndergroundDataArray()
4851 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4853 if(_field_per_mesh.size()!=1)
4854 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4855 if(_field_per_mesh[0]==0)
4856 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4857 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4858 return getUndergroundDataArrayDouble();
4862 * Returns a pointer to the underground DataArrayDouble instance and a
4863 * sequence describing parameters of a support of each part of \a this field. The
4864 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4865 * direct access to the field values. This method is intended for the field lying on one
4867 * \param [in,out] entries - the sequence describing parameters of a support of each
4868 * part of \a this field. Each item of this sequence consists of two parts. The
4869 * first part describes a type of mesh entity and an id of discretization of a
4870 * current field part. The second part describes a range of values [begin,end)
4871 * within the returned array relating to the current field part.
4872 * \return DataArrayDouble * - the pointer to the field values array.
4873 * \throw If the number of underlying meshes is not equal to 1.
4874 * \throw If no field values are available.
4875 * \sa getUndergroundDataArray()
4877 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4879 return getUndergroundDataArrayDoubleExt(entries);
4882 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
4883 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4885 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4886 arr->setInfoAndChangeNbOfCompo(infos);
4889 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4893 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
4895 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4896 ret->deepCpyLeavesFrom(*this);
4900 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
4902 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4903 if((const DataArrayDouble *)_arr)
4904 ret->_arr=_arr->deepCpy();
4908 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
4912 _nb_of_tuples_to_be_allocated=-1;
4916 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4918 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4920 _nb_of_tuples_to_be_allocated=-3;
4925 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4927 return DataArrayDouble::New();
4930 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4932 DataArrayDouble *ret=_arr;
4935 _arr=DataArrayDouble::New();
4939 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4941 return getOrCreateAndGetArrayDouble();
4944 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4946 const DataArrayDouble *ret=_arr;
4949 DataArrayDouble *ret2=DataArrayDouble::New();
4950 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4954 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4956 return getOrCreateAndGetArrayDouble();
4959 //= MEDFileIntField1TSWithoutSDA
4961 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order,
4962 const std::vector<std::string>& infos)
4964 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4967 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4971 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
4972 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4974 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4975 arr->setInfoAndChangeNbOfCompo(infos);
4978 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
4983 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
4985 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4986 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4987 ret->deepCpyLeavesFrom(*this);
4988 const DataArrayInt *arr(_arr);
4991 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4992 ret->setArray(arr2);
4998 * Returns a pointer to the underground DataArrayInt instance. So the
4999 * caller should not decrRef() it. This method allows for a direct access to the field
5000 * values. This method is quite unusable if there is more than a nodal field or a cell
5001 * field on single geometric cell type.
5002 * \return DataArrayInt * - the pointer to the field values array.
5004 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5006 return getUndergroundDataArrayInt();
5010 * Returns a pointer to the underground DataArrayInt instance. So the
5011 * caller should not decrRef() it. This method allows for a direct access to the field
5012 * values. This method is quite unusable if there is more than a nodal field or a cell
5013 * field on single geometric cell type.
5014 * \return DataArrayInt * - the pointer to the field values array.
5016 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5018 const DataArrayInt *ret=_arr;
5020 return const_cast<DataArrayInt *>(ret);
5026 * Returns a pointer to the underground DataArrayInt instance and a
5027 * sequence describing parameters of a support of each part of \a this field. The
5028 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5029 * direct access to the field values. This method is intended for the field lying on one
5031 * \param [in,out] entries - the sequence describing parameters of a support of each
5032 * part of \a this field. Each item of this sequence consists of two parts. The
5033 * first part describes a type of mesh entity and an id of discretization of a
5034 * current field part. The second part describes a range of values [begin,end)
5035 * within the returned array relating to the current field part.
5036 * \return DataArrayInt * - the pointer to the field values array.
5037 * \throw If the number of underlying meshes is not equal to 1.
5038 * \throw If no field values are available.
5039 * \sa getUndergroundDataArray()
5041 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5043 return getUndergroundDataArrayIntExt(entries);
5047 * Returns a pointer to the underground DataArrayInt instance and a
5048 * sequence describing parameters of a support of each part of \a this field. The
5049 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5050 * direct access to the field values. This method is intended for the field lying on one
5052 * \param [in,out] entries - the sequence describing parameters of a support of each
5053 * part of \a this field. Each item of this sequence consists of two parts. The
5054 * first part describes a type of mesh entity and an id of discretization of a
5055 * current field part. The second part describes a range of values [begin,end)
5056 * within the returned array relating to the current field part.
5057 * \return DataArrayInt * - the pointer to the field values array.
5058 * \throw If the number of underlying meshes is not equal to 1.
5059 * \throw If no field values are available.
5060 * \sa getUndergroundDataArray()
5062 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5064 if(_field_per_mesh.size()!=1)
5065 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5066 if(_field_per_mesh[0]==0)
5067 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5068 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5069 return getUndergroundDataArrayInt();
5072 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5074 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5075 ret->deepCpyLeavesFrom(*this);
5079 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5081 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5082 if((const DataArrayInt *)_arr)
5083 ret->_arr=_arr->deepCpy();
5087 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5091 _nb_of_tuples_to_be_allocated=-1;
5095 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5097 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5099 _nb_of_tuples_to_be_allocated=-3;
5104 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5106 return DataArrayInt::New();
5109 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5111 DataArrayInt *ret=_arr;
5114 _arr=DataArrayInt::New();
5118 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5120 return getOrCreateAndGetArrayInt();
5123 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5125 const DataArrayInt *ret=_arr;
5128 DataArrayInt *ret2=DataArrayInt::New();
5129 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5133 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5135 return getOrCreateAndGetArrayInt();
5138 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5142 //= MEDFileAnyTypeField1TS
5144 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll)
5146 med_field_type typcha;
5148 std::vector<std::string> infos;
5149 std::string dtunit,fieldName;
5150 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5151 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5156 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5161 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5166 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] !";
5167 throw INTERP_KERNEL::Exception(oss.str().c_str());
5170 ret->setDtUnit(dtunit.c_str());
5171 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5173 med_int numdt,numit;
5175 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5176 ret->setTime(numdt,numit,dt);
5179 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5181 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5185 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll)
5186 try:MEDFileFieldGlobsReal(fileName)
5188 MEDFileUtilities::CheckFileForRead(fileName);
5189 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5190 _content=BuildContentFrom(fid,fileName,loadAll);
5193 catch(INTERP_KERNEL::Exception& e)
5198 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll)
5200 med_field_type typcha;
5201 std::vector<std::string> infos;
5204 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5205 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5210 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5215 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5220 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] !";
5221 throw INTERP_KERNEL::Exception(oss.str().c_str());
5224 ret->setDtUnit(dtunit.c_str());
5225 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5229 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5230 throw INTERP_KERNEL::Exception(oss.str().c_str());
5233 med_int numdt,numit;
5235 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5236 ret->setTime(numdt,numit,dt);
5239 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5241 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5245 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll)
5246 try:MEDFileFieldGlobsReal(fileName)
5248 MEDFileUtilities::CheckFileForRead(fileName);
5249 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5250 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5253 catch(INTERP_KERNEL::Exception& e)
5258 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5261 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5262 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5264 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5265 ret->setFileName(fileName);
5266 ret->_content=c; c->incrRef();
5269 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5271 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5272 ret->setFileName(fileName);
5273 ret->_content=c; c->incrRef();
5276 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5279 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5281 MEDFileUtilities::CheckFileForRead(fileName);
5282 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5283 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5284 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5285 ret->loadGlobals(fid);
5289 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5291 MEDFileUtilities::CheckFileForRead(fileName);
5292 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5293 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5294 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5295 ret->loadGlobals(fid);
5299 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5301 MEDFileUtilities::CheckFileForRead(fileName);
5302 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5303 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5304 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5305 ret->loadGlobals(fid);
5309 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5311 med_field_type typcha;
5312 std::vector<std::string> infos;
5315 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5316 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5321 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5326 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5331 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] !";
5332 throw INTERP_KERNEL::Exception(oss.str().c_str());
5335 ret->setDtUnit(dtunit.c_str());
5336 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5339 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5340 for(int i=0;i<nbOfStep2 && !found;i++)
5342 med_int numdt,numit;
5344 MEDfieldComputingStepInfo(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt);
5345 if(numdt==iteration && numit==order)
5351 dtits[i]=std::pair<int,int>(numdt,numit);
5355 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5356 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5357 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5358 throw INTERP_KERNEL::Exception(oss.str().c_str());
5361 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5363 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5367 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5368 try:MEDFileFieldGlobsReal(fileName)
5370 MEDFileUtilities::CheckFileForRead(fileName);
5371 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5372 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll);
5375 catch(INTERP_KERNEL::Exception& e)
5381 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5382 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5384 * \warning this is a shallow copy constructor
5386 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5388 if(!shallowCopyOfContent)
5390 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5391 otherPtr->incrRef();
5392 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5396 _content=other.shallowCpy();
5400 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const std::string& fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5404 int nbFields=MEDnField(fid);
5405 if(fieldIdCFormat>=nbFields)
5407 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5408 throw INTERP_KERNEL::Exception(oss.str().c_str());
5411 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5412 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5413 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5414 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5415 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5416 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5419 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5420 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5421 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5422 infos.clear(); infos.resize(ncomp);
5423 for(int j=0;j<ncomp;j++)
5424 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5429 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5432 * \return in case of success the number of time steps available for the field with name \a fieldName.
5434 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fileName, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5436 int nbFields=MEDnField(fid);
5438 std::vector<std::string> fns(nbFields);
5440 for(int i=0;i<nbFields && !found;i++)
5443 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5445 found=(tmp==fieldName);
5451 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5452 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5453 oss << "\"" << *it << "\" ";
5454 throw INTERP_KERNEL::Exception(oss.str().c_str());
5460 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5461 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5462 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5463 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5464 * to keep a valid instance.
5465 * 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.
5466 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5467 * 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.
5469 * \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.
5470 * \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.
5471 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5472 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5473 * \param [in] newLocName is the new localization name.
5474 * \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.
5475 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5477 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5479 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5480 std::string oldPflName=disc->getProfile();
5481 std::vector<std::string> vv=getPflsReallyUsedMulti();
5482 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5483 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5485 disc->setProfile(newPflName);
5486 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5487 pfl->setName(newPflName);
5491 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5492 throw INTERP_KERNEL::Exception(oss.str().c_str());
5497 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5498 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5499 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5500 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5501 * to keep a valid instance.
5502 * 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.
5503 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5504 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5505 * 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.
5507 * \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.
5508 * \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.
5509 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5510 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5511 * \param [in] newLocName is the new localization name.
5512 * \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.
5513 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5515 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5517 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5518 std::string oldLocName=disc->getLocalization();
5519 std::vector<std::string> vv=getLocsReallyUsedMulti();
5520 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5521 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5523 disc->setLocalization(newLocName);
5524 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5525 loc.setName(newLocName);
5529 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5530 throw INTERP_KERNEL::Exception(oss.str().c_str());
5534 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5536 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5538 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5542 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5544 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5546 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5551 * Writes \a this field into a MED file specified by its name.
5552 * \param [in] fileName - the MED file name.
5553 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5554 * - 2 - erase; an existing file is removed.
5555 * - 1 - append; same data should not be present in an existing file.
5556 * - 0 - overwrite; same data present in an existing file is overwritten.
5557 * \throw If the field name is not set.
5558 * \throw If no field data is set.
5559 * \throw If \a mode == 1 and the same data is present in an existing file.
5561 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5563 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5564 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5569 * This method alloc the arrays and load potentially huge arrays contained in this field.
5570 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5571 * This method can be also called to refresh or reinit values from a file.
5573 * \throw If the fileName is not set or points to a non readable MED file.
5574 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5576 void MEDFileAnyTypeField1TS::loadArrays()
5578 if(getFileName().empty())
5579 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5580 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5581 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5585 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5586 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5587 * this method does not throw if \a this does not come from file read.
5589 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5591 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5593 if(!getFileName().empty())
5595 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5596 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5601 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5602 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5603 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5605 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5607 void MEDFileAnyTypeField1TS::unloadArrays()
5609 contentNotNullBase()->unloadArrays();
5613 * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
5614 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5615 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5617 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5619 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5621 if(!getFileName().empty())
5622 contentNotNullBase()->unloadArrays();
5625 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5627 int nbComp=getNumberOfComponents();
5628 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5629 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5630 for(int i=0;i<nbComp;i++)
5632 std::string info=getInfo()[i];
5634 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5635 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5636 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5638 if(getName().empty())
5639 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5640 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5641 writeGlobals(fid,*this);
5642 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5645 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5647 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5650 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildren() const
5652 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildren());
5653 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5654 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5659 * Returns a string describing \a this field. This string is outputted
5660 * by \c print Python command.
5662 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5664 std::ostringstream oss;
5665 contentNotNullBase()->simpleRepr(0,oss,-1);
5666 simpleReprGlobs(oss);
5671 * This method returns all profiles whose name is non empty used.
5672 * \b WARNING If profile is used several times it will be reported \b only \b once.
5673 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5675 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5677 return contentNotNullBase()->getPflsReallyUsed2();
5681 * This method returns all localizations whose name is non empty used.
5682 * \b WARNING If localization is used several times it will be reported \b only \b once.
5684 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5686 return contentNotNullBase()->getLocsReallyUsed2();
5690 * This method returns all profiles whose name is non empty used.
5691 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5693 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5695 return contentNotNullBase()->getPflsReallyUsedMulti2();
5699 * This method returns all localizations whose name is non empty used.
5700 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5702 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5704 return contentNotNullBase()->getLocsReallyUsedMulti2();
5707 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5709 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5712 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5714 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5717 int MEDFileAnyTypeField1TS::getDimension() const
5719 return contentNotNullBase()->getDimension();
5722 int MEDFileAnyTypeField1TS::getIteration() const
5724 return contentNotNullBase()->getIteration();
5727 int MEDFileAnyTypeField1TS::getOrder() const
5729 return contentNotNullBase()->getOrder();
5732 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5734 return contentNotNullBase()->getTime(iteration,order);
5737 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5739 contentNotNullBase()->setTime(iteration,order,val);
5742 std::string MEDFileAnyTypeField1TS::getName() const
5744 return contentNotNullBase()->getName();
5747 void MEDFileAnyTypeField1TS::setName(const std::string& name)
5749 contentNotNullBase()->setName(name);
5752 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5754 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5757 std::string MEDFileAnyTypeField1TS::getDtUnit() const
5759 return contentNotNullBase()->getDtUnit();
5762 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
5764 contentNotNullBase()->setDtUnit(dtUnit);
5767 std::string MEDFileAnyTypeField1TS::getMeshName() const
5769 return contentNotNullBase()->getMeshName();
5772 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
5774 contentNotNullBase()->setMeshName(newMeshName);
5777 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
5779 return contentNotNullBase()->changeMeshNames(modifTab);
5782 int MEDFileAnyTypeField1TS::getMeshIteration() const
5784 return contentNotNullBase()->getMeshIteration();
5787 int MEDFileAnyTypeField1TS::getMeshOrder() const
5789 return contentNotNullBase()->getMeshOrder();
5792 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5794 return contentNotNullBase()->getNumberOfComponents();
5797 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5799 return contentNotNullBase()->isDealingTS(iteration,order);
5802 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5804 return contentNotNullBase()->getDtIt();
5807 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5809 contentNotNullBase()->fillIteration(p);
5812 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
5814 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5817 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
5819 contentNotNullBase()->setInfo(infos);
5822 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5824 return contentNotNullBase()->getInfo();
5826 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5828 return contentNotNullBase()->getInfo();
5831 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
5833 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5836 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
5838 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5841 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
5843 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5846 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
5848 return contentNotNullBase()->getTypesOfFieldAvailable();
5851 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5852 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
5854 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5858 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5859 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5860 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5862 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
5864 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5866 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5867 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5868 std::size_t sz(contentsSplit.size());
5869 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5870 for(std::size_t i=0;i<sz;i++)
5872 ret[i]=shallowCpy();
5873 ret[i]->_content=contentsSplit[i];
5879 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5880 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5882 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
5884 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5886 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5887 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5888 std::size_t sz(contentsSplit.size());
5889 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5890 for(std::size_t i=0;i<sz;i++)
5892 ret[i]=shallowCpy();
5893 ret[i]->_content=contentsSplit[i];
5898 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
5900 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5901 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5902 ret->_content=_content->deepCpy();
5903 ret->deepCpyGlobs(*this);
5907 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5909 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5915 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5916 * the first field that has been read from a specified MED file.
5917 * \param [in] fileName - the name of the MED file to read.
5918 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5919 * is to delete this field using decrRef() as it is no more needed.
5920 * \throw If reading the file fails.
5922 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
5924 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5925 ret->contentNotNull();
5930 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5931 * a given field that has been read from a specified MED file.
5932 * \param [in] fileName - the name of the MED file to read.
5933 * \param [in] fieldName - the name of the field to read.
5934 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5935 * is to delete this field using decrRef() as it is no more needed.
5936 * \throw If reading the file fails.
5937 * \throw If there is no field named \a fieldName in the file.
5939 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5941 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5942 ret->contentNotNull();
5947 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5948 * a given field that has been read from a specified MED file.
5949 * \param [in] fileName - the name of the MED file to read.
5950 * \param [in] fieldName - the name of the field to read.
5951 * \param [in] iteration - the iteration number of a required time step.
5952 * \param [in] order - the iteration order number of required time step.
5953 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5954 * is to delete this field using decrRef() as it is no more needed.
5955 * \throw If reading the file fails.
5956 * \throw If there is no field named \a fieldName in the file.
5957 * \throw If the required time step is missing from the file.
5959 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5961 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5962 ret->contentNotNull();
5967 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5968 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5970 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5971 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5972 * \warning this is a shallow copy constructor
5973 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5974 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5975 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5976 * is to delete this field using decrRef() as it is no more needed.
5978 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5980 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5981 ret->contentNotNull();
5986 * Returns a new empty instance of MEDFileField1TS.
5987 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5988 * is to delete this field using decrRef() as it is no more needed.
5990 MEDFileField1TS *MEDFileField1TS::New()
5992 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5993 ret->contentNotNull();
5998 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5999 * following the given input policy.
6001 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6002 * By default (true) the globals are deeply copied.
6003 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6005 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6007 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
6008 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6011 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6013 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6014 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6015 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6018 ret=MEDFileIntField1TS::New();
6020 ret->deepCpyGlobs(*this);
6022 ret->shallowCpyGlobs(*this);
6026 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6028 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6030 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6031 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6033 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 !");
6037 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6039 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6041 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6042 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6044 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 !");
6048 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6051 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6052 if(!((DataArray*)arr))
6053 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6054 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6056 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6057 f->setArray(arrOutC);
6060 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6062 if(!((DataArray*)arr))
6063 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6064 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6066 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6071 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll)
6072 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6075 catch(INTERP_KERNEL::Exception& e)
6078 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll)
6079 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6082 catch(INTERP_KERNEL::Exception& e)
6085 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6086 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6089 catch(INTERP_KERNEL::Exception& e)
6093 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6094 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6096 * \warning this is a shallow copy constructor
6098 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6099 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6102 catch(INTERP_KERNEL::Exception& e)
6105 MEDFileField1TS::MEDFileField1TS()
6107 _content=new MEDFileField1TSWithoutSDA;
6111 * Returns a new MEDCouplingFieldDouble of a given type lying on
6112 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6113 * has not been constructed via file reading, an exception is thrown.
6114 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6115 * \param [in] type - a spatial discretization of interest.
6116 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6117 * \param [in] renumPol - specifies how to permute values of the result field according to
6118 * the optional numbers of cells and nodes, if any. The valid values are
6119 * - 0 - do not permute.
6120 * - 1 - permute cells.
6121 * - 2 - permute nodes.
6122 * - 3 - permute cells and nodes.
6124 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6125 * caller is to delete this field using decrRef() as it is no more needed.
6126 * \throw If \a this field has not been constructed via file reading.
6127 * \throw If the MED file is not readable.
6128 * \throw If there is no mesh in the MED file.
6129 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6130 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6131 * \sa getFieldOnMeshAtLevel()
6133 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6135 if(getFileName().empty())
6136 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6137 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6138 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6139 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6144 * Returns a new MEDCouplingFieldDouble of a given type lying on
6145 * the top level cells of the first mesh in MED file. If \a this field
6146 * has not been constructed via file reading, an exception is thrown.
6147 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6148 * \param [in] type - a spatial discretization of interest.
6149 * \param [in] renumPol - specifies how to permute values of the result field according to
6150 * the optional numbers of cells and nodes, if any. The valid values are
6151 * - 0 - do not permute.
6152 * - 1 - permute cells.
6153 * - 2 - permute nodes.
6154 * - 3 - permute cells and nodes.
6156 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6157 * caller is to delete this field using decrRef() as it is no more needed.
6158 * \throw If \a this field has not been constructed via file reading.
6159 * \throw If the MED file is not readable.
6160 * \throw If there is no mesh in the MED file.
6161 * \throw If no field values of the given \a type.
6162 * \throw If no field values lying on the top level support.
6163 * \sa getFieldAtLevel()
6165 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6167 if(getFileName().empty())
6168 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6169 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6170 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6171 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6176 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6177 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6178 * \param [in] type - a spatial discretization of the new field.
6179 * \param [in] mesh - the supporting mesh.
6180 * \param [in] renumPol - specifies how to permute values of the result field according to
6181 * the optional numbers of cells and nodes, if any. The valid values are
6182 * - 0 - do not permute.
6183 * - 1 - permute cells.
6184 * - 2 - permute nodes.
6185 * - 3 - permute cells and nodes.
6187 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6188 * caller is to delete this field using decrRef() as it is no more needed.
6189 * \throw If no field of \a this is lying on \a mesh.
6190 * \throw If the mesh is empty.
6191 * \throw If no field values of the given \a type are available.
6192 * \sa getFieldAtLevel()
6193 * \sa getFieldOnMeshAtLevel()
6195 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6197 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6198 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6199 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6204 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6205 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6206 * \param [in] type - a spatial discretization of interest.
6207 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6208 * \param [in] mesh - the supporting mesh.
6209 * \param [in] renumPol - specifies how to permute values of the result field according to
6210 * the optional numbers of cells and nodes, if any. The valid values are
6211 * - 0 - do not permute.
6212 * - 1 - permute cells.
6213 * - 2 - permute nodes.
6214 * - 3 - permute cells and nodes.
6216 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6217 * caller is to delete this field using decrRef() as it is no more needed.
6218 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6219 * \throw If no field of \a this is lying on \a mesh.
6220 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6221 * \sa getFieldAtLevel()
6222 * \sa getFieldOnMeshAtLevel()
6224 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6226 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6227 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6228 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6233 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6234 * This method is called "Old" because in MED3 norm a field has only one meshName
6235 * attached, so this method is for readers of MED2 files. If \a this field
6236 * has not been constructed via file reading, an exception is thrown.
6237 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6238 * \param [in] type - a spatial discretization of interest.
6239 * \param [in] mName - a name of the supporting mesh.
6240 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6241 * \param [in] renumPol - specifies how to permute values of the result field according to
6242 * the optional numbers of cells and nodes, if any. The valid values are
6243 * - 0 - do not permute.
6244 * - 1 - permute cells.
6245 * - 2 - permute nodes.
6246 * - 3 - permute cells and nodes.
6248 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6249 * caller is to delete this field using decrRef() as it is no more needed.
6250 * \throw If the MED file is not readable.
6251 * \throw If there is no mesh named \a mName in the MED file.
6252 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6253 * \throw If \a this field has not been constructed via file reading.
6254 * \throw If no field of \a this is lying on the mesh named \a mName.
6255 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6256 * \sa getFieldAtLevel()
6258 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6260 if(getFileName().empty())
6261 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6262 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6263 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6264 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6269 * Returns values and a profile of the field of a given type lying on a given support.
6270 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6271 * \param [in] type - a spatial discretization of the field.
6272 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6273 * \param [in] mesh - the supporting mesh.
6274 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6275 * field of interest lies on. If the field lies on all entities of the given
6276 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6277 * using decrRef() as it is no more needed.
6278 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6279 * field. The caller is to delete this array using decrRef() as it is no more needed.
6280 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6281 * \throw If no field of \a this is lying on \a mesh.
6282 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6284 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6286 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6287 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6291 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6292 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6293 * "Sort By Type"), if not, an exception is thrown.
6294 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6295 * \param [in] field - the field to add to \a this.
6296 * \throw If the name of \a field is empty.
6297 * \throw If the data array of \a field is not set.
6298 * \throw If the data array is already allocated but has different number of components
6300 * \throw If the underlying mesh of \a field has no name.
6301 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6303 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6306 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6310 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6311 * can be an aggregation of several MEDCouplingFieldDouble instances.
6312 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6313 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6316 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6317 * A new profile is added only if no equal profile is missing.
6318 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6319 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6320 * \param [in] mesh - the supporting mesh of \a field.
6321 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6322 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6323 * \throw If either \a field or \a mesh or \a profile has an empty name.
6324 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6325 * \throw If the data array of \a field is not set.
6326 * \throw If the data array of \a this is already allocated but has different number of
6327 * components than \a field.
6328 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6329 * \sa setFieldNoProfileSBT()
6331 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6334 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6337 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6339 return new MEDFileField1TS(*this);
6342 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6344 return contentNotNull()->getUndergroundDataArrayDouble();
6347 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6349 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6352 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6353 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6355 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6358 //= MEDFileIntField1TS
6360 MEDFileIntField1TS *MEDFileIntField1TS::New()
6362 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6363 ret->contentNotNull();
6367 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6369 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6370 ret->contentNotNull();
6374 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6376 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6377 ret->contentNotNull();
6381 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6383 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6384 ret->contentNotNull();
6388 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6390 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6391 ret->contentNotNull();
6395 MEDFileIntField1TS::MEDFileIntField1TS()
6397 _content=new MEDFileIntField1TSWithoutSDA;
6400 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll)
6401 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6404 catch(INTERP_KERNEL::Exception& e)
6407 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll)
6408 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6411 catch(INTERP_KERNEL::Exception& e)
6414 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6415 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6418 catch(INTERP_KERNEL::Exception& e)
6422 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6423 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6425 * \warning this is a shallow copy constructor
6427 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6431 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6433 return new MEDFileIntField1TS(*this);
6437 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6438 * following the given input policy.
6440 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6441 * By default (true) the globals are deeply copied.
6442 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6444 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6446 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6447 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6450 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6452 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6453 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6454 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6457 ret=MEDFileField1TS::New();
6459 ret->deepCpyGlobs(*this);
6461 ret->shallowCpyGlobs(*this);
6466 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6467 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6468 * "Sort By Type"), if not, an exception is thrown.
6469 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6470 * \param [in] field - the field to add to \a this. The field double values are ignored.
6471 * \param [in] arrOfVals - the values of the field \a field used.
6472 * \throw If the name of \a field is empty.
6473 * \throw If the data array of \a field is not set.
6474 * \throw If the data array is already allocated but has different number of components
6476 * \throw If the underlying mesh of \a field has no name.
6477 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6479 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6482 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6486 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6487 * can be an aggregation of several MEDCouplingFieldDouble instances.
6488 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6489 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6492 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6493 * A new profile is added only if no equal profile is missing.
6494 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6495 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6496 * \param [in] arrOfVals - the values of the field \a field used.
6497 * \param [in] mesh - the supporting mesh of \a field.
6498 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6499 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6500 * \throw If either \a field or \a mesh or \a profile has an empty name.
6501 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6502 * \throw If the data array of \a field is not set.
6503 * \throw If the data array of \a this is already allocated but has different number of
6504 * components than \a field.
6505 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6506 * \sa setFieldNoProfileSBT()
6508 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6511 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6514 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6516 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6518 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6519 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6521 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 !");
6525 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6527 if(getFileName().empty())
6528 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6529 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6530 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6531 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6533 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6538 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6540 if(!((DataArray *)arr))
6541 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6542 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6544 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6550 * Returns a new MEDCouplingFieldDouble of a given type lying on
6551 * the top level cells of the first mesh in MED file. If \a this field
6552 * has not been constructed via file reading, an exception is thrown.
6553 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6554 * \param [in] type - a spatial discretization of interest.
6555 * \param [out] arrOut - the DataArrayInt containing values of field.
6556 * \param [in] renumPol - specifies how to permute values of the result field according to
6557 * the optional numbers of cells and nodes, if any. The valid values are
6558 * - 0 - do not permute.
6559 * - 1 - permute cells.
6560 * - 2 - permute nodes.
6561 * - 3 - permute cells and nodes.
6563 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6564 * caller is to delete this field using decrRef() as it is no more needed.
6565 * \throw If \a this field has not been constructed via file reading.
6566 * \throw If the MED file is not readable.
6567 * \throw If there is no mesh in the MED file.
6568 * \throw If no field values of the given \a type.
6569 * \throw If no field values lying on the top level support.
6570 * \sa getFieldAtLevel()
6572 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6574 if(getFileName().empty())
6575 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6576 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6577 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6578 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6583 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6584 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6585 * \param [in] type - a spatial discretization of the new field.
6586 * \param [in] mesh - the supporting mesh.
6587 * \param [out] arrOut - the DataArrayInt containing values of field.
6588 * \param [in] renumPol - specifies how to permute values of the result field according to
6589 * the optional numbers of cells and nodes, if any. The valid values are
6590 * - 0 - do not permute.
6591 * - 1 - permute cells.
6592 * - 2 - permute nodes.
6593 * - 3 - permute cells and nodes.
6595 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6596 * caller is to delete this field using decrRef() as it is no more needed.
6597 * \throw If no field of \a this is lying on \a mesh.
6598 * \throw If the mesh is empty.
6599 * \throw If no field values of the given \a type are available.
6600 * \sa getFieldAtLevel()
6601 * \sa getFieldOnMeshAtLevel()
6603 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6605 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6606 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6607 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6612 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6613 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6614 * \param [in] type - a spatial discretization of interest.
6615 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6616 * \param [out] arrOut - the DataArrayInt containing values of field.
6617 * \param [in] mesh - the supporting mesh.
6618 * \param [in] renumPol - specifies how to permute values of the result field according to
6619 * the optional numbers of cells and nodes, if any. The valid values are
6620 * - 0 - do not permute.
6621 * - 1 - permute cells.
6622 * - 2 - permute nodes.
6623 * - 3 - permute cells and nodes.
6625 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6626 * caller is to delete this field using decrRef() as it is no more needed.
6627 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6628 * \throw If no field of \a this is lying on \a mesh.
6629 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6630 * \sa getFieldAtLevel()
6631 * \sa getFieldOnMeshAtLevel()
6633 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6635 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6636 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6637 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6642 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6643 * This method is called "Old" because in MED3 norm a field has only one meshName
6644 * attached, so this method is for readers of MED2 files. If \a this field
6645 * has not been constructed via file reading, an exception is thrown.
6646 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6647 * \param [in] type - a spatial discretization of interest.
6648 * \param [in] mName - a name of the supporting mesh.
6649 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6650 * \param [out] arrOut - the DataArrayInt containing values of field.
6651 * \param [in] renumPol - specifies how to permute values of the result field according to
6652 * the optional numbers of cells and nodes, if any. The valid values are
6653 * - 0 - do not permute.
6654 * - 1 - permute cells.
6655 * - 2 - permute nodes.
6656 * - 3 - permute cells and nodes.
6658 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6659 * caller is to delete this field using decrRef() as it is no more needed.
6660 * \throw If the MED file is not readable.
6661 * \throw If there is no mesh named \a mName in the MED file.
6662 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6663 * \throw If \a this field has not been constructed via file reading.
6664 * \throw If no field of \a this is lying on the mesh named \a mName.
6665 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6666 * \sa getFieldAtLevel()
6668 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6670 if(getFileName().empty())
6671 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6672 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6673 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6674 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6679 * Returns values and a profile of the field of a given type lying on a given support.
6680 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6681 * \param [in] type - a spatial discretization of the field.
6682 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6683 * \param [in] mesh - the supporting mesh.
6684 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6685 * field of interest lies on. If the field lies on all entities of the given
6686 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6687 * using decrRef() as it is no more needed.
6688 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6689 * field. The caller is to delete this array using decrRef() as it is no more needed.
6690 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6691 * \throw If no field of \a this is lying on \a mesh.
6692 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6694 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6696 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6697 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6700 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
6702 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6704 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6705 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6707 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 !");
6711 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
6713 return contentNotNull()->getUndergroundDataArrayInt();
6716 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6718 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6722 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
6727 * \param [in] fieldId field id in C mode
6729 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll)
6731 med_field_type typcha;
6732 std::string dtunitOut;
6733 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6734 setDtUnit(dtunitOut.c_str());
6735 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6738 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
6739 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6741 setDtUnit(dtunit.c_str());
6742 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6744 catch(INTERP_KERNEL::Exception& e)
6749 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
6751 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
6752 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6753 ret+=(*it).capacity();
6757 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildren() const
6759 std::vector<const BigMemoryObject *> ret;
6760 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6762 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6770 * 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
6773 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
6775 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6776 ret->setInfo(_infos);
6777 int sz=(int)_time_steps.size();
6778 for(const int *id=startIds;id!=endIds;id++)
6780 if(*id>=0 && *id<sz)
6782 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6783 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6787 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6789 ret->pushBackTimeStep(tse2);
6793 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6794 oss << " ! Should be in [0," << sz << ") !";
6795 throw INTERP_KERNEL::Exception(oss.str().c_str());
6798 if(ret->getNumberOfTS()>0)
6799 ret->synchronizeNameScope();
6800 ret->copyNameScope(*this);
6805 * 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
6808 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
6810 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6811 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6812 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6813 ret->setInfo(_infos);
6814 int sz=(int)_time_steps.size();
6816 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6820 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6821 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6825 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6827 ret->pushBackTimeStep(tse2);
6831 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6832 oss << " ! Should be in [0," << sz << ") !";
6833 throw INTERP_KERNEL::Exception(oss.str().c_str());
6836 if(ret->getNumberOfTS()>0)
6837 ret->synchronizeNameScope();
6838 ret->copyNameScope(*this);
6842 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6845 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6846 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6848 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6851 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6852 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6853 ids->pushBackSilent(id);
6855 return buildFromTimeStepIds(ids->begin(),ids->end());
6858 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6861 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6862 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6864 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6867 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6868 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6869 ids->pushBackSilent(id);
6871 return buildFromTimeStepIds(ids->begin(),ids->end());
6874 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
6879 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
6884 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
6887 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6889 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6890 if(pt->isDealingTS(iteration,order))
6893 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6894 std::vector< std::pair<int,int> > vp=getIterations();
6895 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6896 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6897 throw INTERP_KERNEL::Exception(oss.str().c_str());
6900 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
6902 return *_time_steps[getTimeStepPos(iteration,order)];
6905 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
6907 return *_time_steps[getTimeStepPos(iteration,order)];
6910 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
6912 if(_time_steps.empty())
6913 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6914 return _time_steps[0]->getMeshName();
6917 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
6919 std::string oldName(getMeshName());
6920 std::vector< std::pair<std::string,std::string> > v(1);
6921 v[0].first=oldName; v[0].second=newMeshName;
6925 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6928 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6930 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6932 ret=cur->changeMeshNames(modifTab) || ret;
6938 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6940 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
6942 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6946 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6948 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6950 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6953 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6954 MEDFileFieldGlobsReal& glob)
6957 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6959 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6961 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6966 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6968 std::string startLine(bkOffset,' ');
6969 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6971 oss << " (" << fmtsId << ")";
6972 oss << " has the following name: \"" << _name << "\"." << std::endl;
6973 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6974 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6976 oss << startLine << " - \"" << *it << "\"" << std::endl;
6979 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6981 std::string chapter(17,'0'+i);
6982 oss << startLine << chapter << std::endl;
6983 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6985 cur->simpleRepr(bkOffset+2,oss,i);
6987 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6988 oss << startLine << chapter << std::endl;
6992 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
6994 std::size_t sz=_time_steps.size();
6995 std::vector< std::pair<int,int> > ret(sz);
6997 for(std::size_t i=0;i<sz;i++)
6999 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7002 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7006 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7007 throw INTERP_KERNEL::Exception(oss.str().c_str());
7013 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7015 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7017 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7018 checkCoherencyOfType(tse2);
7019 if(_time_steps.empty())
7021 setName(tse2->getName().c_str());
7022 setInfo(tse2->getInfo());
7024 checkThatComponentsMatch(tse2->getInfo());
7025 _time_steps.push_back(tse);
7028 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7030 std::size_t nbOfCompo=_infos.size();
7031 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7033 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7036 if((cur->getInfo()).size()!=nbOfCompo)
7038 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7039 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7040 throw INTERP_KERNEL::Exception(oss.str().c_str());
7042 cur->copyNameScope(*this);
7047 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll)
7049 _time_steps.resize(nbPdt);
7050 for(int i=0;i<nbPdt;i++)
7052 std::vector< std::pair<int,int> > ts;
7053 med_int numdt=0,numo=0;
7054 med_int meshIt=0,meshOrder=0;
7056 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
7061 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7066 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7070 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7073 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
7075 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
7079 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7081 if(_time_steps.empty())
7082 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7083 checkThatNbOfCompoOfTSMatchThis();
7084 std::vector<std::string> infos(getInfo());
7085 int nbComp=infos.size();
7086 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7087 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7088 for(int i=0;i<nbComp;i++)
7090 std::string info=infos[i];
7092 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7093 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7094 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7097 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7098 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7099 int nbOfTS=_time_steps.size();
7100 for(int i=0;i<nbOfTS;i++)
7101 _time_steps[i]->writeLL(fid,opts,*this);
7104 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7106 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7108 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7110 elt->loadBigArraysRecursively(fid,nasc);
7114 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7116 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7118 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7120 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7124 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7126 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7128 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7130 elt->unloadArrays();
7134 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7136 return _time_steps.size();
7139 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7141 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7142 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7144 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7146 newTS.push_back(*it);
7151 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7153 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7154 int maxId=(int)_time_steps.size();
7156 std::set<int> idsToDel;
7157 for(const int *id=startIds;id!=endIds;id++,ii++)
7159 if(*id>=0 && *id<maxId)
7161 idsToDel.insert(*id);
7165 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7166 throw INTERP_KERNEL::Exception(oss.str().c_str());
7169 for(int iii=0;iii<maxId;iii++)
7170 if(idsToDel.find(iii)==idsToDel.end())
7171 newTS.push_back(_time_steps[iii]);
7175 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7177 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7178 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7179 if(nbOfEntriesToKill==0)
7181 std::size_t sz=_time_steps.size();
7182 std::vector<bool> b(sz,true);
7184 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7186 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7187 for(std::size_t i=0;i<sz;i++)
7189 newTS.push_back(_time_steps[i]);
7193 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7196 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7197 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7199 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7203 tmp->getTime(it2,ord);
7204 if(it2==iteration && order==ord)
7207 oss << "(" << it2 << "," << ord << "), ";
7210 throw INTERP_KERNEL::Exception(oss.str().c_str());
7213 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7216 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7218 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7220 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7224 double ti=tmp->getTime(it2,ord);
7225 if(fabs(time-ti)<eps)
7231 throw INTERP_KERNEL::Exception(oss.str().c_str());
7234 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7236 int lgth=_time_steps.size();
7237 std::vector< std::pair<int,int> > ret(lgth);
7238 for(int i=0;i<lgth;i++)
7239 _time_steps[i]->fillIteration(ret[i]);
7244 * 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'
7245 * This method returns two things.
7246 * - The absolute dimension of 'this' in first parameter.
7247 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7248 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7250 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7251 * Only these 3 discretizations will be taken into account here.
7253 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7254 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7255 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7257 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7258 * 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'.
7260 * Let's consider the typical following case :
7261 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7262 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7263 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7265 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7267 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7269 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7270 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7271 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7272 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7274 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7276 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7279 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7281 if(pos<0 || pos>=(int)_time_steps.size())
7283 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7284 throw INTERP_KERNEL::Exception(oss.str().c_str());
7286 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7289 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7290 oss << "\nTry to use following method eraseEmptyTS !";
7291 throw INTERP_KERNEL::Exception(oss.str().c_str());
7296 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7298 if(pos<0 || pos>=(int)_time_steps.size())
7300 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7301 throw INTERP_KERNEL::Exception(oss.str().c_str());
7303 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7306 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7307 oss << "\nTry to use following method eraseEmptyTS !";
7308 throw INTERP_KERNEL::Exception(oss.str().c_str());
7313 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7315 std::vector<std::string> ret;
7316 std::set<std::string> ret2;
7317 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7319 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7320 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7321 if(ret2.find(*it2)==ret2.end())
7323 ret.push_back(*it2);
7330 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7332 std::vector<std::string> ret;
7333 std::set<std::string> ret2;
7334 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7336 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7337 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7338 if(ret2.find(*it2)==ret2.end())
7340 ret.push_back(*it2);
7347 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7349 std::vector<std::string> ret;
7350 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7352 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7353 ret.insert(ret.end(),tmp.begin(),tmp.end());
7358 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7360 std::vector<std::string> ret;
7361 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7363 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7364 ret.insert(ret.end(),tmp.begin(),tmp.end());
7369 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7371 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7372 (*it)->changePflsRefsNamesGen2(mapOfModif);
7375 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7377 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7378 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7381 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7383 int lgth=_time_steps.size();
7384 std::vector< std::vector<TypeOfField> > ret(lgth);
7385 for(int i=0;i<lgth;i++)
7386 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7391 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7393 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7395 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7398 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7400 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7402 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7404 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7405 ret->_time_steps[i]=(*it)->deepCpy();
7410 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7412 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7413 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7414 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7415 for(std::size_t i=0;i<sz;i++)
7417 ret[i]=shallowCpy();
7418 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7420 for(std::size_t i=0;i<sz2;i++)
7422 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7425 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7426 throw INTERP_KERNEL::Exception(oss.str().c_str());
7430 for(std::size_t i=0;i<sz;i++)
7431 for(std::size_t j=0;j<sz2;j++)
7432 ret[i]->_time_steps[j]=ts[j][i];
7437 * This method splits into discretization each time steps in \a this.
7438 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7440 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7442 std::size_t sz(_time_steps.size());
7443 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7444 for(std::size_t i=0;i<sz;i++)
7446 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7449 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7450 throw INTERP_KERNEL::Exception(oss.str().c_str());
7452 items[i]=timeStep->splitDiscretizations();
7455 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7456 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7457 std::vector< TypeOfField > types;
7458 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7459 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7461 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7463 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7464 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7465 if(it2==types.end())
7466 types.push_back(ts[0]);
7468 ret.resize(types.size()); ret2.resize(types.size());
7469 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7470 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7472 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7473 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7474 ret2[pos].push_back(*it1);
7476 for(std::size_t i=0;i<types.size();i++)
7478 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7479 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7480 elt->pushBackTimeStep(*it1);//also updates infos in elt
7482 elt->MEDFileFieldNameScope::operator=(*this);
7487 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7489 _name=field->getName();
7491 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7493 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7494 _infos=arr->getInfoOnComponents();
7497 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7499 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7500 if(_name!=field->getName())
7502 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7503 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7504 throw INTERP_KERNEL::Exception(oss.str().c_str());
7507 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7508 checkThatComponentsMatch(arr->getInfoOnComponents());
7511 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7513 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7514 if(getInfo().size()!=compos.size())
7516 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7517 oss << " number of components of element to append (" << compos.size() << ") !";
7518 throw INTERP_KERNEL::Exception(oss.str().c_str());
7522 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7523 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7524 oss << " But compo in input fields are : ";
7525 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7527 throw INTERP_KERNEL::Exception(oss.str().c_str());
7531 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7533 std::size_t sz=_infos.size();
7535 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7537 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7539 if(elt->getInfo().size()!=sz)
7541 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7542 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7543 throw INTERP_KERNEL::Exception(oss.str().c_str());
7548 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7551 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7552 if(!_time_steps.empty())
7553 checkCoherencyOfTinyInfo(field,arr);
7554 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7555 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7556 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7557 copyTinyInfoFrom(field,arr);
7558 _time_steps.push_back(obj);
7561 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7564 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7565 if(!_time_steps.empty())
7566 checkCoherencyOfTinyInfo(field,arr);
7567 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7568 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7569 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7570 copyTinyInfoFrom(field,arr);
7571 _time_steps.push_back(obj);
7574 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7576 int sz=(int)_time_steps.size();
7579 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7580 throw INTERP_KERNEL::Exception(oss.str().c_str());
7582 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7585 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7587 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7588 throw INTERP_KERNEL::Exception(oss.str().c_str());
7594 //= MEDFileFieldMultiTSWithoutSDA
7596 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
7598 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7601 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7605 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7610 * \param [in] fieldId field id in C mode
7612 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll)
7613 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7616 catch(INTERP_KERNEL::Exception& e)
7619 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
7620 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7623 catch(INTERP_KERNEL::Exception& e)
7626 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7628 return new MEDFileField1TSWithoutSDA;
7631 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7634 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7635 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7637 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7640 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7642 return MEDFileField1TSWithoutSDA::TYPE_STR;
7645 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7647 return new MEDFileFieldMultiTSWithoutSDA(*this);
7650 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7652 return new MEDFileFieldMultiTSWithoutSDA;
7656 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7657 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7659 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7661 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7662 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7664 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7665 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7668 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
7670 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7671 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7673 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7675 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7678 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7680 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7681 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7682 ret->setIteration(i,elt);
7688 //= MEDFileAnyTypeFieldMultiTS
7690 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7694 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll)
7695 try:MEDFileFieldGlobsReal(fileName)
7697 MEDFileUtilities::CheckFileForRead(fileName);
7698 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7699 _content=BuildContentFrom(fid,fileName,loadAll);
7702 catch(INTERP_KERNEL::Exception& e)
7707 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll)
7709 med_field_type typcha;
7710 std::vector<std::string> infos;
7713 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7714 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7719 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7724 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7729 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] !";
7730 throw INTERP_KERNEL::Exception(oss.str().c_str());
7733 ret->setDtUnit(dtunit.c_str());
7737 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll)
7739 med_field_type typcha;
7741 std::vector<std::string> infos;
7742 std::string dtunit,fieldName;
7743 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7744 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7749 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7754 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7759 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] !";
7760 throw INTERP_KERNEL::Exception(oss.str().c_str());
7763 ret->setDtUnit(dtunit.c_str());
7767 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
7770 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7771 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7773 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7774 ret->setFileName(fileName);
7775 ret->_content=c; c->incrRef();
7778 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7780 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7781 ret->setFileName(fileName);
7782 ret->_content=c; c->incrRef();
7785 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7788 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll)
7789 try:MEDFileFieldGlobsReal(fileName)
7791 MEDFileUtilities::CheckFileForRead(fileName);
7792 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7793 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7796 catch(INTERP_KERNEL::Exception& e)
7801 //= MEDFileIntFieldMultiTSWithoutSDA
7803 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
7805 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7808 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7812 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7816 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
7817 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7820 catch(INTERP_KERNEL::Exception& e)
7824 * \param [in] fieldId field id in C mode
7826 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll)
7827 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7830 catch(INTERP_KERNEL::Exception& e)
7833 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7835 return new MEDFileIntField1TSWithoutSDA;
7838 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7841 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7842 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7844 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7847 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
7849 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7852 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
7854 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7857 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
7859 return new MEDFileIntFieldMultiTSWithoutSDA;
7862 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
7864 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7865 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7867 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7869 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7872 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7874 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7875 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7876 ret->setIteration(i,elt);
7882 //= MEDFileAnyTypeFieldMultiTS
7885 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7886 * that has been read from a specified MED file.
7887 * \param [in] fileName - the name of the MED file to read.
7888 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7889 * is to delete this field using decrRef() as it is no more needed.
7890 * \throw If reading the file fails.
7892 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
7894 MEDFileUtilities::CheckFileForRead(fileName);
7895 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7896 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7897 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7898 ret->loadGlobals(fid);
7903 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7904 * that has been read from a specified MED file.
7905 * \param [in] fileName - the name of the MED file to read.
7906 * \param [in] fieldName - the name of the field to read.
7907 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7908 * is to delete this field using decrRef() as it is no more needed.
7909 * \throw If reading the file fails.
7910 * \throw If there is no field named \a fieldName in the file.
7912 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7914 MEDFileUtilities::CheckFileForRead(fileName);
7915 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7916 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
7917 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7918 ret->loadGlobals(fid);
7923 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7924 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7926 * \warning this is a shallow copy constructor
7928 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7930 if(!shallowCopyOfContent)
7932 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7933 otherPtr->incrRef();
7934 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7938 _content=other.shallowCpy();
7942 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
7944 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7946 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7950 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
7952 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7954 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7958 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7960 return contentNotNullBase()->getPflsReallyUsed2();
7963 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7965 return contentNotNullBase()->getLocsReallyUsed2();
7968 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7970 return contentNotNullBase()->getPflsReallyUsedMulti2();
7973 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7975 return contentNotNullBase()->getLocsReallyUsedMulti2();
7978 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7980 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7983 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7985 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7988 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7990 return contentNotNullBase()->getNumberOfTS();
7993 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
7995 contentNotNullBase()->eraseEmptyTS();
7998 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8000 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8003 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8005 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8008 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8010 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8011 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8016 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8018 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8019 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8024 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8026 return contentNotNullBase()->getIterations();
8029 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8031 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8032 pushBackTimeStep(*it);
8035 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8038 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8039 checkCoherencyOfType(f1ts);
8041 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8042 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8044 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8045 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8046 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8047 _content->pushBackTimeStep(cSafe);
8048 appendGlobs(*f1ts,1e-12);
8051 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8053 contentNotNullBase()->synchronizeNameScope();
8056 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8058 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8061 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8063 return contentNotNullBase()->getPosGivenTime(time,eps);
8066 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8068 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8071 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8073 return contentNotNullBase()->getTypesOfFieldAvailable();
8076 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
8078 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8081 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8083 return contentNotNullBase()->getName();
8086 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8088 contentNotNullBase()->setName(name);
8091 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8093 return contentNotNullBase()->getDtUnit();
8096 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8098 contentNotNullBase()->setDtUnit(dtUnit);
8101 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8103 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8106 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8108 return contentNotNullBase()->getTimeSteps(ret1);
8111 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8113 return contentNotNullBase()->getMeshName();
8116 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8118 contentNotNullBase()->setMeshName(newMeshName);
8121 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8123 return contentNotNullBase()->changeMeshNames(modifTab);
8126 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8128 return contentNotNullBase()->getInfo();
8131 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8133 return contentNotNullBase()->setInfo(info);
8136 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8138 const std::vector<std::string> ret=getInfo();
8139 return (int)ret.size();
8142 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8144 writeGlobals(fid,*this);
8145 contentNotNullBase()->writeLL(fid,*this);
8149 * Writes \a this field into a MED file specified by its name.
8150 * \param [in] fileName - the MED file name.
8151 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8152 * - 2 - erase; an existing file is removed.
8153 * - 1 - append; same data should not be present in an existing file.
8154 * - 0 - overwrite; same data present in an existing file is overwritten.
8155 * \throw If the field name is not set.
8156 * \throw If no field data is set.
8157 * \throw If \a mode == 1 and the same data is present in an existing file.
8159 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8161 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8162 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8167 * This method alloc the arrays and load potentially huge arrays contained in this field.
8168 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8169 * This method can be also called to refresh or reinit values from a file.
8171 * \throw If the fileName is not set or points to a non readable MED file.
8173 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8175 if(getFileName().empty())
8176 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8177 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8178 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8182 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8183 * But once data loaded once, this method does nothing.
8185 * \throw If the fileName is not set or points to a non readable MED file.
8186 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8188 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8190 if(!getFileName().empty())
8192 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8193 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8198 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8199 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8200 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8202 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8204 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8206 contentNotNullBase()->unloadArrays();
8210 * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
8211 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8212 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8214 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8216 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8218 if(!getFileName().empty())
8219 contentNotNullBase()->unloadArrays();
8222 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8224 std::ostringstream oss;
8225 contentNotNullBase()->simpleRepr(0,oss,-1);
8226 simpleReprGlobs(oss);
8230 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8232 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8235 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildren() const
8237 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildren());
8238 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8239 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8244 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8245 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8246 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8248 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8250 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8252 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8253 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8254 std::size_t sz(contentsSplit.size());
8255 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8256 for(std::size_t i=0;i<sz;i++)
8258 ret[i]=shallowCpy();
8259 ret[i]->_content=contentsSplit[i];
8265 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8266 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8268 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8270 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8272 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8273 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8274 std::size_t sz(contentsSplit.size());
8275 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8276 for(std::size_t i=0;i<sz;i++)
8278 ret[i]=shallowCpy();
8279 ret[i]->_content=contentsSplit[i];
8284 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8286 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8287 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8288 ret->_content=_content->deepCpy();
8289 ret->deepCpyGlobs(*this);
8293 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8299 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8300 * \param [in] iteration - the iteration number of a required time step.
8301 * \param [in] order - the iteration order number of required time step.
8302 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8303 * delete this field using decrRef() as it is no more needed.
8304 * \throw If there is no required time step in \a this field.
8306 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8308 int pos=getPosOfTimeStep(iteration,order);
8309 return getTimeStepAtPos(pos);
8313 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8314 * \param [in] time - the time of the time step of interest.
8315 * \param [in] eps - a precision used to compare time values.
8316 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8317 * delete this field using decrRef() as it is no more needed.
8318 * \throw If there is no required time step in \a this field.
8320 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8322 int pos=getPosGivenTime(time,eps);
8323 return getTimeStepAtPos(pos);
8327 * 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.
8328 * The float64 value of time attached to the pair of integers are not considered here.
8329 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8331 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8332 * \throw If there is a null pointer in \a vectFMTS.
8334 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8336 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8337 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8338 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8339 while(!lstFMTS.empty())
8341 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8342 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8344 throw INTERP_KERNEL::Exception(msg);
8345 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8346 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8347 elt.push_back(curIt); it=lstFMTS.erase(it);
8348 while(it!=lstFMTS.end())
8352 throw INTERP_KERNEL::Exception(msg);
8353 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8355 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8365 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8366 * All returned instances in a subvector can be safely loaded, rendered along time
8367 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8368 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8369 * All items in \a vectFMTS must lie on the mesh (located by meshname and time step) and compatible with the input mesh \a mesh (having the same name than those in items).
8370 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8371 * For items in \a vectFMTS that are ON_NODES it is possible to appear several times (more than once or once) in the returned vector.
8373 * \param [in] vectFMTS - list of multi times step part all defined each on a same spatial discretization along time and pointing to a mesh whose name is equal to \c mesh->getName().
8374 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8375 * \param [out] fsc - A vector having same size than returned vector. It specifies the support comporator of the corresponding vector of MEDFileAnyTypeFieldMultiTS in returned vector of vector.
8376 * \return - A vector of vector of objects that contains the same pointers (objects) than thoose in \a vectFMTS except that there are organized differently. So pointers included in returned vector of vector should \b not been dealt by the caller.
8378 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8379 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8380 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8381 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8382 * \throw If mesh is null.
8383 * \throw If an element in \a vectFMTS is null.
8384 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8386 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8388 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8390 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8391 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8392 if(vectFMTS.empty())
8394 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8395 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8397 throw INTERP_KERNEL::Exception(msg);
8399 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8400 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8401 for(;it!=vectFMTS.end();it++,i++)
8404 throw INTERP_KERNEL::Exception(msg);
8405 TypeOfField tof0,tof1;
8406 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8409 vectFMTSNotNodes.push_back(*it);
8411 vectFMTSNodes.push_back(*it);
8414 vectFMTSNotNodes.push_back(*it);
8416 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8417 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8419 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8422 bool isFetched(false);
8423 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8426 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8427 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8428 { ret[i].push_back(*it2); isFetched=true; }
8432 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8433 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8434 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8442 * WARNING no check here. The caller must be sure that all items in vectFMTS are coherent each other in time steps, only one same spatial discretization and not ON_NODES.
8443 * \param [out] cmps - same size than the returned vector.
8445 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8447 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8448 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8449 while(!lstFMTS.empty())
8451 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8452 MEDFileAnyTypeFieldMultiTS *ref(*it);
8453 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8454 elt.push_back(ref); it=lstFMTS.erase(it);
8455 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8456 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8457 while(it!=lstFMTS.end())
8459 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8460 if(cmp->isEqual(curIt))
8461 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8465 ret.push_back(elt); cmps.push_back(cmp);
8471 * This method scan the two main structs along time of \a f0 and \a f1 to see if there are all lying on the same mesh along time than those in \a mesh.
8472 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8474 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8475 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8476 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8477 * \thorw If \a f0 and \a f1 do not have the same times steps.
8478 * \throw If mesh is null.
8479 * \throw If \a f0 or \a f1 is null.
8480 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8482 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8485 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8487 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8488 if(f0->getMeshName()!=mesh->getName())
8490 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8491 throw INTERP_KERNEL::Exception(oss.str().c_str());
8493 if(f1->getMeshName()!=mesh->getName())
8495 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8496 throw INTERP_KERNEL::Exception(oss.str().c_str());
8498 int nts=f0->getNumberOfTS();
8499 if(nts!=f1->getNumberOfTS())
8500 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8503 for(int i=0;i<nts;i++)
8505 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8506 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8507 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8508 if(tofs0.size()!=1 || tofs1.size()!=1)
8509 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8512 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8513 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8516 { tof0=tofs0[0]; tof1=tofs1[0]; }
8517 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8519 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh time step (" << f0cur->getMeshIteration() << ","<< f0cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
8520 throw INTERP_KERNEL::Exception(oss.str().c_str());
8522 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8524 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh time step (" << f1cur->getMeshIteration() << ","<< f1cur->getMeshOrder() << ") whereas input mesh points to time step (" << mesh->getIteration() << "," << mesh->getOrder() << ") !";
8525 throw INTERP_KERNEL::Exception(oss.str().c_str());
8527 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8529 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : all the time steps must be the same ! it is not the case (" << f0cur->getIteration() << "," << f0cur->getOrder() << ")!=(" << f1cur->getIteration() << "," << f1cur->getOrder() << ") !";
8530 throw INTERP_KERNEL::Exception(oss.str().c_str());
8536 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8538 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8541 //= MEDFileFieldMultiTS
8544 * Returns a new empty instance of MEDFileFieldMultiTS.
8545 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8546 * is to delete this field using decrRef() as it is no more needed.
8548 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8550 return new MEDFileFieldMultiTS;
8554 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8555 * that has been read from a specified MED file.
8556 * \param [in] fileName - the name of the MED file to read.
8557 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8558 * is to delete this field using decrRef() as it is no more needed.
8559 * \throw If reading the file fails.
8561 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8563 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
8564 ret->contentNotNull();//to check that content type matches with \a this type.
8569 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8570 * that has been read from a specified MED file.
8571 * \param [in] fileName - the name of the MED file to read.
8572 * \param [in] fieldName - the name of the field to read.
8573 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8574 * is to delete this field using decrRef() as it is no more needed.
8575 * \throw If reading the file fails.
8576 * \throw If there is no field named \a fieldName in the file.
8578 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8580 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
8581 ret->contentNotNull();//to check that content type matches with \a this type.
8586 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8587 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8589 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8590 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8591 * \warning this is a shallow copy constructor
8592 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8593 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8594 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8595 * is to delete this field using decrRef() as it is no more needed.
8597 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8599 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8602 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8604 return new MEDFileFieldMultiTS(*this);
8607 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
8610 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8611 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8613 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8617 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8618 * following the given input policy.
8620 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8621 * By default (true) the globals are deeply copied.
8622 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8624 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
8626 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8627 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8630 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8632 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8633 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8634 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8637 ret=MEDFileIntFieldMultiTS::New();
8639 ret->deepCpyGlobs(*this);
8641 ret->shallowCpyGlobs(*this);
8646 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8647 * \param [in] pos - a time step id.
8648 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8649 * delete this field using decrRef() as it is no more needed.
8650 * \throw If \a pos is not a valid time step id.
8652 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
8654 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8657 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8658 throw INTERP_KERNEL::Exception(oss.str().c_str());
8660 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8663 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8664 ret->shallowCpyGlobs(*this);
8667 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8668 throw INTERP_KERNEL::Exception(oss.str().c_str());
8672 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8673 * mesh entities of a given dimension of the first mesh in MED file.
8674 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8675 * \param [in] type - a spatial discretization of interest.
8676 * \param [in] iteration - the iteration number of a required time step.
8677 * \param [in] order - the iteration order number of required time step.
8678 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8679 * \param [in] renumPol - specifies how to permute values of the result field according to
8680 * the optional numbers of cells and nodes, if any. The valid values are
8681 * - 0 - do not permute.
8682 * - 1 - permute cells.
8683 * - 2 - permute nodes.
8684 * - 3 - permute cells and nodes.
8686 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8687 * caller is to delete this field using decrRef() as it is no more needed.
8688 * \throw If the MED file is not readable.
8689 * \throw If there is no mesh in the MED file.
8690 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8691 * \throw If no field values of the required parameters are available.
8693 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
8695 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8696 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8698 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8699 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8700 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8701 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8706 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8707 * the top level cells of the first mesh in MED file.
8708 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8709 * \param [in] type - a spatial discretization of interest.
8710 * \param [in] iteration - the iteration number of a required time step.
8711 * \param [in] order - the iteration order number of required time step.
8712 * \param [in] renumPol - specifies how to permute values of the result field according to
8713 * the optional numbers of cells and nodes, if any. The valid values are
8714 * - 0 - do not permute.
8715 * - 1 - permute cells.
8716 * - 2 - permute nodes.
8717 * - 3 - permute cells and nodes.
8719 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8720 * caller is to delete this field using decrRef() as it is no more needed.
8721 * \throw If the MED file is not readable.
8722 * \throw If there is no mesh in the MED file.
8723 * \throw If no field values of the required parameters are available.
8725 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
8727 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8728 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8730 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8731 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8732 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8733 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8738 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8740 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8741 * \param [in] type - a spatial discretization of interest.
8742 * \param [in] iteration - the iteration number of a required time step.
8743 * \param [in] order - the iteration order number of required time step.
8744 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8745 * \param [in] mesh - the supporting mesh.
8746 * \param [in] renumPol - specifies how to permute values of the result field according to
8747 * the optional numbers of cells and nodes, if any. The valid values are
8748 * - 0 - do not permute.
8749 * - 1 - permute cells.
8750 * - 2 - permute nodes.
8751 * - 3 - permute cells and nodes.
8753 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8754 * caller is to delete this field using decrRef() as it is no more needed.
8755 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8756 * \throw If no field of \a this is lying on \a mesh.
8757 * \throw If no field values of the required parameters are available.
8759 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
8761 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8762 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8764 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8765 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8766 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8767 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8772 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8774 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8775 * \param [in] type - a spatial discretization of the new field.
8776 * \param [in] iteration - the iteration number of a required time step.
8777 * \param [in] order - the iteration order number of required time step.
8778 * \param [in] mesh - the supporting mesh.
8779 * \param [in] renumPol - specifies how to permute values of the result field according to
8780 * the optional numbers of cells and nodes, if any. The valid values are
8781 * - 0 - do not permute.
8782 * - 1 - permute cells.
8783 * - 2 - permute nodes.
8784 * - 3 - permute cells and nodes.
8786 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8787 * caller is to delete this field using decrRef() as it is no more needed.
8788 * \throw If no field of \a this is lying on \a mesh.
8789 * \throw If no field values of the required parameters are available.
8791 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
8793 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8794 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8796 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8797 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8798 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8799 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8804 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8805 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8806 * This method is useful for MED2 file format when field on different mesh was autorized.
8808 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
8810 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8811 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8813 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8814 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8815 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8816 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8821 * Returns values and a profile of the field of a given type, of a given time step,
8822 * lying on a given support.
8823 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8824 * \param [in] type - a spatial discretization of the field.
8825 * \param [in] iteration - the iteration number of a required time step.
8826 * \param [in] order - the iteration order number of required time step.
8827 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8828 * \param [in] mesh - the supporting mesh.
8829 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8830 * field of interest lies on. If the field lies on all entities of the given
8831 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8832 * using decrRef() as it is no more needed.
8833 * \param [in] glob - the global data storing profiles and localization.
8834 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8835 * field. The caller is to delete this array using decrRef() as it is no more needed.
8836 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8837 * \throw If no field of \a this is lying on \a mesh.
8838 * \throw If no field values of the required parameters are available.
8840 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
8842 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8843 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8845 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8846 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8847 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8850 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
8852 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8854 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8855 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8857 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 !");
8861 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
8863 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8865 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8866 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8868 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 !");
8873 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8874 * the given field is checked if its elements are sorted suitable for writing to MED file
8875 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8876 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8877 * \param [in] field - the field to add to \a this.
8878 * \throw If the name of \a field is empty.
8879 * \throw If the data array of \a field is not set.
8880 * \throw If existing time steps have different name or number of components than \a field.
8881 * \throw If the underlying mesh of \a field has no name.
8882 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8884 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
8886 const DataArrayDouble *arr=0;
8888 arr=field->getArray();
8889 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8893 * Adds a MEDCouplingFieldDouble to \a this as another time step.
8894 * The mesh support of input parameter \a field is ignored here, it can be NULL.
8895 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
8898 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
8899 * A new profile is added only if no equal profile is missing.
8900 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8901 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
8902 * \param [in] mesh - the supporting mesh of \a field.
8903 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
8904 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8905 * \throw If either \a field or \a mesh or \a profile has an empty name.
8906 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8907 * \throw If the data array of \a field is not set.
8908 * \throw If the data array of \a this is already allocated but has different number of
8909 * components than \a field.
8910 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8911 * \sa setFieldNoProfileSBT()
8913 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
8915 const DataArrayDouble *arr=0;
8917 arr=field->getArray();
8918 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8921 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8923 _content=new MEDFileFieldMultiTSWithoutSDA;
8926 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll)
8927 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8930 catch(INTERP_KERNEL::Exception& e)
8933 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll)
8934 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8937 catch(INTERP_KERNEL::Exception& e)
8940 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8944 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
8946 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8949 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
8951 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8954 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
8956 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8959 //= MEDFileAnyTypeFieldMultiTSIterator
8961 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8966 _nb_iter=fmts->getNumberOfTS();
8970 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8974 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
8976 if(_iter_id<_nb_iter)
8978 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8980 return fmts->getTimeStepAtPos(_iter_id++);
8988 //= MEDFileIntFieldMultiTS
8991 * Returns a new empty instance of MEDFileFieldMultiTS.
8992 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8993 * is to delete this field using decrRef() as it is no more needed.
8995 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8997 return new MEDFileIntFieldMultiTS;
9001 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9002 * that has been read from a specified MED file.
9003 * \param [in] fileName - the name of the MED file to read.
9004 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9005 * is to delete this field using decrRef() as it is no more needed.
9006 * \throw If reading the file fails.
9008 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9010 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
9011 ret->contentNotNull();//to check that content type matches with \a this type.
9016 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9017 * that has been read from a specified MED file.
9018 * \param [in] fileName - the name of the MED file to read.
9019 * \param [in] fieldName - the name of the field to read.
9020 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9021 * is to delete this field using decrRef() as it is no more needed.
9022 * \throw If reading the file fails.
9023 * \throw If there is no field named \a fieldName in the file.
9025 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9027 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
9028 ret->contentNotNull();//to check that content type matches with \a this type.
9033 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9034 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9036 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9037 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9038 * \warning this is a shallow copy constructor
9039 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9040 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9041 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9042 * is to delete this field using decrRef() as it is no more needed.
9044 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9046 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9050 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9051 * following the given input policy.
9053 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9054 * By default (true) the globals are deeply copied.
9055 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9057 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9059 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9060 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9063 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9065 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9066 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9067 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9070 ret=MEDFileFieldMultiTS::New();
9072 ret->deepCpyGlobs(*this);
9074 ret->shallowCpyGlobs(*this);
9078 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9080 return new MEDFileIntFieldMultiTS(*this);
9083 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9086 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9087 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9089 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9093 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9094 * mesh entities of a given dimension of the first mesh in MED file.
9095 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9096 * \param [in] type - a spatial discretization of interest.
9097 * \param [in] iteration - the iteration number of a required time step.
9098 * \param [in] order - the iteration order number of required time step.
9099 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9100 * \param [out] arrOut - the DataArrayInt containing values of field.
9101 * \param [in] renumPol - specifies how to permute values of the result field according to
9102 * the optional numbers of cells and nodes, if any. The valid values are
9103 * - 0 - do not permute.
9104 * - 1 - permute cells.
9105 * - 2 - permute nodes.
9106 * - 3 - permute cells and nodes.
9108 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9109 * caller is to delete this field using decrRef() as it is no more needed.
9110 * \throw If the MED file is not readable.
9111 * \throw If there is no mesh in the MED file.
9112 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9113 * \throw If no field values of the required parameters are available.
9115 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9117 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9118 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9120 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9121 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9122 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9123 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9128 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9129 * the top level cells of the first mesh in MED file.
9130 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9131 * \param [in] type - a spatial discretization of interest.
9132 * \param [in] iteration - the iteration number of a required time step.
9133 * \param [in] order - the iteration order number of required time step.
9134 * \param [out] arrOut - the DataArrayInt containing values of field.
9135 * \param [in] renumPol - specifies how to permute values of the result field according to
9136 * the optional numbers of cells and nodes, if any. The valid values are
9137 * - 0 - do not permute.
9138 * - 1 - permute cells.
9139 * - 2 - permute nodes.
9140 * - 3 - permute cells and nodes.
9142 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9143 * caller is to delete this field using decrRef() as it is no more needed.
9144 * \throw If the MED file is not readable.
9145 * \throw If there is no mesh in the MED file.
9146 * \throw If no field values of the required parameters are available.
9148 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9150 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9151 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9153 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9154 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9155 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9156 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9161 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9163 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9164 * \param [in] type - a spatial discretization of interest.
9165 * \param [in] iteration - the iteration number of a required time step.
9166 * \param [in] order - the iteration order number of required time step.
9167 * \param [out] arrOut - the DataArrayInt containing values of field.
9168 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9169 * \param [in] mesh - the supporting mesh.
9170 * \param [in] renumPol - specifies how to permute values of the result field according to
9171 * the optional numbers of cells and nodes, if any. The valid values are
9172 * - 0 - do not permute.
9173 * - 1 - permute cells.
9174 * - 2 - permute nodes.
9175 * - 3 - permute cells and nodes.
9177 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9178 * caller is to delete this field using decrRef() as it is no more needed.
9179 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9180 * \throw If no field of \a this is lying on \a mesh.
9181 * \throw If no field values of the required parameters are available.
9183 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9185 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9186 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9188 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9189 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9190 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9191 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9196 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9198 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9199 * \param [in] type - a spatial discretization of the new field.
9200 * \param [in] iteration - the iteration number of a required time step.
9201 * \param [in] order - the iteration order number of required time step.
9202 * \param [in] mesh - the supporting mesh.
9203 * \param [out] arrOut - the DataArrayInt containing values of field.
9204 * \param [in] renumPol - specifies how to permute values of the result field according to
9205 * the optional numbers of cells and nodes, if any. The valid values are
9206 * - 0 - do not permute.
9207 * - 1 - permute cells.
9208 * - 2 - permute nodes.
9209 * - 3 - permute cells and nodes.
9211 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9212 * caller is to delete this field using decrRef() as it is no more needed.
9213 * \throw If no field of \a this is lying on \a mesh.
9214 * \throw If no field values of the required parameters are available.
9216 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9218 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9219 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9221 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9222 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9223 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9224 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9229 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9230 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9231 * This method is useful for MED2 file format when field on different mesh was autorized.
9233 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9235 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9236 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9238 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9239 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9240 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9241 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9246 * Returns values and a profile of the field of a given type, of a given time step,
9247 * lying on a given support.
9248 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9249 * \param [in] type - a spatial discretization of the field.
9250 * \param [in] iteration - the iteration number of a required time step.
9251 * \param [in] order - the iteration order number of required time step.
9252 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9253 * \param [in] mesh - the supporting mesh.
9254 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9255 * field of interest lies on. If the field lies on all entities of the given
9256 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9257 * using decrRef() as it is no more needed.
9258 * \param [in] glob - the global data storing profiles and localization.
9259 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9260 * field. The caller is to delete this array using decrRef() as it is no more needed.
9261 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9262 * \throw If no field of \a this is lying on \a mesh.
9263 * \throw If no field values of the required parameters are available.
9265 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9267 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9268 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9270 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9271 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9272 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9276 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9277 * \param [in] pos - a time step id.
9278 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9279 * delete this field using decrRef() as it is no more needed.
9280 * \throw If \a pos is not a valid time step id.
9282 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9284 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9287 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9288 throw INTERP_KERNEL::Exception(oss.str().c_str());
9290 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9293 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9294 ret->shallowCpyGlobs(*this);
9297 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9298 throw INTERP_KERNEL::Exception(oss.str().c_str());
9302 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9303 * the given field is checked if its elements are sorted suitable for writing to MED file
9304 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9305 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9306 * \param [in] field - the field to add to \a this.
9307 * \throw If the name of \a field is empty.
9308 * \throw If the data array of \a field is not set.
9309 * \throw If existing time steps have different name or number of components than \a field.
9310 * \throw If the underlying mesh of \a field has no name.
9311 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9313 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9315 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9319 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9320 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9321 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9324 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9325 * A new profile is added only if no equal profile is missing.
9326 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9327 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9328 * \param [in] arrOfVals - the values of the field \a field used.
9329 * \param [in] mesh - the supporting mesh of \a field.
9330 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9331 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9332 * \throw If either \a field or \a mesh or \a profile has an empty name.
9333 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9334 * \throw If the data array of \a field is not set.
9335 * \throw If the data array of \a this is already allocated but has different number of
9336 * components than \a field.
9337 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9338 * \sa setFieldNoProfileSBT()
9340 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9342 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9345 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9347 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9349 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9350 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9352 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 !");
9356 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9358 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9360 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9361 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9363 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 !");
9367 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9369 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9372 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9376 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll)
9377 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
9380 catch(INTERP_KERNEL::Exception& e)
9383 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll)
9384 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
9387 catch(INTERP_KERNEL::Exception& e)
9390 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9392 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9397 MEDFileFields *MEDFileFields::New()
9399 return new MEDFileFields;
9402 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9404 return new MEDFileFields(fileName,loadAll);
9407 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9409 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9410 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9414 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildren() const
9416 std::vector<const BigMemoryObject *> ret;
9417 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9419 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9426 MEDFileFields *MEDFileFields::deepCpy() const
9428 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9430 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9432 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9433 ret->_fields[i]=(*it)->deepCpy();
9435 ret->deepCpyGlobs(*this);
9439 MEDFileFields *MEDFileFields::shallowCpy() const
9441 return new MEDFileFields(*this);
9445 * 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
9446 * 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.
9447 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9449 * \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.
9450 * \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.
9452 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9454 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9456 std::set< std::pair<int,int> > s;
9457 bool firstShot=true;
9458 areThereSomeForgottenTS=false;
9459 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9461 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9463 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9464 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9466 { s=s1; firstShot=false; }
9469 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9471 areThereSomeForgottenTS=true;
9475 std::vector< std::pair<int,int> > ret;
9476 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9480 int MEDFileFields::getNumberOfFields() const
9482 return _fields.size();
9485 std::vector<std::string> MEDFileFields::getFieldsNames() const
9487 std::vector<std::string> ret(_fields.size());
9489 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9491 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9494 ret[i]=f->getName();
9498 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9499 throw INTERP_KERNEL::Exception(oss.str().c_str());
9505 std::vector<std::string> MEDFileFields::getMeshesNames() const
9507 std::vector<std::string> ret;
9508 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9510 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9512 ret.push_back(cur->getMeshName());
9517 std::string MEDFileFields::simpleRepr() const
9519 std::ostringstream oss;
9520 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9525 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9527 int nbOfFields=getNumberOfFields();
9528 std::string startLine(bkOffset,' ');
9529 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9531 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9533 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9536 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9540 oss << startLine << " - not defined !" << std::endl;
9544 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9546 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9547 std::string chapter(17,'0'+i);
9548 oss << startLine << chapter << std::endl;
9551 cur->simpleRepr(bkOffset+2,oss,i);
9555 oss << startLine << " - not defined !" << std::endl;
9557 oss << startLine << chapter << std::endl;
9559 simpleReprGlobs(oss);
9562 MEDFileFields::MEDFileFields()
9566 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll)
9567 try:MEDFileFieldGlobsReal(fileName)
9569 MEDFileUtilities::CheckFileForRead(fileName);
9570 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
9571 int nbFields=MEDnField(fid);
9572 _fields.resize(nbFields);
9573 med_field_type typcha;
9574 for(int i=0;i<nbFields;i++)
9576 std::vector<std::string> infos;
9577 std::string fieldName,dtunit;
9578 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
9583 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9588 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9593 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] !";
9594 throw INTERP_KERNEL::Exception(oss.str().c_str());
9598 loadAllGlobals(fid);
9600 catch(INTERP_KERNEL::Exception& e)
9605 void MEDFileFields::writeLL(med_idt fid) const
9608 writeGlobals(fid,*this);
9609 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9611 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9614 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9615 throw INTERP_KERNEL::Exception(oss.str().c_str());
9617 elt->writeLL(fid,*this);
9621 void MEDFileFields::write(const std::string& fileName, int mode) const
9623 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9624 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
9629 * This method alloc the arrays and load potentially huge arrays contained in this field.
9630 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9631 * This method can be also called to refresh or reinit values from a file.
9633 * \throw If the fileName is not set or points to a non readable MED file.
9635 void MEDFileFields::loadArrays()
9637 if(getFileName().empty())
9638 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9639 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9640 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9642 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9644 elt->loadBigArraysRecursively(fid,*elt);
9649 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9650 * But once data loaded once, this method does nothing.
9652 * \throw If the fileName is not set or points to a non readable MED file.
9653 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9655 void MEDFileFields::loadArraysIfNecessary()
9657 if(!getFileName().empty())
9659 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9660 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9662 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9664 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9670 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9671 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9672 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9674 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9676 void MEDFileFields::unloadArrays()
9678 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9680 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9682 elt->unloadArrays();
9687 * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
9688 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9689 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9691 * \sa MEDFileFields::loadArraysIfNecessary
9693 void MEDFileFields::unloadArraysWithoutDataLoss()
9695 if(!getFileName().empty())
9699 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9701 std::vector<std::string> ret;
9702 std::set<std::string> ret2;
9703 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9705 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9706 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9707 if(ret2.find(*it2)==ret2.end())
9709 ret.push_back(*it2);
9716 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9718 std::vector<std::string> ret;
9719 std::set<std::string> ret2;
9720 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9722 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9723 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9724 if(ret2.find(*it2)==ret2.end())
9726 ret.push_back(*it2);
9733 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9735 std::vector<std::string> ret;
9736 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9738 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9739 ret.insert(ret.end(),tmp.begin(),tmp.end());
9744 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9746 std::vector<std::string> ret;
9747 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9749 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9750 ret.insert(ret.end(),tmp.begin(),tmp.end());
9755 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9757 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9758 (*it)->changePflsRefsNamesGen2(mapOfModif);
9761 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9763 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9764 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9767 void MEDFileFields::resize(int newSize)
9769 _fields.resize(newSize);
9772 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
9774 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9778 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
9781 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9782 _fields.push_back(field->getContent());
9783 appendGlobs(*field,1e-12);
9786 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
9789 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9790 if(i>=(int)_fields.size())
9791 _fields.resize(i+1);
9792 _fields[i]=field->getContent();
9793 appendGlobs(*field,1e-12);
9796 void MEDFileFields::destroyFieldAtPos(int i)
9798 destroyFieldsAtPos(&i,&i+1);
9801 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
9803 std::vector<bool> b(_fields.size(),true);
9804 for(const int *i=startIds;i!=endIds;i++)
9806 if(*i<0 || *i>=(int)_fields.size())
9808 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9809 throw INTERP_KERNEL::Exception(oss.str().c_str());
9813 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9815 for(std::size_t i=0;i<_fields.size();i++)
9817 fields[j++]=_fields[i];
9821 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
9823 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9824 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9825 std::vector<bool> b(_fields.size(),true);
9827 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9829 if(k<0 || k>=(int)_fields.size())
9831 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9832 throw INTERP_KERNEL::Exception(oss.str().c_str());
9836 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9838 for(std::size_t i=0;i<_fields.size();i++)
9840 fields[j++]=_fields[i];
9844 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9847 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9849 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9851 ret=cur->changeMeshNames(modifTab) || ret;
9857 * \param [in] meshName the name of the mesh that will be renumbered.
9858 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9859 * This code corresponds to the distribution of types in the corresponding mesh.
9860 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9861 * \param [in] renumO2N the old to new renumber array.
9862 * \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
9865 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
9868 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9870 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9873 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9879 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
9881 if(i<0 || i>=(int)_fields.size())
9883 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9884 throw INTERP_KERNEL::Exception(oss.str().c_str());
9886 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9889 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9890 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9891 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9893 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9895 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9898 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9899 throw INTERP_KERNEL::Exception(oss.str().c_str());
9901 ret->shallowCpyGlobs(*this);
9906 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9907 * This method is accessible in python using __getitem__ with a list in input.
9908 * \return a new object that the caller should deal with.
9910 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
9912 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9913 std::size_t sz=std::distance(startIds,endIds);
9914 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9916 for(const int *i=startIds;i!=endIds;i++,j++)
9918 if(*i<0 || *i>=(int)_fields.size())
9920 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9921 throw INTERP_KERNEL::Exception(oss.str().c_str());
9923 fields[j]=_fields[*i];
9925 ret->_fields=fields;
9929 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
9931 return getFieldAtPos(getPosFromFieldName(fieldName));
9935 * This method removes, if any, fields in \a this having no time steps.
9936 * If there is one or more than one such field in \a this true is returned and those fields will not be referenced anymore in \a this.
9938 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
9940 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
9942 std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
9943 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9945 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9948 if(elt->getNumberOfTS()>0)
9949 newFields.push_back(*it);
9952 if(_fields.size()==newFields.size())
9959 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9960 * This method can be seen as a filter applied on \a this, that returns an object containing
9961 * 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
9962 * shallow copied from \a this.
9964 * \param [in] meshName - the name of the mesh on w
9965 * \return a new object that the caller should deal with.
9967 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
9969 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9970 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9972 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9975 if(cur->getMeshName()==meshName)
9978 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9979 ret->_fields.push_back(cur2);
9982 ret->shallowCpyOnlyUsedGlobs(*this);
9987 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9988 * Input time steps are specified using a pair of integer (iteration, order).
9989 * 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,
9990 * but for each multitimestep only the time steps in \a timeSteps are kept.
9991 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9993 * The returned object points to shallow copy of elements in \a this.
9995 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9996 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9997 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9999 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10001 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10002 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10004 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10007 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10008 ret->_fields.push_back(elt);
10010 ret->shallowCpyOnlyUsedGlobs(*this);
10015 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10017 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10019 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10020 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10022 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10025 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10026 if(elt->getNumberOfTS()!=0)
10027 ret->_fields.push_back(elt);
10029 ret->shallowCpyOnlyUsedGlobs(*this);
10033 MEDFileFieldsIterator *MEDFileFields::iterator()
10035 return new MEDFileFieldsIterator(this);
10038 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10040 std::string tmp(fieldName);
10041 std::vector<std::string> poss;
10042 for(std::size_t i=0;i<_fields.size();i++)
10044 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10047 std::string fname(f->getName());
10051 poss.push_back(fname);
10054 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10055 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10057 throw INTERP_KERNEL::Exception(oss.str().c_str());
10060 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10065 _nb_iter=fs->getNumberOfFields();
10069 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10073 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10075 if(_iter_id<_nb_iter)
10077 MEDFileFields *fs(_fs);
10079 return fs->getFieldAtPos(_iter_id++);