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::getDirectChildrenWithNull() 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::getDirectChildrenWithNull() 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::getDirectChildrenWithNull() 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++)
996 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1000 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const
1002 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1003 ret->_father=father;
1005 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1007 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1008 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
1013 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1015 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1016 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1017 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1021 * This method is the most general one. No optimization is done here.
1022 * \param [in] multiTypePfl is the end user profile specified in high level API
1023 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1024 * \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.
1025 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1026 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1027 * \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.
1029 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)
1031 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1032 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1033 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1036 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1038 _field_pm_pt_pd.resize(1);
1039 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1040 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1043 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1045 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1046 if(!arr || !arr->isAllocated())
1047 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1048 _field_pm_pt_pd.resize(1);
1049 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1050 _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.
1053 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1055 TypeOfField type=field->getTypeOfField();
1056 if(type!=ON_GAUSS_PT)
1058 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1059 int sz=_field_pm_pt_pd.size();
1061 for(int j=0;j<sz && !found;j++)
1063 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1065 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1071 _field_pm_pt_pd.resize(sz+1);
1072 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1074 std::vector<int> ret(1,(int)sz);
1079 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1080 int sz2=ret2.size();
1081 std::vector<int> ret3(sz2);
1083 for(int i=0;i<sz2;i++)
1085 int sz=_field_pm_pt_pd.size();
1086 int locIdToFind=ret2[i];
1088 for(int j=0;j<sz && !found;j++)
1090 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1092 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1099 _field_pm_pt_pd.resize(sz+1);
1100 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1108 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1110 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1111 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1113 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1114 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1116 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1117 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1118 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1119 if(retTmp->presenceOfValue(-1))
1120 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1121 std::vector<int> ret(retTmp->begin(),retTmp->end());
1125 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1127 TypeOfField type=field->getTypeOfField();
1128 if(type!=ON_GAUSS_PT)
1130 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1131 int sz=_field_pm_pt_pd.size();
1133 for(int j=0;j<sz && !found;j++)
1135 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1137 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1143 _field_pm_pt_pd.resize(sz+1);
1144 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1146 std::vector<int> ret(1,0);
1151 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1152 int sz2=ret2.size();
1153 std::vector<int> ret3(sz2);
1155 for(int i=0;i<sz2;i++)
1157 int sz=_field_pm_pt_pd.size();
1158 int locIdToFind=ret2[i];
1160 for(int j=0;j<sz && !found;j++)
1162 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1164 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1171 _field_pm_pt_pd.resize(sz+1);
1172 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1180 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1182 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1183 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1185 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1186 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1188 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1189 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1190 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1191 if(retTmp->presenceOfValue(-1))
1192 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1193 std::vector<int> ret(retTmp->begin(),retTmp->end());
1197 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1202 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1204 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1205 int curDim=(int)cm.getDimension();
1206 dim=std::max(dim,curDim);
1209 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1211 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1213 (*it)->fillTypesOfFieldAvailable(types);
1217 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
1219 int sz=_field_pm_pt_pd.size();
1220 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1221 for(int i=0;i<sz;i++)
1223 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1227 int MEDFileFieldPerMeshPerType::getIteration() const
1229 return _father->getIteration();
1232 int MEDFileFieldPerMeshPerType::getOrder() const
1234 return _father->getOrder();
1237 double MEDFileFieldPerMeshPerType::getTime() const
1239 return _father->getTime();
1242 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1244 return _father->getMeshName();
1247 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1249 const char startLine[]=" ## ";
1250 std::string startLine2(bkOffset,' ');
1251 std::string startLine3(startLine2);
1252 startLine3+=startLine;
1253 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1255 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1256 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1259 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1260 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1262 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1264 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1266 cur->simpleRepr(bkOffset,oss,i);
1269 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1274 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1276 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1278 globalSz+=(*it)->getNumberOfTuples();
1280 nbOfEntries+=(int)_field_pm_pt_pd.size();
1283 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1289 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1291 return _father->getNumberOfComponents();
1294 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1296 return _father->getOrCreateAndGetArray();
1299 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1301 const MEDFileFieldPerMesh *fath=_father;
1302 return fath->getOrCreateAndGetArray();
1305 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1307 return _father->getInfo();
1310 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1312 std::vector<std::string> ret;
1313 std::set<std::string> ret2;
1314 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1316 std::string tmp=(*it1)->getProfile();
1318 if(ret2.find(tmp)==ret2.end())
1327 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1329 std::vector<std::string> ret;
1330 std::set<std::string> ret2;
1331 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1333 std::string tmp=(*it1)->getLocalization();
1334 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1335 if(ret2.find(tmp)==ret2.end())
1344 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1346 std::vector<std::string> ret;
1347 std::set<std::string> ret2;
1348 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1350 std::string tmp=(*it1)->getProfile();
1357 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1359 std::vector<std::string> ret;
1360 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1362 std::string tmp=(*it1)->getLocalization();
1363 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1369 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1371 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1372 (*it1)->changePflsRefsNamesGen(mapOfModif);
1375 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1377 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1378 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1381 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1383 if(_field_pm_pt_pd.empty())
1385 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1386 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1387 throw INTERP_KERNEL::Exception(oss.str().c_str());
1389 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1390 return _field_pm_pt_pd[locId];
1391 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1392 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1393 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1394 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1395 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1398 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1400 if(_field_pm_pt_pd.empty())
1402 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1403 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1404 throw INTERP_KERNEL::Exception(oss.str().c_str());
1406 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1407 return _field_pm_pt_pd[locId];
1408 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1409 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1410 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1411 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1412 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1415 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
1417 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1419 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1420 if(meshDim!=(int)cm.getDimension())
1423 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1424 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1427 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1430 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1432 (*it)->fillValues(i,startEntryId,entries);
1436 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1438 _field_pm_pt_pd=leaves;
1439 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1440 (*it)->setFather(this);
1444 * \param [in,out] globalNum a global numbering counter for the renumbering.
1445 * \param [out] its - list of pair (start,stop) kept
1446 * \return bool - false if the type of field \a tof is not contained in \a this.
1448 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1451 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1452 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1453 if((*it)->getType()==tof)
1455 newPmPtPd.push_back(*it);
1456 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1457 (*it)->setNewStart(globalNum);
1458 globalNum=(*it)->getEnd();
1459 its.push_back(bgEnd);
1463 _field_pm_pt_pd=newPmPtPd;
1467 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1471 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc):_father(fath),_geo_type(geoType)
1473 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1474 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1475 med_geometry_type mgeoti;
1476 med_entity_type menti;
1477 menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1478 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1479 _field_pm_pt_pd.resize(nbProfiles);
1480 for(int i=0;i<nbProfiles;i++)
1482 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1486 int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1487 for(int i=0;i<nbProfiles2;i++)
1488 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i+1));
1492 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1494 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1495 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1498 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1500 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1501 (*it)->loadBigArray(fid,nasc);
1504 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1506 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1508 (*it)->copyOptionsFrom(*this);
1509 (*it)->writeLL(fid,nasc);
1513 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1518 medfGeoType=typmai3[(int)ikGeoType];
1521 medfGeoType=MED_NONE;
1524 medfGeoType=typmai3[(int)ikGeoType];
1525 return MED_NODE_ELEMENT;
1527 medfGeoType=typmai3[(int)ikGeoType];
1530 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1532 return MED_UNDEF_ENTITY_TYPE;
1535 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc)
1537 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1540 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1542 return new MEDFileFieldPerMesh(fath,mesh);
1545 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1547 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1550 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1552 std::vector<const BigMemoryObject *> ret;
1553 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1554 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1558 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1560 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1561 ret->_father=father;
1563 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1565 if((const MEDFileFieldPerMeshPerType *)*it)
1566 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1571 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1573 std::string startLine(bkOffset,' ');
1574 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1575 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1577 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1579 const MEDFileFieldPerMeshPerType *cur=*it;
1581 cur->simpleRepr(bkOffset,oss,i);
1584 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1589 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1591 _mesh_name=mesh->getName();
1592 mesh->getTime(_mesh_iteration,_mesh_order);
1595 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1597 int nbOfTypes=code.size()/3;
1599 for(int i=0;i<nbOfTypes;i++)
1601 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1602 int nbOfCells=code[3*i+1];
1603 int pos=addNewEntryIfNecessary(type);
1604 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1610 * This method is the most general one. No optimization is done here.
1611 * \param [in] multiTypePfl is the end user profile specified in high level API
1612 * \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].
1613 * \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.
1614 * \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.
1615 * \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.
1616 * \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.
1618 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)
1620 int nbOfTypes(code.size()/3);
1621 for(int i=0;i<nbOfTypes;i++)
1623 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1624 int pos=addNewEntryIfNecessary(type);
1625 DataArrayInt *pfl=0;
1627 pfl=idsPerType[code[3*i+2]];
1628 int nbOfTupes2=code2.size()/3;
1630 for(;found<nbOfTupes2;found++)
1631 if(code[3*i]==code2[3*found])
1633 if(found==nbOfTupes2)
1634 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1635 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1639 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1641 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1642 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1645 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1647 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1648 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1651 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1653 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1654 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1657 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1659 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1660 (*it)->loadBigArraysRecursively(fid,nasc);
1663 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1665 int nbOfTypes=_field_pm_pt.size();
1666 for(int i=0;i<nbOfTypes;i++)
1668 _field_pm_pt[i]->copyOptionsFrom(*this);
1669 _field_pm_pt[i]->writeLL(fid,nasc);
1673 void MEDFileFieldPerMesh::getDimension(int& dim) const
1675 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1676 (*it)->getDimension(dim);
1679 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1681 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1682 (*it)->fillTypesOfFieldAvailable(types);
1685 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
1687 int sz=_field_pm_pt.size();
1688 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1689 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1690 for(int i=0;i<sz;i++)
1692 types[i]=_field_pm_pt[i]->getGeoType();
1693 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1698 double MEDFileFieldPerMesh::getTime() const
1701 return _father->getTime(tmp1,tmp2);
1704 int MEDFileFieldPerMesh::getIteration() const
1706 return _father->getIteration();
1709 int MEDFileFieldPerMesh::getOrder() const
1711 return _father->getOrder();
1714 int MEDFileFieldPerMesh::getNumberOfComponents() const
1716 return _father->getNumberOfComponents();
1719 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1722 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1723 return _father->getOrCreateAndGetArray();
1726 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1729 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1730 return _father->getOrCreateAndGetArray();
1733 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1735 return _father->getInfo();
1739 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1740 * 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.
1741 * It returns 2 output vectors :
1742 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1743 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1744 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1746 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)
1748 int notNullPflsSz=0;
1749 int nbOfArrs=geoTypes.size();
1750 for(int i=0;i<nbOfArrs;i++)
1753 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1754 int nbOfDiffGeoTypes=geoTypes3.size();
1755 code.resize(3*nbOfDiffGeoTypes);
1756 notNullPfls.resize(notNullPflsSz);
1759 for(int i=0;i<nbOfDiffGeoTypes;i++)
1762 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1763 std::vector<const DataArrayInt *> notNullTmp;
1765 notNullTmp.push_back(pfls[j]);
1767 for(;j<nbOfArrs;j++)
1768 if(geoTypes[j]==refType)
1771 notNullTmp.push_back(pfls[j]);
1775 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1776 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1777 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1778 code[3*i]=(int)refType;
1779 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1780 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1781 if(notNullTmp.empty())
1785 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1786 code[3*i+2]=notNullPflsSz++;
1792 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1794 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)
1798 for(int i=0;i<sz;i++)
1802 if(type!=ON_GAUSS_NE)
1803 ret+=dads[i].second-dads[i].first;
1806 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1807 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1812 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1813 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1819 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1821 std::vector<std::string> ret;
1822 std::set<std::string> ret2;
1823 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1825 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1826 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1827 if(ret2.find(*it2)==ret2.end())
1829 ret.push_back(*it2);
1836 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1838 std::vector<std::string> ret;
1839 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1841 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1842 ret.insert(ret.end(),tmp.begin(),tmp.end());
1847 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1849 std::vector<std::string> ret;
1850 std::set<std::string> ret2;
1851 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1853 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1854 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1855 if(ret2.find(*it2)==ret2.end())
1857 ret.push_back(*it2);
1864 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1866 std::vector<std::string> ret;
1867 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1869 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1870 ret.insert(ret.end(),tmp.begin(),tmp.end());
1875 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1877 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1879 if((*it).first==_mesh_name)
1881 _mesh_name=(*it).second;
1888 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1889 MEDFileFieldGlobsReal& glob)
1891 if(_mesh_name!=meshName)
1893 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1894 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1895 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1896 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1897 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1898 getUndergroundDataArrayExt(entries);
1899 DataArray *arr0=getOrCreateAndGetArray();//tony
1901 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1902 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1904 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1907 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1908 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1910 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1912 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1913 sz+=(*it).second.second-(*it).second.first;
1916 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1918 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1919 ////////////////////
1920 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1921 int *workI2=explicitIdsOldInMesh->getPointer();
1922 int sz1=0,sz2=0,sid=1;
1923 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1924 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1925 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1927 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1928 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1929 int *workI=explicitIdsOldInArr->getPointer();
1930 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1932 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1933 (*itL2)->setLocId(sz2);
1934 (*itL2)->_tmp_work1=(*itL2)->getStart();
1935 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1937 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1939 explicitIdsOldInMesh->reAlloc(sz2);
1940 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1941 ////////////////////
1942 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1943 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1944 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1945 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1947 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1948 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1949 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1951 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1952 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1953 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1955 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1956 int newStart=elt->getLocId();
1957 elt->setLocId((*it)->getGeoType());
1958 elt->setNewStart(newStart);
1959 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1960 entriesKeptNew.push_back(elt);
1961 entriesKeptNew2.push_back(elt);
1963 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1964 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1965 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1966 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1968 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1971 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1973 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1974 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1976 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1977 glob,arr2,otherEntriesNew) || ret;
1981 // Assign new dispatching
1982 assignNewLeaves(otherEntriesNew);
1983 arr->cpyFrom(*arr2);
1988 * \param [in,out] globalNum a global numbering counter for the renumbering.
1989 * \param [out] its - list of pair (start,stop) kept
1991 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1993 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
1994 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1996 std::vector< std::pair<int,int> > its2;
1997 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2000 its.insert(its.end(),its2.begin(),its2.end());
2006 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2008 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2009 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2010 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2012 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2013 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2014 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2015 for(;it1!=types.end();it1++,it2++)
2017 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2018 elt->setLeaves((*it1).second);
2021 _field_pm_pt=fieldPmPt;
2024 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2026 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2027 (*it)->changePflsRefsNamesGen(mapOfModif);
2030 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2032 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2033 (*it)->changeLocsRefsNamesGen(mapOfModif);
2037 * \param [in] mesh is the whole mesh
2039 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2041 if(_field_pm_pt.empty())
2042 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2044 std::vector< std::pair<int,int> > dads;
2045 std::vector<const DataArrayInt *> pfls;
2046 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2047 std::vector<int> locs,code;
2048 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2049 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2050 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2052 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2055 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2056 throw INTERP_KERNEL::Exception(oss.str().c_str());
2059 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2060 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2063 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2065 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2068 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2069 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2075 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2079 if(nb!=mesh->getNumberOfNodes())
2081 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2082 oss << " nodes in mesh !";
2083 throw INTERP_KERNEL::Exception(oss.str().c_str());
2085 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2088 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2092 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2094 if(_field_pm_pt.empty())
2095 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2097 std::vector<std::pair<int,int> > dads;
2098 std::vector<const DataArrayInt *> pfls;
2099 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2100 std::vector<int> locs,code;
2101 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2102 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2103 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2105 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2108 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2109 throw INTERP_KERNEL::Exception(oss.str().c_str());
2111 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2112 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2115 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2116 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2121 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2125 if(nb!=mesh->getNumberOfNodes())
2127 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2128 oss << " nodes in mesh !";
2129 throw INTERP_KERNEL::Exception(oss.str().c_str());
2132 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2138 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2142 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2144 (*it)->getSizes(globalSz,nbOfEntries);
2146 entries.resize(nbOfEntries);
2148 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2150 (*it)->fillValues(nbOfEntries,entries);
2154 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2156 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2158 if((*it)->getGeoType()==typ)
2159 return (*it)->getLeafGivenLocId(locId);
2161 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2162 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2163 oss << "Possiblities are : ";
2164 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2166 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2167 oss << "\"" << cm2.getRepr() << "\", ";
2169 throw INTERP_KERNEL::Exception(oss.str().c_str());
2172 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2174 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2176 if((*it)->getGeoType()==typ)
2177 return (*it)->getLeafGivenLocId(locId);
2179 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2180 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2181 oss << "Possiblities are : ";
2182 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2184 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2185 oss << "\"" << cm2.getRepr() << "\", ";
2187 throw INTERP_KERNEL::Exception(oss.str().c_str());
2190 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2193 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2194 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2195 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2197 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2202 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2207 int ret=std::distance(_field_pm_pt.begin(),it2);
2208 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2213 * 'dads' and 'locs' input parameters have the same number of elements
2214 * \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
2216 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2217 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2218 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2221 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2222 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2223 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2224 const std::vector<std::string>& infos=getInfo();
2225 da->setInfoOnComponents(infos);
2227 if(type==ON_GAUSS_PT)
2230 int nbOfArrs=dads.size();
2231 for(int i=0;i<nbOfArrs;i++)
2233 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2234 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2235 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2236 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2237 di->alloc(nbOfElems,1);
2239 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2240 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2249 * 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.
2250 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2251 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2252 * The order of cells in the returned field is those imposed by the profile.
2253 * \param [in] mesh is the global mesh.
2255 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2256 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2257 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2258 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2260 if(da->isIdentity())
2262 int nbOfTuples=da->getNumberOfTuples();
2263 if(nbOfTuples==mesh->getNumberOfCells())
2264 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2266 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2267 m2->setName(mesh->getName().c_str());
2268 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2274 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2276 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2277 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2278 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2280 if(da->isIdentity())
2282 int nbOfTuples=da->getNumberOfTuples();
2283 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2284 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2286 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2287 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2290 if(meshu->getNodalConnectivity()==0)
2292 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2293 int nb=da->getNbOfElems();
2294 const int *ptr=da->getConstPointer();
2295 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2296 meshuc->allocateCells(nb);
2297 for(int i=0;i<nb;i++)
2298 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2299 meshuc->finishInsertingCells();
2300 ret->setMesh(meshuc);
2301 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2302 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2303 disc->checkCoherencyBetween(meshuc,arrOut);
2308 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2310 DataArrayInt *arr2=0;
2311 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2312 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2313 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2314 int nnodes=mesh2->getNumberOfNodes();
2315 if(nnodes==(int)da->getNbOfElems())
2317 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2318 arrOut->renumberInPlace(da3->getConstPointer());
2319 mesh2->setName(mesh->getName().c_str());
2320 ret->setMesh(mesh2);
2325 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 !!!";
2326 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2327 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2328 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2329 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2330 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2331 throw INTERP_KERNEL::Exception(oss.str().c_str());
2337 * This method is the most light method of field retrieving.
2339 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2343 pflOut=DataArrayInt::New();
2344 pflOut->alloc(nbOfElems,1);
2349 pflOut=const_cast<DataArrayInt*>(pflIn);
2352 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2353 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2354 const std::vector<std::string>& infos=getInfo();
2355 int nbOfComp=infos.size();
2356 for(int i=0;i<nbOfComp;i++)
2357 da->setInfoOnComponent(i,infos[i].c_str());
2362 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2363 _mesh_csit(meshCsit),_father(fath)
2365 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2366 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2367 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2368 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2370 int nbProfile =MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[i],_mesh_csit,meshName,pflName,locName);
2371 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2372 int nbProfile2=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2373 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2374 if(nbProfile>0 || nbProfile2>0)
2376 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2383 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2386 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2387 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2391 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2393 copyTinyInfoFrom(mesh);
2396 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2398 if(id>=(int)_pfls.size())
2400 _pfls[id]=DataArrayInt::New();
2401 int lgth=MEDprofileSizeByName(fid,pflName.c_str());
2402 _pfls[id]->setName(pflName);
2403 _pfls[id]->alloc(lgth,1);
2404 MEDprofileRd(fid,pflName.c_str(),_pfls[id]->getPointer());
2405 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2408 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2410 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2412 MEDprofileInfo(fid,i+1,pflName,&sz);
2413 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2414 if(i>=(int)_pfls.size())
2416 _pfls[i]=DataArrayInt::New();
2417 _pfls[i]->alloc(sz,1);
2418 _pfls[i]->setName(pflCpp.c_str());
2419 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2420 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2423 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2425 int nbOfPfls=_pfls.size();
2426 for(int i=0;i<nbOfPfls;i++)
2428 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2429 cpy->applyLin(1,1,0);
2430 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2431 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2432 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2435 int nbOfLocs=_locs.size();
2436 for(int i=0;i<nbOfLocs;i++)
2437 _locs[i]->writeLL(fid);
2440 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2442 std::vector<std::string> pfls=getPfls();
2443 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2445 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2448 _pfls.push_back(*it);
2452 int id=std::distance(pfls.begin(),it2);
2453 if(!(*it)->isEqual(*_pfls[id]))
2455 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2456 throw INTERP_KERNEL::Exception(oss.str().c_str());
2460 std::vector<std::string> locs=getLocs();
2461 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2463 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2466 _locs.push_back(*it);
2470 int id=std::distance(locs.begin(),it2);
2471 if(!(*it)->isEqual(*_locs[id],eps))
2473 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2474 throw INTERP_KERNEL::Exception(oss.str().c_str());
2480 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2482 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2483 getProfile((*it).c_str());
2486 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2488 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2489 getLocalization((*it).c_str());
2492 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2494 std::vector<std::string> profiles=real.getPflsReallyUsed();
2495 int sz=profiles.size();
2497 for(int i=0;i<sz;i++)
2498 loadProfileInFile(fid,i,profiles[i].c_str());
2500 std::vector<std::string> locs=real.getLocsReallyUsed();
2503 for(int i=0;i<sz;i++)
2504 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2507 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2509 int nProfil=MEDnProfile(fid);
2510 for(int i=0;i<nProfil;i++)
2511 loadProfileInFile(fid,i);
2512 int sz=MEDnLocalization(fid);
2514 for(int i=0;i<sz;i++)
2516 _locs[i]=MEDFileFieldLoc::New(fid,i);
2520 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2522 return new MEDFileFieldGlobs(fname);
2525 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2527 return new MEDFileFieldGlobs;
2530 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2532 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2535 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2537 std::vector<const BigMemoryObject *> ret;
2538 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2539 ret.push_back((const DataArrayInt *)*it);
2540 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2541 ret.push_back((const MEDFileFieldLoc *)*it);
2545 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2547 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2549 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2551 if((const DataArrayInt *)*it)
2552 ret->_pfls[i]=(*it)->deepCpy();
2555 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2557 if((const MEDFileFieldLoc*)*it)
2558 ret->_locs[i]=(*it)->deepCpy();
2564 * \throw if a profile in \a pfls in not in \a this.
2565 * \throw if a localization in \a locs in not in \a this.
2566 * \sa MEDFileFieldGlobs::deepCpyPart
2568 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2570 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2571 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2573 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2575 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2577 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2578 ret->_pfls.push_back(pfl2);
2580 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2582 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2584 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2586 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2587 ret->_locs.push_back(loc2);
2589 ret->setFileName(getFileName());
2594 * \throw if a profile in \a pfls in not in \a this.
2595 * \throw if a localization in \a locs in not in \a this.
2596 * \sa MEDFileFieldGlobs::shallowCpyPart
2598 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2600 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2601 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2603 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2605 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2606 ret->_pfls.push_back(pfl->deepCpy());
2608 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2610 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2612 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2613 ret->_locs.push_back(loc->deepCpy());
2615 ret->setFileName(getFileName());
2619 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2623 MEDFileFieldGlobs::MEDFileFieldGlobs()
2627 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2631 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2633 oss << "Profiles :\n";
2634 std::size_t n=_pfls.size();
2635 for(std::size_t i=0;i<n;i++)
2637 oss << " - #" << i << " ";
2638 const DataArrayInt *pfl=_pfls[i];
2640 oss << "\"" << pfl->getName() << "\"\n";
2645 oss << "Localizations :\n";
2646 for(std::size_t i=0;i<n;i++)
2648 oss << " - #" << i << " ";
2649 const MEDFileFieldLoc *loc=_locs[i];
2651 loc->simpleRepr(oss);
2657 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2659 _file_name=fileName;
2662 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2664 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2666 DataArrayInt *elt(*it);
2669 std::string name(elt->getName());
2670 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2672 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2674 elt->setName((*it2).second.c_str());
2682 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2684 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2686 MEDFileFieldLoc *elt(*it);
2689 std::string name(elt->getName());
2690 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2692 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2694 elt->setName((*it2).second.c_str());
2702 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2704 if(locId<0 || locId>=(int)_locs.size())
2705 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2706 return _locs[locId]->getNbOfGaussPtPerCell();
2709 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2711 return getLocalizationFromId(getLocalizationId(locName));
2714 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2716 if(locId<0 || locId>=(int)_locs.size())
2717 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2718 return *_locs[locId];
2721 namespace ParaMEDMEMImpl
2726 LocFinder(const std::string& loc):_loc(loc) { }
2727 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2729 const std::string &_loc;
2735 PflFinder(const std::string& pfl):_pfl(pfl) { }
2736 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2738 const std::string& _pfl;
2742 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2744 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2747 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2748 for(it=_locs.begin();it!=_locs.end();it++)
2749 oss << "\"" << (*it)->getName() << "\", ";
2750 throw INTERP_KERNEL::Exception(oss.str().c_str());
2752 return std::distance(_locs.begin(),it);
2756 * The returned value is never null.
2758 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2760 std::string pflNameCpp(pflName);
2761 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2764 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2765 for(it=_pfls.begin();it!=_pfls.end();it++)
2766 oss << "\"" << (*it)->getName() << "\", ";
2767 throw INTERP_KERNEL::Exception(oss.str().c_str());
2772 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2774 if(pflId<0 || pflId>=(int)_pfls.size())
2775 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2776 return _pfls[pflId];
2779 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
2781 if(locId<0 || locId>=(int)_locs.size())
2782 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2783 return *_locs[locId];
2786 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
2788 return getLocalizationFromId(getLocalizationId(locName));
2792 * The returned value is never null.
2794 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
2796 std::string pflNameCpp(pflName);
2797 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2800 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2801 for(it=_pfls.begin();it!=_pfls.end();it++)
2802 oss << "\"" << (*it)->getName() << "\", ";
2803 throw INTERP_KERNEL::Exception(oss.str().c_str());
2808 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
2810 if(pflId<0 || pflId>=(int)_pfls.size())
2811 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2812 return _pfls[pflId];
2815 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
2817 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2819 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2821 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2822 newPfls.push_back(*it);
2827 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
2829 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2831 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2833 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2834 newLocs.push_back(*it);
2839 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2841 int sz=_pfls.size();
2842 std::vector<std::string> ret(sz);
2843 for(int i=0;i<sz;i++)
2844 ret[i]=_pfls[i]->getName();
2848 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2850 int sz=_locs.size();
2851 std::vector<std::string> ret(sz);
2852 for(int i=0;i<sz;i++)
2853 ret[i]=_locs[i]->getName();
2857 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
2859 std::vector<std::string> v=getPfls();
2860 std::string s(pflName);
2861 return std::find(v.begin(),v.end(),s)!=v.end();
2864 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
2866 std::vector<std::string> v=getLocs();
2867 std::string s(locName);
2868 return std::find(v.begin(),v.end(),s)!=v.end();
2871 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2873 std::map<int,std::vector<int> > m;
2875 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2877 const DataArrayInt *tmp=(*it);
2880 m[tmp->getHashCode()].push_back(i);
2883 std::vector< std::vector<int> > ret;
2884 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2886 if((*it2).second.size()>1)
2888 std::vector<int> ret0;
2889 bool equalityOrNot=false;
2890 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2892 std::vector<int>::const_iterator it4=it3; it4++;
2893 for(;it4!=(*it2).second.end();it4++)
2895 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2898 ret0.push_back(*it3);
2899 ret0.push_back(*it4);
2905 ret.push_back(ret0);
2911 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2913 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2916 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
2918 std::string name(pfl->getName());
2920 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2921 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2922 if(name==(*it)->getName())
2924 if(!pfl->isEqual(*(*it)))
2926 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2927 throw INTERP_KERNEL::Exception(oss.str().c_str());
2931 _pfls.push_back(pfl);
2934 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)
2936 std::string name(locName);
2938 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2939 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2940 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2941 if((*it)->isName(locName))
2943 if(!(*it)->isEqual(*obj,1e-12))
2945 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2946 throw INTERP_KERNEL::Exception(oss.str().c_str());
2949 _locs.push_back(obj);
2952 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
2954 std::vector<std::string> names=getPfls();
2955 return CreateNewNameNotIn("NewPfl_",names);
2958 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
2960 std::vector<std::string> names=getLocs();
2961 return CreateNewNameNotIn("NewLoc_",names);
2964 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
2966 for(std::size_t sz=0;sz<100000;sz++)
2968 std::ostringstream tryName;
2969 tryName << prefix << sz;
2970 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2971 return tryName.str();
2973 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2977 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2978 * \param [in] fname - the file name.
2980 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
2985 * Creates an empty MEDFileFieldGlobsReal.
2987 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
2991 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
2996 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
2998 std::vector<const BigMemoryObject *> ret;
2999 ret.push_back((const MEDFileFieldGlobs *)_globals);
3004 * Returns a string describing profiles and Gauss points held in \a this.
3005 * \return std::string - the description string.
3007 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3009 const MEDFileFieldGlobs *glob=_globals;
3010 std::ostringstream oss2; oss2 << glob;
3011 std::string stars(oss2.str().length(),'*');
3012 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3014 glob->simpleRepr(oss);
3016 oss << "NO GLOBAL INFORMATION !\n";
3019 void MEDFileFieldGlobsReal::resetContent()
3021 _globals=MEDFileFieldGlobs::New();
3024 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3029 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3030 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3032 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3034 _globals=other._globals;
3038 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3039 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3041 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3043 const MEDFileFieldGlobs *otherg(other._globals);
3046 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3050 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3051 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3053 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3055 const MEDFileFieldGlobs *otherg(other._globals);
3058 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3061 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3063 _globals=other._globals;
3064 if((const MEDFileFieldGlobs *)_globals)
3065 _globals=other._globals->deepCpy();
3069 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3070 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3071 * \param [in] eps - a precision used to compare Gauss points with same name held by
3072 * \a this and \a other MEDFileFieldGlobsReal.
3073 * \throw If \a this and \a other hold profiles with equal names but different ids.
3074 * \throw If \a this and \a other hold different Gauss points with equal names.
3076 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3078 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3079 if(thisGlobals==otherGlobals)
3083 _globals=other._globals;
3086 _globals->appendGlobs(*other._globals,eps);
3089 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3091 checkGlobsPflsPartCoherency();
3092 checkGlobsLocsPartCoherency();
3095 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3097 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3100 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3102 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3105 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3107 contentNotNull()->loadProfileInFile(fid,id,pflName);
3110 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3112 contentNotNull()->loadProfileInFile(fid,id);
3115 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3117 contentNotNull()->loadGlobals(fid,*this);
3120 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3122 contentNotNull()->loadAllGlobals(fid);
3125 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3127 contentNotNull()->writeGlobals(fid,opt);
3131 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3132 * or getPflsReallyUsedMulti().
3133 * \return std::vector<std::string> - a sequence of names of all profiles.
3135 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3137 return contentNotNull()->getPfls();
3141 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3142 * or getLocsReallyUsedMulti().
3143 * \return std::vector<std::string> - a sequence of names of all localizations.
3145 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3147 return contentNotNull()->getLocs();
3151 * Checks if the profile with a given name exists.
3152 * \param [in] pflName - the profile name of interest.
3153 * \return bool - \c true if the profile named \a pflName exists.
3155 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3157 return contentNotNull()->existsPfl(pflName);
3161 * Checks if the localization with a given name exists.
3162 * \param [in] locName - the localization name of interest.
3163 * \return bool - \c true if the localization named \a locName exists.
3165 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3167 return contentNotNull()->existsLoc(locName);
3170 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3172 return contentNotNull()->createNewNameOfPfl();
3175 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3177 return contentNotNull()->createNewNameOfLoc();
3181 * Sets the name of a MED file.
3182 * \param [inout] fileName - the file name.
3184 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3186 contentNotNull()->setFileName(fileName);
3190 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3191 * in the same order.
3192 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3193 * Each item of this sequence is a vector containing ids of equal profiles.
3195 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3197 return contentNotNull()->whichAreEqualProfiles();
3201 * Finds equal localizations.
3202 * \param [in] eps - a precision used to compare real values of the localizations.
3203 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3204 * Each item of this sequence is a vector containing ids of equal localizations.
3206 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3208 return contentNotNull()->whichAreEqualLocs(eps);
3212 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3213 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3214 * this sequence is a pair whose
3215 * - the first item is a vector of profile names to replace by the second item,
3216 * - the second item is a profile name to replace every profile name of the first item.
3218 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3220 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3224 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3225 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3226 * this sequence is a pair whose
3227 * - the first item is a vector of localization names to replace by the second item,
3228 * - the second item is a localization name to replace every localization name of the first item.
3230 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3232 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3236 * Replaces references to some profiles (a reference is a profile name) by references
3237 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3238 * them-selves accordingly. <br>
3239 * This method is a generalization of changePflName().
3240 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3241 * this sequence is a pair whose
3242 * - the first item is a vector of profile names to replace by the second item,
3243 * - the second item is a profile name to replace every profile of the first item.
3244 * \sa changePflsRefsNamesGen()
3245 * \sa changePflName()
3247 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3249 changePflsRefsNamesGen(mapOfModif);
3250 changePflsNamesInStruct(mapOfModif);
3254 * Replaces references to some localizations (a reference is a localization name) by references
3255 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3256 * them-selves accordingly. <br>
3257 * This method is a generalization of changeLocName().
3258 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3259 * this sequence is a pair whose
3260 * - the first item is a vector of localization names to replace by the second item,
3261 * - the second item is a localization name to replace every localization of the first item.
3262 * \sa changeLocsRefsNamesGen()
3263 * \sa changeLocName()
3265 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3267 changeLocsRefsNamesGen(mapOfModif);
3268 changeLocsNamesInStruct(mapOfModif);
3272 * Renames the profile having a given name and updates references to this profile.
3273 * \param [in] oldName - the name of the profile to rename.
3274 * \param [in] newName - a new name of the profile.
3275 * \sa changePflsNames().
3277 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3279 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3280 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3282 changePflsNames(mapOfModif);
3286 * Renames the localization having a given name and updates references to this localization.
3287 * \param [in] oldName - the name of the localization to rename.
3288 * \param [in] newName - a new name of the localization.
3289 * \sa changeLocsNames().
3291 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3293 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3294 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3296 changeLocsNames(mapOfModif);
3300 * Removes duplicated profiles. Returns a map used to update references to removed
3301 * profiles via changePflsRefsNamesGen().
3302 * Equal profiles are found using whichAreEqualProfiles().
3303 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3304 * a sequence describing the performed replacements of profiles. Each element of
3305 * this sequence is a pair whose
3306 * - the first item is a vector of profile names replaced by the second item,
3307 * - the second item is a profile name replacing every profile of the first item.
3309 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3311 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3312 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3314 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3316 std::vector< std::string > tmp((*it).size());
3318 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3319 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3320 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3322 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3323 killProfileIds(tmp2);
3325 changePflsRefsNamesGen(ret);
3330 * Removes duplicated localizations. Returns a map used to update references to removed
3331 * localizations via changeLocsRefsNamesGen().
3332 * Equal localizations are found using whichAreEqualLocs().
3333 * \param [in] eps - a precision used to compare real values of the localizations.
3334 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3335 * a sequence describing the performed replacements of localizations. Each element of
3336 * this sequence is a pair whose
3337 * - the first item is a vector of localization names replaced by the second item,
3338 * - the second item is a localization name replacing every localization of the first item.
3340 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3342 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3343 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3345 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3347 std::vector< std::string > tmp((*it).size());
3349 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3350 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3351 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3353 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3354 killLocalizationIds(tmp2);
3356 changeLocsRefsNamesGen(ret);
3361 * Returns number of Gauss points per cell in a given localization.
3362 * \param [in] locId - an id of the localization of interest.
3363 * \return int - the number of the Gauss points per cell.
3365 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3367 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3371 * Returns an id of a localization by its name.
3372 * \param [in] loc - the localization name of interest.
3373 * \return int - the id of the localization.
3374 * \throw If there is no a localization named \a loc.
3376 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3378 return contentNotNull()->getLocalizationId(loc);
3382 * Returns the name of the MED file.
3383 * \return const std::string& - the MED file name.
3385 std::string MEDFileFieldGlobsReal::getFileName() const
3387 return contentNotNull()->getFileName();
3391 * Returns a localization object by its name.
3392 * \param [in] locName - the name of the localization of interest.
3393 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3394 * \throw If there is no a localization named \a locName.
3396 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3398 return contentNotNull()->getLocalization(locName);
3402 * Returns a localization object by its id.
3403 * \param [in] locId - the id of the localization of interest.
3404 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3405 * \throw If there is no a localization with id \a locId.
3407 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3409 return contentNotNull()->getLocalizationFromId(locId);
3413 * Returns a profile array by its name.
3414 * \param [in] pflName - the name of the profile of interest.
3415 * \return const DataArrayInt * - the profile array having the name \a pflName.
3416 * \throw If there is no a profile named \a pflName.
3418 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3420 return contentNotNull()->getProfile(pflName);
3424 * Returns a profile array by its id.
3425 * \param [in] pflId - the id of the profile of interest.
3426 * \return const DataArrayInt * - the profile array having the id \a pflId.
3427 * \throw If there is no a profile with id \a pflId.
3429 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3431 return contentNotNull()->getProfileFromId(pflId);
3435 * Returns a localization object, apt for modification, by its id.
3436 * \param [in] locId - the id of the localization of interest.
3437 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3438 * having the id \a locId.
3439 * \throw If there is no a localization with id \a locId.
3441 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3443 return contentNotNull()->getLocalizationFromId(locId);
3447 * Returns a localization object, apt for modification, by its name.
3448 * \param [in] locName - the name of the localization of interest.
3449 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3450 * having the name \a locName.
3451 * \throw If there is no a localization named \a locName.
3453 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3455 return contentNotNull()->getLocalization(locName);
3459 * Returns a profile array, apt for modification, by its name.
3460 * \param [in] pflName - the name of the profile of interest.
3461 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3462 * \throw If there is no a profile named \a pflName.
3464 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3466 return contentNotNull()->getProfile(pflName);
3470 * Returns a profile array, apt for modification, by its id.
3471 * \param [in] pflId - the id of the profile of interest.
3472 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3473 * \throw If there is no a profile with id \a pflId.
3475 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3477 return contentNotNull()->getProfileFromId(pflId);
3481 * Removes profiles given by their ids. No data is updated to track this removal.
3482 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3484 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3486 contentNotNull()->killProfileIds(pflIds);
3490 * Removes localizations given by their ids. No data is updated to track this removal.
3491 * \param [in] locIds - a sequence of ids of the localizations to remove.
3493 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3495 contentNotNull()->killLocalizationIds(locIds);
3499 * Stores a profile array.
3500 * \param [in] pfl - the profile array to store.
3501 * \throw If the name of \a pfl is empty.
3502 * \throw If a profile with the same name as that of \a pfl already exists but contains
3505 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3507 contentNotNull()->appendProfile(pfl);
3511 * Adds a new localization of Gauss points.
3512 * \param [in] locName - the name of the new localization.
3513 * \param [in] geoType - a geometrical type of the reference cell.
3514 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3515 * must be \c nbOfNodesPerCell * \c dimOfType.
3516 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3517 * must be _wg_.size() * \c dimOfType.
3518 * \param [in] w - the weights of Gauss points.
3519 * \throw If \a locName is empty.
3520 * \throw If a localization with the name \a locName already exists but is
3521 * different form the new one.
3523 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)
3525 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3528 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3530 MEDFileFieldGlobs *g(_globals);
3532 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3536 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3538 const MEDFileFieldGlobs *g(_globals);
3540 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3544 //= MEDFileFieldNameScope
3546 MEDFileFieldNameScope::MEDFileFieldNameScope()
3550 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3555 * Returns the name of \a this field.
3556 * \return std::string - a string containing the field name.
3558 std::string MEDFileFieldNameScope::getName() const
3564 * Sets name of \a this field
3565 * \param [in] name - the new field name.
3567 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3572 std::string MEDFileFieldNameScope::getDtUnit() const
3577 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3582 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3585 _dt_unit=other._dt_unit;
3588 //= MEDFileAnyTypeField1TSWithoutSDA
3590 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3592 _field_per_mesh.resize(other._field_per_mesh.size());
3594 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3596 if((const MEDFileFieldPerMesh *)*it)
3597 _field_per_mesh[i]=(*it)->deepCpy(this);
3602 * Prints a string describing \a this field into a stream. This string is outputted
3603 * by \c print Python command.
3604 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3605 * \param [in,out] oss - the out stream.
3606 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3607 * info id printed, else, not.
3609 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3611 std::string startOfLine(bkOffset,' ');
3612 oss << startOfLine << "Field ";
3614 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3615 oss << "on one time Step ";
3617 oss << "(" << f1tsId << ") ";
3618 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3619 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3620 const DataArray *arr=getUndergroundDataArray();
3623 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3626 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3627 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3628 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3630 if(arr->isAllocated())
3632 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3635 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3639 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3641 oss << startOfLine << "----------------------" << std::endl;
3642 if(!_field_per_mesh.empty())
3645 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3647 const MEDFileFieldPerMesh *cur=(*it2);
3649 cur->simpleRepr(bkOffset,oss,i);
3651 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3656 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3658 oss << startOfLine << "----------------------" << std::endl;
3661 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3663 const DataArray *arr(getUndergroundDataArray());
3665 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3666 int nbOfCompo=arr->getNumberOfComponents();
3667 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3668 for(int i=0;i<nbOfCompo;i++)
3671 std::vector<int> v(1,i);
3672 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3673 ret[i]->setArray(arr2);
3678 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)
3682 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3687 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3688 * empty. Returns -1 if this in on nodes.
3689 * \return int - the dimension of \a this.
3691 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3694 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3695 (*it)->getDimension(ret);
3700 * Returns the mesh name.
3701 * \return std::string - a string holding the mesh name.
3702 * \throw If \c _field_per_mesh.empty()
3704 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3706 if(_field_per_mesh.empty())
3707 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3708 return _field_per_mesh[0]->getMeshName();
3711 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3713 std::string oldName(getMeshName());
3714 std::vector< std::pair<std::string,std::string> > v(1);
3715 v[0].first=oldName; v[0].second=newMeshName;
3719 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3722 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3724 MEDFileFieldPerMesh *cur(*it);
3726 ret=cur->changeMeshNames(modifTab) || ret;
3732 * Returns the number of iteration of the state of underlying mesh.
3733 * \return int - the iteration number.
3734 * \throw If \c _field_per_mesh.empty()
3736 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3738 if(_field_per_mesh.empty())
3739 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3740 return _field_per_mesh[0]->getMeshIteration();
3744 * Returns the order number of iteration of the state of underlying mesh.
3745 * \return int - the order number.
3746 * \throw If \c _field_per_mesh.empty()
3748 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3750 if(_field_per_mesh.empty())
3751 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3752 return _field_per_mesh[0]->getMeshOrder();
3756 * Checks if \a this field is tagged by a given iteration number and a given
3757 * iteration order number.
3758 * \param [in] iteration - the iteration number of interest.
3759 * \param [in] order - the iteration order number of interest.
3760 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3761 * \a this->getOrder() == \a order.
3763 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3765 return iteration==_iteration && order==_order;
3769 * Returns number of iteration and order number of iteration when
3770 * \a this field has been calculated.
3771 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3774 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3776 std::pair<int,int> p;
3782 * Returns number of iteration and order number of iteration when
3783 * \a this field has been calculated.
3784 * \param [in,out] p - a pair returning the iteration number and the iteration
3787 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3794 * Returns all types of spatial discretization of \a this field.
3795 * \param [in,out] types - a sequence of types of \a this field.
3797 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
3799 std::set<TypeOfField> types2;
3800 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3802 (*it)->fillTypesOfFieldAvailable(types2);
3804 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3805 std::copy(types2.begin(),types2.end(),bi);
3809 * Returns all types of spatial discretization of \a this field.
3810 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3813 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
3815 std::vector<TypeOfField> ret;
3816 fillTypesOfFieldAvailable(ret);
3820 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3822 std::vector<std::string> ret;
3823 std::set<std::string> ret2;
3824 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3826 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3827 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3828 if(ret2.find(*it2)==ret2.end())
3830 ret.push_back(*it2);
3837 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() 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)->getLocsReallyUsed();
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::getPflsReallyUsedMulti2() const
3856 std::vector<std::string> ret;
3857 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3859 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3860 ret.insert(ret.end(),tmp.begin(),tmp.end());
3865 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3867 std::vector<std::string> ret;
3868 std::set<std::string> ret2;
3869 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3871 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3872 ret.insert(ret.end(),tmp.begin(),tmp.end());
3877 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3879 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3880 (*it)->changePflsRefsNamesGen(mapOfModif);
3883 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3885 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3886 (*it)->changeLocsRefsNamesGen(mapOfModif);
3890 * Returns all attributes of parts of \a this field lying on a given mesh.
3891 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3892 * item of every of returned sequences refers to the _i_-th part of \a this field.
3893 * Thus all sequences returned by this method are of the same length equal to number
3894 * of different types of supporting entities.<br>
3895 * A field part can include sub-parts with several different spatial discretizations,
3896 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3897 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3898 * of a nested sequence corresponds to a type of spatial discretization.<br>
3899 * This method allows for iteration over MEDFile DataStructure without any overhead.
3900 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3901 * for the case with only one underlying mesh. (Actually, the number of meshes is
3902 * not checked if \a mname == \c NULL).
3903 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3904 * a field part is returned.
3905 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3906 * This sequence is of the same length as \a types.
3907 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3908 * discretization. A profile name can be empty.
3909 * Length of this and of nested sequences is the same as that of \a typesF.
3910 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3911 * discretization. A localization name can be empty.
3912 * Length of this and of nested sequences is the same as that of \a typesF.
3913 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3914 * of ids of tuples within the data array, per each type of spatial
3915 * discretization within one mesh entity type.
3916 * Length of this and of nested sequences is the same as that of \a typesF.
3917 * \throw If no field is lying on \a mname.
3919 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
3923 meshId=getMeshIdFromMeshName(mname);
3925 if(_field_per_mesh.empty())
3926 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3927 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3931 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3932 * maximal absolute dimension and values returned via the out parameter \a levs are
3933 * dimensions relative to the maximal absolute dimension. <br>
3934 * This method is designed for MEDFileField1TS instances that have a discretization
3935 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3936 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3937 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3938 * Only these 3 discretizations will be taken into account here. If \a this is
3939 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3940 * This method is useful to make the link between the dimension of the underlying mesh
3941 * and the levels of \a this, because it is possible that the highest dimension of \a this
3942 * field is not equal to the dimension of the underlying mesh.
3944 * Let's consider the following case:
3945 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3946 * TETRA4, HEXA8, TRI3 and SEG2.
3947 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3948 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3950 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3951 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3952 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3953 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3954 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3955 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3957 * to retrieve the highest level of
3958 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3959 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3960 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3961 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3962 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3963 * for the case with only one underlying mesh. (Actually, the number of meshes is
3964 * not checked if \a mname == \c NULL).
3965 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3966 * absolute one. They are in decreasing order. This sequence is cleared before
3968 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3969 * \throw If no field is lying on \a mname.
3971 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
3974 int meshId=getMeshIdFromMeshName(mname);
3975 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3976 std::vector< std::vector<TypeOfField> > typesF;
3977 std::vector< std::vector<std::string> > pfls, locs;
3978 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3980 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3981 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3982 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
3984 st.erase(INTERP_KERNEL::NORM_ERROR);
3986 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
3988 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
3989 ret1.insert((int)cm.getDimension());
3991 int ret=*std::max_element(ret1.begin(),ret1.end());
3992 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
3993 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
3998 * \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.
3999 * \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.
4000 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4001 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4003 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4005 int mid=getMeshIdFromMeshName(mName);
4006 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4010 * \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.
4011 * \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.
4012 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4013 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4015 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4017 int mid=getMeshIdFromMeshName(mName);
4018 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4022 * \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.
4024 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4026 if(_field_per_mesh.empty())
4027 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4030 std::string mName2(mName);
4032 std::vector<std::string> msg;
4033 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4034 if(mName2==(*it)->getMeshName())
4037 msg.push_back((*it)->getMeshName());
4038 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4039 oss << "Possible meshes are : ";
4040 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4041 oss << "\"" << (*it2) << "\" ";
4042 throw INTERP_KERNEL::Exception(oss.str().c_str());
4045 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4048 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4049 std::string tmp(mesh->getName());
4051 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4052 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4054 for(;it!=_field_per_mesh.end();it++,i++)
4056 if((*it)->getMeshName()==tmp)
4059 int sz=_field_per_mesh.size();
4060 _field_per_mesh.resize(sz+1);
4061 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4065 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4066 MEDFileFieldGlobsReal& glob)
4069 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4071 MEDFileFieldPerMesh *fpm(*it);
4073 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4078 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4080 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4081 std::vector< std::vector<TypeOfField> > typesF;
4082 std::vector< std::vector<std::string> > pfls,locs;
4083 std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4084 std::set<TypeOfField> allEnt;
4085 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4086 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4087 allEnt.insert(*it2);
4088 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4089 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4090 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4092 std::vector< std::pair<int,int> > its;
4093 ret[i]=shallowCpy();
4094 int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4095 ret[i]->updateData(newLgth,its);
4100 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4102 int globalCounter=0;
4103 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4104 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4105 return globalCounter;
4108 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4110 if(_nb_of_tuples_to_be_allocated>=0)
4112 _nb_of_tuples_to_be_allocated=newLgth;
4113 const DataArray *oldArr(getUndergroundDataArray());
4116 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4117 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4119 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4123 if(_nb_of_tuples_to_be_allocated==-1)
4125 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4127 const DataArray *oldArr(getUndergroundDataArray());
4128 if(!oldArr || !oldArr->isAllocated())
4129 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4130 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4131 newArr->alloc(newLgth,getNumberOfComponents());
4133 newArr->copyStringInfoFrom(*oldArr);
4135 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4137 if((*it).second<(*it).first)
4138 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4139 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4140 pos+=(*it).second-(*it).first;
4145 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4148 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4150 if(_field_per_mesh.empty())
4151 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4152 if(_field_per_mesh.size()>1)
4153 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4154 _field_per_mesh[0]->copyOptionsFrom(opts);
4155 _field_per_mesh[0]->writeLL(fid,nasc);
4159 * 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.
4160 * If false is returned the memory allocation is not required.
4162 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4164 if(_nb_of_tuples_to_be_allocated>=0)
4166 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4167 _nb_of_tuples_to_be_allocated=-2;
4170 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4172 if(_nb_of_tuples_to_be_allocated==-1)
4173 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4174 if(_nb_of_tuples_to_be_allocated<-3)
4175 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4176 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4179 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4181 med_int numdt,numit;
4185 med_int meshnumdt,meshnumit;
4186 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4187 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4188 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4189 if(_iteration!=numdt || _order!=numit)
4190 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4191 _field_per_mesh.resize(nmesh);
4192 for(int i=0;i<nmesh;i++)
4193 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4194 _nb_of_tuples_to_be_allocated=0;
4195 for(int i=0;i<nmesh;i++)
4196 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4199 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4201 allocIfNecessaryTheArrayToReceiveDataFromFile();
4202 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4203 (*it)->loadBigArraysRecursively(fid,nasc);
4206 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4208 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4209 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4210 (*it)->loadBigArraysRecursively(fid,nasc);
4213 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4215 loadOnlyStructureOfDataRecursively(fid,nasc);
4216 loadBigArraysRecursively(fid,nasc);
4219 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4221 DataArray *thisArr(getUndergroundDataArray());
4222 if(thisArr && thisArr->isAllocated())
4224 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4225 thisArr->desallocate();
4229 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4231 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4234 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4236 std::vector<const BigMemoryObject *> ret;
4237 if(getUndergroundDataArray())
4238 ret.push_back(getUndergroundDataArray());
4239 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4240 ret.push_back((const MEDFileFieldPerMesh *)*it);
4245 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4246 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4247 * "Sort By Type"), if not, an exception is thrown.
4248 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4249 * \param [in] arr - the array of values.
4250 * \param [in,out] glob - the global data where profiles and localization present in
4251 * \a field, if any, are added.
4252 * \throw If the name of \a field is empty.
4253 * \throw If the data array of \a field is not set.
4254 * \throw If \a this->_arr is already allocated but has different number of components
4256 * \throw If the underlying mesh of \a field has no name.
4257 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4259 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4261 const MEDCouplingMesh *mesh=field->getMesh();
4263 TypeOfField type=field->getTypeOfField();
4264 std::vector<DataArrayInt *> dummy;
4265 int start=copyTinyInfoFrom(field,arr);
4266 int pos=addNewEntryIfNecessary(mesh);
4269 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4270 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4273 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4277 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4278 * of a given mesh are used as the support of the given field (a real support is not used).
4279 * Elements of the given mesh must be sorted suitable for writing to MED file.
4280 * Order of underlying mesh entities of the given field specified by \a profile parameter
4281 * is not prescribed; this method permutes field values to have them sorted by element
4282 * type as required for writing to MED file. A new profile is added only if no equal
4283 * profile is missing.
4284 * \param [in] field - the field to add to \a this. The field double values are ignored.
4285 * \param [in] arrOfVals - the values of the field \a field used.
4286 * \param [in] mesh - the supporting mesh of \a field.
4287 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4288 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4289 * \param [in,out] glob - the global data where profiles and localization present in
4290 * \a field, if any, are added.
4291 * \throw If either \a field or \a mesh or \a profile has an empty name.
4292 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4293 * \throw If the data array of \a field is not set.
4294 * \throw If \a this->_arr is already allocated but has different number of components
4296 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4297 * \sa setFieldNoProfileSBT()
4299 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4302 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4303 if(!arrOfVals || !arrOfVals->isAllocated())
4304 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4305 TypeOfField type=field->getTypeOfField();
4306 std::vector<DataArrayInt *> idsInPflPerType;
4307 std::vector<DataArrayInt *> idsPerType;
4308 std::vector<int> code,code2;
4309 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4312 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4313 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4314 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4315 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4317 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4318 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4319 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4321 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4322 throw INTERP_KERNEL::Exception(oss.str().c_str());
4325 int start=copyTinyInfoFrom(field,arrOfVals);
4326 code2=m->getDistributionOfTypes();
4328 int pos=addNewEntryIfNecessary(m);
4329 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4333 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4334 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4335 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4336 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4337 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4338 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4340 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4341 throw INTERP_KERNEL::Exception(oss.str().c_str());
4343 int start=copyTinyInfoFrom(field,arrOfVals);
4344 int pos=addNewEntryIfNecessary(m);
4345 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4350 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4352 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4354 if(_nb_of_tuples_to_be_allocated>=0)
4355 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 !");
4356 DataArray *arr(getOrCreateAndGetArray());
4357 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4358 _nb_of_tuples_to_be_allocated=-3;
4362 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4363 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4364 * larger by the size of \a field. Returns an id of the first not filled
4365 * tuple of \a this->_arr.
4366 * \param [in] field - the field to copy the info on components and the name from.
4367 * \return int - the id of first not initialized tuple of \a this->_arr.
4368 * \throw If the name of \a field is empty.
4369 * \throw If the data array of \a field is not set.
4370 * \throw If \a this->_arr is already allocated but has different number of components
4373 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4376 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4377 std::string name(field->getName());
4378 setName(name.c_str());
4379 setDtUnit(field->getTimeUnit());
4381 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4383 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4384 if(!arr->isAllocated())
4385 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4386 _dt=field->getTime(_iteration,_order);
4387 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4388 if(!getOrCreateAndGetArray()->isAllocated())
4390 allocNotFromFile(arr->getNumberOfTuples());
4395 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4396 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4397 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4398 _nb_of_tuples_to_be_allocated=-3;
4399 return oldNbOfTuples;
4404 * Returns number of components in \a this field
4405 * \return int - the number of components.
4407 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4409 return getOrCreateAndGetArray()->getNumberOfComponents();
4413 * Change info on components in \a this.
4414 * \throw If size of \a infos is not equal to the number of components already in \a this.
4416 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4418 DataArray *arr=getOrCreateAndGetArray();
4419 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4423 * Returns info on components of \a this field.
4424 * \return const std::vector<std::string>& - a sequence of strings each being an
4425 * information on _i_-th component.
4427 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4429 const DataArray *arr=getOrCreateAndGetArray();
4430 return arr->getInfoOnComponents();
4434 * Returns a mutable info on components of \a this field.
4435 * \return std::vector<std::string>& - a sequence of strings each being an
4436 * information on _i_-th component.
4438 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4440 DataArray *arr=getOrCreateAndGetArray();
4441 return arr->getInfoOnComponents();
4445 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4446 * \param [in] type - a spatial discretization of the new field.
4447 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4448 * \param [in] mName - a name of the supporting mesh.
4449 * \param [in] renumPol - specifies how to permute values of the result field according to
4450 * the optional numbers of cells and nodes, if any. The valid values are
4451 * - 0 - do not permute.
4452 * - 1 - permute cells.
4453 * - 2 - permute nodes.
4454 * - 3 - permute cells and nodes.
4456 * \param [in] glob - the global data storing profiles and localization.
4457 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4458 * caller is to delete this field using decrRef() as it is no more needed.
4459 * \throw If the MED file is not readable.
4460 * \throw If there is no mesh named \a mName in the MED file.
4461 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4462 * \throw If no field of \a this is lying on the mesh \a mName.
4463 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4465 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4467 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4469 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4471 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4472 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4476 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4477 * \param [in] type - a spatial discretization of the new field.
4478 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4479 * \param [in] renumPol - specifies how to permute values of the result field according to
4480 * the optional numbers of cells and nodes, if any. The valid values are
4481 * - 0 - do not permute.
4482 * - 1 - permute cells.
4483 * - 2 - permute nodes.
4484 * - 3 - permute cells and nodes.
4486 * \param [in] glob - the global data storing profiles and localization.
4487 * \param [in] mesh - the supporting mesh.
4488 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4489 * caller is to delete this field using decrRef() as it is no more needed.
4490 * \throw If the MED file is not readable.
4491 * \throw If no field of \a this is lying on \a mesh.
4492 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4493 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4495 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4497 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4498 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4499 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4500 if(meshDimRelToMax==1)
4501 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4502 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4506 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4508 * \param [in] type - a spatial discretization of the new field.
4509 * \param [in] mName - a name of the supporting mesh.
4510 * \param [in] renumPol - specifies how to permute values of the result field according to
4511 * the optional numbers of cells and nodes, if any. The valid values are
4512 * - 0 - do not permute.
4513 * - 1 - permute cells.
4514 * - 2 - permute nodes.
4515 * - 3 - permute cells and nodes.
4517 * \param [in] glob - the global data storing profiles and localization.
4518 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4519 * caller is to delete this field using decrRef() as it is no more needed.
4520 * \throw If the MED file is not readable.
4521 * \throw If there is no mesh named \a mName in the MED file.
4522 * \throw If there are no mesh entities in the mesh.
4523 * \throw If no field values of the given \a type are available.
4525 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4527 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4529 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4531 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4532 int absDim=getDimension();
4533 int meshDimRelToMax=absDim-mm->getMeshDimension();
4534 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4538 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4539 * \param [in] type - a spatial discretization of the new field.
4540 * \param [in] renumPol - specifies how to permute values of the result field according to
4541 * the optional numbers of cells and nodes, if any. The valid values are
4542 * - 0 - do not permute.
4543 * - 1 - permute cells.
4544 * - 2 - permute nodes.
4545 * - 3 - permute cells and nodes.
4547 * \param [in] glob - the global data storing profiles and localization.
4548 * \param [in] mesh - the supporting mesh.
4549 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4550 * field according to \a renumPol.
4551 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4552 * field according to \a renumPol.
4553 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4554 * caller is to delete this field using decrRef() as it is no more needed.
4555 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4556 * \throw If no field of \a this is lying on \a mesh.
4557 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4559 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
4561 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4562 int meshId=getMeshIdFromMeshName(mesh->getName());
4564 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4569 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4576 throw INTERP_KERNEL::Exception(msg1);
4577 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4580 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4582 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4583 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4584 throw INTERP_KERNEL::Exception(oss.str().c_str());
4586 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4587 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4588 std::vector<DataArray *> arrOut2(1,arrOut);
4589 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4590 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4591 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4598 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4600 throw INTERP_KERNEL::Exception(msg1);
4603 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4605 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4606 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4607 throw INTERP_KERNEL::Exception(oss.str().c_str());
4609 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4610 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4611 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4612 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4617 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4622 * Returns values and a profile of the field of a given type lying on a given support.
4623 * \param [in] type - a spatial discretization of the field.
4624 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4625 * \param [in] mesh - the supporting mesh.
4626 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4627 * field of interest lies on. If the field lies on all entities of the given
4628 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4629 * using decrRef() as it is no more needed.
4630 * \param [in] glob - the global data storing profiles and localization.
4631 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4632 * field. The caller is to delete this array using decrRef() as it is no more needed.
4633 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4634 * \throw If no field of \a this is lying on \a mesh.
4635 * \throw If no field values of the given \a type are available.
4637 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4639 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4640 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4641 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4642 ret->setName(nasc.getName().c_str());
4646 //= MEDFileField1TSWithoutSDA
4649 * Throws if a given value is not a valid (non-extended) relative dimension.
4650 * \param [in] meshDimRelToMax - the relative dimension value.
4651 * \throw If \a meshDimRelToMax > 0.
4653 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4655 if(meshDimRelToMax>0)
4656 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4660 * Checks if elements of a given mesh are in the order suitable for writing
4661 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4662 * vector describing types of elements and their number.
4663 * \param [in] mesh - the mesh to check.
4664 * \return std::vector<int> - a vector holding for each element type (1) item of
4665 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4666 * These values are in full-interlace mode.
4667 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4669 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4672 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4673 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4674 int nbOfTypes=geoTypes.size();
4675 std::vector<int> code(3*nbOfTypes);
4676 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4677 arr1->alloc(nbOfTypes,1);
4678 int *arrPtr=arr1->getPointer();
4679 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4680 for(int i=0;i<nbOfTypes;i++,it++)
4681 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4682 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4683 const int *arrPtr2=arr2->getConstPointer();
4685 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4688 int nbCells=mesh->getNumberOfCellsWithType(*it);
4689 code[3*pos]=(int)(*it);
4690 code[3*pos+1]=nbCells;
4691 code[3*pos+2]=-1;//no profiles
4693 std::vector<const DataArrayInt *> idsPerType;//no profiles
4694 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4698 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4703 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4705 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4709 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4710 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4711 * item of every of returned sequences refers to the _i_-th part of \a this field.
4712 * Thus all sequences returned by this method are of the same length equal to number
4713 * of different types of supporting entities.<br>
4714 * A field part can include sub-parts with several different spatial discretizations,
4715 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4716 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4717 * of a nested sequence corresponds to a type of spatial discretization.<br>
4718 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4719 * The overhead is due to selecting values into new instances of DataArrayDouble.
4720 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4721 * for the case with only one underlying mesh. (Actually, the number of meshes is
4722 * not checked if \a mname == \c NULL).
4723 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4724 * a field part is returned.
4725 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4726 * A field part can include sub-parts with several different spatial discretizations,
4727 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4728 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4729 * This sequence is of the same length as \a types.
4730 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4731 * discretization. A profile name can be empty.
4732 * Length of this and of nested sequences is the same as that of \a typesF.
4733 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4734 * discretization. A localization name can be empty.
4735 * Length of this and of nested sequences is the same as that of \a typesF.
4736 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4737 * per each type of spatial discretization within one mesh entity type.
4738 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4739 * Length of this and of nested sequences is the same as that of \a typesF.
4740 * \throw If no field is lying on \a mname.
4742 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
4746 meshId=getMeshIdFromMeshName(mname);
4748 if(_field_per_mesh.empty())
4749 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4750 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4751 int nbOfRet=ret0.size();
4752 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4753 for(int i=0;i<nbOfRet;i++)
4755 const std::vector< std::pair<int,int> >& p=ret0[i];
4756 int nbOfRet1=p.size();
4757 ret[i].resize(nbOfRet1);
4758 for(int j=0;j<nbOfRet1;j++)
4760 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4768 * Returns a pointer to the underground DataArrayDouble instance. So the
4769 * caller should not decrRef() it. This method allows for a direct access to the field
4770 * values. This method is quite unusable if there is more than a nodal field or a cell
4771 * field on single geometric cell type.
4772 * \return DataArrayDouble * - the pointer to the field values array.
4774 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
4776 const DataArrayDouble *ret=_arr;
4778 return const_cast<DataArrayDouble *>(ret);
4783 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
4788 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
4790 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4791 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4792 ret->deepCpyLeavesFrom(*this);
4793 const DataArrayDouble *arr(_arr);
4796 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4797 ret->setArray(arr2);
4803 * Returns a pointer to the underground DataArrayDouble instance. So the
4804 * caller should not decrRef() it. This method allows for a direct access to the field
4805 * values. This method is quite unusable if there is more than a nodal field or a cell
4806 * field on single geometric cell type.
4807 * \return DataArrayDouble * - the pointer to the field values array.
4809 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
4811 return getUndergroundDataArrayDouble();
4815 * Returns a pointer to the underground DataArrayDouble instance and a
4816 * sequence describing parameters of a support of each part of \a this field. The
4817 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4818 * direct access to the field values. This method is intended for the field lying on one
4820 * \param [in,out] entries - the sequence describing parameters of a support of each
4821 * part of \a this field. Each item of this sequence consists of two parts. The
4822 * first part describes a type of mesh entity and an id of discretization of a
4823 * current field part. The second part describes a range of values [begin,end)
4824 * within the returned array relating to the current field part.
4825 * \return DataArrayDouble * - the pointer to the field values array.
4826 * \throw If the number of underlying meshes is not equal to 1.
4827 * \throw If no field values are available.
4828 * \sa getUndergroundDataArray()
4830 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4832 if(_field_per_mesh.size()!=1)
4833 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4834 if(_field_per_mesh[0]==0)
4835 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4836 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4837 return getUndergroundDataArrayDouble();
4841 * Returns a pointer to the underground DataArrayDouble instance and a
4842 * sequence describing parameters of a support of each part of \a this field. The
4843 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4844 * direct access to the field values. This method is intended for the field lying on one
4846 * \param [in,out] entries - the sequence describing parameters of a support of each
4847 * part of \a this field. Each item of this sequence consists of two parts. The
4848 * first part describes a type of mesh entity and an id of discretization of a
4849 * current field part. The second part describes a range of values [begin,end)
4850 * within the returned array relating to the current field part.
4851 * \return DataArrayDouble * - the pointer to the field values array.
4852 * \throw If the number of underlying meshes is not equal to 1.
4853 * \throw If no field values are available.
4854 * \sa getUndergroundDataArray()
4856 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4858 return getUndergroundDataArrayDoubleExt(entries);
4861 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
4862 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4864 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4865 arr->setInfoAndChangeNbOfCompo(infos);
4868 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4872 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
4874 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4875 ret->deepCpyLeavesFrom(*this);
4879 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
4881 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4882 if((const DataArrayDouble *)_arr)
4883 ret->_arr=_arr->deepCpy();
4887 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
4891 _nb_of_tuples_to_be_allocated=-1;
4895 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4897 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4899 _nb_of_tuples_to_be_allocated=-3;
4904 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4906 return DataArrayDouble::New();
4909 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4911 DataArrayDouble *ret=_arr;
4914 _arr=DataArrayDouble::New();
4918 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4920 return getOrCreateAndGetArrayDouble();
4923 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4925 const DataArrayDouble *ret=_arr;
4928 DataArrayDouble *ret2=DataArrayDouble::New();
4929 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4933 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4935 return getOrCreateAndGetArrayDouble();
4938 //= MEDFileIntField1TSWithoutSDA
4940 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order,
4941 const std::vector<std::string>& infos)
4943 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4946 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4950 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
4951 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4953 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4954 arr->setInfoAndChangeNbOfCompo(infos);
4957 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
4962 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
4964 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4965 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4966 ret->deepCpyLeavesFrom(*this);
4967 const DataArrayInt *arr(_arr);
4970 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4971 ret->setArray(arr2);
4977 * Returns a pointer to the underground DataArrayInt instance. So the
4978 * caller should not decrRef() it. This method allows for a direct access to the field
4979 * values. This method is quite unusable if there is more than a nodal field or a cell
4980 * field on single geometric cell type.
4981 * \return DataArrayInt * - the pointer to the field values array.
4983 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
4985 return getUndergroundDataArrayInt();
4989 * Returns a pointer to the underground DataArrayInt instance. So the
4990 * caller should not decrRef() it. This method allows for a direct access to the field
4991 * values. This method is quite unusable if there is more than a nodal field or a cell
4992 * field on single geometric cell type.
4993 * \return DataArrayInt * - the pointer to the field values array.
4995 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
4997 const DataArrayInt *ret=_arr;
4999 return const_cast<DataArrayInt *>(ret);
5005 * Returns a pointer to the underground DataArrayInt instance and a
5006 * sequence describing parameters of a support of each part of \a this field. The
5007 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5008 * direct access to the field values. This method is intended for the field lying on one
5010 * \param [in,out] entries - the sequence describing parameters of a support of each
5011 * part of \a this field. Each item of this sequence consists of two parts. The
5012 * first part describes a type of mesh entity and an id of discretization of a
5013 * current field part. The second part describes a range of values [begin,end)
5014 * within the returned array relating to the current field part.
5015 * \return DataArrayInt * - the pointer to the field values array.
5016 * \throw If the number of underlying meshes is not equal to 1.
5017 * \throw If no field values are available.
5018 * \sa getUndergroundDataArray()
5020 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5022 return getUndergroundDataArrayIntExt(entries);
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 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5043 if(_field_per_mesh.size()!=1)
5044 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5045 if(_field_per_mesh[0]==0)
5046 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5047 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5048 return getUndergroundDataArrayInt();
5051 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5053 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5054 ret->deepCpyLeavesFrom(*this);
5058 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5060 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5061 if((const DataArrayInt *)_arr)
5062 ret->_arr=_arr->deepCpy();
5066 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5070 _nb_of_tuples_to_be_allocated=-1;
5074 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5076 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5078 _nb_of_tuples_to_be_allocated=-3;
5083 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5085 return DataArrayInt::New();
5088 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5090 DataArrayInt *ret=_arr;
5093 _arr=DataArrayInt::New();
5097 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5099 return getOrCreateAndGetArrayInt();
5102 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5104 const DataArrayInt *ret=_arr;
5107 DataArrayInt *ret2=DataArrayInt::New();
5108 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5112 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5114 return getOrCreateAndGetArrayInt();
5117 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5121 //= MEDFileAnyTypeField1TS
5123 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll)
5125 med_field_type typcha;
5127 std::vector<std::string> infos;
5128 std::string dtunit,fieldName;
5129 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5130 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5135 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5140 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5145 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] !";
5146 throw INTERP_KERNEL::Exception(oss.str().c_str());
5149 ret->setDtUnit(dtunit.c_str());
5150 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5152 med_int numdt,numit;
5154 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5155 ret->setTime(numdt,numit,dt);
5158 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5160 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5164 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll)
5165 try:MEDFileFieldGlobsReal(fileName)
5167 MEDFileUtilities::CheckFileForRead(fileName);
5168 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5169 _content=BuildContentFrom(fid,fileName,loadAll);
5172 catch(INTERP_KERNEL::Exception& e)
5177 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll)
5179 med_field_type typcha;
5180 std::vector<std::string> infos;
5183 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5184 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5189 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5194 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5199 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] !";
5200 throw INTERP_KERNEL::Exception(oss.str().c_str());
5203 ret->setDtUnit(dtunit.c_str());
5204 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5208 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5209 throw INTERP_KERNEL::Exception(oss.str().c_str());
5212 med_int numdt,numit;
5214 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5215 ret->setTime(numdt,numit,dt);
5218 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5220 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5224 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll)
5225 try:MEDFileFieldGlobsReal(fileName)
5227 MEDFileUtilities::CheckFileForRead(fileName);
5228 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5229 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5232 catch(INTERP_KERNEL::Exception& e)
5237 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5240 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5241 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5243 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5244 ret->setFileName(fileName);
5245 ret->_content=c; c->incrRef();
5248 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5250 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5251 ret->setFileName(fileName);
5252 ret->_content=c; c->incrRef();
5255 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5258 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5260 MEDFileUtilities::CheckFileForRead(fileName);
5261 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5262 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5263 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5264 ret->loadGlobals(fid);
5268 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5270 MEDFileUtilities::CheckFileForRead(fileName);
5271 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5272 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5273 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5274 ret->loadGlobals(fid);
5278 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5280 MEDFileUtilities::CheckFileForRead(fileName);
5281 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5282 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5283 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5284 ret->loadGlobals(fid);
5288 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5290 med_field_type typcha;
5291 std::vector<std::string> infos;
5294 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5295 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5300 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5305 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5310 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] !";
5311 throw INTERP_KERNEL::Exception(oss.str().c_str());
5314 ret->setDtUnit(dtunit.c_str());
5315 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5318 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5319 for(int i=0;i<nbOfStep2 && !found;i++)
5321 med_int numdt,numit;
5323 MEDfieldComputingStepInfo(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt);
5324 if(numdt==iteration && numit==order)
5330 dtits[i]=std::pair<int,int>(numdt,numit);
5334 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5335 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5336 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5337 throw INTERP_KERNEL::Exception(oss.str().c_str());
5340 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5342 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5346 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5347 try:MEDFileFieldGlobsReal(fileName)
5349 MEDFileUtilities::CheckFileForRead(fileName);
5350 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5351 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll);
5354 catch(INTERP_KERNEL::Exception& e)
5360 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5361 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5363 * \warning this is a shallow copy constructor
5365 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5367 if(!shallowCopyOfContent)
5369 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5370 otherPtr->incrRef();
5371 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5375 _content=other.shallowCpy();
5379 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)
5383 int nbFields=MEDnField(fid);
5384 if(fieldIdCFormat>=nbFields)
5386 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5387 throw INTERP_KERNEL::Exception(oss.str().c_str());
5390 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5391 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5392 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5393 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5394 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5395 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5398 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5399 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5400 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5401 infos.clear(); infos.resize(ncomp);
5402 for(int j=0;j<ncomp;j++)
5403 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5408 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5411 * \return in case of success the number of time steps available for the field with name \a fieldName.
5413 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)
5415 int nbFields=MEDnField(fid);
5417 std::vector<std::string> fns(nbFields);
5419 for(int i=0;i<nbFields && !found;i++)
5422 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5424 found=(tmp==fieldName);
5430 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5431 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5432 oss << "\"" << *it << "\" ";
5433 throw INTERP_KERNEL::Exception(oss.str().c_str());
5439 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5440 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5441 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5442 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5443 * to keep a valid instance.
5444 * 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.
5445 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5446 * 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.
5448 * \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.
5449 * \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.
5450 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5451 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5452 * \param [in] newLocName is the new localization name.
5453 * \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.
5454 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5456 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5458 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5459 std::string oldPflName=disc->getProfile();
5460 std::vector<std::string> vv=getPflsReallyUsedMulti();
5461 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5462 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5464 disc->setProfile(newPflName);
5465 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5466 pfl->setName(newPflName);
5470 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5471 throw INTERP_KERNEL::Exception(oss.str().c_str());
5476 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5477 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5478 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5479 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5480 * to keep a valid instance.
5481 * 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.
5482 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5483 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5484 * 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.
5486 * \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.
5487 * \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.
5488 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5489 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5490 * \param [in] newLocName is the new localization name.
5491 * \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.
5492 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5494 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5496 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5497 std::string oldLocName=disc->getLocalization();
5498 std::vector<std::string> vv=getLocsReallyUsedMulti();
5499 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5500 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5502 disc->setLocalization(newLocName);
5503 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5504 loc.setName(newLocName);
5508 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5509 throw INTERP_KERNEL::Exception(oss.str().c_str());
5513 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5515 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5517 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5521 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5523 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5525 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5530 * Writes \a this field into a MED file specified by its name.
5531 * \param [in] fileName - the MED file name.
5532 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5533 * - 2 - erase; an existing file is removed.
5534 * - 1 - append; same data should not be present in an existing file.
5535 * - 0 - overwrite; same data present in an existing file is overwritten.
5536 * \throw If the field name is not set.
5537 * \throw If no field data is set.
5538 * \throw If \a mode == 1 and the same data is present in an existing file.
5540 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5542 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5543 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5548 * This method alloc the arrays and load potentially huge arrays contained in this field.
5549 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5550 * This method can be also called to refresh or reinit values from a file.
5552 * \throw If the fileName is not set or points to a non readable MED file.
5553 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5555 void MEDFileAnyTypeField1TS::loadArrays()
5557 if(getFileName().empty())
5558 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5559 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5560 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5564 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5565 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5566 * this method does not throw if \a this does not come from file read.
5568 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5570 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5572 if(!getFileName().empty())
5574 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5575 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5580 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5581 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5582 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5584 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5586 void MEDFileAnyTypeField1TS::unloadArrays()
5588 contentNotNullBase()->unloadArrays();
5592 * 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.
5593 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5594 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5596 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5598 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5600 if(!getFileName().empty())
5601 contentNotNullBase()->unloadArrays();
5604 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5606 int nbComp=getNumberOfComponents();
5607 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5608 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5609 for(int i=0;i<nbComp;i++)
5611 std::string info=getInfo()[i];
5613 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5614 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5615 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5617 if(getName().empty())
5618 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5619 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5620 writeGlobals(fid,*this);
5621 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5624 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5626 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5629 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5631 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5632 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5637 * Returns a string describing \a this field. This string is outputted
5638 * by \c print Python command.
5640 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5642 std::ostringstream oss;
5643 contentNotNullBase()->simpleRepr(0,oss,-1);
5644 simpleReprGlobs(oss);
5649 * This method returns all profiles whose name is non empty used.
5650 * \b WARNING If profile is used several times it will be reported \b only \b once.
5651 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5653 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5655 return contentNotNullBase()->getPflsReallyUsed2();
5659 * This method returns all localizations whose name is non empty used.
5660 * \b WARNING If localization is used several times it will be reported \b only \b once.
5662 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5664 return contentNotNullBase()->getLocsReallyUsed2();
5668 * This method returns all profiles whose name is non empty used.
5669 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5671 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5673 return contentNotNullBase()->getPflsReallyUsedMulti2();
5677 * This method returns all localizations whose name is non empty used.
5678 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5680 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5682 return contentNotNullBase()->getLocsReallyUsedMulti2();
5685 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5687 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5690 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5692 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5695 int MEDFileAnyTypeField1TS::getDimension() const
5697 return contentNotNullBase()->getDimension();
5700 int MEDFileAnyTypeField1TS::getIteration() const
5702 return contentNotNullBase()->getIteration();
5705 int MEDFileAnyTypeField1TS::getOrder() const
5707 return contentNotNullBase()->getOrder();
5710 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5712 return contentNotNullBase()->getTime(iteration,order);
5715 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5717 contentNotNullBase()->setTime(iteration,order,val);
5720 std::string MEDFileAnyTypeField1TS::getName() const
5722 return contentNotNullBase()->getName();
5725 void MEDFileAnyTypeField1TS::setName(const std::string& name)
5727 contentNotNullBase()->setName(name);
5730 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5732 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5735 std::string MEDFileAnyTypeField1TS::getDtUnit() const
5737 return contentNotNullBase()->getDtUnit();
5740 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
5742 contentNotNullBase()->setDtUnit(dtUnit);
5745 std::string MEDFileAnyTypeField1TS::getMeshName() const
5747 return contentNotNullBase()->getMeshName();
5750 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
5752 contentNotNullBase()->setMeshName(newMeshName);
5755 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
5757 return contentNotNullBase()->changeMeshNames(modifTab);
5760 int MEDFileAnyTypeField1TS::getMeshIteration() const
5762 return contentNotNullBase()->getMeshIteration();
5765 int MEDFileAnyTypeField1TS::getMeshOrder() const
5767 return contentNotNullBase()->getMeshOrder();
5770 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5772 return contentNotNullBase()->getNumberOfComponents();
5775 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5777 return contentNotNullBase()->isDealingTS(iteration,order);
5780 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5782 return contentNotNullBase()->getDtIt();
5785 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5787 contentNotNullBase()->fillIteration(p);
5790 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
5792 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5795 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
5797 contentNotNullBase()->setInfo(infos);
5800 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5802 return contentNotNullBase()->getInfo();
5804 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5806 return contentNotNullBase()->getInfo();
5809 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
5811 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5814 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
5816 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5819 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
5821 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5824 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
5826 return contentNotNullBase()->getTypesOfFieldAvailable();
5829 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,
5830 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
5832 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5836 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5837 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5838 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5840 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
5842 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5844 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5845 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5846 std::size_t sz(contentsSplit.size());
5847 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5848 for(std::size_t i=0;i<sz;i++)
5850 ret[i]=shallowCpy();
5851 ret[i]->_content=contentsSplit[i];
5857 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5858 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5860 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
5862 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5864 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5865 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5866 std::size_t sz(contentsSplit.size());
5867 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5868 for(std::size_t i=0;i<sz;i++)
5870 ret[i]=shallowCpy();
5871 ret[i]->_content=contentsSplit[i];
5876 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
5878 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5879 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5880 ret->_content=_content->deepCpy();
5881 ret->deepCpyGlobs(*this);
5885 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5887 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5893 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5894 * the first field that has been read from a specified MED file.
5895 * \param [in] fileName - the name of the MED file to read.
5896 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5897 * is to delete this field using decrRef() as it is no more needed.
5898 * \throw If reading the file fails.
5900 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
5902 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5903 ret->contentNotNull();
5908 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5909 * a given field that has been read from a specified MED file.
5910 * \param [in] fileName - the name of the MED file to read.
5911 * \param [in] fieldName - the name of the field to read.
5912 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5913 * is to delete this field using decrRef() as it is no more needed.
5914 * \throw If reading the file fails.
5915 * \throw If there is no field named \a fieldName in the file.
5917 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5919 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5920 ret->contentNotNull();
5925 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5926 * a given field that has been read from a specified MED file.
5927 * \param [in] fileName - the name of the MED file to read.
5928 * \param [in] fieldName - the name of the field to read.
5929 * \param [in] iteration - the iteration number of a required time step.
5930 * \param [in] order - the iteration order number of required time step.
5931 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5932 * is to delete this field using decrRef() as it is no more needed.
5933 * \throw If reading the file fails.
5934 * \throw If there is no field named \a fieldName in the file.
5935 * \throw If the required time step is missing from the file.
5937 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5939 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5940 ret->contentNotNull();
5945 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5946 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5948 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5949 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5950 * \warning this is a shallow copy constructor
5951 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5952 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5953 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5954 * is to delete this field using decrRef() as it is no more needed.
5956 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5958 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5959 ret->contentNotNull();
5964 * Returns a new empty instance of MEDFileField1TS.
5965 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5966 * is to delete this field using decrRef() as it is no more needed.
5968 MEDFileField1TS *MEDFileField1TS::New()
5970 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5971 ret->contentNotNull();
5976 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5977 * following the given input policy.
5979 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5980 * By default (true) the globals are deeply copied.
5981 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5983 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
5985 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5986 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5989 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5991 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5992 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5993 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5996 ret=MEDFileIntField1TS::New();
5998 ret->deepCpyGlobs(*this);
6000 ret->shallowCpyGlobs(*this);
6004 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6006 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6008 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6009 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6011 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 !");
6015 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6017 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6019 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6020 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6022 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 !");
6026 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6029 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6030 if(!((DataArray*)arr))
6031 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6032 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6034 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6035 f->setArray(arrOutC);
6038 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6040 if(!((DataArray*)arr))
6041 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6042 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6044 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6049 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll)
6050 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6053 catch(INTERP_KERNEL::Exception& e)
6056 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll)
6057 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6060 catch(INTERP_KERNEL::Exception& e)
6063 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6064 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6067 catch(INTERP_KERNEL::Exception& e)
6071 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6072 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6074 * \warning this is a shallow copy constructor
6076 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6077 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6080 catch(INTERP_KERNEL::Exception& e)
6083 MEDFileField1TS::MEDFileField1TS()
6085 _content=new MEDFileField1TSWithoutSDA;
6089 * Returns a new MEDCouplingFieldDouble of a given type lying on
6090 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6091 * has not been constructed via file reading, an exception is thrown.
6092 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6093 * \param [in] type - a spatial discretization of interest.
6094 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6095 * \param [in] renumPol - specifies how to permute values of the result field according to
6096 * the optional numbers of cells and nodes, if any. The valid values are
6097 * - 0 - do not permute.
6098 * - 1 - permute cells.
6099 * - 2 - permute nodes.
6100 * - 3 - permute cells and nodes.
6102 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6103 * caller is to delete this field using decrRef() as it is no more needed.
6104 * \throw If \a this field has not been constructed via file reading.
6105 * \throw If the MED file is not readable.
6106 * \throw If there is no mesh in the MED file.
6107 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6108 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6109 * \sa getFieldOnMeshAtLevel()
6111 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6113 if(getFileName().empty())
6114 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6115 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6116 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6117 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6122 * Returns a new MEDCouplingFieldDouble of a given type lying on
6123 * the top level cells of the first mesh in MED file. If \a this field
6124 * has not been constructed via file reading, an exception is thrown.
6125 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6126 * \param [in] type - a spatial discretization of interest.
6127 * \param [in] renumPol - specifies how to permute values of the result field according to
6128 * the optional numbers of cells and nodes, if any. The valid values are
6129 * - 0 - do not permute.
6130 * - 1 - permute cells.
6131 * - 2 - permute nodes.
6132 * - 3 - permute cells and nodes.
6134 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6135 * caller is to delete this field using decrRef() as it is no more needed.
6136 * \throw If \a this field has not been constructed via file reading.
6137 * \throw If the MED file is not readable.
6138 * \throw If there is no mesh in the MED file.
6139 * \throw If no field values of the given \a type.
6140 * \throw If no field values lying on the top level support.
6141 * \sa getFieldAtLevel()
6143 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6145 if(getFileName().empty())
6146 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6147 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6148 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6149 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6154 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6155 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6156 * \param [in] type - a spatial discretization of the new field.
6157 * \param [in] mesh - the supporting mesh.
6158 * \param [in] renumPol - specifies how to permute values of the result field according to
6159 * the optional numbers of cells and nodes, if any. The valid values are
6160 * - 0 - do not permute.
6161 * - 1 - permute cells.
6162 * - 2 - permute nodes.
6163 * - 3 - permute cells and nodes.
6165 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6166 * caller is to delete this field using decrRef() as it is no more needed.
6167 * \throw If no field of \a this is lying on \a mesh.
6168 * \throw If the mesh is empty.
6169 * \throw If no field values of the given \a type are available.
6170 * \sa getFieldAtLevel()
6171 * \sa getFieldOnMeshAtLevel()
6173 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6175 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6176 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6177 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6182 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6183 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6184 * \param [in] type - a spatial discretization of interest.
6185 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6186 * \param [in] mesh - the supporting mesh.
6187 * \param [in] renumPol - specifies how to permute values of the result field according to
6188 * the optional numbers of cells and nodes, if any. The valid values are
6189 * - 0 - do not permute.
6190 * - 1 - permute cells.
6191 * - 2 - permute nodes.
6192 * - 3 - permute cells and nodes.
6194 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6195 * caller is to delete this field using decrRef() as it is no more needed.
6196 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6197 * \throw If no field of \a this is lying on \a mesh.
6198 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6199 * \sa getFieldAtLevel()
6200 * \sa getFieldOnMeshAtLevel()
6202 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6204 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6205 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6206 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6211 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6212 * This method is called "Old" because in MED3 norm a field has only one meshName
6213 * attached, so this method is for readers of MED2 files. If \a this field
6214 * has not been constructed via file reading, an exception is thrown.
6215 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6216 * \param [in] type - a spatial discretization of interest.
6217 * \param [in] mName - a name of the supporting mesh.
6218 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6219 * \param [in] renumPol - specifies how to permute values of the result field according to
6220 * the optional numbers of cells and nodes, if any. The valid values are
6221 * - 0 - do not permute.
6222 * - 1 - permute cells.
6223 * - 2 - permute nodes.
6224 * - 3 - permute cells and nodes.
6226 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6227 * caller is to delete this field using decrRef() as it is no more needed.
6228 * \throw If the MED file is not readable.
6229 * \throw If there is no mesh named \a mName in the MED file.
6230 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6231 * \throw If \a this field has not been constructed via file reading.
6232 * \throw If no field of \a this is lying on the mesh named \a mName.
6233 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6234 * \sa getFieldAtLevel()
6236 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6238 if(getFileName().empty())
6239 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6240 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6241 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6242 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6247 * Returns values and a profile of the field of a given type lying on a given support.
6248 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6249 * \param [in] type - a spatial discretization of the field.
6250 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6251 * \param [in] mesh - the supporting mesh.
6252 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6253 * field of interest lies on. If the field lies on all entities of the given
6254 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6255 * using decrRef() as it is no more needed.
6256 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6257 * field. The caller is to delete this array using decrRef() as it is no more needed.
6258 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6259 * \throw If no field of \a this is lying on \a mesh.
6260 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6262 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6264 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6265 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6269 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6270 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6271 * "Sort By Type"), if not, an exception is thrown.
6272 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6273 * \param [in] field - the field to add to \a this.
6274 * \throw If the name of \a field is empty.
6275 * \throw If the data array of \a field is not set.
6276 * \throw If the data array is already allocated but has different number of components
6278 * \throw If the underlying mesh of \a field has no name.
6279 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6281 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6284 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6288 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6289 * can be an aggregation of several MEDCouplingFieldDouble instances.
6290 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6291 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6294 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6295 * A new profile is added only if no equal profile is missing.
6296 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6297 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6298 * \param [in] mesh - the supporting mesh of \a field.
6299 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6300 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6301 * \throw If either \a field or \a mesh or \a profile has an empty name.
6302 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6303 * \throw If the data array of \a field is not set.
6304 * \throw If the data array of \a this is already allocated but has different number of
6305 * components than \a field.
6306 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6307 * \sa setFieldNoProfileSBT()
6309 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6312 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6315 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6317 return new MEDFileField1TS(*this);
6320 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6322 return contentNotNull()->getUndergroundDataArrayDouble();
6325 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6327 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6330 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6331 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6333 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6336 //= MEDFileIntField1TS
6338 MEDFileIntField1TS *MEDFileIntField1TS::New()
6340 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6341 ret->contentNotNull();
6345 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6347 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6348 ret->contentNotNull();
6352 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6354 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6355 ret->contentNotNull();
6359 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6361 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6362 ret->contentNotNull();
6366 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6368 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6369 ret->contentNotNull();
6373 MEDFileIntField1TS::MEDFileIntField1TS()
6375 _content=new MEDFileIntField1TSWithoutSDA;
6378 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll)
6379 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6382 catch(INTERP_KERNEL::Exception& e)
6385 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll)
6386 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6389 catch(INTERP_KERNEL::Exception& e)
6392 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6393 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6396 catch(INTERP_KERNEL::Exception& e)
6400 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6401 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6403 * \warning this is a shallow copy constructor
6405 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6409 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6411 return new MEDFileIntField1TS(*this);
6415 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6416 * following the given input policy.
6418 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6419 * By default (true) the globals are deeply copied.
6420 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6422 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6424 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6425 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6428 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6430 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6431 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6432 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6435 ret=MEDFileField1TS::New();
6437 ret->deepCpyGlobs(*this);
6439 ret->shallowCpyGlobs(*this);
6444 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6445 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6446 * "Sort By Type"), if not, an exception is thrown.
6447 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6448 * \param [in] field - the field to add to \a this. The field double values are ignored.
6449 * \param [in] arrOfVals - the values of the field \a field used.
6450 * \throw If the name of \a field is empty.
6451 * \throw If the data array of \a field is not set.
6452 * \throw If the data array is already allocated but has different number of components
6454 * \throw If the underlying mesh of \a field has no name.
6455 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6457 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6460 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6464 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6465 * can be an aggregation of several MEDCouplingFieldDouble instances.
6466 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6467 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6470 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6471 * A new profile is added only if no equal profile is missing.
6472 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6473 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6474 * \param [in] arrOfVals - the values of the field \a field used.
6475 * \param [in] mesh - the supporting mesh of \a field.
6476 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6477 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6478 * \throw If either \a field or \a mesh or \a profile has an empty name.
6479 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6480 * \throw If the data array of \a field is not set.
6481 * \throw If the data array of \a this is already allocated but has different number of
6482 * components than \a field.
6483 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6484 * \sa setFieldNoProfileSBT()
6486 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6489 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6492 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6494 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6496 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6497 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6499 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 !");
6503 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6505 if(getFileName().empty())
6506 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6507 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6508 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6509 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6511 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6516 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6518 if(!((DataArray *)arr))
6519 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6520 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6522 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6528 * Returns a new MEDCouplingFieldDouble of a given type lying on
6529 * the top level cells of the first mesh in MED file. If \a this field
6530 * has not been constructed via file reading, an exception is thrown.
6531 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6532 * \param [in] type - a spatial discretization of interest.
6533 * \param [out] arrOut - the DataArrayInt containing values of field.
6534 * \param [in] renumPol - specifies how to permute values of the result field according to
6535 * the optional numbers of cells and nodes, if any. The valid values are
6536 * - 0 - do not permute.
6537 * - 1 - permute cells.
6538 * - 2 - permute nodes.
6539 * - 3 - permute cells and nodes.
6541 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6542 * caller is to delete this field using decrRef() as it is no more needed.
6543 * \throw If \a this field has not been constructed via file reading.
6544 * \throw If the MED file is not readable.
6545 * \throw If there is no mesh in the MED file.
6546 * \throw If no field values of the given \a type.
6547 * \throw If no field values lying on the top level support.
6548 * \sa getFieldAtLevel()
6550 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6552 if(getFileName().empty())
6553 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6554 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6555 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6556 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6561 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6562 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6563 * \param [in] type - a spatial discretization of the new field.
6564 * \param [in] mesh - the supporting mesh.
6565 * \param [out] arrOut - the DataArrayInt containing values of field.
6566 * \param [in] renumPol - specifies how to permute values of the result field according to
6567 * the optional numbers of cells and nodes, if any. The valid values are
6568 * - 0 - do not permute.
6569 * - 1 - permute cells.
6570 * - 2 - permute nodes.
6571 * - 3 - permute cells and nodes.
6573 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6574 * caller is to delete this field using decrRef() as it is no more needed.
6575 * \throw If no field of \a this is lying on \a mesh.
6576 * \throw If the mesh is empty.
6577 * \throw If no field values of the given \a type are available.
6578 * \sa getFieldAtLevel()
6579 * \sa getFieldOnMeshAtLevel()
6581 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6583 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6584 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6585 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6590 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6591 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6592 * \param [in] type - a spatial discretization of interest.
6593 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6594 * \param [out] arrOut - the DataArrayInt containing values of field.
6595 * \param [in] mesh - the supporting mesh.
6596 * \param [in] renumPol - specifies how to permute values of the result field according to
6597 * the optional numbers of cells and nodes, if any. The valid values are
6598 * - 0 - do not permute.
6599 * - 1 - permute cells.
6600 * - 2 - permute nodes.
6601 * - 3 - permute cells and nodes.
6603 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6604 * caller is to delete this field using decrRef() as it is no more needed.
6605 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6606 * \throw If no field of \a this is lying on \a mesh.
6607 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6608 * \sa getFieldAtLevel()
6609 * \sa getFieldOnMeshAtLevel()
6611 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6613 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6614 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6615 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6620 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6621 * This method is called "Old" because in MED3 norm a field has only one meshName
6622 * attached, so this method is for readers of MED2 files. If \a this field
6623 * has not been constructed via file reading, an exception is thrown.
6624 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6625 * \param [in] type - a spatial discretization of interest.
6626 * \param [in] mName - a name of the supporting mesh.
6627 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6628 * \param [out] arrOut - the DataArrayInt containing values of field.
6629 * \param [in] renumPol - specifies how to permute values of the result field according to
6630 * the optional numbers of cells and nodes, if any. The valid values are
6631 * - 0 - do not permute.
6632 * - 1 - permute cells.
6633 * - 2 - permute nodes.
6634 * - 3 - permute cells and nodes.
6636 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6637 * caller is to delete this field using decrRef() as it is no more needed.
6638 * \throw If the MED file is not readable.
6639 * \throw If there is no mesh named \a mName in the MED file.
6640 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6641 * \throw If \a this field has not been constructed via file reading.
6642 * \throw If no field of \a this is lying on the mesh named \a mName.
6643 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6644 * \sa getFieldAtLevel()
6646 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6648 if(getFileName().empty())
6649 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6650 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6651 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6652 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6657 * Returns values and a profile of the field of a given type lying on a given support.
6658 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6659 * \param [in] type - a spatial discretization of the field.
6660 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6661 * \param [in] mesh - the supporting mesh.
6662 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6663 * field of interest lies on. If the field lies on all entities of the given
6664 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6665 * using decrRef() as it is no more needed.
6666 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6667 * field. The caller is to delete this array using decrRef() as it is no more needed.
6668 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6669 * \throw If no field of \a this is lying on \a mesh.
6670 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6672 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6674 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6675 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6678 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
6680 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6682 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6683 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6685 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 !");
6689 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
6691 return contentNotNull()->getUndergroundDataArrayInt();
6694 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6696 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6700 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
6705 * \param [in] fieldId field id in C mode
6707 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll)
6709 med_field_type typcha;
6710 std::string dtunitOut;
6711 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6712 setDtUnit(dtunitOut.c_str());
6713 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6716 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)
6717 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6719 setDtUnit(dtunit.c_str());
6720 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6722 catch(INTERP_KERNEL::Exception& e)
6727 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
6729 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
6730 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6731 ret+=(*it).capacity();
6735 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
6737 std::vector<const BigMemoryObject *> ret;
6738 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6739 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
6744 * 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
6747 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
6749 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6750 ret->setInfo(_infos);
6751 int sz=(int)_time_steps.size();
6752 for(const int *id=startIds;id!=endIds;id++)
6754 if(*id>=0 && *id<sz)
6756 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6757 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6761 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6763 ret->pushBackTimeStep(tse2);
6767 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6768 oss << " ! Should be in [0," << sz << ") !";
6769 throw INTERP_KERNEL::Exception(oss.str().c_str());
6772 if(ret->getNumberOfTS()>0)
6773 ret->synchronizeNameScope();
6774 ret->copyNameScope(*this);
6779 * 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
6782 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
6784 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6785 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6786 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6787 ret->setInfo(_infos);
6788 int sz=(int)_time_steps.size();
6790 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6794 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6795 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6799 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6801 ret->pushBackTimeStep(tse2);
6805 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6806 oss << " ! Should be in [0," << sz << ") !";
6807 throw INTERP_KERNEL::Exception(oss.str().c_str());
6810 if(ret->getNumberOfTS()>0)
6811 ret->synchronizeNameScope();
6812 ret->copyNameScope(*this);
6816 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6819 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6820 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6822 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6825 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6826 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6827 ids->pushBackSilent(id);
6829 return buildFromTimeStepIds(ids->begin(),ids->end());
6832 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6835 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6836 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6838 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6841 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6842 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6843 ids->pushBackSilent(id);
6845 return buildFromTimeStepIds(ids->begin(),ids->end());
6848 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
6853 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
6858 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
6861 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6863 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6864 if(pt->isDealingTS(iteration,order))
6867 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6868 std::vector< std::pair<int,int> > vp=getIterations();
6869 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6870 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6871 throw INTERP_KERNEL::Exception(oss.str().c_str());
6874 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
6876 return *_time_steps[getTimeStepPos(iteration,order)];
6879 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
6881 return *_time_steps[getTimeStepPos(iteration,order)];
6884 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
6886 if(_time_steps.empty())
6887 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6888 return _time_steps[0]->getMeshName();
6891 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
6893 std::string oldName(getMeshName());
6894 std::vector< std::pair<std::string,std::string> > v(1);
6895 v[0].first=oldName; v[0].second=newMeshName;
6899 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6902 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6904 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6906 ret=cur->changeMeshNames(modifTab) || ret;
6912 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6914 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
6916 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6920 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6922 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6924 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6927 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6928 MEDFileFieldGlobsReal& glob)
6931 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6933 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6935 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6940 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6942 std::string startLine(bkOffset,' ');
6943 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6945 oss << " (" << fmtsId << ")";
6946 oss << " has the following name: \"" << _name << "\"." << std::endl;
6947 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6948 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6950 oss << startLine << " - \"" << *it << "\"" << std::endl;
6953 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6955 std::string chapter(17,'0'+i);
6956 oss << startLine << chapter << std::endl;
6957 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6959 cur->simpleRepr(bkOffset+2,oss,i);
6961 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6962 oss << startLine << chapter << std::endl;
6966 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
6968 std::size_t sz=_time_steps.size();
6969 std::vector< std::pair<int,int> > ret(sz);
6971 for(std::size_t i=0;i<sz;i++)
6973 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6976 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6980 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6981 throw INTERP_KERNEL::Exception(oss.str().c_str());
6987 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
6989 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6991 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6992 checkCoherencyOfType(tse2);
6993 if(_time_steps.empty())
6995 setName(tse2->getName().c_str());
6996 setInfo(tse2->getInfo());
6998 checkThatComponentsMatch(tse2->getInfo());
6999 _time_steps.push_back(tse);
7002 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7004 std::size_t nbOfCompo=_infos.size();
7005 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7007 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7010 if((cur->getInfo()).size()!=nbOfCompo)
7012 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7013 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7014 throw INTERP_KERNEL::Exception(oss.str().c_str());
7016 cur->copyNameScope(*this);
7021 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll)
7023 _time_steps.resize(nbPdt);
7024 for(int i=0;i<nbPdt;i++)
7026 std::vector< std::pair<int,int> > ts;
7027 med_int numdt=0,numo=0;
7028 med_int meshIt=0,meshOrder=0;
7030 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
7035 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7040 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7044 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7047 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
7049 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
7053 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7055 if(_time_steps.empty())
7056 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7057 checkThatNbOfCompoOfTSMatchThis();
7058 std::vector<std::string> infos(getInfo());
7059 int nbComp=infos.size();
7060 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7061 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7062 for(int i=0;i<nbComp;i++)
7064 std::string info=infos[i];
7066 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7067 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7068 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7071 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7072 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7073 int nbOfTS=_time_steps.size();
7074 for(int i=0;i<nbOfTS;i++)
7075 _time_steps[i]->writeLL(fid,opts,*this);
7078 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7080 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7082 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7084 elt->loadBigArraysRecursively(fid,nasc);
7088 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7090 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7092 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7094 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7098 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7100 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7102 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7104 elt->unloadArrays();
7108 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7110 return _time_steps.size();
7113 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7115 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7116 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7118 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7120 newTS.push_back(*it);
7125 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7127 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7128 int maxId=(int)_time_steps.size();
7130 std::set<int> idsToDel;
7131 for(const int *id=startIds;id!=endIds;id++,ii++)
7133 if(*id>=0 && *id<maxId)
7135 idsToDel.insert(*id);
7139 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7140 throw INTERP_KERNEL::Exception(oss.str().c_str());
7143 for(int iii=0;iii<maxId;iii++)
7144 if(idsToDel.find(iii)==idsToDel.end())
7145 newTS.push_back(_time_steps[iii]);
7149 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7151 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7152 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7153 if(nbOfEntriesToKill==0)
7155 std::size_t sz=_time_steps.size();
7156 std::vector<bool> b(sz,true);
7158 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7160 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7161 for(std::size_t i=0;i<sz;i++)
7163 newTS.push_back(_time_steps[i]);
7167 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7170 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7171 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7173 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7177 tmp->getTime(it2,ord);
7178 if(it2==iteration && order==ord)
7181 oss << "(" << it2 << "," << ord << "), ";
7184 throw INTERP_KERNEL::Exception(oss.str().c_str());
7187 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7190 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7192 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7194 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7198 double ti=tmp->getTime(it2,ord);
7199 if(fabs(time-ti)<eps)
7205 throw INTERP_KERNEL::Exception(oss.str().c_str());
7208 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7210 int lgth=_time_steps.size();
7211 std::vector< std::pair<int,int> > ret(lgth);
7212 for(int i=0;i<lgth;i++)
7213 _time_steps[i]->fillIteration(ret[i]);
7218 * 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'
7219 * This method returns two things.
7220 * - The absolute dimension of 'this' in first parameter.
7221 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7222 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7224 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7225 * Only these 3 discretizations will be taken into account here.
7227 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7228 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7229 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7231 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7232 * 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'.
7234 * Let's consider the typical following case :
7235 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7236 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7237 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7239 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7241 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7243 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7244 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7245 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7246 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7248 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7250 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7253 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7255 if(pos<0 || pos>=(int)_time_steps.size())
7257 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7258 throw INTERP_KERNEL::Exception(oss.str().c_str());
7260 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7263 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7264 oss << "\nTry to use following method eraseEmptyTS !";
7265 throw INTERP_KERNEL::Exception(oss.str().c_str());
7270 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7272 if(pos<0 || pos>=(int)_time_steps.size())
7274 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7275 throw INTERP_KERNEL::Exception(oss.str().c_str());
7277 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7280 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7281 oss << "\nTry to use following method eraseEmptyTS !";
7282 throw INTERP_KERNEL::Exception(oss.str().c_str());
7287 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7289 std::vector<std::string> ret;
7290 std::set<std::string> ret2;
7291 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7293 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7294 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7295 if(ret2.find(*it2)==ret2.end())
7297 ret.push_back(*it2);
7304 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7306 std::vector<std::string> ret;
7307 std::set<std::string> ret2;
7308 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7310 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7311 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7312 if(ret2.find(*it2)==ret2.end())
7314 ret.push_back(*it2);
7321 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7323 std::vector<std::string> ret;
7324 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7326 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7327 ret.insert(ret.end(),tmp.begin(),tmp.end());
7332 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7334 std::vector<std::string> ret;
7335 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7337 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7338 ret.insert(ret.end(),tmp.begin(),tmp.end());
7343 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7345 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7346 (*it)->changePflsRefsNamesGen2(mapOfModif);
7349 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7351 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7352 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7355 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7357 int lgth=_time_steps.size();
7358 std::vector< std::vector<TypeOfField> > ret(lgth);
7359 for(int i=0;i<lgth;i++)
7360 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7365 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7367 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
7369 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7372 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7374 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7376 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7378 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7379 ret->_time_steps[i]=(*it)->deepCpy();
7384 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7386 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7387 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7388 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7389 for(std::size_t i=0;i<sz;i++)
7391 ret[i]=shallowCpy();
7392 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7394 for(std::size_t i=0;i<sz2;i++)
7396 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7399 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7400 throw INTERP_KERNEL::Exception(oss.str().c_str());
7404 for(std::size_t i=0;i<sz;i++)
7405 for(std::size_t j=0;j<sz2;j++)
7406 ret[i]->_time_steps[j]=ts[j][i];
7411 * This method splits into discretization each time steps in \a this.
7412 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7414 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7416 std::size_t sz(_time_steps.size());
7417 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7418 for(std::size_t i=0;i<sz;i++)
7420 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7423 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7424 throw INTERP_KERNEL::Exception(oss.str().c_str());
7426 items[i]=timeStep->splitDiscretizations();
7429 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7430 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7431 std::vector< TypeOfField > types;
7432 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7433 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7435 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7437 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7438 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7439 if(it2==types.end())
7440 types.push_back(ts[0]);
7442 ret.resize(types.size()); ret2.resize(types.size());
7443 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7444 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7446 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7447 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7448 ret2[pos].push_back(*it1);
7450 for(std::size_t i=0;i<types.size();i++)
7452 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7453 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7454 elt->pushBackTimeStep(*it1);//also updates infos in elt
7456 elt->MEDFileFieldNameScope::operator=(*this);
7461 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7463 _name=field->getName();
7465 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7467 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7468 _infos=arr->getInfoOnComponents();
7471 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7473 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7474 if(_name!=field->getName())
7476 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7477 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7478 throw INTERP_KERNEL::Exception(oss.str().c_str());
7481 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7482 checkThatComponentsMatch(arr->getInfoOnComponents());
7485 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7487 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7488 if(getInfo().size()!=compos.size())
7490 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7491 oss << " number of components of element to append (" << compos.size() << ") !";
7492 throw INTERP_KERNEL::Exception(oss.str().c_str());
7496 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7497 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7498 oss << " But compo in input fields are : ";
7499 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7501 throw INTERP_KERNEL::Exception(oss.str().c_str());
7505 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7507 std::size_t sz=_infos.size();
7509 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7511 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7513 if(elt->getInfo().size()!=sz)
7515 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7516 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7517 throw INTERP_KERNEL::Exception(oss.str().c_str());
7522 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7525 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7526 if(!_time_steps.empty())
7527 checkCoherencyOfTinyInfo(field,arr);
7528 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7529 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7530 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7531 copyTinyInfoFrom(field,arr);
7532 _time_steps.push_back(obj);
7535 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7538 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7539 if(!_time_steps.empty())
7540 checkCoherencyOfTinyInfo(field,arr);
7541 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7542 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7543 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7544 copyTinyInfoFrom(field,arr);
7545 _time_steps.push_back(obj);
7548 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7550 int sz=(int)_time_steps.size();
7553 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7554 throw INTERP_KERNEL::Exception(oss.str().c_str());
7556 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7559 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7561 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7562 throw INTERP_KERNEL::Exception(oss.str().c_str());
7568 //= MEDFileFieldMultiTSWithoutSDA
7570 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)
7572 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7575 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7579 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7584 * \param [in] fieldId field id in C mode
7586 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll)
7587 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7590 catch(INTERP_KERNEL::Exception& e)
7593 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)
7594 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7597 catch(INTERP_KERNEL::Exception& e)
7600 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7602 return new MEDFileField1TSWithoutSDA;
7605 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7608 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7609 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7611 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7614 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7616 return MEDFileField1TSWithoutSDA::TYPE_STR;
7619 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7621 return new MEDFileFieldMultiTSWithoutSDA(*this);
7624 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7626 return new MEDFileFieldMultiTSWithoutSDA;
7630 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7631 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7633 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
7635 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7636 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7638 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7639 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7642 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
7644 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7645 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7647 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7649 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7652 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7654 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7655 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7656 ret->setIteration(i,elt);
7662 //= MEDFileAnyTypeFieldMultiTS
7664 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7668 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll)
7669 try:MEDFileFieldGlobsReal(fileName)
7671 MEDFileUtilities::CheckFileForRead(fileName);
7672 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7673 _content=BuildContentFrom(fid,fileName,loadAll);
7676 catch(INTERP_KERNEL::Exception& e)
7681 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll)
7683 med_field_type typcha;
7684 std::vector<std::string> infos;
7687 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7688 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7693 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7698 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7703 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] !";
7704 throw INTERP_KERNEL::Exception(oss.str().c_str());
7707 ret->setDtUnit(dtunit.c_str());
7711 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll)
7713 med_field_type typcha;
7715 std::vector<std::string> infos;
7716 std::string dtunit,fieldName;
7717 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7718 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7723 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7728 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7733 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] !";
7734 throw INTERP_KERNEL::Exception(oss.str().c_str());
7737 ret->setDtUnit(dtunit.c_str());
7741 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
7744 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7745 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7747 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7748 ret->setFileName(fileName);
7749 ret->_content=c; c->incrRef();
7752 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7754 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7755 ret->setFileName(fileName);
7756 ret->_content=c; c->incrRef();
7759 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7762 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll)
7763 try:MEDFileFieldGlobsReal(fileName)
7765 MEDFileUtilities::CheckFileForRead(fileName);
7766 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7767 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7770 catch(INTERP_KERNEL::Exception& e)
7775 //= MEDFileIntFieldMultiTSWithoutSDA
7777 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)
7779 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7782 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7786 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7790 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)
7791 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7794 catch(INTERP_KERNEL::Exception& e)
7798 * \param [in] fieldId field id in C mode
7800 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll)
7801 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7804 catch(INTERP_KERNEL::Exception& e)
7807 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7809 return new MEDFileIntField1TSWithoutSDA;
7812 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7815 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7816 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7818 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7821 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
7823 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7826 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
7828 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7831 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
7833 return new MEDFileIntFieldMultiTSWithoutSDA;
7836 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
7838 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7839 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7841 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7843 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7846 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7848 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7849 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7850 ret->setIteration(i,elt);
7856 //= MEDFileAnyTypeFieldMultiTS
7859 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7860 * that has been read from a specified MED file.
7861 * \param [in] fileName - the name of the MED file to read.
7862 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7863 * is to delete this field using decrRef() as it is no more needed.
7864 * \throw If reading the file fails.
7866 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
7868 MEDFileUtilities::CheckFileForRead(fileName);
7869 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7870 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7871 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7872 ret->loadGlobals(fid);
7877 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7878 * that has been read from a specified MED file.
7879 * \param [in] fileName - the name of the MED file to read.
7880 * \param [in] fieldName - the name of the field to read.
7881 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7882 * is to delete this field using decrRef() as it is no more needed.
7883 * \throw If reading the file fails.
7884 * \throw If there is no field named \a fieldName in the file.
7886 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7888 MEDFileUtilities::CheckFileForRead(fileName);
7889 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
7890 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
7891 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7892 ret->loadGlobals(fid);
7897 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7898 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7900 * \warning this is a shallow copy constructor
7902 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7904 if(!shallowCopyOfContent)
7906 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7907 otherPtr->incrRef();
7908 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7912 _content=other.shallowCpy();
7916 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
7918 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7920 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7924 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
7926 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7928 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7932 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7934 return contentNotNullBase()->getPflsReallyUsed2();
7937 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7939 return contentNotNullBase()->getLocsReallyUsed2();
7942 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7944 return contentNotNullBase()->getPflsReallyUsedMulti2();
7947 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7949 return contentNotNullBase()->getLocsReallyUsedMulti2();
7952 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7954 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7957 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7959 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7962 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7964 return contentNotNullBase()->getNumberOfTS();
7967 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
7969 contentNotNullBase()->eraseEmptyTS();
7972 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
7974 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7977 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
7979 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7982 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
7984 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7985 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7990 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
7992 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7993 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7998 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8000 return contentNotNullBase()->getIterations();
8003 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8005 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8006 pushBackTimeStep(*it);
8009 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8012 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8013 checkCoherencyOfType(f1ts);
8015 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8016 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8018 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8019 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8020 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8021 _content->pushBackTimeStep(cSafe);
8022 appendGlobs(*f1ts,1e-12);
8025 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8027 contentNotNullBase()->synchronizeNameScope();
8030 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8032 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8035 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8037 return contentNotNullBase()->getPosGivenTime(time,eps);
8040 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8042 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8045 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8047 return contentNotNullBase()->getTypesOfFieldAvailable();
8050 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
8052 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8055 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8057 return contentNotNullBase()->getName();
8060 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8062 contentNotNullBase()->setName(name);
8065 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8067 return contentNotNullBase()->getDtUnit();
8070 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8072 contentNotNullBase()->setDtUnit(dtUnit);
8075 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8077 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8080 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8082 return contentNotNullBase()->getTimeSteps(ret1);
8085 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8087 return contentNotNullBase()->getMeshName();
8090 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8092 contentNotNullBase()->setMeshName(newMeshName);
8095 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8097 return contentNotNullBase()->changeMeshNames(modifTab);
8100 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8102 return contentNotNullBase()->getInfo();
8105 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8107 return contentNotNullBase()->setInfo(info);
8110 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8112 const std::vector<std::string> ret=getInfo();
8113 return (int)ret.size();
8116 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8118 writeGlobals(fid,*this);
8119 contentNotNullBase()->writeLL(fid,*this);
8123 * Writes \a this field into a MED file specified by its name.
8124 * \param [in] fileName - the MED file name.
8125 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8126 * - 2 - erase; an existing file is removed.
8127 * - 1 - append; same data should not be present in an existing file.
8128 * - 0 - overwrite; same data present in an existing file is overwritten.
8129 * \throw If the field name is not set.
8130 * \throw If no field data is set.
8131 * \throw If \a mode == 1 and the same data is present in an existing file.
8133 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8135 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8136 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8141 * This method alloc the arrays and load potentially huge arrays contained in this field.
8142 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8143 * This method can be also called to refresh or reinit values from a file.
8145 * \throw If the fileName is not set or points to a non readable MED file.
8147 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8149 if(getFileName().empty())
8150 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8151 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8152 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8156 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8157 * But once data loaded once, this method does nothing.
8159 * \throw If the fileName is not set or points to a non readable MED file.
8160 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8162 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8164 if(!getFileName().empty())
8166 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8167 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8172 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8173 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8174 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8176 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8178 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8180 contentNotNullBase()->unloadArrays();
8184 * 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.
8185 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8186 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8188 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8190 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8192 if(!getFileName().empty())
8193 contentNotNullBase()->unloadArrays();
8196 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8198 std::ostringstream oss;
8199 contentNotNullBase()->simpleRepr(0,oss,-1);
8200 simpleReprGlobs(oss);
8204 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8206 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8209 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8211 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8212 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8217 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8218 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8219 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8221 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8223 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8225 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8226 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8227 std::size_t sz(contentsSplit.size());
8228 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8229 for(std::size_t i=0;i<sz;i++)
8231 ret[i]=shallowCpy();
8232 ret[i]->_content=contentsSplit[i];
8238 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8239 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8241 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8243 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8245 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8246 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8247 std::size_t sz(contentsSplit.size());
8248 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8249 for(std::size_t i=0;i<sz;i++)
8251 ret[i]=shallowCpy();
8252 ret[i]->_content=contentsSplit[i];
8257 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8259 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8260 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8261 ret->_content=_content->deepCpy();
8262 ret->deepCpyGlobs(*this);
8266 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8272 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8273 * \param [in] iteration - the iteration number of a required time step.
8274 * \param [in] order - the iteration order number of required time step.
8275 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8276 * delete this field using decrRef() as it is no more needed.
8277 * \throw If there is no required time step in \a this field.
8279 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8281 int pos=getPosOfTimeStep(iteration,order);
8282 return getTimeStepAtPos(pos);
8286 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8287 * \param [in] time - the time of the time step of interest.
8288 * \param [in] eps - a precision used to compare time values.
8289 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8290 * delete this field using decrRef() as it is no more needed.
8291 * \throw If there is no required time step in \a this field.
8293 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8295 int pos=getPosGivenTime(time,eps);
8296 return getTimeStepAtPos(pos);
8300 * 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.
8301 * The float64 value of time attached to the pair of integers are not considered here.
8302 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8304 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8305 * \throw If there is a null pointer in \a vectFMTS.
8307 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8309 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8310 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8311 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8312 while(!lstFMTS.empty())
8314 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8315 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8317 throw INTERP_KERNEL::Exception(msg);
8318 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8319 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8320 elt.push_back(curIt); it=lstFMTS.erase(it);
8321 while(it!=lstFMTS.end())
8325 throw INTERP_KERNEL::Exception(msg);
8326 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8328 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8338 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8339 * All returned instances in a subvector can be safely loaded, rendered along time
8340 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8341 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8342 * 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).
8343 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8344 * 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.
8346 * \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().
8347 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8348 * \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.
8349 * \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.
8351 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8352 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8353 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8354 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8355 * \throw If mesh is null.
8356 * \throw If an element in \a vectFMTS is null.
8357 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8359 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8361 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8363 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8364 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8365 if(vectFMTS.empty())
8367 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8368 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8370 throw INTERP_KERNEL::Exception(msg);
8372 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8373 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8374 for(;it!=vectFMTS.end();it++,i++)
8377 throw INTERP_KERNEL::Exception(msg);
8378 TypeOfField tof0,tof1;
8379 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8382 vectFMTSNotNodes.push_back(*it);
8384 vectFMTSNodes.push_back(*it);
8387 vectFMTSNotNodes.push_back(*it);
8389 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8390 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8392 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8395 bool isFetched(false);
8396 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8399 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8400 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8401 { ret[i].push_back(*it2); isFetched=true; }
8405 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8406 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8407 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8415 * 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.
8416 * \param [out] cmps - same size than the returned vector.
8418 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8420 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8421 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8422 while(!lstFMTS.empty())
8424 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8425 MEDFileAnyTypeFieldMultiTS *ref(*it);
8426 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8427 elt.push_back(ref); it=lstFMTS.erase(it);
8428 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8429 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8430 while(it!=lstFMTS.end())
8432 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8433 if(cmp->isEqual(curIt))
8434 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8438 ret.push_back(elt); cmps.push_back(cmp);
8444 * 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.
8445 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8447 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8448 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8449 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8450 * \thorw If \a f0 and \a f1 do not have the same times steps.
8451 * \throw If mesh is null.
8452 * \throw If \a f0 or \a f1 is null.
8453 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8455 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8458 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8460 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8461 if(f0->getMeshName()!=mesh->getName())
8463 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8464 throw INTERP_KERNEL::Exception(oss.str().c_str());
8466 if(f1->getMeshName()!=mesh->getName())
8468 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8469 throw INTERP_KERNEL::Exception(oss.str().c_str());
8471 int nts=f0->getNumberOfTS();
8472 if(nts!=f1->getNumberOfTS())
8473 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8476 for(int i=0;i<nts;i++)
8478 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8479 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8480 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8481 if(tofs0.size()!=1 || tofs1.size()!=1)
8482 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8485 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8486 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8489 { tof0=tofs0[0]; tof1=tofs1[0]; }
8490 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8492 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() << ") !";
8493 throw INTERP_KERNEL::Exception(oss.str().c_str());
8495 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8497 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() << ") !";
8498 throw INTERP_KERNEL::Exception(oss.str().c_str());
8500 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8502 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() << ") !";
8503 throw INTERP_KERNEL::Exception(oss.str().c_str());
8509 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8511 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8514 //= MEDFileFieldMultiTS
8517 * Returns a new empty instance of MEDFileFieldMultiTS.
8518 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8519 * is to delete this field using decrRef() as it is no more needed.
8521 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8523 return new MEDFileFieldMultiTS;
8527 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8528 * that has been read from a specified MED file.
8529 * \param [in] fileName - the name of the MED file to read.
8530 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8531 * is to delete this field using decrRef() as it is no more needed.
8532 * \throw If reading the file fails.
8534 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8536 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
8537 ret->contentNotNull();//to check that content type matches with \a this type.
8542 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8543 * that has been read from a specified MED file.
8544 * \param [in] fileName - the name of the MED file to read.
8545 * \param [in] fieldName - the name of the field to read.
8546 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8547 * is to delete this field using decrRef() as it is no more needed.
8548 * \throw If reading the file fails.
8549 * \throw If there is no field named \a fieldName in the file.
8551 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8553 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
8554 ret->contentNotNull();//to check that content type matches with \a this type.
8559 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8560 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8562 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8563 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8564 * \warning this is a shallow copy constructor
8565 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8566 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8567 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8568 * is to delete this field using decrRef() as it is no more needed.
8570 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8572 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8575 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8577 return new MEDFileFieldMultiTS(*this);
8580 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
8583 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8584 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8586 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8590 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8591 * following the given input policy.
8593 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8594 * By default (true) the globals are deeply copied.
8595 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8597 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
8599 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8600 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8603 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8605 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8606 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8607 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8610 ret=MEDFileIntFieldMultiTS::New();
8612 ret->deepCpyGlobs(*this);
8614 ret->shallowCpyGlobs(*this);
8619 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8620 * \param [in] pos - a time step id.
8621 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8622 * delete this field using decrRef() as it is no more needed.
8623 * \throw If \a pos is not a valid time step id.
8625 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
8627 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8630 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8631 throw INTERP_KERNEL::Exception(oss.str().c_str());
8633 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8636 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8637 ret->shallowCpyGlobs(*this);
8640 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8641 throw INTERP_KERNEL::Exception(oss.str().c_str());
8645 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8646 * mesh entities of a given dimension of the first mesh in MED file.
8647 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8648 * \param [in] type - a spatial discretization of interest.
8649 * \param [in] iteration - the iteration number of a required time step.
8650 * \param [in] order - the iteration order number of required time step.
8651 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8652 * \param [in] renumPol - specifies how to permute values of the result field according to
8653 * the optional numbers of cells and nodes, if any. The valid values are
8654 * - 0 - do not permute.
8655 * - 1 - permute cells.
8656 * - 2 - permute nodes.
8657 * - 3 - permute cells and nodes.
8659 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8660 * caller is to delete this field using decrRef() as it is no more needed.
8661 * \throw If the MED file is not readable.
8662 * \throw If there is no mesh in the MED file.
8663 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8664 * \throw If no field values of the required parameters are available.
8666 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
8668 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8669 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8671 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8672 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8673 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8674 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8679 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8680 * the top level cells of the first mesh in MED file.
8681 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8682 * \param [in] type - a spatial discretization of interest.
8683 * \param [in] iteration - the iteration number of a required time step.
8684 * \param [in] order - the iteration order number of required time step.
8685 * \param [in] renumPol - specifies how to permute values of the result field according to
8686 * the optional numbers of cells and nodes, if any. The valid values are
8687 * - 0 - do not permute.
8688 * - 1 - permute cells.
8689 * - 2 - permute nodes.
8690 * - 3 - permute cells and nodes.
8692 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8693 * caller is to delete this field using decrRef() as it is no more needed.
8694 * \throw If the MED file is not readable.
8695 * \throw If there is no mesh in the MED file.
8696 * \throw If no field values of the required parameters are available.
8698 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
8700 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8701 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8703 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8704 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8705 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
8706 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8711 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8713 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8714 * \param [in] type - a spatial discretization of interest.
8715 * \param [in] iteration - the iteration number of a required time step.
8716 * \param [in] order - the iteration order number of required time step.
8717 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8718 * \param [in] mesh - the supporting mesh.
8719 * \param [in] renumPol - specifies how to permute values of the result field according to
8720 * the optional numbers of cells and nodes, if any. The valid values are
8721 * - 0 - do not permute.
8722 * - 1 - permute cells.
8723 * - 2 - permute nodes.
8724 * - 3 - permute cells and nodes.
8726 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8727 * caller is to delete this field using decrRef() as it is no more needed.
8728 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8729 * \throw If no field of \a this is lying on \a mesh.
8730 * \throw If no field values of the required parameters are available.
8732 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
8734 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8735 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8737 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8738 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8739 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8740 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8745 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8747 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8748 * \param [in] type - a spatial discretization of the new field.
8749 * \param [in] iteration - the iteration number of a required time step.
8750 * \param [in] order - the iteration order number of required time step.
8751 * \param [in] mesh - the supporting mesh.
8752 * \param [in] renumPol - specifies how to permute values of the result field according to
8753 * the optional numbers of cells and nodes, if any. The valid values are
8754 * - 0 - do not permute.
8755 * - 1 - permute cells.
8756 * - 2 - permute nodes.
8757 * - 3 - permute cells and nodes.
8759 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8760 * caller is to delete this field using decrRef() as it is no more needed.
8761 * \throw If no field of \a this is lying on \a mesh.
8762 * \throw If no field values of the required parameters are available.
8764 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
8766 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8767 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8769 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8770 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8771 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8772 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8777 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8778 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8779 * This method is useful for MED2 file format when field on different mesh was autorized.
8781 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
8783 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8784 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8786 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8787 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8788 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8789 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8794 * Returns values and a profile of the field of a given type, of a given time step,
8795 * lying on a given support.
8796 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8797 * \param [in] type - a spatial discretization of the field.
8798 * \param [in] iteration - the iteration number of a required time step.
8799 * \param [in] order - the iteration order number of required time step.
8800 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8801 * \param [in] mesh - the supporting mesh.
8802 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8803 * field of interest lies on. If the field lies on all entities of the given
8804 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8805 * using decrRef() as it is no more needed.
8806 * \param [in] glob - the global data storing profiles and localization.
8807 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8808 * field. The caller is to delete this array using decrRef() as it is no more needed.
8809 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8810 * \throw If no field of \a this is lying on \a mesh.
8811 * \throw If no field values of the required parameters are available.
8813 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
8815 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8816 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8818 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8819 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8820 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8823 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
8825 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8827 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8828 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8830 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 !");
8834 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
8836 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8838 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8839 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8841 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 !");
8846 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8847 * the given field is checked if its elements are sorted suitable for writing to MED file
8848 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8849 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8850 * \param [in] field - the field to add to \a this.
8851 * \throw If the name of \a field is empty.
8852 * \throw If the data array of \a field is not set.
8853 * \throw If existing time steps have different name or number of components than \a field.
8854 * \throw If the underlying mesh of \a field has no name.
8855 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8857 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
8859 const DataArrayDouble *arr=0;
8861 arr=field->getArray();
8862 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8866 * Adds a MEDCouplingFieldDouble to \a this as another time step.
8867 * The mesh support of input parameter \a field is ignored here, it can be NULL.
8868 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
8871 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
8872 * A new profile is added only if no equal profile is missing.
8873 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8874 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
8875 * \param [in] mesh - the supporting mesh of \a field.
8876 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
8877 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8878 * \throw If either \a field or \a mesh or \a profile has an empty name.
8879 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8880 * \throw If the data array of \a field is not set.
8881 * \throw If the data array of \a this is already allocated but has different number of
8882 * components than \a field.
8883 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8884 * \sa setFieldNoProfileSBT()
8886 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
8888 const DataArrayDouble *arr=0;
8890 arr=field->getArray();
8891 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8894 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8896 _content=new MEDFileFieldMultiTSWithoutSDA;
8899 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll)
8900 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8903 catch(INTERP_KERNEL::Exception& e)
8906 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll)
8907 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8910 catch(INTERP_KERNEL::Exception& e)
8913 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8917 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
8919 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8922 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
8924 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8927 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
8929 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8932 //= MEDFileAnyTypeFieldMultiTSIterator
8934 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8939 _nb_iter=fmts->getNumberOfTS();
8943 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8947 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
8949 if(_iter_id<_nb_iter)
8951 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8953 return fmts->getTimeStepAtPos(_iter_id++);
8961 //= MEDFileIntFieldMultiTS
8964 * Returns a new empty instance of MEDFileFieldMultiTS.
8965 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8966 * is to delete this field using decrRef() as it is no more needed.
8968 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8970 return new MEDFileIntFieldMultiTS;
8974 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8975 * that has been read from a specified MED file.
8976 * \param [in] fileName - the name of the MED file to read.
8977 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8978 * is to delete this field using decrRef() as it is no more needed.
8979 * \throw If reading the file fails.
8981 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
8983 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
8984 ret->contentNotNull();//to check that content type matches with \a this type.
8989 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8990 * that has been read from a specified MED file.
8991 * \param [in] fileName - the name of the MED file to read.
8992 * \param [in] fieldName - the name of the field to read.
8993 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8994 * is to delete this field using decrRef() as it is no more needed.
8995 * \throw If reading the file fails.
8996 * \throw If there is no field named \a fieldName in the file.
8998 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9000 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
9001 ret->contentNotNull();//to check that content type matches with \a this type.
9006 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9007 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9009 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9010 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9011 * \warning this is a shallow copy constructor
9012 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9013 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9014 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9015 * is to delete this field using decrRef() as it is no more needed.
9017 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9019 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9023 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9024 * following the given input policy.
9026 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9027 * By default (true) the globals are deeply copied.
9028 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9030 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9032 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9033 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9036 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9038 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9039 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9040 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9043 ret=MEDFileFieldMultiTS::New();
9045 ret->deepCpyGlobs(*this);
9047 ret->shallowCpyGlobs(*this);
9051 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9053 return new MEDFileIntFieldMultiTS(*this);
9056 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9059 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9060 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9062 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9066 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9067 * mesh entities of a given dimension of the first mesh in MED file.
9068 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9069 * \param [in] type - a spatial discretization of interest.
9070 * \param [in] iteration - the iteration number of a required time step.
9071 * \param [in] order - the iteration order number of required time step.
9072 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9073 * \param [out] arrOut - the DataArrayInt containing values of field.
9074 * \param [in] renumPol - specifies how to permute values of the result field according to
9075 * the optional numbers of cells and nodes, if any. The valid values are
9076 * - 0 - do not permute.
9077 * - 1 - permute cells.
9078 * - 2 - permute nodes.
9079 * - 3 - permute cells and nodes.
9081 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9082 * caller is to delete this field using decrRef() as it is no more needed.
9083 * \throw If the MED file is not readable.
9084 * \throw If there is no mesh in the MED file.
9085 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9086 * \throw If no field values of the required parameters are available.
9088 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9090 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9091 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9093 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9094 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9095 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9096 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9101 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9102 * the top level cells of the first mesh in MED file.
9103 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9104 * \param [in] type - a spatial discretization of interest.
9105 * \param [in] iteration - the iteration number of a required time step.
9106 * \param [in] order - the iteration order number of required time step.
9107 * \param [out] arrOut - the DataArrayInt containing values of field.
9108 * \param [in] renumPol - specifies how to permute values of the result field according to
9109 * the optional numbers of cells and nodes, if any. The valid values are
9110 * - 0 - do not permute.
9111 * - 1 - permute cells.
9112 * - 2 - permute nodes.
9113 * - 3 - permute cells and nodes.
9115 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9116 * caller is to delete this field using decrRef() as it is no more needed.
9117 * \throw If the MED file is not readable.
9118 * \throw If there is no mesh in the MED file.
9119 * \throw If no field values of the required parameters are available.
9121 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9123 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9124 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9126 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9127 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9128 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9129 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9134 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9136 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9137 * \param [in] type - a spatial discretization of interest.
9138 * \param [in] iteration - the iteration number of a required time step.
9139 * \param [in] order - the iteration order number of required time step.
9140 * \param [out] arrOut - the DataArrayInt containing values of field.
9141 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9142 * \param [in] mesh - the supporting mesh.
9143 * \param [in] renumPol - specifies how to permute values of the result field according to
9144 * the optional numbers of cells and nodes, if any. The valid values are
9145 * - 0 - do not permute.
9146 * - 1 - permute cells.
9147 * - 2 - permute nodes.
9148 * - 3 - permute cells and nodes.
9150 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9151 * caller is to delete this field using decrRef() as it is no more needed.
9152 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9153 * \throw If no field of \a this is lying on \a mesh.
9154 * \throw If no field values of the required parameters are available.
9156 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9158 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9159 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9161 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9162 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9163 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9164 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9169 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9171 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9172 * \param [in] type - a spatial discretization of the new field.
9173 * \param [in] iteration - the iteration number of a required time step.
9174 * \param [in] order - the iteration order number of required time step.
9175 * \param [in] mesh - the supporting mesh.
9176 * \param [out] arrOut - the DataArrayInt containing values of field.
9177 * \param [in] renumPol - specifies how to permute values of the result field according to
9178 * the optional numbers of cells and nodes, if any. The valid values are
9179 * - 0 - do not permute.
9180 * - 1 - permute cells.
9181 * - 2 - permute nodes.
9182 * - 3 - permute cells and nodes.
9184 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9185 * caller is to delete this field using decrRef() as it is no more needed.
9186 * \throw If no field of \a this is lying on \a mesh.
9187 * \throw If no field values of the required parameters are available.
9189 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9191 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9192 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9194 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9195 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9196 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9197 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9202 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9203 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9204 * This method is useful for MED2 file format when field on different mesh was autorized.
9206 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9208 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9209 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9211 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9212 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9213 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9214 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9219 * Returns values and a profile of the field of a given type, of a given time step,
9220 * lying on a given support.
9221 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9222 * \param [in] type - a spatial discretization of the field.
9223 * \param [in] iteration - the iteration number of a required time step.
9224 * \param [in] order - the iteration order number of required time step.
9225 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9226 * \param [in] mesh - the supporting mesh.
9227 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9228 * field of interest lies on. If the field lies on all entities of the given
9229 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9230 * using decrRef() as it is no more needed.
9231 * \param [in] glob - the global data storing profiles and localization.
9232 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9233 * field. The caller is to delete this array using decrRef() as it is no more needed.
9234 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9235 * \throw If no field of \a this is lying on \a mesh.
9236 * \throw If no field values of the required parameters are available.
9238 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9240 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9241 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9243 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9244 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9245 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9249 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9250 * \param [in] pos - a time step id.
9251 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9252 * delete this field using decrRef() as it is no more needed.
9253 * \throw If \a pos is not a valid time step id.
9255 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9257 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9260 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9261 throw INTERP_KERNEL::Exception(oss.str().c_str());
9263 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9266 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9267 ret->shallowCpyGlobs(*this);
9270 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9271 throw INTERP_KERNEL::Exception(oss.str().c_str());
9275 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9276 * the given field is checked if its elements are sorted suitable for writing to MED file
9277 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9278 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9279 * \param [in] field - the field to add to \a this.
9280 * \throw If the name of \a field is empty.
9281 * \throw If the data array of \a field is not set.
9282 * \throw If existing time steps have different name or number of components than \a field.
9283 * \throw If the underlying mesh of \a field has no name.
9284 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9286 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9288 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9292 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9293 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9294 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9297 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9298 * A new profile is added only if no equal profile is missing.
9299 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9300 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9301 * \param [in] arrOfVals - the values of the field \a field used.
9302 * \param [in] mesh - the supporting mesh of \a field.
9303 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9304 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9305 * \throw If either \a field or \a mesh or \a profile has an empty name.
9306 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9307 * \throw If the data array of \a field is not set.
9308 * \throw If the data array of \a this is already allocated but has different number of
9309 * components than \a field.
9310 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9311 * \sa setFieldNoProfileSBT()
9313 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9315 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9318 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9320 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9322 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9323 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9325 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 !");
9329 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9331 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9333 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9334 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9336 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 !");
9340 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9342 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9345 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9349 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll)
9350 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
9353 catch(INTERP_KERNEL::Exception& e)
9356 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll)
9357 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
9360 catch(INTERP_KERNEL::Exception& e)
9363 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9365 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9370 MEDFileFields *MEDFileFields::New()
9372 return new MEDFileFields;
9375 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9377 return new MEDFileFields(fileName,loadAll);
9380 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9382 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9383 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9387 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9389 std::vector<const BigMemoryObject *> ret;
9390 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9391 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9395 MEDFileFields *MEDFileFields::deepCpy() const
9397 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9399 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9401 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9402 ret->_fields[i]=(*it)->deepCpy();
9404 ret->deepCpyGlobs(*this);
9408 MEDFileFields *MEDFileFields::shallowCpy() const
9410 return new MEDFileFields(*this);
9414 * 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
9415 * 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.
9416 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9418 * \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.
9419 * \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.
9421 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9423 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9425 std::set< std::pair<int,int> > s;
9426 bool firstShot=true;
9427 areThereSomeForgottenTS=false;
9428 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9430 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9432 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9433 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9435 { s=s1; firstShot=false; }
9438 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9440 areThereSomeForgottenTS=true;
9444 std::vector< std::pair<int,int> > ret;
9445 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9449 int MEDFileFields::getNumberOfFields() const
9451 return _fields.size();
9454 std::vector<std::string> MEDFileFields::getFieldsNames() const
9456 std::vector<std::string> ret(_fields.size());
9458 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9460 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9463 ret[i]=f->getName();
9467 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9468 throw INTERP_KERNEL::Exception(oss.str().c_str());
9474 std::vector<std::string> MEDFileFields::getMeshesNames() const
9476 std::vector<std::string> ret;
9477 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9479 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9481 ret.push_back(cur->getMeshName());
9486 std::string MEDFileFields::simpleRepr() const
9488 std::ostringstream oss;
9489 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9494 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9496 int nbOfFields=getNumberOfFields();
9497 std::string startLine(bkOffset,' ');
9498 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9500 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9502 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9505 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9509 oss << startLine << " - not defined !" << std::endl;
9513 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9515 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9516 std::string chapter(17,'0'+i);
9517 oss << startLine << chapter << std::endl;
9520 cur->simpleRepr(bkOffset+2,oss,i);
9524 oss << startLine << " - not defined !" << std::endl;
9526 oss << startLine << chapter << std::endl;
9528 simpleReprGlobs(oss);
9531 MEDFileFields::MEDFileFields()
9535 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll)
9536 try:MEDFileFieldGlobsReal(fileName)
9538 MEDFileUtilities::CheckFileForRead(fileName);
9539 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
9540 int nbFields=MEDnField(fid);
9541 _fields.resize(nbFields);
9542 med_field_type typcha;
9543 for(int i=0;i<nbFields;i++)
9545 std::vector<std::string> infos;
9546 std::string fieldName,dtunit;
9547 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
9552 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9557 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9562 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] !";
9563 throw INTERP_KERNEL::Exception(oss.str().c_str());
9567 loadAllGlobals(fid);
9569 catch(INTERP_KERNEL::Exception& e)
9574 void MEDFileFields::writeLL(med_idt fid) const
9577 writeGlobals(fid,*this);
9578 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9580 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9583 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9584 throw INTERP_KERNEL::Exception(oss.str().c_str());
9586 elt->writeLL(fid,*this);
9590 void MEDFileFields::write(const std::string& fileName, int mode) const
9592 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9593 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
9598 * This method alloc the arrays and load potentially huge arrays contained in this field.
9599 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9600 * This method can be also called to refresh or reinit values from a file.
9602 * \throw If the fileName is not set or points to a non readable MED file.
9604 void MEDFileFields::loadArrays()
9606 if(getFileName().empty())
9607 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
9608 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9609 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9611 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9613 elt->loadBigArraysRecursively(fid,*elt);
9618 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9619 * But once data loaded once, this method does nothing.
9621 * \throw If the fileName is not set or points to a non readable MED file.
9622 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9624 void MEDFileFields::loadArraysIfNecessary()
9626 if(!getFileName().empty())
9628 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
9629 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9631 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9633 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9639 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9640 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9641 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
9643 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
9645 void MEDFileFields::unloadArrays()
9647 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9649 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9651 elt->unloadArrays();
9656 * 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.
9657 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
9658 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9660 * \sa MEDFileFields::loadArraysIfNecessary
9662 void MEDFileFields::unloadArraysWithoutDataLoss()
9664 if(!getFileName().empty())
9668 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9670 std::vector<std::string> ret;
9671 std::set<std::string> ret2;
9672 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9674 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9675 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9676 if(ret2.find(*it2)==ret2.end())
9678 ret.push_back(*it2);
9685 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9687 std::vector<std::string> ret;
9688 std::set<std::string> ret2;
9689 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9691 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9692 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9693 if(ret2.find(*it2)==ret2.end())
9695 ret.push_back(*it2);
9702 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9704 std::vector<std::string> ret;
9705 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9707 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9708 ret.insert(ret.end(),tmp.begin(),tmp.end());
9713 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9715 std::vector<std::string> ret;
9716 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9718 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9719 ret.insert(ret.end(),tmp.begin(),tmp.end());
9724 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9726 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9727 (*it)->changePflsRefsNamesGen2(mapOfModif);
9730 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9732 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9733 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9736 void MEDFileFields::resize(int newSize)
9738 _fields.resize(newSize);
9741 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
9743 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9747 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
9750 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9751 _fields.push_back(field->getContent());
9752 appendGlobs(*field,1e-12);
9755 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
9758 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9759 if(i>=(int)_fields.size())
9760 _fields.resize(i+1);
9761 _fields[i]=field->getContent();
9762 appendGlobs(*field,1e-12);
9765 void MEDFileFields::destroyFieldAtPos(int i)
9767 destroyFieldsAtPos(&i,&i+1);
9770 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
9772 std::vector<bool> b(_fields.size(),true);
9773 for(const int *i=startIds;i!=endIds;i++)
9775 if(*i<0 || *i>=(int)_fields.size())
9777 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9778 throw INTERP_KERNEL::Exception(oss.str().c_str());
9782 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9784 for(std::size_t i=0;i<_fields.size();i++)
9786 fields[j++]=_fields[i];
9790 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
9792 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9793 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9794 std::vector<bool> b(_fields.size(),true);
9796 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9798 if(k<0 || k>=(int)_fields.size())
9800 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9801 throw INTERP_KERNEL::Exception(oss.str().c_str());
9805 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9807 for(std::size_t i=0;i<_fields.size();i++)
9809 fields[j++]=_fields[i];
9813 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9816 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9818 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9820 ret=cur->changeMeshNames(modifTab) || ret;
9826 * \param [in] meshName the name of the mesh that will be renumbered.
9827 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9828 * This code corresponds to the distribution of types in the corresponding mesh.
9829 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9830 * \param [in] renumO2N the old to new renumber array.
9831 * \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
9834 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
9837 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9839 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9842 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9848 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
9850 if(i<0 || i>=(int)_fields.size())
9852 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9853 throw INTERP_KERNEL::Exception(oss.str().c_str());
9855 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9858 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9859 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9860 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9862 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9864 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9867 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9868 throw INTERP_KERNEL::Exception(oss.str().c_str());
9870 ret->shallowCpyGlobs(*this);
9875 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9876 * This method is accessible in python using __getitem__ with a list in input.
9877 * \return a new object that the caller should deal with.
9879 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
9881 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9882 std::size_t sz=std::distance(startIds,endIds);
9883 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9885 for(const int *i=startIds;i!=endIds;i++,j++)
9887 if(*i<0 || *i>=(int)_fields.size())
9889 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9890 throw INTERP_KERNEL::Exception(oss.str().c_str());
9892 fields[j]=_fields[*i];
9894 ret->_fields=fields;
9898 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
9900 return getFieldAtPos(getPosFromFieldName(fieldName));
9904 * This method removes, if any, fields in \a this having no time steps.
9905 * 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.
9907 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
9909 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
9911 std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
9912 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9914 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9917 if(elt->getNumberOfTS()>0)
9918 newFields.push_back(*it);
9921 if(_fields.size()==newFields.size())
9928 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9929 * This method can be seen as a filter applied on \a this, that returns an object containing
9930 * 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
9931 * shallow copied from \a this.
9933 * \param [in] meshName - the name of the mesh on w
9934 * \return a new object that the caller should deal with.
9936 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
9938 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9939 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9941 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9944 if(cur->getMeshName()==meshName)
9947 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9948 ret->_fields.push_back(cur2);
9951 ret->shallowCpyOnlyUsedGlobs(*this);
9956 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9957 * Input time steps are specified using a pair of integer (iteration, order).
9958 * 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,
9959 * but for each multitimestep only the time steps in \a timeSteps are kept.
9960 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9962 * The returned object points to shallow copy of elements in \a this.
9964 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9965 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9966 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9968 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9970 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9971 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9973 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9976 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9977 ret->_fields.push_back(elt);
9979 ret->shallowCpyOnlyUsedGlobs(*this);
9984 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9986 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9988 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9989 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9991 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9994 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9995 if(elt->getNumberOfTS()!=0)
9996 ret->_fields.push_back(elt);
9998 ret->shallowCpyOnlyUsedGlobs(*this);
10002 MEDFileFieldsIterator *MEDFileFields::iterator()
10004 return new MEDFileFieldsIterator(this);
10007 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10009 std::string tmp(fieldName);
10010 std::vector<std::string> poss;
10011 for(std::size_t i=0;i<_fields.size();i++)
10013 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10016 std::string fname(f->getName());
10020 poss.push_back(fname);
10023 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10024 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10026 throw INTERP_KERNEL::Exception(oss.str().c_str());
10029 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10034 _nb_iter=fs->getNumberOfFields();
10038 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10042 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10044 if(_iter_id<_nb_iter)
10046 MEDFileFields *fs(_fs);
10048 return fs->getFieldAtPos(_iter_id++);