1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
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[32];
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 char *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 char *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 char *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,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
69 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+32,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,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+32,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 char *locName, INTERP_KERNEL::NormalizedCellType geoType,
98 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
101 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
102 _dim=cm.getDimension();
103 _nb_node_per_cell=cm.getNumberOfNodes();
104 _nb_gauss_pt=_w.size();
107 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
109 return new MEDFileFieldLoc(*this);
112 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
114 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
117 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildren() const
119 return std::vector<const BigMemoryObject *>();
122 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
124 static const char OFF7[]="\n ";
125 oss << "\"" << _name << "\"" << OFF7;
126 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
127 oss << "Dimension=" << _dim << OFF7;
128 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
129 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
130 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
131 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
132 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
135 void MEDFileFieldLoc::setName(const char *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(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;
289 if(_type!=ON_NODES) { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); } else { oss << "_NODE"; }
293 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
294 if(_type!=ON_GAUSS_PT)
296 locIds->setName(oss.str().c_str());
297 glob.appendProfile(locIds);
306 _nval=idsInPfl->getNumberOfTuples();
307 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
313 _nval=idsInPfl->getNumberOfTuples();
314 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
320 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
321 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
322 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
323 arr3->computeOffsets2();
324 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
325 int trueNval=tmp->getNumberOfTuples();
326 _nval=idsInPfl->getNumberOfTuples();
327 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
328 _end=_start+trueNval;
333 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
335 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
336 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
337 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
338 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
339 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
340 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
342 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
343 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
345 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
347 for(const int *pt=da4->begin();pt!=da4->end();pt++)
348 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
349 tmp->alloc(trueNval,1);
350 int *tmpPtr=tmp->getPointer();
351 for(const int *pt=da4->begin();pt!=da4->end();pt++)
352 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
355 _nval=da4->getNumberOfTuples();
356 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
357 _end=_start+trueNval;
358 oss << "_loc_" << _loc_id;
361 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
362 da5->setName(oss.str().c_str());
363 glob.appendProfile(da5);
368 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
370 da3->setName(oss.str().c_str());
371 glob.appendProfile(da3);
375 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
376 _localization=oss2.str();
377 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
381 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
386 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
389 _nval=arrr->getNumberOfTuples();
390 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
395 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt)
397 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt);
400 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
402 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
405 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
407 return new MEDFileFieldPerMeshPerTypePerDisc(other);
410 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
412 return _profile.capacity()+_localization.capacity()+5*sizeof(int);
415 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildren() const
417 return std::vector<const BigMemoryObject *>();
420 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const
422 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
427 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt)
428 try:_type(atype),_father(fath),_profile_it(profileIt)
431 catch(INTERP_KERNEL::Exception& e)
436 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
440 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_tmp_work1(other._tmp_work1)
444 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
445 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
449 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
454 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
456 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
457 INTERP_KERNEL::AutoPtr<char> pflname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
458 std::string fieldName=nasc.getName();
459 std::string meshName=getMeshName();
460 int iteration=getIteration();
461 int order=getOrder();
462 TypeOfField type=getType();
463 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
465 med_geometry_type mgeoti;
466 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
467 _nval=MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it,MED_COMPACT_PFLMODE,
468 pflname,&profilesize,locname,&nbi);
469 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
470 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
472 _end=start+_nval*nbi;
474 if(type==ON_CELLS && !_localization.empty())
476 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
477 setType(ON_GAUSS_PT);
480 setType(ON_GAUSS_NE);
481 _localization.clear();
486 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
488 std::string fieldName=nasc.getName();
489 std::string meshName=getMeshName();
490 int iteration=getIteration();
491 int order=getOrder();
492 TypeOfField type=getType();
493 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
494 med_geometry_type mgeoti;
495 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
497 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
500 DataArray *arr=getOrCreateAndGetArray();//arr is not null due to the spec of getOrCreateAndGetArray
501 if(_start<0 || _start>=arr->getNumberOfTuples())
503 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
504 throw INTERP_KERNEL::Exception(oss.str().c_str());
506 if(_end<0 || _end>arr->getNumberOfTuples())
508 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
509 throw INTERP_KERNEL::Exception(oss.str().c_str());
512 INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
513 med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi);
514 int nbOfCompo=arr->getNumberOfComponents();
515 if(_end-_start!=nbValsInFile*nbi)
517 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 !";
518 throw INTERP_KERNEL::Exception(oss.str().c_str());
520 DataArrayDouble *arrD=dynamic_cast<DataArrayDouble *>(arr);
523 double *startFeeding=arrD->getPointer()+_start*nbOfCompo;
524 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
525 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
528 DataArrayInt *arrI=dynamic_cast<DataArrayInt *>(arr);
531 int *startFeeding=arrI->getPointer()+_start*nbOfCompo;
532 MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
533 _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(startFeeding));
536 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
540 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
542 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
544 int delta=_end-_start;
545 _start=newValueOfStart;
549 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
551 return _father->getIteration();
554 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
556 return _father->getOrder();
559 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
561 return _father->getTime();
564 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
566 return _father->getMeshName();
569 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
571 const char startLine[]=" ## ";
572 std::string startLine2(bkOffset,' ');
573 startLine2+=startLine;
574 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
575 oss << startLine2 << "Localization #" << id << "." << std::endl;
576 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
578 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
579 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
580 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
583 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
588 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
593 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
598 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
600 return _father->getGeoType();
603 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
605 return _father->getNumberOfComponents();
608 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
613 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
615 return _father->getOrCreateAndGetArray();
618 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
620 const MEDFileFieldPerMeshPerType *fath=_father;
621 return fath->getOrCreateAndGetArray();
624 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
626 return _father->getInfo();
629 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
634 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const char *newPflName)
639 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
641 return _localization;
644 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const char *newLocName)
646 _localization=newLocName;
649 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
651 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
653 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
655 _profile=(*it2).second;
661 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
663 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
665 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
667 _localization=(*it2).second;
673 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
677 dads.push_back(std::pair<int,int>(_start,_end));
678 geoTypes.push_back(getGeoType());
683 pfls.push_back(glob->getProfile(_profile.c_str()));
685 if(_localization.empty())
689 locs.push_back(glob->getLocalizationId(_localization.c_str()));
693 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
695 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));
699 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
701 TypeOfField type=getType();
702 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
703 med_geometry_type mgeoti;
704 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
705 const DataArray *arr=getOrCreateAndGetArray();
707 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
708 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
709 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
710 const unsigned char *locToWrite=0;
712 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
714 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
716 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
717 MEDfieldValueWithProfileWr(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
718 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
722 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
727 dad.first=_start; dad.second=_end;
731 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
732 * This code corresponds to the distribution of types in the corresponding mesh.
733 * \param [out] ptToFill memory zone where the output will be stored.
734 * \return the size of data pushed into output param \a ptToFill
736 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
739 std::ostringstream oss;
740 std::size_t nbOfType=codeOfMesh.size()/3;
742 for(std::size_t i=0;i<nbOfType && found==-1;i++)
743 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
747 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
748 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
749 throw INTERP_KERNEL::Exception(oss.str().c_str());
754 if(_nval!=codeOfMesh[3*found+1])
756 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
757 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
758 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
759 throw INTERP_KERNEL::Exception(oss.str().c_str());
761 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
766 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
767 if(pfl->getNumberOfTuples()!=_nval)
769 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
770 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
772 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
773 throw INTERP_KERNEL::Exception(oss.str().c_str());
775 int offset2=codeOfMesh[3*found+2];
776 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
778 if(*pflId<codeOfMesh[3*found+1])
779 *work++=offset2+*pflId;
785 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
787 for(int i=_start;i<_end;i++)
792 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
803 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
807 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
810 std::map<std::pair<std::string,TypeOfField>,int> m;
811 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
812 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
813 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
814 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
816 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
817 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
822 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
824 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
825 * \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.
826 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
827 * \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)
828 * \param [in,out] glob if necessary by the method, new profiles can be added to it
829 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
830 * \param [out] result All new entries will be appended on it.
831 * \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 !)
833 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
834 const DataArrayInt *explicitIdsInMesh,
835 const std::vector<int>& newCode,
836 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
837 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
839 if(entriesOnSameDisc.empty())
841 TypeOfField type=entriesOnSameDisc[0]->getType();
842 int szEntities=0,szTuples=0;
843 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
844 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
845 int nbi=szTuples/szEntities;
846 if(szTuples%szEntities!=0)
847 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
848 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
849 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
850 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
851 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
852 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
853 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
854 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
856 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
858 int startOfEltIdOfChunk=(*it)->_start;
859 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
860 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
861 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
863 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
864 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
866 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
867 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
869 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
870 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
871 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
872 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
874 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
876 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
877 arrPart->renumberInPlace(renumTupleIds->begin());
878 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
880 const int *idIt=diffVals->begin();
881 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
883 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
885 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
886 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
887 int nbEntityElts=subIds->getNumberOfTuples();
889 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
890 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
894 result.push_back(eltToAdd);
895 offset2+=nbEntityElts*nbi;
897 ret=ret || li.empty();
902 * \param [in] typeF type of field of new chunk
903 * \param [in] geoType the geometric type of the chunk
904 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
905 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
906 * \param [in] nbi number of integration points
907 * \param [in] offset The offset in the **global array of data**.
908 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
909 * to the new chunk to create.
910 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
911 * \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
912 * and corresponding entry erased from \a entriesOnSameDisc.
913 * \return a newly allocated chunk
915 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
916 bool isPfl, int nbi, int offset,
917 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
918 MEDFileFieldGlobsReal& glob,
919 bool ¬InExisting) throw(INTERP_KERNEL::Exception)
921 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
922 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
923 for(;it!=entriesOnSameDisc.end();it++)
925 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
929 if((*it)->_profile.empty())
932 if(!(*it)->_profile.empty())
934 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
935 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
941 if(it==entriesOnSameDisc.end())
944 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
946 ret->_loc_id=(int)geoType;
947 ret->_nval=nbMeshEntities;
949 ret->_end=ret->_start+ret->_nval*nbi;
952 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
953 glob.appendProfile(idsOfMeshElt);
954 ret->_profile=idsOfMeshElt->getName();
956 //tony treatment of localization
962 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
963 ret->_loc_id=(int)geoType;
964 ret->setNewStart(offset);
965 entriesOnSameDisc.erase(it);
971 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc)
973 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc);
976 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
978 return new MEDFileFieldPerMeshPerType(fath,geoType);
981 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
983 return _field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
986 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildren() const
988 std::vector<const BigMemoryObject *> ret;
989 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
991 const MEDFileFieldPerMeshPerTypePerDisc *cur(*it);
998 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const
1000 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1001 ret->_father=father;
1003 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1005 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1006 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
1011 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1013 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1014 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1015 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1019 * This method is the most general one. No optimization is done here.
1020 * \param [in] multiTypePfl is the end user profile specified in high level API
1021 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1022 * \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.
1023 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1024 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1025 * \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.
1027 void MEDFileFieldPerMeshPerType::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1029 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1030 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1031 _field_pm_pt_pd[*it]->assignFieldProfile(start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1034 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1036 _field_pm_pt_pd.resize(1);
1037 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1038 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1041 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1043 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1044 if(!arr || !arr->isAllocated())
1045 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1046 _field_pm_pt_pd.resize(1);
1047 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1048 _field_pm_pt_pd[0]->assignFieldProfile(start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1051 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1053 TypeOfField type=field->getTypeOfField();
1054 if(type!=ON_GAUSS_PT)
1056 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1057 int sz=_field_pm_pt_pd.size();
1059 for(int j=0;j<sz && !found;j++)
1061 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1063 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1069 _field_pm_pt_pd.resize(sz+1);
1070 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1072 std::vector<int> ret(1,(int)sz);
1077 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1078 int sz2=ret2.size();
1079 std::vector<int> ret3(sz2);
1081 for(int i=0;i<sz2;i++)
1083 int sz=_field_pm_pt_pd.size();
1084 int locIdToFind=ret2[i];
1086 for(int j=0;j<sz && !found;j++)
1088 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1090 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1097 _field_pm_pt_pd.resize(sz+1);
1098 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1106 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1108 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1109 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1111 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1112 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1114 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1115 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1116 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1117 if(retTmp->presenceOfValue(-1))
1118 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1119 std::vector<int> ret(retTmp->begin(),retTmp->end());
1123 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1125 TypeOfField type=field->getTypeOfField();
1126 if(type!=ON_GAUSS_PT)
1128 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1129 int sz=_field_pm_pt_pd.size();
1131 for(int j=0;j<sz && !found;j++)
1133 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1135 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1141 _field_pm_pt_pd.resize(sz+1);
1142 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1144 std::vector<int> ret(1,0);
1149 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1150 int sz2=ret2.size();
1151 std::vector<int> ret3(sz2);
1153 for(int i=0;i<sz2;i++)
1155 int sz=_field_pm_pt_pd.size();
1156 int locIdToFind=ret2[i];
1158 for(int j=0;j<sz && !found;j++)
1160 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1162 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1169 _field_pm_pt_pd.resize(sz+1);
1170 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1178 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1180 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1181 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1183 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1184 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1186 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1187 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1188 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1189 if(retTmp->presenceOfValue(-1))
1190 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1191 std::vector<int> ret(retTmp->begin(),retTmp->end());
1195 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1200 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1202 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1203 int curDim=(int)cm.getDimension();
1204 dim=std::max(dim,curDim);
1207 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1209 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1211 (*it)->fillTypesOfFieldAvailable(types);
1215 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
1217 int sz=_field_pm_pt_pd.size();
1218 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1219 for(int i=0;i<sz;i++)
1221 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1225 int MEDFileFieldPerMeshPerType::getIteration() const
1227 return _father->getIteration();
1230 int MEDFileFieldPerMeshPerType::getOrder() const
1232 return _father->getOrder();
1235 double MEDFileFieldPerMeshPerType::getTime() const
1237 return _father->getTime();
1240 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1242 return _father->getMeshName();
1245 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1247 const char startLine[]=" ## ";
1248 std::string startLine2(bkOffset,' ');
1249 std::string startLine3(startLine2);
1250 startLine3+=startLine;
1251 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1253 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1254 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1257 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1258 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1260 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1262 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1264 cur->simpleRepr(bkOffset,oss,i);
1267 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1272 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1274 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1276 globalSz+=(*it)->getNumberOfTuples();
1278 nbOfEntries+=(int)_field_pm_pt_pd.size();
1281 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1287 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1289 return _father->getNumberOfComponents();
1292 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1294 return _father->getOrCreateAndGetArray();
1297 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1299 const MEDFileFieldPerMesh *fath=_father;
1300 return fath->getOrCreateAndGetArray();
1303 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1305 return _father->getInfo();
1308 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1310 std::vector<std::string> ret;
1311 std::set<std::string> ret2;
1312 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1314 std::string tmp=(*it1)->getProfile();
1316 if(ret2.find(tmp)==ret2.end())
1325 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1327 std::vector<std::string> ret;
1328 std::set<std::string> ret2;
1329 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1331 std::string tmp=(*it1)->getLocalization();
1332 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1333 if(ret2.find(tmp)==ret2.end())
1342 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1344 std::vector<std::string> ret;
1345 std::set<std::string> ret2;
1346 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1348 std::string tmp=(*it1)->getProfile();
1355 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1357 std::vector<std::string> ret;
1358 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1360 std::string tmp=(*it1)->getLocalization();
1361 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1367 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1369 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1370 (*it1)->changePflsRefsNamesGen(mapOfModif);
1373 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1375 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1376 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1379 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1381 if(_field_pm_pt_pd.empty())
1383 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1384 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1385 throw INTERP_KERNEL::Exception(oss.str().c_str());
1387 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1388 return _field_pm_pt_pd[locId];
1389 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1390 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1391 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1392 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1393 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1396 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1398 if(_field_pm_pt_pd.empty())
1400 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1401 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1402 throw INTERP_KERNEL::Exception(oss.str().c_str());
1404 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1405 return _field_pm_pt_pd[locId];
1406 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1407 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1408 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1409 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1410 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1413 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
1415 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1417 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1418 if(meshDim!=(int)cm.getDimension())
1421 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1422 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1425 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1428 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1430 (*it)->fillValues(i,startEntryId,entries);
1434 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1436 _field_pm_pt_pd=leaves;
1437 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1438 (*it)->setFather(this);
1442 * \param [in,out] globalNum a global numbering counter for the renumbering.
1443 * \param [out] its - list of pair (start,stop) kept
1444 * \return bool - false if the type of field \a tof is not contained in \a this.
1446 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1449 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1450 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1451 if((*it)->getType()==tof)
1453 newPmPtPd.push_back(*it);
1454 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1455 (*it)->setNewStart(globalNum);
1456 globalNum=(*it)->getEnd();
1457 its.push_back(bgEnd);
1461 _field_pm_pt_pd=newPmPtPd;
1465 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1469 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc):_father(fath),_geo_type(geoType)
1471 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1472 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1473 med_geometry_type mgeoti;
1474 med_entity_type menti;
1475 menti=ConvertIntoMEDFileType(type,geoType,mgeoti);
1476 int nbProfiles=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName);
1477 _field_pm_pt_pd.resize(nbProfiles);
1478 for(int i=0;i<nbProfiles;i++)
1480 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i+1);
1484 int nbProfiles2=MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName);
1485 for(int i=0;i<nbProfiles2;i++)
1486 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i+1));
1490 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1492 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1493 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1496 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1498 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1499 (*it)->loadBigArray(fid,nasc);
1502 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1504 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1506 (*it)->copyOptionsFrom(*this);
1507 (*it)->writeLL(fid,nasc);
1511 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1516 medfGeoType=typmai3[(int)ikGeoType];
1519 medfGeoType=MED_NONE;
1522 medfGeoType=typmai3[(int)ikGeoType];
1523 return MED_NODE_ELEMENT;
1525 medfGeoType=typmai3[(int)ikGeoType];
1528 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1530 return MED_UNDEF_ENTITY_TYPE;
1533 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc)
1535 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc);
1538 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1540 return new MEDFileFieldPerMesh(fath,mesh);
1543 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1545 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1548 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildren() const
1550 std::vector<const BigMemoryObject *> ret;
1551 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1553 const MEDFileFieldPerMeshPerType *cur(*it);
1560 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1562 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1563 ret->_father=father;
1565 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1567 if((const MEDFileFieldPerMeshPerType *)*it)
1568 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1573 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1575 std::string startLine(bkOffset,' ');
1576 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1577 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1579 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1581 const MEDFileFieldPerMeshPerType *cur=*it;
1583 cur->simpleRepr(bkOffset,oss,i);
1586 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1591 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1593 _mesh_name=mesh->getName();
1594 mesh->getTime(_mesh_iteration,_mesh_order);
1597 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1599 int nbOfTypes=code.size()/3;
1601 for(int i=0;i<nbOfTypes;i++)
1603 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1604 int nbOfCells=code[3*i+1];
1605 int pos=addNewEntryIfNecessary(type);
1606 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1612 * This method is the most general one. No optimization is done here.
1613 * \param [in] multiTypePfl is the end user profile specified in high level API
1614 * \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].
1615 * \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.
1616 * \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.
1617 * \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.
1618 * \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.
1620 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)
1622 int nbOfTypes=code.size()/3;
1623 for(int i=0;i<nbOfTypes;i++)
1625 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1626 int pos=addNewEntryIfNecessary(type);
1627 DataArrayInt *pfl=0;
1629 pfl=idsPerType[code[3*i+2]];
1630 int nbOfTupes2=code2.size()/3;
1632 for(;found<nbOfTupes2;found++)
1633 if(code[3*i]==code2[3*found])
1635 if(found==nbOfTupes2)
1636 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1637 _field_pm_pt[pos]->assignFieldProfile(start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1641 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1643 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1644 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1647 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1649 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1650 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1653 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1655 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1656 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1659 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1661 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1662 (*it)->loadBigArraysRecursively(fid,nasc);
1665 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1667 int nbOfTypes=_field_pm_pt.size();
1668 for(int i=0;i<nbOfTypes;i++)
1670 _field_pm_pt[i]->copyOptionsFrom(*this);
1671 _field_pm_pt[i]->writeLL(fid,nasc);
1675 void MEDFileFieldPerMesh::getDimension(int& dim) const
1677 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1678 (*it)->getDimension(dim);
1681 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1683 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1684 (*it)->fillTypesOfFieldAvailable(types);
1687 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
1689 int sz=_field_pm_pt.size();
1690 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1691 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1692 for(int i=0;i<sz;i++)
1694 types[i]=_field_pm_pt[i]->getGeoType();
1695 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1700 double MEDFileFieldPerMesh::getTime() const
1703 return _father->getTime(tmp1,tmp2);
1706 int MEDFileFieldPerMesh::getIteration() const
1708 return _father->getIteration();
1711 int MEDFileFieldPerMesh::getOrder() const
1713 return _father->getOrder();
1716 int MEDFileFieldPerMesh::getNumberOfComponents() const
1718 return _father->getNumberOfComponents();
1721 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1724 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1725 return _father->getOrCreateAndGetArray();
1728 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1731 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1732 return _father->getOrCreateAndGetArray();
1735 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1737 return _father->getInfo();
1741 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1742 * 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.
1743 * It returns 2 output vectors :
1744 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1745 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1746 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1748 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)
1750 int notNullPflsSz=0;
1751 int nbOfArrs=geoTypes.size();
1752 for(int i=0;i<nbOfArrs;i++)
1755 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1756 int nbOfDiffGeoTypes=geoTypes3.size();
1757 code.resize(3*nbOfDiffGeoTypes);
1758 notNullPfls.resize(notNullPflsSz);
1761 for(int i=0;i<nbOfDiffGeoTypes;i++)
1764 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1765 std::vector<const DataArrayInt *> notNullTmp;
1767 notNullTmp.push_back(pfls[j]);
1769 for(;j<nbOfArrs;j++)
1770 if(geoTypes[j]==refType)
1773 notNullTmp.push_back(pfls[j]);
1777 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1778 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1779 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1780 code[3*i]=(int)refType;
1781 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1782 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1783 if(notNullTmp.empty())
1787 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1788 code[3*i+2]=notNullPflsSz++;
1794 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1796 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)
1800 for(int i=0;i<sz;i++)
1804 if(type!=ON_GAUSS_NE)
1805 ret+=dads[i].second-dads[i].first;
1808 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1809 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1814 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1815 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1821 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1823 std::vector<std::string> ret;
1824 std::set<std::string> ret2;
1825 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1827 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1828 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1829 if(ret2.find(*it2)==ret2.end())
1831 ret.push_back(*it2);
1838 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1840 std::vector<std::string> ret;
1841 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1843 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1844 ret.insert(ret.end(),tmp.begin(),tmp.end());
1849 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1851 std::vector<std::string> ret;
1852 std::set<std::string> ret2;
1853 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1855 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1856 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1857 if(ret2.find(*it2)==ret2.end())
1859 ret.push_back(*it2);
1866 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1868 std::vector<std::string> ret;
1869 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1871 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1872 ret.insert(ret.end(),tmp.begin(),tmp.end());
1877 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1879 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1881 if((*it).first==_mesh_name)
1883 _mesh_name=(*it).second;
1890 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1891 MEDFileFieldGlobsReal& glob)
1893 if(_mesh_name!=meshName)
1895 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
1896 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
1897 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
1898 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
1899 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
1900 getUndergroundDataArrayExt(entries);
1901 DataArray *arr0=getOrCreateAndGetArray();//tony
1903 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
1904 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
1906 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
1909 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
1910 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
1912 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
1914 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1915 sz+=(*it).second.second-(*it).second.first;
1918 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
1920 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
1921 ////////////////////
1922 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
1923 int *workI2=explicitIdsOldInMesh->getPointer();
1924 int sz1=0,sz2=0,sid=1;
1925 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
1926 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
1927 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
1929 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
1930 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
1931 int *workI=explicitIdsOldInArr->getPointer();
1932 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
1934 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
1935 (*itL2)->setLocId(sz2);
1936 (*itL2)->_tmp_work1=(*itL2)->getStart();
1937 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
1939 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
1941 explicitIdsOldInMesh->reAlloc(sz2);
1942 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
1943 ////////////////////
1944 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
1945 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
1946 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
1947 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
1949 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
1950 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
1951 otherEntriesNew.back()->setLocId((*it)->getGeoType());
1953 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
1954 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
1955 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
1957 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1958 int newStart=elt->getLocId();
1959 elt->setLocId((*it)->getGeoType());
1960 elt->setNewStart(newStart);
1961 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
1962 entriesKeptNew.push_back(elt);
1963 entriesKeptNew2.push_back(elt);
1965 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
1966 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
1967 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
1968 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
1970 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
1973 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
1975 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
1976 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
1978 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
1979 glob,arr2,otherEntriesNew) || ret;
1983 // Assign new dispatching
1984 assignNewLeaves(otherEntriesNew);
1985 arr->cpyFrom(*arr2);
1990 * \param [in,out] globalNum a global numbering counter for the renumbering.
1991 * \param [out] its - list of pair (start,stop) kept
1993 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1995 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
1996 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1998 std::vector< std::pair<int,int> > its2;
1999 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2002 its.insert(its.end(),its2.begin(),its2.end());
2008 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2010 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2011 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2012 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2014 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2015 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2016 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2017 for(;it1!=types.end();it1++,it2++)
2019 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2020 elt->setLeaves((*it1).second);
2023 _field_pm_pt=fieldPmPt;
2026 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2028 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2029 (*it)->changePflsRefsNamesGen(mapOfModif);
2032 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2034 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2035 (*it)->changeLocsRefsNamesGen(mapOfModif);
2039 * \param [in] mesh is the whole mesh
2041 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2043 if(_field_pm_pt.empty())
2044 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2046 std::vector< std::pair<int,int> > dads;
2047 std::vector<const DataArrayInt *> pfls;
2048 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2049 std::vector<int> locs,code;
2050 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2051 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2052 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2054 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2057 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2058 throw INTERP_KERNEL::Exception(oss.str().c_str());
2061 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2062 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2065 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2067 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2070 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2071 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2077 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2081 if(nb!=mesh->getNumberOfNodes())
2083 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2084 oss << " nodes in mesh !";
2085 throw INTERP_KERNEL::Exception(oss.str().c_str());
2087 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2090 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2094 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2096 if(_field_pm_pt.empty())
2097 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2099 std::vector<std::pair<int,int> > dads;
2100 std::vector<const DataArrayInt *> pfls;
2101 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2102 std::vector<int> locs,code;
2103 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2104 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2105 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2107 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2110 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2111 throw INTERP_KERNEL::Exception(oss.str().c_str());
2113 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2114 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2117 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2118 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2123 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2127 if(nb!=mesh->getNumberOfNodes())
2129 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2130 oss << " nodes in mesh !";
2131 throw INTERP_KERNEL::Exception(oss.str().c_str());
2134 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2140 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2144 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2146 (*it)->getSizes(globalSz,nbOfEntries);
2148 entries.resize(nbOfEntries);
2150 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2152 (*it)->fillValues(nbOfEntries,entries);
2156 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2158 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2160 if((*it)->getGeoType()==typ)
2161 return (*it)->getLeafGivenLocId(locId);
2163 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2164 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2165 oss << "Possiblities are : ";
2166 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2168 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2169 oss << "\"" << cm2.getRepr() << "\", ";
2171 throw INTERP_KERNEL::Exception(oss.str().c_str());
2174 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2176 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2178 if((*it)->getGeoType()==typ)
2179 return (*it)->getLeafGivenLocId(locId);
2181 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2182 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2183 oss << "Possiblities are : ";
2184 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2186 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2187 oss << "\"" << cm2.getRepr() << "\", ";
2189 throw INTERP_KERNEL::Exception(oss.str().c_str());
2192 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2195 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2196 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2197 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2199 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2204 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2209 int ret=std::distance(_field_pm_pt.begin(),it2);
2210 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2215 * 'dads' and 'locs' input parameters have the same number of elements
2216 * \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
2218 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2219 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2220 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2223 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2224 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2225 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2226 const std::vector<std::string>& infos=getInfo();
2227 da->setInfoOnComponents(infos);
2229 if(type==ON_GAUSS_PT)
2232 int nbOfArrs=dads.size();
2233 for(int i=0;i<nbOfArrs;i++)
2235 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2236 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2237 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2238 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2239 di->alloc(nbOfElems,1);
2241 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2242 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2251 * 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.
2252 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2253 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2254 * The order of cells in the returned field is those imposed by the profile.
2255 * \param [in] mesh is the global mesh.
2257 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2258 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2259 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2260 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2262 if(da->isIdentity())
2264 int nbOfTuples=da->getNumberOfTuples();
2265 if(nbOfTuples==mesh->getNumberOfCells())
2266 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2268 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2269 m2->setName(mesh->getName().c_str());
2270 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2276 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2278 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2279 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2280 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception)
2282 if(da->isIdentity())
2284 int nbOfTuples=da->getNumberOfTuples();
2285 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2286 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2288 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2289 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2292 if(meshu->getNodalConnectivity()==0)
2294 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2295 int nb=da->getNbOfElems();
2296 const int *ptr=da->getConstPointer();
2297 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2298 meshuc->allocateCells(nb);
2299 for(int i=0;i<nb;i++)
2300 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2301 meshuc->finishInsertingCells();
2302 ret->setMesh(meshuc);
2303 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2304 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2305 disc->checkCoherencyBetween(meshuc,arrOut);
2310 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2312 DataArrayInt *arr2=0;
2313 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2314 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2315 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2316 int nnodes=mesh2->getNumberOfNodes();
2317 if(nnodes==(int)da->getNbOfElems())
2319 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2320 arrOut->renumberInPlace(da3->getConstPointer());
2321 mesh2->setName(mesh->getName().c_str());
2322 ret->setMesh(mesh2);
2327 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 !!!";
2328 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2329 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2330 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2331 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2332 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2333 throw INTERP_KERNEL::Exception(oss.str().c_str());
2339 * This method is the most light method of field retrieving.
2341 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2345 pflOut=DataArrayInt::New();
2346 pflOut->alloc(nbOfElems,1);
2351 pflOut=const_cast<DataArrayInt*>(pflIn);
2354 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2355 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2356 const std::vector<std::string>& infos=getInfo();
2357 int nbOfComp=infos.size();
2358 for(int i=0;i<nbOfComp;i++)
2359 da->setInfoOnComponent(i,infos[i].c_str());
2364 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2365 _mesh_csit(meshCsit),_father(fath)
2367 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2368 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2369 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2370 for(int i=0;i<MED_N_CELL_FIXED_GEO;i++)
2372 int nbProfile =MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[i],_mesh_csit,meshName,pflName,locName);
2373 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2374 int nbProfile2=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
2375 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2376 if(nbProfile>0 || nbProfile2>0)
2378 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[i],nasc));
2385 int nbProfile=MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
2388 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc));
2389 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2393 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2395 copyTinyInfoFrom(mesh);
2398 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const char *pflName)
2400 if(id>=(int)_pfls.size())
2402 _pfls[id]=DataArrayInt::New();
2403 int lgth=MEDprofileSizeByName(fid,pflName);
2404 _pfls[id]->setName(pflName);
2405 _pfls[id]->alloc(lgth,1);
2406 MEDprofileRd(fid,pflName,_pfls[id]->getPointer());
2407 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2410 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2412 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2414 MEDprofileInfo(fid,i+1,pflName,&sz);
2415 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2416 if(i>=(int)_pfls.size())
2418 _pfls[i]=DataArrayInt::New();
2419 _pfls[i]->alloc(sz,1);
2420 _pfls[i]->setName(pflCpp.c_str());
2421 MEDprofileRd(fid,pflName,_pfls[i]->getPointer());
2422 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2425 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2427 int nbOfPfls=_pfls.size();
2428 for(int i=0;i<nbOfPfls;i++)
2430 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2431 cpy->applyLin(1,1,0);
2432 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2433 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2434 MEDprofileWr(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer());
2437 int nbOfLocs=_locs.size();
2438 for(int i=0;i<nbOfLocs;i++)
2439 _locs[i]->writeLL(fid);
2442 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2444 std::vector<std::string> pfls=getPfls();
2445 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2447 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2450 _pfls.push_back(*it);
2454 int id=std::distance(pfls.begin(),it2);
2455 if(!(*it)->isEqual(*_pfls[id]))
2457 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2458 throw INTERP_KERNEL::Exception(oss.str().c_str());
2462 std::vector<std::string> locs=getLocs();
2463 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2465 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2468 _locs.push_back(*it);
2472 int id=std::distance(locs.begin(),it2);
2473 if(!(*it)->isEqual(*_locs[id],eps))
2475 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2476 throw INTERP_KERNEL::Exception(oss.str().c_str());
2482 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2484 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2485 getProfile((*it).c_str());
2488 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2490 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2491 getLocalization((*it).c_str());
2494 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2496 std::vector<std::string> profiles=real.getPflsReallyUsed();
2497 int sz=profiles.size();
2499 for(int i=0;i<sz;i++)
2500 loadProfileInFile(fid,i,profiles[i].c_str());
2502 std::vector<std::string> locs=real.getLocsReallyUsed();
2505 for(int i=0;i<sz;i++)
2506 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2509 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2511 int nProfil=MEDnProfile(fid);
2512 for(int i=0;i<nProfil;i++)
2513 loadProfileInFile(fid,i);
2514 int sz=MEDnLocalization(fid);
2516 for(int i=0;i<sz;i++)
2518 _locs[i]=MEDFileFieldLoc::New(fid,i);
2522 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const char *fname)
2524 return new MEDFileFieldGlobs(fname);
2527 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2529 return new MEDFileFieldGlobs;
2532 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2534 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2537 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildren() const
2539 std::vector<const BigMemoryObject *> ret;
2540 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2542 const DataArrayInt *cur(*it);
2546 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2548 const MEDFileFieldLoc *cur(*it);
2555 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2557 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2559 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2561 if((const DataArrayInt *)*it)
2562 ret->_pfls[i]=(*it)->deepCpy();
2565 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2567 if((const MEDFileFieldLoc*)*it)
2568 ret->_locs[i]=(*it)->deepCpy();
2574 * \throw if a profile in \a pfls in not in \a this.
2575 * \throw if a localization in \a locs in not in \a this.
2576 * \sa MEDFileFieldGlobs::deepCpyPart
2578 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2580 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2581 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2583 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2585 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2587 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2588 ret->_pfls.push_back(pfl2);
2590 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2592 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2594 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2596 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2597 ret->_locs.push_back(loc2);
2599 ret->setFileName(getFileName());
2604 * \throw if a profile in \a pfls in not in \a this.
2605 * \throw if a localization in \a locs in not in \a this.
2606 * \sa MEDFileFieldGlobs::shallowCpyPart
2608 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2610 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2611 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2613 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2615 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2616 ret->_pfls.push_back(pfl->deepCpy());
2618 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2620 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2622 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2623 ret->_locs.push_back(loc->deepCpy());
2625 ret->setFileName(getFileName());
2629 MEDFileFieldGlobs::MEDFileFieldGlobs(const char *fname):_file_name(fname)
2633 MEDFileFieldGlobs::MEDFileFieldGlobs()
2637 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2641 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2643 oss << "Profiles :\n";
2644 std::size_t n=_pfls.size();
2645 for(std::size_t i=0;i<n;i++)
2647 oss << " - #" << i << " ";
2648 const DataArrayInt *pfl=_pfls[i];
2650 oss << "\"" << pfl->getName() << "\"\n";
2655 oss << "Localizations :\n";
2656 for(std::size_t i=0;i<n;i++)
2658 oss << " - #" << i << " ";
2659 const MEDFileFieldLoc *loc=_locs[i];
2661 loc->simpleRepr(oss);
2667 void MEDFileFieldGlobs::setFileName(const char *fileName)
2669 _file_name=fileName;
2672 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2674 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2676 DataArrayInt *elt(*it);
2679 std::string name(elt->getName());
2680 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2682 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2684 elt->setName((*it2).second.c_str());
2692 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2694 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2696 MEDFileFieldLoc *elt(*it);
2699 std::string name(elt->getName());
2700 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2702 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2704 elt->setName((*it2).second.c_str());
2712 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2714 if(locId<0 || locId>=(int)_locs.size())
2715 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2716 return _locs[locId]->getNbOfGaussPtPerCell();
2719 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName) const
2721 return getLocalizationFromId(getLocalizationId(locName));
2724 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2726 if(locId<0 || locId>=(int)_locs.size())
2727 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2728 return *_locs[locId];
2731 namespace ParaMEDMEMImpl
2736 LocFinder(const char *loc):_loc(loc) { }
2737 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2745 PflFinder(const std::string& pfl):_pfl(pfl) { }
2746 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2748 const std::string& _pfl;
2752 int MEDFileFieldGlobs::getLocalizationId(const char *loc) const
2754 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2757 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2758 for(it=_locs.begin();it!=_locs.end();it++)
2759 oss << "\"" << (*it)->getName() << "\", ";
2760 throw INTERP_KERNEL::Exception(oss.str().c_str());
2762 return std::distance(_locs.begin(),it);
2766 * The returned value is never null.
2768 const DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName) const
2770 std::string pflNameCpp(pflName);
2771 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2774 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2775 for(it=_pfls.begin();it!=_pfls.end();it++)
2776 oss << "\"" << (*it)->getName() << "\", ";
2777 throw INTERP_KERNEL::Exception(oss.str().c_str());
2782 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2784 if(pflId<0 || pflId>=(int)_pfls.size())
2785 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2786 return _pfls[pflId];
2789 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
2791 if(locId<0 || locId>=(int)_locs.size())
2792 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2793 return *_locs[locId];
2796 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const char *locName)
2798 return getLocalizationFromId(getLocalizationId(locName));
2802 * The returned value is never null.
2804 DataArrayInt *MEDFileFieldGlobs::getProfile(const char *pflName)
2806 std::string pflNameCpp(pflName);
2807 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2810 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2811 for(it=_pfls.begin();it!=_pfls.end();it++)
2812 oss << "\"" << (*it)->getName() << "\", ";
2813 throw INTERP_KERNEL::Exception(oss.str().c_str());
2818 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
2820 if(pflId<0 || pflId>=(int)_pfls.size())
2821 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2822 return _pfls[pflId];
2825 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
2827 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
2829 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2831 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
2832 newPfls.push_back(*it);
2837 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
2839 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
2841 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2843 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
2844 newLocs.push_back(*it);
2849 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
2851 int sz=_pfls.size();
2852 std::vector<std::string> ret(sz);
2853 for(int i=0;i<sz;i++)
2854 ret[i]=_pfls[i]->getName();
2858 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
2860 int sz=_locs.size();
2861 std::vector<std::string> ret(sz);
2862 for(int i=0;i<sz;i++)
2863 ret[i]=_locs[i]->getName();
2867 bool MEDFileFieldGlobs::existsPfl(const char *pflName) const
2869 std::vector<std::string> v=getPfls();
2870 std::string s(pflName);
2871 return std::find(v.begin(),v.end(),s)!=v.end();
2874 bool MEDFileFieldGlobs::existsLoc(const char *locName) const
2876 std::vector<std::string> v=getLocs();
2877 std::string s(locName);
2878 return std::find(v.begin(),v.end(),s)!=v.end();
2881 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
2883 std::map<int,std::vector<int> > m;
2885 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2887 const DataArrayInt *tmp=(*it);
2890 m[tmp->getHashCode()].push_back(i);
2893 std::vector< std::vector<int> > ret;
2894 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
2896 if((*it2).second.size()>1)
2898 std::vector<int> ret0;
2899 bool equalityOrNot=false;
2900 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
2902 std::vector<int>::const_iterator it4=it3; it4++;
2903 for(;it4!=(*it2).second.end();it4++)
2905 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
2908 ret0.push_back(*it3);
2909 ret0.push_back(*it4);
2915 ret.push_back(ret0);
2921 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
2923 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
2926 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
2928 std::string name(pfl->getName());
2930 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
2931 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2932 if(name==(*it)->getName())
2934 if(!pfl->isEqual(*(*it)))
2936 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
2937 throw INTERP_KERNEL::Exception(oss.str().c_str());
2941 _pfls.push_back(pfl);
2944 void MEDFileFieldGlobs::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
2946 std::string name(locName);
2948 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
2949 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
2950 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2951 if((*it)->isName(locName))
2953 if(!(*it)->isEqual(*obj,1e-12))
2955 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
2956 throw INTERP_KERNEL::Exception(oss.str().c_str());
2959 _locs.push_back(obj);
2962 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
2964 std::vector<std::string> names=getPfls();
2965 return CreateNewNameNotIn("NewPfl_",names);
2968 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
2970 std::vector<std::string> names=getLocs();
2971 return CreateNewNameNotIn("NewLoc_",names);
2974 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid)
2976 for(std::size_t sz=0;sz<100000;sz++)
2978 std::ostringstream tryName;
2979 tryName << prefix << sz;
2980 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
2981 return tryName.str();
2983 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
2987 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
2988 * \param [in] fname - the file name.
2990 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const char *fname):_globals(MEDFileFieldGlobs::New(fname))
2995 * Creates an empty MEDFileFieldGlobsReal.
2997 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3001 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3006 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildren() const
3008 std::vector<const BigMemoryObject *> ret;
3009 if((const MEDFileFieldGlobs *)_globals)
3010 ret.push_back((const MEDFileFieldGlobs *)_globals);
3015 * Returns a string describing profiles and Gauss points held in \a this.
3016 * \return std::string - the description string.
3018 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3020 const MEDFileFieldGlobs *glob=_globals;
3021 std::ostringstream oss2; oss2 << glob;
3022 std::string stars(oss2.str().length(),'*');
3023 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3025 glob->simpleRepr(oss);
3027 oss << "NO GLOBAL INFORMATION !\n";
3030 void MEDFileFieldGlobsReal::resetContent()
3032 _globals=MEDFileFieldGlobs::New();
3035 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3040 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3041 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3043 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3045 _globals=other._globals;
3049 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3050 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3052 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3054 const MEDFileFieldGlobs *otherg(other._globals);
3057 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3061 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3062 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3064 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3066 const MEDFileFieldGlobs *otherg(other._globals);
3069 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3072 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3074 _globals=other._globals;
3075 if((const MEDFileFieldGlobs *)_globals)
3076 _globals=other._globals->deepCpy();
3080 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3081 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3082 * \param [in] eps - a precision used to compare Gauss points with same name held by
3083 * \a this and \a other MEDFileFieldGlobsReal.
3084 * \throw If \a this and \a other hold profiles with equal names but different ids.
3085 * \throw If \a this and \a other hold different Gauss points with equal names.
3087 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3089 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3090 if(thisGlobals==otherGlobals)
3094 _globals=other._globals;
3097 _globals->appendGlobs(*other._globals,eps);
3100 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3102 checkGlobsPflsPartCoherency();
3103 checkGlobsLocsPartCoherency();
3106 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3108 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3111 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3113 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3116 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const char *pflName)
3118 contentNotNull()->loadProfileInFile(fid,id,pflName);
3121 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3123 contentNotNull()->loadProfileInFile(fid,id);
3126 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3128 contentNotNull()->loadGlobals(fid,*this);
3131 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3133 contentNotNull()->loadAllGlobals(fid);
3136 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3138 contentNotNull()->writeGlobals(fid,opt);
3142 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3143 * or getPflsReallyUsedMulti().
3144 * \return std::vector<std::string> - a sequence of names of all profiles.
3146 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3148 return contentNotNull()->getPfls();
3152 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3153 * or getLocsReallyUsedMulti().
3154 * \return std::vector<std::string> - a sequence of names of all localizations.
3156 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3158 return contentNotNull()->getLocs();
3162 * Checks if the profile with a given name exists.
3163 * \param [in] pflName - the profile name of interest.
3164 * \return bool - \c true if the profile named \a pflName exists.
3166 bool MEDFileFieldGlobsReal::existsPfl(const char *pflName) const
3168 return contentNotNull()->existsPfl(pflName);
3172 * Checks if the localization with a given name exists.
3173 * \param [in] locName - the localization name of interest.
3174 * \return bool - \c true if the localization named \a locName exists.
3176 bool MEDFileFieldGlobsReal::existsLoc(const char *locName) const
3178 return contentNotNull()->existsLoc(locName);
3181 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3183 return contentNotNull()->createNewNameOfPfl();
3186 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3188 return contentNotNull()->createNewNameOfLoc();
3192 * Sets the name of a MED file.
3193 * \param [inout] fileName - the file name.
3195 void MEDFileFieldGlobsReal::setFileName(const char *fileName)
3197 contentNotNull()->setFileName(fileName);
3201 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3202 * in the same order.
3203 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3204 * Each item of this sequence is a vector containing ids of equal profiles.
3206 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3208 return contentNotNull()->whichAreEqualProfiles();
3212 * Finds equal localizations.
3213 * \param [in] eps - a precision used to compare real values of the localizations.
3214 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3215 * Each item of this sequence is a vector containing ids of equal localizations.
3217 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3219 return contentNotNull()->whichAreEqualLocs(eps);
3223 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3224 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3225 * this sequence is a pair whose
3226 * - the first item is a vector of profile names to replace by the second item,
3227 * - the second item is a profile name to replace every profile name of the first item.
3229 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3231 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3235 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3236 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3237 * this sequence is a pair whose
3238 * - the first item is a vector of localization names to replace by the second item,
3239 * - the second item is a localization name to replace every localization name of the first item.
3241 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3243 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3247 * Replaces references to some profiles (a reference is a profile name) by references
3248 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3249 * them-selves accordingly. <br>
3250 * This method is a generalization of changePflName().
3251 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3252 * this sequence is a pair whose
3253 * - the first item is a vector of profile names to replace by the second item,
3254 * - the second item is a profile name to replace every profile of the first item.
3255 * \sa changePflsRefsNamesGen()
3256 * \sa changePflName()
3258 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3260 changePflsRefsNamesGen(mapOfModif);
3261 changePflsNamesInStruct(mapOfModif);
3265 * Replaces references to some localizations (a reference is a localization name) by references
3266 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3267 * them-selves accordingly. <br>
3268 * This method is a generalization of changeLocName().
3269 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3270 * this sequence is a pair whose
3271 * - the first item is a vector of localization names to replace by the second item,
3272 * - the second item is a localization name to replace every localization of the first item.
3273 * \sa changeLocsRefsNamesGen()
3274 * \sa changeLocName()
3276 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3278 changeLocsRefsNamesGen(mapOfModif);
3279 changeLocsNamesInStruct(mapOfModif);
3283 * Renames the profile having a given name and updates references to this profile.
3284 * \param [in] oldName - the name of the profile to rename.
3285 * \param [in] newName - a new name of the profile.
3286 * \sa changePflsNames().
3288 void MEDFileFieldGlobsReal::changePflName(const char *oldName, const char *newName)
3290 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3291 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3293 changePflsNames(mapOfModif);
3297 * Renames the localization having a given name and updates references to this localization.
3298 * \param [in] oldName - the name of the localization to rename.
3299 * \param [in] newName - a new name of the localization.
3300 * \sa changeLocsNames().
3302 void MEDFileFieldGlobsReal::changeLocName(const char *oldName, const char *newName)
3304 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3305 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3307 changeLocsNames(mapOfModif);
3311 * Removes duplicated profiles. Returns a map used to update references to removed
3312 * profiles via changePflsRefsNamesGen().
3313 * Equal profiles are found using whichAreEqualProfiles().
3314 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3315 * a sequence describing the performed replacements of profiles. Each element of
3316 * this sequence is a pair whose
3317 * - the first item is a vector of profile names replaced by the second item,
3318 * - the second item is a profile name replacing every profile of the first item.
3320 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3322 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3323 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3325 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3327 std::vector< std::string > tmp((*it).size());
3329 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3330 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3331 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3333 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3334 killProfileIds(tmp2);
3336 changePflsRefsNamesGen(ret);
3341 * Removes duplicated localizations. Returns a map used to update references to removed
3342 * localizations via changeLocsRefsNamesGen().
3343 * Equal localizations are found using whichAreEqualLocs().
3344 * \param [in] eps - a precision used to compare real values of the localizations.
3345 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3346 * a sequence describing the performed replacements of localizations. Each element of
3347 * this sequence is a pair whose
3348 * - the first item is a vector of localization names replaced by the second item,
3349 * - the second item is a localization name replacing every localization of the first item.
3351 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3353 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3354 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3356 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3358 std::vector< std::string > tmp((*it).size());
3360 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3361 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3362 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3364 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3365 killLocalizationIds(tmp2);
3367 changeLocsRefsNamesGen(ret);
3372 * Returns number of Gauss points per cell in a given localization.
3373 * \param [in] locId - an id of the localization of interest.
3374 * \return int - the number of the Gauss points per cell.
3376 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3378 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3382 * Returns an id of a localization by its name.
3383 * \param [in] loc - the localization name of interest.
3384 * \return int - the id of the localization.
3385 * \throw If there is no a localization named \a loc.
3387 int MEDFileFieldGlobsReal::getLocalizationId(const char *loc) const
3389 return contentNotNull()->getLocalizationId(loc);
3393 * Returns the name of the MED file.
3394 * \return const char * - the MED file name.
3396 const char *MEDFileFieldGlobsReal::getFileName() const
3398 return contentNotNull()->getFileName();
3401 std::string MEDFileFieldGlobsReal::getFileName2() const
3403 return contentNotNull()->getFileName2();
3407 * Returns a localization object by its name.
3408 * \param [in] locName - the name of the localization of interest.
3409 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3410 * \throw If there is no a localization named \a locName.
3412 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName) const
3414 return contentNotNull()->getLocalization(locName);
3418 * Returns a localization object by its id.
3419 * \param [in] locId - the id of the localization of interest.
3420 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3421 * \throw If there is no a localization with id \a locId.
3423 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3425 return contentNotNull()->getLocalizationFromId(locId);
3429 * Returns a profile array by its name.
3430 * \param [in] pflName - the name of the profile of interest.
3431 * \return const DataArrayInt * - the profile array having the name \a pflName.
3432 * \throw If there is no a profile named \a pflName.
3434 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName) const
3436 return contentNotNull()->getProfile(pflName);
3440 * Returns a profile array by its id.
3441 * \param [in] pflId - the id of the profile of interest.
3442 * \return const DataArrayInt * - the profile array having the id \a pflId.
3443 * \throw If there is no a profile with id \a pflId.
3445 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3447 return contentNotNull()->getProfileFromId(pflId);
3451 * Returns a localization object, apt for modification, by its id.
3452 * \param [in] locId - the id of the localization of interest.
3453 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3454 * having the id \a locId.
3455 * \throw If there is no a localization with id \a locId.
3457 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3459 return contentNotNull()->getLocalizationFromId(locId);
3463 * Returns a localization object, apt for modification, by its name.
3464 * \param [in] locName - the name of the localization of interest.
3465 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3466 * having the name \a locName.
3467 * \throw If there is no a localization named \a locName.
3469 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const char *locName)
3471 return contentNotNull()->getLocalization(locName);
3475 * Returns a profile array, apt for modification, by its name.
3476 * \param [in] pflName - the name of the profile of interest.
3477 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3478 * \throw If there is no a profile named \a pflName.
3480 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const char *pflName)
3482 return contentNotNull()->getProfile(pflName);
3486 * Returns a profile array, apt for modification, by its id.
3487 * \param [in] pflId - the id of the profile of interest.
3488 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3489 * \throw If there is no a profile with id \a pflId.
3491 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3493 return contentNotNull()->getProfileFromId(pflId);
3497 * Removes profiles given by their ids. No data is updated to track this removal.
3498 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3500 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3502 contentNotNull()->killProfileIds(pflIds);
3506 * Removes localizations given by their ids. No data is updated to track this removal.
3507 * \param [in] locIds - a sequence of ids of the localizations to remove.
3509 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3511 contentNotNull()->killLocalizationIds(locIds);
3515 * Stores a profile array.
3516 * \param [in] pfl - the profile array to store.
3517 * \throw If the name of \a pfl is empty.
3518 * \throw If a profile with the same name as that of \a pfl already exists but contains
3521 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3523 contentNotNull()->appendProfile(pfl);
3527 * Adds a new localization of Gauss points.
3528 * \param [in] locName - the name of the new localization.
3529 * \param [in] geoType - a geometrical type of the reference cell.
3530 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3531 * must be \c nbOfNodesPerCell * \c dimOfType.
3532 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3533 * must be _wg_.size() * \c dimOfType.
3534 * \param [in] w - the weights of Gauss points.
3535 * \throw If \a locName is empty.
3536 * \throw If a localization with the name \a locName already exists but is
3537 * different form the new one.
3539 void MEDFileFieldGlobsReal::appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
3541 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3544 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3546 MEDFileFieldGlobs *g(_globals);
3548 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3552 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3554 const MEDFileFieldGlobs *g(_globals);
3556 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3560 //= MEDFileFieldNameScope
3562 MEDFileFieldNameScope::MEDFileFieldNameScope()
3566 MEDFileFieldNameScope::MEDFileFieldNameScope(const char *fieldName):_name(fieldName)
3571 * Returns the name of \a this field.
3572 * \return std::string - a string containing the field name.
3574 std::string MEDFileFieldNameScope::getName() const
3580 * Sets name of \a this field
3581 * \param [in] name - the new field name.
3583 void MEDFileFieldNameScope::setName(const char *fieldName)
3588 std::string MEDFileFieldNameScope::getDtUnit() const
3593 void MEDFileFieldNameScope::setDtUnit(const char *dtUnit)
3598 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3601 _dt_unit=other._dt_unit;
3604 //= MEDFileAnyTypeField1TSWithoutSDA
3606 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3608 _field_per_mesh.resize(other._field_per_mesh.size());
3610 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3612 if((const MEDFileFieldPerMesh *)*it)
3613 _field_per_mesh[i]=(*it)->deepCpy(this);
3618 * Prints a string describing \a this field into a stream. This string is outputted
3619 * by \c print Python command.
3620 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3621 * \param [in,out] oss - the out stream.
3622 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3623 * info id printed, else, not.
3625 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3627 std::string startOfLine(bkOffset,' ');
3628 oss << startOfLine << "Field ";
3630 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3631 oss << "on one time Step ";
3633 oss << "(" << f1tsId << ") ";
3634 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3635 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3636 const DataArray *arr=getUndergroundDataArray();
3639 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3642 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3643 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3644 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3646 if(arr->isAllocated())
3648 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3651 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3655 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3657 oss << startOfLine << "----------------------" << std::endl;
3658 if(!_field_per_mesh.empty())
3661 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3663 const MEDFileFieldPerMesh *cur=(*it2);
3665 cur->simpleRepr(bkOffset,oss,i);
3667 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3672 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3674 oss << startOfLine << "----------------------" << std::endl;
3677 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3679 const DataArray *arr(getUndergroundDataArray());
3681 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3682 int nbOfCompo=arr->getNumberOfComponents();
3683 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3684 for(int i=0;i<nbOfCompo;i++)
3687 std::vector<int> v(1,i);
3688 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3689 ret[i]->setArray(arr2);
3694 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
3698 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3703 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3704 * empty. Returns -1 if this in on nodes.
3705 * \return int - the dimension of \a this.
3707 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3710 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3711 (*it)->getDimension(ret);
3716 * Returns the mesh name.
3717 * \return std::string - a string holding the mesh name.
3718 * \throw If \c _field_per_mesh.empty()
3720 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3722 if(_field_per_mesh.empty())
3723 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3724 return _field_per_mesh[0]->getMeshName();
3727 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const char *newMeshName)
3729 std::string oldName(getMeshName());
3730 std::vector< std::pair<std::string,std::string> > v(1);
3731 v[0].first=oldName; v[0].second=newMeshName;
3735 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3738 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3740 MEDFileFieldPerMesh *cur(*it);
3742 ret=cur->changeMeshNames(modifTab) || ret;
3748 * Returns the number of iteration of the state of underlying mesh.
3749 * \return int - the iteration number.
3750 * \throw If \c _field_per_mesh.empty()
3752 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3754 if(_field_per_mesh.empty())
3755 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3756 return _field_per_mesh[0]->getMeshIteration();
3760 * Returns the order number of iteration of the state of underlying mesh.
3761 * \return int - the order number.
3762 * \throw If \c _field_per_mesh.empty()
3764 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3766 if(_field_per_mesh.empty())
3767 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3768 return _field_per_mesh[0]->getMeshOrder();
3772 * Checks if \a this field is tagged by a given iteration number and a given
3773 * iteration order number.
3774 * \param [in] iteration - the iteration number of interest.
3775 * \param [in] order - the iteration order number of interest.
3776 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3777 * \a this->getOrder() == \a order.
3779 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3781 return iteration==_iteration && order==_order;
3785 * Returns number of iteration and order number of iteration when
3786 * \a this field has been calculated.
3787 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3790 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3792 std::pair<int,int> p;
3798 * Returns number of iteration and order number of iteration when
3799 * \a this field has been calculated.
3800 * \param [in,out] p - a pair returning the iteration number and the iteration
3803 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
3810 * Returns all types of spatial discretization of \a this field.
3811 * \param [in,out] types - a sequence of types of \a this field.
3813 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
3815 std::set<TypeOfField> types2;
3816 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3818 (*it)->fillTypesOfFieldAvailable(types2);
3820 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
3821 std::copy(types2.begin(),types2.end(),bi);
3825 * Returns all types of spatial discretization of \a this field.
3826 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
3829 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
3831 std::vector<TypeOfField> ret;
3832 fillTypesOfFieldAvailable(ret);
3836 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
3838 std::vector<std::string> ret;
3839 std::set<std::string> ret2;
3840 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3842 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
3843 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3844 if(ret2.find(*it2)==ret2.end())
3846 ret.push_back(*it2);
3853 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
3855 std::vector<std::string> ret;
3856 std::set<std::string> ret2;
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)->getLocsReallyUsed();
3860 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
3861 if(ret2.find(*it2)==ret2.end())
3863 ret.push_back(*it2);
3870 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
3872 std::vector<std::string> ret;
3873 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3875 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
3876 ret.insert(ret.end(),tmp.begin(),tmp.end());
3881 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
3883 std::vector<std::string> ret;
3884 std::set<std::string> ret2;
3885 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3887 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
3888 ret.insert(ret.end(),tmp.begin(),tmp.end());
3893 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3895 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3896 (*it)->changePflsRefsNamesGen(mapOfModif);
3899 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3901 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3902 (*it)->changeLocsRefsNamesGen(mapOfModif);
3906 * Returns all attributes of parts of \a this field lying on a given mesh.
3907 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
3908 * item of every of returned sequences refers to the _i_-th part of \a this field.
3909 * Thus all sequences returned by this method are of the same length equal to number
3910 * of different types of supporting entities.<br>
3911 * A field part can include sub-parts with several different spatial discretizations,
3912 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
3913 * for example. Hence, some of the returned sequences contains nested sequences, and an item
3914 * of a nested sequence corresponds to a type of spatial discretization.<br>
3915 * This method allows for iteration over MEDFile DataStructure without any overhead.
3916 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3917 * for the case with only one underlying mesh. (Actually, the number of meshes is
3918 * not checked if \a mname == \c NULL).
3919 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
3920 * a field part is returned.
3921 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
3922 * This sequence is of the same length as \a types.
3923 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
3924 * discretization. A profile name can be empty.
3925 * Length of this and of nested sequences is the same as that of \a typesF.
3926 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
3927 * discretization. A localization name can be empty.
3928 * Length of this and of nested sequences is the same as that of \a typesF.
3929 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
3930 * of ids of tuples within the data array, per each type of spatial
3931 * discretization within one mesh entity type.
3932 * Length of this and of nested sequences is the same as that of \a typesF.
3933 * \throw If no field is lying on \a mname.
3935 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
3939 meshId=getMeshIdFromMeshName(mname);
3941 if(_field_per_mesh.empty())
3942 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
3943 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3947 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
3948 * maximal absolute dimension and values returned via the out parameter \a levs are
3949 * dimensions relative to the maximal absolute dimension. <br>
3950 * This method is designed for MEDFileField1TS instances that have a discretization
3951 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
3952 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
3953 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
3954 * Only these 3 discretizations will be taken into account here. If \a this is
3955 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
3956 * This method is useful to make the link between the dimension of the underlying mesh
3957 * and the levels of \a this, because it is possible that the highest dimension of \a this
3958 * field is not equal to the dimension of the underlying mesh.
3960 * Let's consider the following case:
3961 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
3962 * TETRA4, HEXA8, TRI3 and SEG2.
3963 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
3964 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
3966 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
3967 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
3968 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
3969 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
3970 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
3971 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
3973 * to retrieve the highest level of
3974 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
3975 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
3976 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
3977 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
3978 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
3979 * for the case with only one underlying mesh. (Actually, the number of meshes is
3980 * not checked if \a mname == \c NULL).
3981 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
3982 * absolute one. They are in decreasing order. This sequence is cleared before
3984 * \return int - the maximal absolute dimension of elements \a this fields lies on.
3985 * \throw If no field is lying on \a mname.
3987 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const
3990 int meshId=getMeshIdFromMeshName(mname);
3991 std::vector<INTERP_KERNEL::NormalizedCellType> types;
3992 std::vector< std::vector<TypeOfField> > typesF;
3993 std::vector< std::vector<std::string> > pfls, locs;
3994 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
3996 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
3997 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
3998 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4000 st.erase(INTERP_KERNEL::NORM_ERROR);
4002 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4004 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4005 ret1.insert((int)cm.getDimension());
4007 int ret=*std::max_element(ret1.begin(),ret1.end());
4008 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4009 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4014 * \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.
4015 * \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.
4016 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4017 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4019 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4021 int mid=getMeshIdFromMeshName(mName);
4022 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4026 * \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.
4027 * \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.
4028 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4029 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4031 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4033 int mid=getMeshIdFromMeshName(mName);
4034 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4038 * \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.
4040 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const char *mName) const
4042 if(_field_per_mesh.empty())
4043 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4046 std::string mName2(mName);
4048 std::vector<std::string> msg;
4049 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4050 if(mName2==(*it)->getMeshName())
4053 msg.push_back((*it)->getMeshName());
4054 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4055 oss << "Possible meshes are : ";
4056 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4057 oss << "\"" << (*it2) << "\" ";
4058 throw INTERP_KERNEL::Exception(oss.str().c_str());
4061 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4064 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4065 std::string tmp(mesh->getName());
4067 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4068 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4070 for(;it!=_field_per_mesh.end();it++,i++)
4072 if((*it)->getMeshName()==tmp)
4075 int sz=_field_per_mesh.size();
4076 _field_per_mesh.resize(sz+1);
4077 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4081 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4082 MEDFileFieldGlobsReal& glob)
4085 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4087 MEDFileFieldPerMesh *fpm(*it);
4089 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4094 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4096 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4097 std::vector< std::vector<TypeOfField> > typesF;
4098 std::vector< std::vector<std::string> > pfls,locs;
4099 std::vector< std::vector<std::pair<int,int> > > bgEnd=getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs);
4100 std::set<TypeOfField> allEnt;
4101 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4102 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4103 allEnt.insert(*it2);
4104 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4105 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4106 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4108 std::vector< std::pair<int,int> > its;
4109 ret[i]=shallowCpy();
4110 int newLgth=ret[i]->keepOnlySpatialDiscretization(*it3,its);
4111 ret[i]->updateData(newLgth,its);
4116 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4118 int globalCounter=0;
4119 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4120 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4121 return globalCounter;
4124 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4126 if(_nb_of_tuples_to_be_allocated>=0)
4128 _nb_of_tuples_to_be_allocated=newLgth;
4131 if(_nb_of_tuples_to_be_allocated==-1)
4133 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4135 const DataArray *oldArr=getUndergroundDataArray();
4136 if(!oldArr || !oldArr->isAllocated())
4137 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4138 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr=createNewEmptyDataArrayInstance();
4139 newArr->alloc(newLgth,getNumberOfComponents());
4141 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4143 if((*it).second<(*it).first)
4144 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4145 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4146 pos+=(*it).second-(*it).first;
4151 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4154 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4156 if(_field_per_mesh.empty())
4157 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4158 if(_field_per_mesh.size()>1)
4159 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4160 _field_per_mesh[0]->copyOptionsFrom(opts);
4161 _field_per_mesh[0]->writeLL(fid,nasc);
4165 * 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.
4166 * If false is returned the memory allocation is not required.
4168 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4170 if(_nb_of_tuples_to_be_allocated>=0)
4172 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4173 _nb_of_tuples_to_be_allocated=-2;
4176 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4178 if(_nb_of_tuples_to_be_allocated==-1)
4179 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4180 if(_nb_of_tuples_to_be_allocated<-3)
4181 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4182 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4185 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4187 med_int numdt,numit;
4191 med_int meshnumdt,meshnumit;
4192 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4193 MEDfieldComputingStepInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt);
4194 MEDfield23ComputingStepMeshInfo(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit);
4195 if(_iteration!=numdt || _order!=numit)
4196 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4197 _field_per_mesh.resize(nmesh);
4198 for(int i=0;i<nmesh;i++)
4199 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i+1,meshnumdt,meshnumit,nasc);//tony
4200 _nb_of_tuples_to_be_allocated=0;
4201 for(int i=0;i<nmesh;i++)
4202 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4205 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4207 allocIfNecessaryTheArrayToReceiveDataFromFile();
4208 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4209 (*it)->loadBigArraysRecursively(fid,nasc);
4212 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4214 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4215 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4216 (*it)->loadBigArraysRecursively(fid,nasc);
4219 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4221 loadOnlyStructureOfDataRecursively(fid,nasc);
4222 loadBigArraysRecursively(fid,nasc);
4225 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4227 DataArray *thisArr(getUndergroundDataArray());
4228 if(thisArr && thisArr->isAllocated())
4230 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4231 thisArr->desallocate();
4235 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4237 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4240 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildren() const
4242 std::vector<const BigMemoryObject *> ret;
4243 if(getUndergroundDataArray())
4244 ret.push_back(getUndergroundDataArray());
4245 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4247 const MEDFileFieldPerMesh *cur(*it);
4255 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4256 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4257 * "Sort By Type"), if not, an exception is thrown.
4258 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4259 * \param [in] arr - the array of values.
4260 * \param [in,out] glob - the global data where profiles and localization present in
4261 * \a field, if any, are added.
4262 * \throw If the name of \a field is empty.
4263 * \throw If the data array of \a field is not set.
4264 * \throw If \a this->_arr is already allocated but has different number of components
4266 * \throw If the underlying mesh of \a field has no name.
4267 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4269 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4271 const MEDCouplingMesh *mesh=field->getMesh();
4273 TypeOfField type=field->getTypeOfField();
4274 std::vector<DataArrayInt *> dummy;
4275 int start=copyTinyInfoFrom(field,arr);
4276 int pos=addNewEntryIfNecessary(mesh);
4279 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4280 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4283 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4287 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4288 * of a given mesh are used as the support of the given field (a real support is not used).
4289 * Elements of the given mesh must be sorted suitable for writing to MED file.
4290 * Order of underlying mesh entities of the given field specified by \a profile parameter
4291 * is not prescribed; this method permutes field values to have them sorted by element
4292 * type as required for writing to MED file. A new profile is added only if no equal
4293 * profile is missing.
4294 * \param [in] field - the field to add to \a this. The field double values are ignored.
4295 * \param [in] arrOfVals - the values of the field \a field used.
4296 * \param [in] mesh - the supporting mesh of \a field.
4297 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4298 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4299 * \param [in,out] glob - the global data where profiles and localization present in
4300 * \a field, if any, are added.
4301 * \throw If either \a field or \a mesh or \a profile has an empty name.
4302 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4303 * \throw If the data array of \a field is not set.
4304 * \throw If \a this->_arr is already allocated but has different number of components
4306 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4307 * \sa setFieldNoProfileSBT()
4309 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4312 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4313 if(!arrOfVals || !arrOfVals->isAllocated())
4314 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4315 TypeOfField type=field->getTypeOfField();
4316 std::vector<DataArrayInt *> idsInPflPerType;
4317 std::vector<DataArrayInt *> idsPerType;
4318 std::vector<int> code,code2;
4319 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4322 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4323 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4324 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4325 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4327 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4328 if(type==ON_GAUSS_NE)
4330 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mPart=m->buildPart(profile->begin(),profile->end());
4331 field2->setMesh(mPart);
4333 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4334 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4336 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4337 throw INTERP_KERNEL::Exception(oss.str().c_str());
4340 int start=copyTinyInfoFrom(field,arrOfVals);
4341 code2=m->getDistributionOfTypes();
4343 int pos=addNewEntryIfNecessary(m);
4344 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4348 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4349 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4350 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4351 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4352 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4353 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4355 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4356 throw INTERP_KERNEL::Exception(oss.str().c_str());
4358 int start=copyTinyInfoFrom(field,arrOfVals);
4359 int pos=addNewEntryIfNecessary(m);
4360 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4365 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4367 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4369 if(_nb_of_tuples_to_be_allocated>=0)
4370 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 !");
4371 DataArray *arr(getOrCreateAndGetArray());
4372 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4373 _nb_of_tuples_to_be_allocated=-3;
4377 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4378 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4379 * larger by the size of \a field. Returns an id of the first not filled
4380 * tuple of \a this->_arr.
4381 * \param [in] field - the field to copy the info on components and the name from.
4382 * \return int - the id of first not initialized tuple of \a this->_arr.
4383 * \throw If the name of \a field is empty.
4384 * \throw If the data array of \a field is not set.
4385 * \throw If \a this->_arr is already allocated but has different number of components
4388 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4391 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4392 std::string name(field->getName());
4393 setName(name.c_str());
4394 setDtUnit(field->getTimeUnit());
4396 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4398 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4399 if(!arr->isAllocated())
4400 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4401 _dt=field->getTime(_iteration,_order);
4402 int nbOfComponents=arr->getNumberOfComponents();
4403 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4404 if(!getOrCreateAndGetArray()->isAllocated())
4406 allocNotFromFile(arr->getNumberOfTuples());
4411 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4412 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4413 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4414 _nb_of_tuples_to_be_allocated=-3;
4415 return oldNbOfTuples;
4420 * Returns number of components in \a this field
4421 * \return int - the number of components.
4423 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4425 return getOrCreateAndGetArray()->getNumberOfComponents();
4429 * Change info on components in \a this.
4430 * \throw If size of \a infos is not equal to the number of components already in \a this.
4432 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4434 DataArray *arr=getOrCreateAndGetArray();
4435 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4439 * Returns info on components of \a this field.
4440 * \return const std::vector<std::string>& - a sequence of strings each being an
4441 * information on _i_-th component.
4443 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4445 const DataArray *arr=getOrCreateAndGetArray();
4446 return arr->getInfoOnComponents();
4450 * Returns a mutable info on components of \a this field.
4451 * \return std::vector<std::string>& - a sequence of strings each being an
4452 * information on _i_-th component.
4454 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4456 DataArray *arr=getOrCreateAndGetArray();
4457 return arr->getInfoOnComponents();
4461 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4462 * \param [in] type - a spatial discretization of the new field.
4463 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4464 * \param [in] mName - a name of the supporting mesh.
4465 * \param [in] renumPol - specifies how to permute values of the result field according to
4466 * the optional numbers of cells and nodes, if any. The valid values are
4467 * - 0 - do not permute.
4468 * - 1 - permute cells.
4469 * - 2 - permute nodes.
4470 * - 3 - permute cells and nodes.
4472 * \param [in] glob - the global data storing profiles and localization.
4473 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4474 * caller is to delete this field using decrRef() as it is no more needed.
4475 * \throw If the MED file is not readable.
4476 * \throw If there is no mesh named \a mName in the MED file.
4477 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4478 * \throw If no field of \a this is lying on the mesh \a mName.
4479 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4481 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4483 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4485 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4487 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4488 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4492 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4493 * \param [in] type - a spatial discretization of the new field.
4494 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4495 * \param [in] renumPol - specifies how to permute values of the result field according to
4496 * the optional numbers of cells and nodes, if any. The valid values are
4497 * - 0 - do not permute.
4498 * - 1 - permute cells.
4499 * - 2 - permute nodes.
4500 * - 3 - permute cells and nodes.
4502 * \param [in] glob - the global data storing profiles and localization.
4503 * \param [in] mesh - the supporting mesh.
4504 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4505 * caller is to delete this field using decrRef() as it is no more needed.
4506 * \throw If the MED file is not readable.
4507 * \throw If no field of \a this is lying on \a mesh.
4508 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4509 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4511 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4513 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4514 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4515 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4516 if(meshDimRelToMax==1)
4517 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4518 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4522 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4524 * \param [in] type - a spatial discretization of the new field.
4525 * \param [in] mName - a name of the supporting mesh.
4526 * \param [in] renumPol - specifies how to permute values of the result field according to
4527 * the optional numbers of cells and nodes, if any. The valid values are
4528 * - 0 - do not permute.
4529 * - 1 - permute cells.
4530 * - 2 - permute nodes.
4531 * - 3 - permute cells and nodes.
4533 * \param [in] glob - the global data storing profiles and localization.
4534 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4535 * caller is to delete this field using decrRef() as it is no more needed.
4536 * \throw If the MED file is not readable.
4537 * \throw If there is no mesh named \a mName in the MED file.
4538 * \throw If there are no mesh entities in the mesh.
4539 * \throw If no field values of the given \a type are available.
4541 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4543 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4545 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4547 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4548 int absDim=getDimension();
4549 int meshDimRelToMax=absDim-mm->getMeshDimension();
4550 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4554 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4555 * \param [in] type - a spatial discretization of the new field.
4556 * \param [in] renumPol - specifies how to permute values of the result field according to
4557 * the optional numbers of cells and nodes, if any. The valid values are
4558 * - 0 - do not permute.
4559 * - 1 - permute cells.
4560 * - 2 - permute nodes.
4561 * - 3 - permute cells and nodes.
4563 * \param [in] glob - the global data storing profiles and localization.
4564 * \param [in] mesh - the supporting mesh.
4565 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4566 * field according to \a renumPol.
4567 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4568 * field according to \a renumPol.
4569 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4570 * caller is to delete this field using decrRef() as it is no more needed.
4571 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4572 * \throw If no field of \a this is lying on \a mesh.
4573 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4575 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
4577 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4578 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4580 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4585 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4592 throw INTERP_KERNEL::Exception(msg1);
4593 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4596 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4598 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4599 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4600 throw INTERP_KERNEL::Exception(oss.str().c_str());
4602 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4603 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4604 std::vector<DataArray *> arrOut2(1,arrOut);
4605 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4606 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4607 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4614 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4616 throw INTERP_KERNEL::Exception(msg1);
4619 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4621 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4622 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4623 throw INTERP_KERNEL::Exception(oss.str().c_str());
4625 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4626 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4627 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4628 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4633 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4638 * Returns values and a profile of the field of a given type lying on a given support.
4639 * \param [in] type - a spatial discretization of the field.
4640 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4641 * \param [in] mesh - the supporting mesh.
4642 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4643 * field of interest lies on. If the field lies on all entities of the given
4644 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4645 * using decrRef() as it is no more needed.
4646 * \param [in] glob - the global data storing profiles and localization.
4647 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4648 * field. The caller is to delete this array using decrRef() as it is no more needed.
4649 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4650 * \throw If no field of \a this is lying on \a mesh.
4651 * \throw If no field values of the given \a type are available.
4653 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4655 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4656 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4657 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4658 ret->setName(nasc.getName().c_str());
4662 //= MEDFileField1TSWithoutSDA
4665 * Throws if a given value is not a valid (non-extended) relative dimension.
4666 * \param [in] meshDimRelToMax - the relative dimension value.
4667 * \throw If \a meshDimRelToMax > 0.
4669 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4671 if(meshDimRelToMax>0)
4672 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4676 * Checks if elements of a given mesh are in the order suitable for writing
4677 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4678 * vector describing types of elements and their number.
4679 * \param [in] mesh - the mesh to check.
4680 * \return std::vector<int> - a vector holding for each element type (1) item of
4681 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4682 * These values are in full-interlace mode.
4683 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4685 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4688 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4689 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4690 int nbOfTypes=geoTypes.size();
4691 std::vector<int> code(3*nbOfTypes);
4692 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4693 arr1->alloc(nbOfTypes,1);
4694 int *arrPtr=arr1->getPointer();
4695 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4696 for(int i=0;i<nbOfTypes;i++,it++)
4697 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4698 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4699 const int *arrPtr2=arr2->getConstPointer();
4701 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4704 int nbCells=mesh->getNumberOfCellsWithType(*it);
4705 code[3*pos]=(int)(*it);
4706 code[3*pos+1]=nbCells;
4707 code[3*pos+2]=-1;//no profiles
4709 std::vector<const DataArrayInt *> idsPerType;//no profiles
4710 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4714 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4719 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
4721 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4725 * Returns all attributes and values of parts of \a this field lying on a given mesh.
4726 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4727 * item of every of returned sequences refers to the _i_-th part of \a this field.
4728 * Thus all sequences returned by this method are of the same length equal to number
4729 * of different types of supporting entities.<br>
4730 * A field part can include sub-parts with several different spatial discretizations,
4731 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4732 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4733 * of a nested sequence corresponds to a type of spatial discretization.<br>
4734 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
4735 * The overhead is due to selecting values into new instances of DataArrayDouble.
4736 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4737 * for the case with only one underlying mesh. (Actually, the number of meshes is
4738 * not checked if \a mname == \c NULL).
4739 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4740 * a field part is returned.
4741 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4742 * A field part can include sub-parts with several different spatial discretizations,
4743 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
4744 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
4745 * This sequence is of the same length as \a types.
4746 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4747 * discretization. A profile name can be empty.
4748 * Length of this and of nested sequences is the same as that of \a typesF.
4749 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4750 * discretization. A localization name can be empty.
4751 * Length of this and of nested sequences is the same as that of \a typesF.
4752 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
4753 * per each type of spatial discretization within one mesh entity type.
4754 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
4755 * Length of this and of nested sequences is the same as that of \a typesF.
4756 * \throw If no field is lying on \a mname.
4758 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
4762 meshId=getMeshIdFromMeshName(mname);
4764 if(_field_per_mesh.empty())
4765 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4766 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4767 int nbOfRet=ret0.size();
4768 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
4769 for(int i=0;i<nbOfRet;i++)
4771 const std::vector< std::pair<int,int> >& p=ret0[i];
4772 int nbOfRet1=p.size();
4773 ret[i].resize(nbOfRet1);
4774 for(int j=0;j<nbOfRet1;j++)
4776 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
4784 * Returns a pointer to the underground DataArrayDouble instance. So the
4785 * caller should not decrRef() it. This method allows for a direct access to the field
4786 * values. This method is quite unusable if there is more than a nodal field or a cell
4787 * field on single geometric cell type.
4788 * \return DataArrayDouble * - the pointer to the field values array.
4790 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
4792 const DataArrayDouble *ret=_arr;
4794 return const_cast<DataArrayDouble *>(ret);
4799 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
4804 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
4806 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
4807 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4808 ret->deepCpyLeavesFrom(*this);
4809 const DataArrayDouble *arr(_arr);
4812 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
4813 ret->setArray(arr2);
4819 * Returns a pointer to the underground DataArrayDouble instance. So the
4820 * caller should not decrRef() it. This method allows for a direct access to the field
4821 * values. This method is quite unusable if there is more than a nodal field or a cell
4822 * field on single geometric cell type.
4823 * \return DataArrayDouble * - the pointer to the field values array.
4825 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
4827 return getUndergroundDataArrayDouble();
4831 * Returns a pointer to the underground DataArrayDouble instance and a
4832 * sequence describing parameters of a support of each part of \a this field. The
4833 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4834 * direct access to the field values. This method is intended for the field lying on one
4836 * \param [in,out] entries - the sequence describing parameters of a support of each
4837 * part of \a this field. Each item of this sequence consists of two parts. The
4838 * first part describes a type of mesh entity and an id of discretization of a
4839 * current field part. The second part describes a range of values [begin,end)
4840 * within the returned array relating to the current field part.
4841 * \return DataArrayDouble * - the pointer to the field values array.
4842 * \throw If the number of underlying meshes is not equal to 1.
4843 * \throw If no field values are available.
4844 * \sa getUndergroundDataArray()
4846 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4848 if(_field_per_mesh.size()!=1)
4849 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
4850 if(_field_per_mesh[0]==0)
4851 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
4852 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
4853 return getUndergroundDataArrayDouble();
4857 * Returns a pointer to the underground DataArrayDouble instance and a
4858 * sequence describing parameters of a support of each part of \a this field. The
4859 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
4860 * direct access to the field values. This method is intended for the field lying on one
4862 * \param [in,out] entries - the sequence describing parameters of a support of each
4863 * part of \a this field. Each item of this sequence consists of two parts. The
4864 * first part describes a type of mesh entity and an id of discretization of a
4865 * current field part. The second part describes a range of values [begin,end)
4866 * within the returned array relating to the current field part.
4867 * \return DataArrayDouble * - the pointer to the field values array.
4868 * \throw If the number of underlying meshes is not equal to 1.
4869 * \throw If no field values are available.
4870 * \sa getUndergroundDataArray()
4872 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
4874 return getUndergroundDataArrayDoubleExt(entries);
4877 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4878 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4880 DataArrayDouble *arr=getOrCreateAndGetArrayDouble();
4881 arr->setInfoAndChangeNbOfCompo(infos);
4884 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4888 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
4890 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
4891 ret->deepCpyLeavesFrom(*this);
4895 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
4897 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
4898 if((const DataArrayDouble *)_arr)
4899 ret->_arr=_arr->deepCpy();
4903 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
4907 _nb_of_tuples_to_be_allocated=-1;
4911 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
4913 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
4915 _nb_of_tuples_to_be_allocated=-3;
4920 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
4922 return DataArrayDouble::New();
4925 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
4927 DataArrayDouble *ret=_arr;
4930 _arr=DataArrayDouble::New();
4934 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
4936 return getOrCreateAndGetArrayDouble();
4939 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
4941 const DataArrayDouble *ret=_arr;
4944 DataArrayDouble *ret2=DataArrayDouble::New();
4945 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
4949 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
4951 return getOrCreateAndGetArrayDouble();
4954 //= MEDFileIntField1TSWithoutSDA
4956 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const char *fieldName, int csit, int iteration, int order,
4957 const std::vector<std::string>& infos)
4959 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
4962 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
4966 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order,
4967 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
4969 DataArrayInt *arr=getOrCreateAndGetArrayInt();
4970 arr->setInfoAndChangeNbOfCompo(infos);
4973 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
4978 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
4980 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
4981 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
4982 ret->deepCpyLeavesFrom(*this);
4983 const DataArrayInt *arr(_arr);
4986 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
4987 ret->setArray(arr2);
4993 * Returns a pointer to the underground DataArrayInt instance. So the
4994 * caller should not decrRef() it. This method allows for a direct access to the field
4995 * values. This method is quite unusable if there is more than a nodal field or a cell
4996 * field on single geometric cell type.
4997 * \return DataArrayInt * - the pointer to the field values array.
4999 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5001 return getUndergroundDataArrayInt();
5005 * Returns a pointer to the underground DataArrayInt instance. So the
5006 * caller should not decrRef() it. This method allows for a direct access to the field
5007 * values. This method is quite unusable if there is more than a nodal field or a cell
5008 * field on single geometric cell type.
5009 * \return DataArrayInt * - the pointer to the field values array.
5011 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5013 const DataArrayInt *ret=_arr;
5015 return const_cast<DataArrayInt *>(ret);
5021 * Returns a pointer to the underground DataArrayInt instance and a
5022 * sequence describing parameters of a support of each part of \a this field. The
5023 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5024 * direct access to the field values. This method is intended for the field lying on one
5026 * \param [in,out] entries - the sequence describing parameters of a support of each
5027 * part of \a this field. Each item of this sequence consists of two parts. The
5028 * first part describes a type of mesh entity and an id of discretization of a
5029 * current field part. The second part describes a range of values [begin,end)
5030 * within the returned array relating to the current field part.
5031 * \return DataArrayInt * - the pointer to the field values array.
5032 * \throw If the number of underlying meshes is not equal to 1.
5033 * \throw If no field values are available.
5034 * \sa getUndergroundDataArray()
5036 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5038 return getUndergroundDataArrayIntExt(entries);
5042 * Returns a pointer to the underground DataArrayInt instance and a
5043 * sequence describing parameters of a support of each part of \a this field. The
5044 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5045 * direct access to the field values. This method is intended for the field lying on one
5047 * \param [in,out] entries - the sequence describing parameters of a support of each
5048 * part of \a this field. Each item of this sequence consists of two parts. The
5049 * first part describes a type of mesh entity and an id of discretization of a
5050 * current field part. The second part describes a range of values [begin,end)
5051 * within the returned array relating to the current field part.
5052 * \return DataArrayInt * - the pointer to the field values array.
5053 * \throw If the number of underlying meshes is not equal to 1.
5054 * \throw If no field values are available.
5055 * \sa getUndergroundDataArray()
5057 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5059 if(_field_per_mesh.size()!=1)
5060 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5061 if(_field_per_mesh[0]==0)
5062 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5063 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5064 return getUndergroundDataArrayInt();
5067 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5069 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5070 ret->deepCpyLeavesFrom(*this);
5074 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5076 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5077 if((const DataArrayInt *)_arr)
5078 ret->_arr=_arr->deepCpy();
5082 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5086 _nb_of_tuples_to_be_allocated=-1;
5090 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5092 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5094 _nb_of_tuples_to_be_allocated=-3;
5099 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5101 return DataArrayInt::New();
5104 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5106 DataArrayInt *ret=_arr;
5109 _arr=DataArrayInt::New();
5113 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5115 return getOrCreateAndGetArrayInt();
5118 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5120 const DataArrayInt *ret=_arr;
5123 DataArrayInt *ret2=DataArrayInt::New();
5124 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5128 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5130 return getOrCreateAndGetArrayInt();
5133 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5137 //= MEDFileAnyTypeField1TS
5139 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll)
5141 med_field_type typcha;
5143 std::vector<std::string> infos;
5144 std::string dtunit,fieldName;
5145 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5146 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5151 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5156 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5161 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] !";
5162 throw INTERP_KERNEL::Exception(oss.str().c_str());
5165 ret->setDtUnit(dtunit.c_str());
5166 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5168 med_int numdt,numit;
5170 MEDfieldComputingStepInfo(fid,fieldName.c_str(),1,&numdt,&numit,&dt);
5171 ret->setTime(numdt,numit,dt);
5174 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5176 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5180 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, bool loadAll)
5181 try:MEDFileFieldGlobsReal(fileName)
5183 MEDFileUtilities::CheckFileForRead(fileName);
5184 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5185 _content=BuildContentFrom(fid,fileName,loadAll);
5188 catch(INTERP_KERNEL::Exception& e)
5193 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll)
5195 med_field_type typcha;
5196 std::vector<std::string> infos;
5199 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5200 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5205 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5210 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5215 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] !";
5216 throw INTERP_KERNEL::Exception(oss.str().c_str());
5219 ret->setDtUnit(dtunit.c_str());
5220 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5224 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5225 throw INTERP_KERNEL::Exception(oss.str().c_str());
5228 med_int numdt,numit;
5230 MEDfieldComputingStepInfo(fid,fieldName,1,&numdt,&numit,&dt);
5231 ret->setTime(numdt,numit,dt);
5234 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5236 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5240 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll)
5241 try:MEDFileFieldGlobsReal(fileName)
5243 MEDFileUtilities::CheckFileForRead(fileName);
5244 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5245 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
5248 catch(INTERP_KERNEL::Exception& e)
5253 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName)
5256 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5257 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5259 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5260 ret->setFileName(fileName);
5261 ret->_content=c; c->incrRef();
5264 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5266 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5267 ret->setFileName(fileName);
5268 ret->_content=c; c->incrRef();
5271 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5274 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, bool loadAll)
5276 MEDFileUtilities::CheckFileForRead(fileName);
5277 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5278 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
5279 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5280 ret->loadGlobals(fid);
5284 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, bool loadAll)
5286 MEDFileUtilities::CheckFileForRead(fileName);
5287 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5288 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
5289 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5290 ret->loadGlobals(fid);
5294 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
5296 MEDFileUtilities::CheckFileForRead(fileName);
5297 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5298 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5299 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5300 ret->loadGlobals(fid);
5304 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
5306 med_field_type typcha;
5307 std::vector<std::string> infos;
5310 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5311 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5316 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5321 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5326 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] !";
5327 throw INTERP_KERNEL::Exception(oss.str().c_str());
5330 ret->setDtUnit(dtunit.c_str());
5331 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5334 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5335 for(int i=0;i<nbOfStep2 && !found;i++)
5337 med_int numdt,numit;
5339 MEDfieldComputingStepInfo(fid,fieldName,i+1,&numdt,&numit,&dt);
5340 if(numdt==iteration && numit==order)
5346 dtits[i]=std::pair<int,int>(numdt,numit);
5350 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5351 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5352 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5353 throw INTERP_KERNEL::Exception(oss.str().c_str());
5356 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5358 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret));
5362 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
5363 try:MEDFileFieldGlobsReal(fileName)
5365 MEDFileUtilities::CheckFileForRead(fileName);
5366 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
5367 _content=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll);
5370 catch(INTERP_KERNEL::Exception& e)
5376 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5377 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5379 * \warning this is a shallow copy constructor
5381 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5383 if(!shallowCopyOfContent)
5385 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5386 otherPtr->incrRef();
5387 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5391 _content=other.shallowCpy();
5395 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5399 int nbFields=MEDnField(fid);
5400 if(fieldIdCFormat>=nbFields)
5402 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5403 throw INTERP_KERNEL::Exception(oss.str().c_str());
5406 int ncomp=MEDfieldnComponent(fid,fieldIdCFormat+1);
5407 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5408 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5409 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5410 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5411 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5414 MEDfieldInfo(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
5415 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5416 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5417 infos.clear(); infos.resize(ncomp);
5418 for(int j=0;j<ncomp;j++)
5419 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5424 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5427 * \return in case of success the number of time steps available for the field with name \a fieldName.
5429 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5431 int nbFields=MEDnField(fid);
5433 std::vector<std::string> fns(nbFields);
5435 for(int i=0;i<nbFields && !found;i++)
5438 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5440 found=(tmp==fieldName);
5446 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5447 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5448 oss << "\"" << *it << "\" ";
5449 throw INTERP_KERNEL::Exception(oss.str().c_str());
5455 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5456 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5457 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5458 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5459 * to keep a valid instance.
5460 * 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.
5461 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5462 * 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.
5464 * \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.
5465 * \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.
5466 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5467 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5468 * \param [in] newLocName is the new localization name.
5469 * \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.
5470 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5472 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob)
5474 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5475 std::string oldPflName=disc->getProfile();
5476 std::vector<std::string> vv=getPflsReallyUsedMulti();
5477 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5478 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5480 disc->setProfile(newPflName);
5481 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5482 pfl->setName(newPflName);
5486 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5487 throw INTERP_KERNEL::Exception(oss.str().c_str());
5492 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5493 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5494 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5495 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5496 * to keep a valid instance.
5497 * 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.
5498 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5499 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5500 * 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.
5502 * \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.
5503 * \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.
5504 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5505 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5506 * \param [in] newLocName is the new localization name.
5507 * \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.
5508 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5510 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob)
5512 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5513 std::string oldLocName=disc->getLocalization();
5514 std::vector<std::string> vv=getLocsReallyUsedMulti();
5515 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5516 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5518 disc->setLocalization(newLocName);
5519 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5520 loc.setName(newLocName);
5524 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5525 throw INTERP_KERNEL::Exception(oss.str().c_str());
5529 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5531 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5533 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5537 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5539 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5541 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5546 * Writes \a this field into a MED file specified by its name.
5547 * \param [in] fileName - the MED file name.
5548 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5549 * - 2 - erase; an existing file is removed.
5550 * - 1 - append; same data should not be present in an existing file.
5551 * - 0 - overwrite; same data present in an existing file is overwritten.
5552 * \throw If the field name is not set.
5553 * \throw If no field data is set.
5554 * \throw If \a mode == 1 and the same data is present in an existing file.
5556 void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const
5558 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5559 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
5564 * This method alloc the arrays and load potentially huge arrays contained in this field.
5565 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5566 * This method can be also called to refresh or reinit values from a file.
5568 * \throw If the fileName is not set or points to a non readable MED file.
5569 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5571 void MEDFileAnyTypeField1TS::loadArrays()
5573 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5574 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5578 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5579 * But once data loaded once, this method does nothing.
5581 * \throw If the fileName is not set or points to a non readable MED file.
5582 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5584 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5586 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
5587 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5591 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5592 * This method does not release arrays set outside the context of a MED file.
5594 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary
5596 void MEDFileAnyTypeField1TS::unloadArrays()
5598 contentNotNullBase()->unloadArrays();
5601 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5603 int nbComp=getNumberOfComponents();
5604 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5605 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5606 for(int i=0;i<nbComp;i++)
5608 std::string info=getInfo()[i];
5610 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5611 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5612 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5614 if(getName().empty())
5615 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5616 MEDfieldCr(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
5617 writeGlobals(fid,*this);
5618 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5621 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5623 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5626 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildren() const
5628 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildren());
5629 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5630 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5635 * Returns a string describing \a this field. This string is outputted
5636 * by \c print Python command.
5638 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5640 std::ostringstream oss;
5641 contentNotNullBase()->simpleRepr(0,oss,-1);
5642 simpleReprGlobs(oss);
5647 * This method returns all profiles whose name is non empty used.
5648 * \b WARNING If profile is used several times it will be reported \b only \b once.
5649 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5651 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5653 return contentNotNullBase()->getPflsReallyUsed2();
5657 * This method returns all localizations whose name is non empty used.
5658 * \b WARNING If localization is used several times it will be reported \b only \b once.
5660 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5662 return contentNotNullBase()->getLocsReallyUsed2();
5666 * This method returns all profiles whose name is non empty used.
5667 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5669 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5671 return contentNotNullBase()->getPflsReallyUsedMulti2();
5675 * This method returns all localizations whose name is non empty used.
5676 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5678 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5680 return contentNotNullBase()->getLocsReallyUsedMulti2();
5683 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5685 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5688 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5690 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5693 int MEDFileAnyTypeField1TS::getDimension() const
5695 return contentNotNullBase()->getDimension();
5698 int MEDFileAnyTypeField1TS::getIteration() const
5700 return contentNotNullBase()->getIteration();
5703 int MEDFileAnyTypeField1TS::getOrder() const
5705 return contentNotNullBase()->getOrder();
5708 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
5710 return contentNotNullBase()->getTime(iteration,order);
5713 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
5715 contentNotNullBase()->setTime(iteration,order,val);
5718 std::string MEDFileAnyTypeField1TS::getName() const
5720 return contentNotNullBase()->getName();
5723 void MEDFileAnyTypeField1TS::setName(const char *name)
5725 contentNotNullBase()->setName(name);
5728 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
5730 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
5733 std::string MEDFileAnyTypeField1TS::getDtUnit() const
5735 return contentNotNullBase()->getDtUnit();
5738 void MEDFileAnyTypeField1TS::setDtUnit(const char *dtUnit)
5740 contentNotNullBase()->setDtUnit(dtUnit);
5743 std::string MEDFileAnyTypeField1TS::getMeshName() const
5745 return contentNotNullBase()->getMeshName();
5748 void MEDFileAnyTypeField1TS::setMeshName(const char *newMeshName)
5750 contentNotNullBase()->setMeshName(newMeshName);
5753 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
5755 return contentNotNullBase()->changeMeshNames(modifTab);
5758 int MEDFileAnyTypeField1TS::getMeshIteration() const
5760 return contentNotNullBase()->getMeshIteration();
5763 int MEDFileAnyTypeField1TS::getMeshOrder() const
5765 return contentNotNullBase()->getMeshOrder();
5768 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
5770 return contentNotNullBase()->getNumberOfComponents();
5773 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
5775 return contentNotNullBase()->isDealingTS(iteration,order);
5778 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
5780 return contentNotNullBase()->getDtIt();
5783 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
5785 contentNotNullBase()->fillIteration(p);
5788 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
5790 contentNotNullBase()->fillTypesOfFieldAvailable(types);
5793 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
5795 contentNotNullBase()->setInfo(infos);
5798 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
5800 return contentNotNullBase()->getInfo();
5802 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
5804 return contentNotNullBase()->getInfo();
5807 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
5809 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5812 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
5814 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5817 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const char *mname, std::vector<int>& levs) const
5819 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
5822 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
5824 return contentNotNullBase()->getTypesOfFieldAvailable();
5827 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
5828 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
5830 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
5834 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
5835 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5836 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
5838 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
5840 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5842 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
5843 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
5844 std::size_t sz(contentsSplit.size());
5845 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5846 for(std::size_t i=0;i<sz;i++)
5848 ret[i]=shallowCpy();
5849 ret[i]->_content=contentsSplit[i];
5855 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
5856 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
5858 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
5860 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5862 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
5863 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitDiscretizations();
5864 std::size_t sz(contentsSplit.size());
5865 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
5866 for(std::size_t i=0;i<sz;i++)
5868 ret[i]=shallowCpy();
5869 ret[i]->_content=contentsSplit[i];
5874 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
5876 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
5877 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
5878 ret->_content=_content->deepCpy();
5879 ret->deepCpyGlobs(*this);
5883 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5885 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
5891 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5892 * the first field that has been read from a specified MED file.
5893 * \param [in] fileName - the name of the MED file to read.
5894 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5895 * is to delete this field using decrRef() as it is no more needed.
5896 * \throw If reading the file fails.
5898 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, bool loadAll)
5900 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,loadAll);
5901 ret->contentNotNull();
5906 * Returns a new instance of MEDFileField1TS holding data of the first time step of
5907 * a given field that has been read from a specified MED file.
5908 * \param [in] fileName - the name of the MED file to read.
5909 * \param [in] fieldName - the name of the field to read.
5910 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5911 * is to delete this field using decrRef() as it is no more needed.
5912 * \throw If reading the file fails.
5913 * \throw If there is no field named \a fieldName in the file.
5915 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, bool loadAll)
5917 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,loadAll);
5918 ret->contentNotNull();
5923 * Returns a new instance of MEDFileField1TS holding data of a given time step of
5924 * a given field that has been read from a specified MED file.
5925 * \param [in] fileName - the name of the MED file to read.
5926 * \param [in] fieldName - the name of the field to read.
5927 * \param [in] iteration - the iteration number of a required time step.
5928 * \param [in] order - the iteration order number of required time step.
5929 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
5930 * is to delete this field using decrRef() as it is no more needed.
5931 * \throw If reading the file fails.
5932 * \throw If there is no field named \a fieldName in the file.
5933 * \throw If the required time step is missing from the file.
5935 MEDFileField1TS *MEDFileField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
5937 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll);
5938 ret->contentNotNull();
5943 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5944 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5946 * Returns a new instance of MEDFileField1TS holding either a shallow copy
5947 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
5948 * \warning this is a shallow copy constructor
5949 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
5950 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
5951 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5952 * is to delete this field using decrRef() as it is no more needed.
5954 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
5956 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
5957 ret->contentNotNull();
5962 * Returns a new empty instance of MEDFileField1TS.
5963 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
5964 * is to delete this field using decrRef() as it is no more needed.
5966 MEDFileField1TS *MEDFileField1TS::New()
5968 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
5969 ret->contentNotNull();
5974 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
5975 * following the given input policy.
5977 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
5978 * By default (true) the globals are deeply copied.
5979 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
5981 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool deepCpyGlobs) const
5983 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
5984 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
5987 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
5989 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
5990 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
5991 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
5994 ret=MEDFileIntField1TS::New();
5996 ret->deepCpyGlobs(*this);
5998 ret->shallowCpyGlobs(*this);
6002 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6004 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6006 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6007 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6009 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 !");
6013 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6015 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6017 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6018 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6020 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 !");
6024 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6027 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6028 if(!((DataArray*)arr))
6029 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6030 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6032 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6033 f->setArray(arrOutC);
6036 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6038 if(!((DataArray*)arr))
6039 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6040 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6042 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6047 MEDFileField1TS::MEDFileField1TS(const char *fileName, bool loadAll)
6048 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6051 catch(INTERP_KERNEL::Exception& e)
6054 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll)
6055 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6058 catch(INTERP_KERNEL::Exception& e)
6061 MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
6062 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6065 catch(INTERP_KERNEL::Exception& e)
6069 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6070 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6072 * \warning this is a shallow copy constructor
6074 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6075 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6078 catch(INTERP_KERNEL::Exception& e)
6081 MEDFileField1TS::MEDFileField1TS()
6083 _content=new MEDFileField1TSWithoutSDA;
6087 * Returns a new MEDCouplingFieldDouble of a given type lying on
6088 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6089 * has not been constructed via file reading, an exception is thrown.
6090 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6091 * \param [in] type - a spatial discretization of interest.
6092 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6093 * \param [in] renumPol - specifies how to permute values of the result field according to
6094 * the optional numbers of cells and nodes, if any. The valid values are
6095 * - 0 - do not permute.
6096 * - 1 - permute cells.
6097 * - 2 - permute nodes.
6098 * - 3 - permute cells and nodes.
6100 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6101 * caller is to delete this field using decrRef() as it is no more needed.
6102 * \throw If \a this field has not been constructed via file reading.
6103 * \throw If the MED file is not readable.
6104 * \throw If there is no mesh in the MED file.
6105 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6106 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6107 * \sa getFieldOnMeshAtLevel()
6109 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6111 if(getFileName2().empty())
6112 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6113 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6114 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNull());
6115 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6120 * Returns a new MEDCouplingFieldDouble of a given type lying on
6121 * the top level cells of the first mesh in MED file. If \a this field
6122 * has not been constructed via file reading, an exception is thrown.
6123 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6124 * \param [in] type - a spatial discretization of interest.
6125 * \param [in] renumPol - specifies how to permute values of the result field according to
6126 * the optional numbers of cells and nodes, if any. The valid values are
6127 * - 0 - do not permute.
6128 * - 1 - permute cells.
6129 * - 2 - permute nodes.
6130 * - 3 - permute cells and nodes.
6132 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6133 * caller is to delete this field using decrRef() as it is no more needed.
6134 * \throw If \a this field has not been constructed via file reading.
6135 * \throw If the MED file is not readable.
6136 * \throw If there is no mesh in the MED file.
6137 * \throw If no field values of the given \a type.
6138 * \throw If no field values lying on the top level support.
6139 * \sa getFieldAtLevel()
6141 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6143 if(getFileName2().empty())
6144 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6145 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6146 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNull());
6147 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6152 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6153 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6154 * \param [in] type - a spatial discretization of the new field.
6155 * \param [in] mesh - the supporting mesh.
6156 * \param [in] renumPol - specifies how to permute values of the result field according to
6157 * the optional numbers of cells and nodes, if any. The valid values are
6158 * - 0 - do not permute.
6159 * - 1 - permute cells.
6160 * - 2 - permute nodes.
6161 * - 3 - permute cells and nodes.
6163 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6164 * caller is to delete this field using decrRef() as it is no more needed.
6165 * \throw If no field of \a this is lying on \a mesh.
6166 * \throw If the mesh is empty.
6167 * \throw If no field values of the given \a type are available.
6168 * \sa getFieldAtLevel()
6169 * \sa getFieldOnMeshAtLevel()
6171 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6173 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6174 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6175 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6180 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6181 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6182 * \param [in] type - a spatial discretization of interest.
6183 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6184 * \param [in] mesh - the supporting mesh.
6185 * \param [in] renumPol - specifies how to permute values of the result field according to
6186 * the optional numbers of cells and nodes, if any. The valid values are
6187 * - 0 - do not permute.
6188 * - 1 - permute cells.
6189 * - 2 - permute nodes.
6190 * - 3 - permute cells and nodes.
6192 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6193 * caller is to delete this field using decrRef() as it is no more needed.
6194 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6195 * \throw If no field of \a this is lying on \a mesh.
6196 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6197 * \sa getFieldAtLevel()
6198 * \sa getFieldOnMeshAtLevel()
6200 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6202 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6203 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6204 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6209 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6210 * This method is called "Old" because in MED3 norm a field has only one meshName
6211 * attached, so this method is for readers of MED2 files. If \a this field
6212 * has not been constructed via file reading, an exception is thrown.
6213 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6214 * \param [in] type - a spatial discretization of interest.
6215 * \param [in] mName - a name of the supporting mesh.
6216 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6217 * \param [in] renumPol - specifies how to permute values of the result field according to
6218 * the optional numbers of cells and nodes, if any. The valid values are
6219 * - 0 - do not permute.
6220 * - 1 - permute cells.
6221 * - 2 - permute nodes.
6222 * - 3 - permute cells and nodes.
6224 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6225 * caller is to delete this field using decrRef() as it is no more needed.
6226 * \throw If the MED file is not readable.
6227 * \throw If there is no mesh named \a mName in the MED file.
6228 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6229 * \throw If \a this field has not been constructed via file reading.
6230 * \throw If no field of \a this is lying on the mesh named \a mName.
6231 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6232 * \sa getFieldAtLevel()
6234 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol) const
6236 if(getFileName2().empty())
6237 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6238 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6239 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6240 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6245 * Returns values and a profile of the field of a given type lying on a given support.
6246 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6247 * \param [in] type - a spatial discretization of the field.
6248 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6249 * \param [in] mesh - the supporting mesh.
6250 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6251 * field of interest lies on. If the field lies on all entities of the given
6252 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6253 * using decrRef() as it is no more needed.
6254 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6255 * field. The caller is to delete this array using decrRef() as it is no more needed.
6256 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6257 * \throw If no field of \a this is lying on \a mesh.
6258 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6260 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6262 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6263 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6267 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6268 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6269 * "Sort By Type"), if not, an exception is thrown.
6270 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6271 * \param [in] field - the field to add to \a this.
6272 * \throw If the name of \a field is empty.
6273 * \throw If the data array of \a field is not set.
6274 * \throw If the data array is already allocated but has different number of components
6276 * \throw If the underlying mesh of \a field has no name.
6277 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6279 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6282 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6286 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6287 * can be an aggregation of several MEDCouplingFieldDouble instances.
6288 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6289 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6292 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6293 * A new profile is added only if no equal profile is missing.
6294 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6295 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6296 * \param [in] mesh - the supporting mesh of \a field.
6297 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6298 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6299 * \throw If either \a field or \a mesh or \a profile has an empty name.
6300 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6301 * \throw If the data array of \a field is not set.
6302 * \throw If the data array of \a this is already allocated but has different number of
6303 * components than \a field.
6304 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6305 * \sa setFieldNoProfileSBT()
6307 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6310 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6313 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6315 return new MEDFileField1TS(*this);
6318 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6320 return contentNotNull()->getUndergroundDataArrayDouble();
6323 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6325 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6328 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6329 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception)
6331 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6334 //= MEDFileIntField1TS
6336 MEDFileIntField1TS *MEDFileIntField1TS::New()
6338 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6339 ret->contentNotNull();
6343 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, bool loadAll)
6345 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,loadAll);
6346 ret->contentNotNull();
6350 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, bool loadAll)
6352 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,loadAll);
6353 ret->contentNotNull();
6357 MEDFileIntField1TS *MEDFileIntField1TS::New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
6359 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll);
6360 ret->contentNotNull();
6364 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6366 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6367 ret->contentNotNull();
6371 MEDFileIntField1TS::MEDFileIntField1TS()
6373 _content=new MEDFileIntField1TSWithoutSDA;
6376 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, bool loadAll)
6377 try:MEDFileAnyTypeField1TS(fileName,loadAll)
6380 catch(INTERP_KERNEL::Exception& e)
6383 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll)
6384 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll)
6387 catch(INTERP_KERNEL::Exception& e)
6390 MEDFileIntField1TS::MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll)
6391 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll)
6394 catch(INTERP_KERNEL::Exception& e)
6398 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6399 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6401 * \warning this is a shallow copy constructor
6403 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6407 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6409 return new MEDFileIntField1TS(*this);
6413 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6414 * following the given input policy.
6416 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6417 * By default (true) the globals are deeply copied.
6418 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6420 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool deepCpyGlobs) const
6422 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6423 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6426 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6428 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6429 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6430 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6433 ret=MEDFileField1TS::New();
6435 ret->deepCpyGlobs(*this);
6437 ret->shallowCpyGlobs(*this);
6442 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6443 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6444 * "Sort By Type"), if not, an exception is thrown.
6445 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6446 * \param [in] field - the field to add to \a this. The field double values are ignored.
6447 * \param [in] arrOfVals - the values of the field \a field used.
6448 * \throw If the name of \a field is empty.
6449 * \throw If the data array of \a field is not set.
6450 * \throw If the data array is already allocated but has different number of components
6452 * \throw If the underlying mesh of \a field has no name.
6453 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6455 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6458 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6462 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6463 * can be an aggregation of several MEDCouplingFieldDouble instances.
6464 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6465 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6468 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6469 * A new profile is added only if no equal profile is missing.
6470 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6471 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6472 * \param [in] arrOfVals - the values of the field \a field used.
6473 * \param [in] mesh - the supporting mesh of \a field.
6474 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6475 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6476 * \throw If either \a field or \a mesh or \a profile has an empty name.
6477 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6478 * \throw If the data array of \a field is not set.
6479 * \throw If the data array of \a this is already allocated but has different number of
6480 * components than \a field.
6481 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6482 * \sa setFieldNoProfileSBT()
6484 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6487 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6490 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6492 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6494 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6495 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6497 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 !");
6501 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6503 if(getFileName2().empty())
6504 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6505 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6506 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut2,*contentNotNull());
6507 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6509 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6514 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6516 if(!((DataArray *)arr))
6517 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6518 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6520 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6526 * Returns a new MEDCouplingFieldDouble of a given type lying on
6527 * the top level cells of the first mesh in MED file. If \a this field
6528 * has not been constructed via file reading, an exception is thrown.
6529 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6530 * \param [in] type - a spatial discretization of interest.
6531 * \param [out] arrOut - the DataArrayInt containing values of field.
6532 * \param [in] renumPol - specifies how to permute values of the result field according to
6533 * the optional numbers of cells and nodes, if any. The valid values are
6534 * - 0 - do not permute.
6535 * - 1 - permute cells.
6536 * - 2 - permute nodes.
6537 * - 3 - permute cells and nodes.
6539 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6540 * caller is to delete this field using decrRef() as it is no more needed.
6541 * \throw If \a this field has not been constructed via file reading.
6542 * \throw If the MED file is not readable.
6543 * \throw If there is no mesh in the MED file.
6544 * \throw If no field values of the given \a type.
6545 * \throw If no field values lying on the top level support.
6546 * \sa getFieldAtLevel()
6548 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6550 if(getFileName2().empty())
6551 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6552 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6553 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNull());
6554 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6559 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6560 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6561 * \param [in] type - a spatial discretization of the new field.
6562 * \param [in] mesh - the supporting mesh.
6563 * \param [out] arrOut - the DataArrayInt containing values of field.
6564 * \param [in] renumPol - specifies how to permute values of the result field according to
6565 * the optional numbers of cells and nodes, if any. The valid values are
6566 * - 0 - do not permute.
6567 * - 1 - permute cells.
6568 * - 2 - permute nodes.
6569 * - 3 - permute cells and nodes.
6571 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6572 * caller is to delete this field using decrRef() as it is no more needed.
6573 * \throw If no field of \a this is lying on \a mesh.
6574 * \throw If the mesh is empty.
6575 * \throw If no field values of the given \a type are available.
6576 * \sa getFieldAtLevel()
6577 * \sa getFieldOnMeshAtLevel()
6579 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6581 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6582 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6583 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6588 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6589 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6590 * \param [in] type - a spatial discretization of interest.
6591 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6592 * \param [out] arrOut - the DataArrayInt containing values of field.
6593 * \param [in] mesh - the supporting mesh.
6594 * \param [in] renumPol - specifies how to permute values of the result field according to
6595 * the optional numbers of cells and nodes, if any. The valid values are
6596 * - 0 - do not permute.
6597 * - 1 - permute cells.
6598 * - 2 - permute nodes.
6599 * - 3 - permute cells and nodes.
6601 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6602 * caller is to delete this field using decrRef() as it is no more needed.
6603 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6604 * \throw If no field of \a this is lying on \a mesh.
6605 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6606 * \sa getFieldAtLevel()
6607 * \sa getFieldOnMeshAtLevel()
6609 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6611 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6612 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6613 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6618 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6619 * This method is called "Old" because in MED3 norm a field has only one meshName
6620 * attached, so this method is for readers of MED2 files. If \a this field
6621 * has not been constructed via file reading, an exception is thrown.
6622 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6623 * \param [in] type - a spatial discretization of interest.
6624 * \param [in] mName - a name of the supporting mesh.
6625 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6626 * \param [out] arrOut - the DataArrayInt containing values of field.
6627 * \param [in] renumPol - specifies how to permute values of the result field according to
6628 * the optional numbers of cells and nodes, if any. The valid values are
6629 * - 0 - do not permute.
6630 * - 1 - permute cells.
6631 * - 2 - permute nodes.
6632 * - 3 - permute cells and nodes.
6634 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6635 * caller is to delete this field using decrRef() as it is no more needed.
6636 * \throw If the MED file is not readable.
6637 * \throw If there is no mesh named \a mName in the MED file.
6638 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6639 * \throw If \a this field has not been constructed via file reading.
6640 * \throw If no field of \a this is lying on the mesh named \a mName.
6641 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6642 * \sa getFieldAtLevel()
6644 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6646 if(getFileName2().empty())
6647 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6648 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6649 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6650 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6655 * Returns values and a profile of the field of a given type lying on a given support.
6656 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6657 * \param [in] type - a spatial discretization of the field.
6658 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6659 * \param [in] mesh - the supporting mesh.
6660 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6661 * field of interest lies on. If the field lies on all entities of the given
6662 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6663 * using decrRef() as it is no more needed.
6664 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6665 * field. The caller is to delete this array using decrRef() as it is no more needed.
6666 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6667 * \throw If no field of \a this is lying on \a mesh.
6668 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6670 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6672 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6673 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6676 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
6678 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6680 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
6681 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
6683 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 !");
6687 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
6689 return contentNotNull()->getUndergroundDataArrayInt();
6692 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
6694 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
6698 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName):MEDFileFieldNameScope(fieldName)
6703 * \param [in] fieldId field id in C mode
6705 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll)
6707 med_field_type typcha;
6708 std::string dtunitOut;
6709 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
6710 setDtUnit(dtunitOut.c_str());
6711 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll);
6714 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
6715 try:MEDFileFieldNameScope(fieldName),_infos(infos)
6717 setDtUnit(dtunit.c_str());
6718 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll);
6720 catch(INTERP_KERNEL::Exception& e)
6725 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
6727 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
6728 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6729 ret+=(*it).capacity();
6733 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildren() const
6735 std::vector<const BigMemoryObject *> ret;
6736 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6738 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6746 * 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
6749 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
6751 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6752 ret->setInfo(_infos);
6753 int sz=(int)_time_steps.size();
6754 for(const int *id=startIds;id!=endIds;id++)
6756 if(*id>=0 && *id<sz)
6758 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
6759 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6763 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6765 ret->pushBackTimeStep(tse2);
6769 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
6770 oss << " ! Should be in [0," << sz << ") !";
6771 throw INTERP_KERNEL::Exception(oss.str().c_str());
6774 if(ret->getNumberOfTS()>0)
6775 ret->synchronizeNameScope();
6776 ret->copyNameScope(*this);
6781 * 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
6784 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
6786 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
6787 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
6788 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
6789 ret->setInfo(_infos);
6790 int sz=(int)_time_steps.size();
6792 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
6796 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
6797 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
6801 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
6803 ret->pushBackTimeStep(tse2);
6807 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
6808 oss << " ! Should be in [0," << sz << ") !";
6809 throw INTERP_KERNEL::Exception(oss.str().c_str());
6812 if(ret->getNumberOfTS()>0)
6813 ret->synchronizeNameScope();
6814 ret->copyNameScope(*this);
6818 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6821 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6822 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6824 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6827 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6828 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
6829 ids->pushBackSilent(id);
6831 return buildFromTimeStepIds(ids->begin(),ids->end());
6834 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
6837 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
6838 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
6840 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6843 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
6844 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
6845 ids->pushBackSilent(id);
6847 return buildFromTimeStepIds(ids->begin(),ids->end());
6850 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
6855 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
6860 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
6863 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
6865 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
6866 if(pt->isDealingTS(iteration,order))
6869 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
6870 std::vector< std::pair<int,int> > vp=getIterations();
6871 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
6872 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
6873 throw INTERP_KERNEL::Exception(oss.str().c_str());
6876 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
6878 return *_time_steps[getTimeStepPos(iteration,order)];
6881 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
6883 return *_time_steps[getTimeStepPos(iteration,order)];
6886 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
6888 if(_time_steps.empty())
6889 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
6890 return _time_steps[0]->getMeshName();
6893 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const char *newMeshName)
6895 std::string oldName(getMeshName());
6896 std::vector< std::pair<std::string,std::string> > v(1);
6897 v[0].first=oldName; v[0].second=newMeshName;
6901 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6904 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6906 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
6908 ret=cur->changeMeshNames(modifTab) || ret;
6914 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
6916 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
6918 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
6922 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
6924 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6926 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
6929 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
6930 MEDFileFieldGlobsReal& glob)
6933 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
6935 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
6937 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
6942 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
6944 std::string startLine(bkOffset,' ');
6945 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
6947 oss << " (" << fmtsId << ")";
6948 oss << " has the following name: \"" << _name << "\"." << std::endl;
6949 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
6950 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
6952 oss << startLine << " - \"" << *it << "\"" << std::endl;
6955 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
6957 std::string chapter(17,'0'+i);
6958 oss << startLine << chapter << std::endl;
6959 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
6961 cur->simpleRepr(bkOffset+2,oss,i);
6963 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
6964 oss << startLine << chapter << std::endl;
6968 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
6970 std::size_t sz=_time_steps.size();
6971 std::vector< std::pair<int,int> > ret(sz);
6973 for(std::size_t i=0;i<sz;i++)
6975 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
6978 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
6982 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
6983 throw INTERP_KERNEL::Exception(oss.str().c_str());
6989 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
6991 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
6993 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
6994 checkCoherencyOfType(tse2);
6995 if(_time_steps.empty())
6997 setName(tse2->getName().c_str());
6998 setInfo(tse2->getInfo());
7000 checkThatComponentsMatch(tse2->getInfo());
7001 _time_steps.push_back(tse);
7004 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7006 std::size_t nbOfCompo=_infos.size();
7007 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7009 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7012 if((cur->getInfo()).size()!=nbOfCompo)
7014 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7015 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7016 throw INTERP_KERNEL::Exception(oss.str().c_str());
7018 cur->copyNameScope(*this);
7023 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll)
7025 _time_steps.resize(nbPdt);
7026 for(int i=0;i<nbPdt;i++)
7028 std::vector< std::pair<int,int> > ts;
7029 med_int numdt=0,numo=0;
7030 med_int meshIt=0,meshOrder=0;
7032 MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
7037 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7042 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7046 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7049 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this);
7051 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this);
7055 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7057 if(_time_steps.empty())
7058 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7059 checkThatNbOfCompoOfTSMatchThis();
7060 std::vector<std::string> infos(getInfo());
7061 int nbComp=infos.size();
7062 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7063 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7064 for(int i=0;i<nbComp;i++)
7066 std::string info=infos[i];
7068 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7069 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7070 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7073 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7074 MEDfieldCr(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str());
7075 int nbOfTS=_time_steps.size();
7076 for(int i=0;i<nbOfTS;i++)
7077 _time_steps[i]->writeLL(fid,opts,*this);
7080 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7082 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7084 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7086 elt->loadBigArraysRecursively(fid,nasc);
7090 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7092 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7094 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7096 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7100 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7102 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7104 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7106 elt->unloadArrays();
7110 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7112 return _time_steps.size();
7115 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7117 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7118 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7120 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7122 newTS.push_back(*it);
7127 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7129 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7130 int maxId=(int)_time_steps.size();
7132 std::set<int> idsToDel;
7133 for(const int *id=startIds;id!=endIds;id++,ii++)
7135 if(*id>=0 && *id<maxId)
7137 idsToDel.insert(*id);
7141 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7142 throw INTERP_KERNEL::Exception(oss.str().c_str());
7145 for(int iii=0;iii<maxId;iii++)
7146 if(idsToDel.find(iii)==idsToDel.end())
7147 newTS.push_back(_time_steps[iii]);
7151 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7153 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7154 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7155 if(nbOfEntriesToKill==0)
7157 std::size_t sz=_time_steps.size();
7158 std::vector<bool> b(sz,true);
7160 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7162 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7163 for(std::size_t i=0;i<sz;i++)
7165 newTS.push_back(_time_steps[i]);
7169 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7172 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7173 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7175 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7179 tmp->getTime(it2,ord);
7180 if(it2==iteration && order==ord)
7183 oss << "(" << it2 << "," << ord << "), ";
7186 throw INTERP_KERNEL::Exception(oss.str().c_str());
7189 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7192 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7194 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7196 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7200 double ti=tmp->getTime(it2,ord);
7201 if(fabs(time-ti)<eps)
7207 throw INTERP_KERNEL::Exception(oss.str().c_str());
7210 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7212 int lgth=_time_steps.size();
7213 std::vector< std::pair<int,int> > ret(lgth);
7214 for(int i=0;i<lgth;i++)
7215 _time_steps[i]->fillIteration(ret[i]);
7220 * 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'
7221 * This method returns two things.
7222 * - The absolute dimension of 'this' in first parameter.
7223 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7224 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7226 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7227 * Only these 3 discretizations will be taken into account here.
7229 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7230 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7231 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7233 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7234 * 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'.
7236 * Let's consider the typical following case :
7237 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7238 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7239 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7241 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7243 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7245 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7246 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7247 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7248 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7250 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const
7252 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7255 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7257 if(pos<0 || pos>=(int)_time_steps.size())
7259 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7260 throw INTERP_KERNEL::Exception(oss.str().c_str());
7262 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7265 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7266 oss << "\nTry to use following method eraseEmptyTS !";
7267 throw INTERP_KERNEL::Exception(oss.str().c_str());
7272 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7274 if(pos<0 || pos>=(int)_time_steps.size())
7276 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7277 throw INTERP_KERNEL::Exception(oss.str().c_str());
7279 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7282 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7283 oss << "\nTry to use following method eraseEmptyTS !";
7284 throw INTERP_KERNEL::Exception(oss.str().c_str());
7289 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7291 std::vector<std::string> ret;
7292 std::set<std::string> ret2;
7293 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7295 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7296 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7297 if(ret2.find(*it2)==ret2.end())
7299 ret.push_back(*it2);
7306 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7308 std::vector<std::string> ret;
7309 std::set<std::string> ret2;
7310 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7312 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7313 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7314 if(ret2.find(*it2)==ret2.end())
7316 ret.push_back(*it2);
7323 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7325 std::vector<std::string> ret;
7326 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7328 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7329 ret.insert(ret.end(),tmp.begin(),tmp.end());
7334 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7336 std::vector<std::string> ret;
7337 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7339 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7340 ret.insert(ret.end(),tmp.begin(),tmp.end());
7345 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7347 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7348 (*it)->changePflsRefsNamesGen2(mapOfModif);
7351 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7353 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7354 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7357 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7359 int lgth=_time_steps.size();
7360 std::vector< std::vector<TypeOfField> > ret(lgth);
7361 for(int i=0;i<lgth;i++)
7362 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7367 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7369 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7371 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7374 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7376 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7378 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7380 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7381 ret->_time_steps[i]=(*it)->deepCpy();
7386 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7388 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7389 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7390 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7391 for(std::size_t i=0;i<sz;i++)
7393 ret[i]=shallowCpy();
7394 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7396 for(std::size_t i=0;i<sz2;i++)
7398 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7401 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7402 throw INTERP_KERNEL::Exception(oss.str().c_str());
7406 for(std::size_t i=0;i<sz;i++)
7407 for(std::size_t j=0;j<sz2;j++)
7408 ret[i]->_time_steps[j]=ts[j][i];
7413 * This method splits into discretization each time steps in \a this.
7414 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7416 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7418 std::size_t sz(_time_steps.size());
7419 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7420 for(std::size_t i=0;i<sz;i++)
7422 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7425 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7426 throw INTERP_KERNEL::Exception(oss.str().c_str());
7428 items[i]=timeStep->splitDiscretizations();
7431 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7432 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7433 std::vector< TypeOfField > types;
7434 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7435 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7437 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7439 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7440 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7441 if(it2==types.end())
7442 types.push_back(ts[0]);
7444 ret.resize(types.size()); ret2.resize(types.size());
7445 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7446 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7448 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7449 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7450 ret2[pos].push_back(*it1);
7452 for(std::size_t i=0;i<types.size();i++)
7454 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=createNew();
7455 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7456 elt->pushBackTimeStep(*it1);//also updates infos in elt
7458 elt->MEDFileFieldNameScope::operator=(*this);
7463 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7465 _name=field->getName();
7467 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7469 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7470 _infos=arr->getInfoOnComponents();
7473 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7475 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7476 if(_name!=field->getName())
7478 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7479 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7480 throw INTERP_KERNEL::Exception(oss.str().c_str());
7483 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7484 checkThatComponentsMatch(arr->getInfoOnComponents());
7487 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7489 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7490 if(getInfo().size()!=compos.size())
7492 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7493 oss << " number of components of element to append (" << compos.size() << ") !";
7494 throw INTERP_KERNEL::Exception(oss.str().c_str());
7498 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7499 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7500 oss << " But compo in input fields are : ";
7501 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7503 throw INTERP_KERNEL::Exception(oss.str().c_str());
7507 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7509 std::size_t sz=_infos.size();
7511 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7513 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7515 if(elt->getInfo().size()!=sz)
7517 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7518 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7519 throw INTERP_KERNEL::Exception(oss.str().c_str());
7524 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7527 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7528 if(!_time_steps.empty())
7529 checkCoherencyOfTinyInfo(field,arr);
7530 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7531 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7532 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7533 copyTinyInfoFrom(field,arr);
7534 _time_steps.push_back(obj);
7537 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7540 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7541 if(!_time_steps.empty())
7542 checkCoherencyOfTinyInfo(field,arr);
7543 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7544 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7545 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7546 copyTinyInfoFrom(field,arr);
7547 _time_steps.push_back(obj);
7550 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7552 int sz=(int)_time_steps.size();
7555 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7556 throw INTERP_KERNEL::Exception(oss.str().c_str());
7558 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7561 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7563 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7564 throw INTERP_KERNEL::Exception(oss.str().c_str());
7570 //= MEDFileFieldMultiTSWithoutSDA
7572 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
7574 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7577 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7581 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7586 * \param [in] fieldId field id in C mode
7588 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll)
7589 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7592 catch(INTERP_KERNEL::Exception& e)
7595 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
7596 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7599 catch(INTERP_KERNEL::Exception& e)
7602 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7604 return new MEDFileField1TSWithoutSDA;
7607 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7610 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7611 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7613 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7616 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7618 return MEDFileField1TSWithoutSDA::TYPE_STR;
7621 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7623 return new MEDFileFieldMultiTSWithoutSDA(*this);
7626 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
7628 return new MEDFileFieldMultiTSWithoutSDA;
7632 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
7633 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
7635 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7637 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
7638 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
7640 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
7641 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7644 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
7646 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
7647 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7649 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7651 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7654 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
7656 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
7657 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
7658 ret->setIteration(i,elt);
7664 //= MEDFileAnyTypeFieldMultiTS
7666 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
7670 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll)
7671 try:MEDFileFieldGlobsReal(fileName)
7673 MEDFileUtilities::CheckFileForRead(fileName);
7674 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7675 _content=BuildContentFrom(fid,fileName,loadAll);
7678 catch(INTERP_KERNEL::Exception& e)
7683 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll)
7685 med_field_type typcha;
7686 std::vector<std::string> infos;
7689 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
7690 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7695 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll);
7700 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll);
7705 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] !";
7706 throw INTERP_KERNEL::Exception(oss.str().c_str());
7709 ret->setDtUnit(dtunit.c_str());
7713 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const char *fileName, bool loadAll)
7715 med_field_type typcha;
7717 std::vector<std::string> infos;
7718 std::string dtunit,fieldName;
7719 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
7720 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
7725 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll);
7730 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll);
7735 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] !";
7736 throw INTERP_KERNEL::Exception(oss.str().c_str());
7739 ret->setDtUnit(dtunit.c_str());
7743 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName)
7746 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
7747 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
7749 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
7750 ret->setFileName(fileName);
7751 ret->_content=c; c->incrRef();
7754 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
7756 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
7757 ret->setFileName(fileName);
7758 ret->_content=c; c->incrRef();
7761 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
7764 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll)
7765 try:MEDFileFieldGlobsReal(fileName)
7767 MEDFileUtilities::CheckFileForRead(fileName);
7768 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7769 _content=BuildContentFrom(fid,fileName,fieldName,loadAll);
7772 catch(INTERP_KERNEL::Exception& e)
7777 //= MEDFileIntFieldMultiTSWithoutSDA
7779 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
7781 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll);
7784 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
7788 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7792 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll)
7793 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll)
7796 catch(INTERP_KERNEL::Exception& e)
7800 * \param [in] fieldId field id in C mode
7802 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll)
7803 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll)
7806 catch(INTERP_KERNEL::Exception& e)
7809 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7811 return new MEDFileIntField1TSWithoutSDA;
7814 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7817 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7818 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
7820 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
7823 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
7825 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
7828 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
7830 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
7833 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
7835 return new MEDFileIntFieldMultiTSWithoutSDA;
7838 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
7840 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
7841 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
7843 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7845 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
7848 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
7850 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
7851 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
7852 ret->setIteration(i,elt);
7858 //= MEDFileAnyTypeFieldMultiTS
7861 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
7862 * that has been read from a specified MED file.
7863 * \param [in] fileName - the name of the MED file to read.
7864 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7865 * is to delete this field using decrRef() as it is no more needed.
7866 * \throw If reading the file fails.
7868 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, bool loadAll)
7870 MEDFileUtilities::CheckFileForRead(fileName);
7871 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7872 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll);
7873 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7874 ret->loadGlobals(fid);
7879 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
7880 * that has been read from a specified MED file.
7881 * \param [in] fileName - the name of the MED file to read.
7882 * \param [in] fieldName - the name of the field to read.
7883 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
7884 * is to delete this field using decrRef() as it is no more needed.
7885 * \throw If reading the file fails.
7886 * \throw If there is no field named \a fieldName in the file.
7888 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll)
7890 MEDFileUtilities::CheckFileForRead(fileName);
7891 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
7892 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll);
7893 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
7894 ret->loadGlobals(fid);
7899 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7900 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7902 * \warning this is a shallow copy constructor
7904 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
7906 if(!shallowCopyOfContent)
7908 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
7909 otherPtr->incrRef();
7910 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
7914 _content=other.shallowCpy();
7918 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
7920 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7922 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
7926 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
7928 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
7930 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
7934 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
7936 return contentNotNullBase()->getPflsReallyUsed2();
7939 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
7941 return contentNotNullBase()->getLocsReallyUsed2();
7944 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
7946 return contentNotNullBase()->getPflsReallyUsedMulti2();
7949 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
7951 return contentNotNullBase()->getLocsReallyUsedMulti2();
7954 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7956 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
7959 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7961 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
7964 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
7966 return contentNotNullBase()->getNumberOfTS();
7969 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
7971 contentNotNullBase()->eraseEmptyTS();
7974 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
7976 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
7979 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
7981 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
7984 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
7986 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
7987 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
7992 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
7994 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
7995 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8000 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8002 return contentNotNullBase()->getIterations();
8005 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8007 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8008 pushBackTimeStep(*it);
8011 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8014 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8015 checkCoherencyOfType(f1ts);
8017 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8018 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8020 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8021 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8022 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8023 _content->pushBackTimeStep(cSafe);
8024 appendGlobs(*f1ts,1e-12);
8027 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8029 contentNotNullBase()->synchronizeNameScope();
8032 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8034 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8037 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8039 return contentNotNullBase()->getPosGivenTime(time,eps);
8042 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const
8044 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8047 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8049 return contentNotNullBase()->getTypesOfFieldAvailable();
8052 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
8054 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8057 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8059 return contentNotNullBase()->getName();
8062 void MEDFileAnyTypeFieldMultiTS::setName(const char *name)
8064 contentNotNullBase()->setName(name);
8067 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8069 return contentNotNullBase()->getDtUnit();
8072 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const char *dtUnit)
8074 contentNotNullBase()->setDtUnit(dtUnit);
8077 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8079 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8082 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8084 return contentNotNullBase()->getTimeSteps(ret1);
8087 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8089 return contentNotNullBase()->getMeshName();
8092 void MEDFileAnyTypeFieldMultiTS::setMeshName(const char *newMeshName)
8094 contentNotNullBase()->setMeshName(newMeshName);
8097 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8099 return contentNotNullBase()->changeMeshNames(modifTab);
8102 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8104 return contentNotNullBase()->getInfo();
8107 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8109 return contentNotNullBase()->setInfo(info);
8112 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8114 const std::vector<std::string> ret=getInfo();
8115 return (int)ret.size();
8118 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8120 writeGlobals(fid,*this);
8121 contentNotNullBase()->writeLL(fid,*this);
8125 * Writes \a this field into a MED file specified by its name.
8126 * \param [in] fileName - the MED file name.
8127 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8128 * - 2 - erase; an existing file is removed.
8129 * - 1 - append; same data should not be present in an existing file.
8130 * - 0 - overwrite; same data present in an existing file is overwritten.
8131 * \throw If the field name is not set.
8132 * \throw If no field data is set.
8133 * \throw If \a mode == 1 and the same data is present in an existing file.
8135 void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const
8137 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8138 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
8143 * This method alloc the arrays and load potentially huge arrays contained in this field.
8144 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8145 * This method can be also called to refresh or reinit values from a file.
8147 * \throw If the fileName is not set or points to a non readable MED file.
8149 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8151 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),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 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
8165 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8169 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8170 * This method does not release arrays set outside the context of a MED file.
8172 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8174 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8176 contentNotNullBase()->unloadArrays();
8179 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8181 std::ostringstream oss;
8182 contentNotNullBase()->simpleRepr(0,oss,-1);
8183 simpleReprGlobs(oss);
8187 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8189 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8192 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildren() const
8194 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildren());
8195 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8196 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8201 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8202 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8203 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8205 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8207 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8209 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8210 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8211 std::size_t sz(contentsSplit.size());
8212 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8213 for(std::size_t i=0;i<sz;i++)
8215 ret[i]=shallowCpy();
8216 ret[i]->_content=contentsSplit[i];
8222 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8223 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8225 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8227 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8229 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8230 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitDiscretizations();
8231 std::size_t sz(contentsSplit.size());
8232 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8233 for(std::size_t i=0;i<sz;i++)
8235 ret[i]=shallowCpy();
8236 ret[i]->_content=contentsSplit[i];
8241 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8243 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8244 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8245 ret->_content=_content->deepCpy();
8246 ret->deepCpyGlobs(*this);
8250 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8256 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8257 * \param [in] iteration - the iteration number of a required time step.
8258 * \param [in] order - the iteration order number of required time step.
8259 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8260 * delete this field using decrRef() as it is no more needed.
8261 * \throw If there is no required time step in \a this field.
8263 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8265 int pos=getPosOfTimeStep(iteration,order);
8266 return getTimeStepAtPos(pos);
8270 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8271 * \param [in] time - the time of the time step of interest.
8272 * \param [in] eps - a precision used to compare time values.
8273 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8274 * delete this field using decrRef() as it is no more needed.
8275 * \throw If there is no required time step in \a this field.
8277 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8279 int pos=getPosGivenTime(time,eps);
8280 return getTimeStepAtPos(pos);
8284 * 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.
8285 * The float64 value of time attached to the pair of integers are not considered here.
8287 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8288 * \throw If there is a null pointer in \a vectFMTS.
8290 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8292 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8293 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8294 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8295 while(!lstFMTS.empty())
8297 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8298 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8300 throw INTERP_KERNEL::Exception(msg);
8301 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8302 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8303 elt.push_back(curIt); it=lstFMTS.erase(it);
8304 while(it!=lstFMTS.end())
8308 throw INTERP_KERNEL::Exception(msg);
8309 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8311 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8321 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8322 * All returned instances in a subvector can be safely loaded, rendered along time
8323 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8324 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8325 * 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).
8326 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8327 * 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.
8329 * \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().
8330 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8331 * \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.
8333 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8334 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8335 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8336 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8337 * \throw If mesh is null.
8338 * \throw If an element in \a vectFMTS is null.
8339 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8341 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8343 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8345 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8346 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8347 if(vectFMTS.empty())
8349 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8350 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8352 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8353 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8354 for(;it!=vectFMTS.end();it++,i++)
8356 TypeOfField tof0,tof1;
8357 int ret=CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1);
8361 vectFMTSNotNodes.push_back(*it);
8363 vectFMTSNodes.push_back(*it);
8366 vectFMTSNotNodes.push_back(*it);
8368 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8369 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8371 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8374 bool isFetched(false);
8375 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8378 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8379 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8380 { ret[i].push_back(*it2); isFetched=true; }
8384 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8385 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8386 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8394 * 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.
8395 * \param [out] cmps - same size than the returned vector.
8397 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8399 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8400 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8401 while(!lstFMTS.empty())
8403 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8404 MEDFileAnyTypeFieldMultiTS *ref(*it);
8405 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8406 elt.push_back(ref); it=lstFMTS.erase(it);
8407 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8408 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8409 while(it!=lstFMTS.end())
8411 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8412 if(cmp->isEqual(curIt))
8413 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8417 ret.push_back(elt); cmps.push_back(cmp);
8423 * 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.
8424 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8426 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8427 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8428 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8429 * \thorw If \a f0 and \a f1 do not have the same times steps.
8430 * \throw If mesh is null.
8431 * \throw If \a f0 or \a f1 is null.
8432 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8434 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8437 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8439 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8440 if(f0->getMeshName()!=mesh->getName())
8442 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8443 throw INTERP_KERNEL::Exception(oss.str().c_str());
8445 if(f1->getMeshName()!=mesh->getName())
8447 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8448 throw INTERP_KERNEL::Exception(oss.str().c_str());
8450 int nts=f0->getNumberOfTS();
8451 if(nts!=f1->getNumberOfTS())
8452 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8455 for(int i=0;i<nts;i++)
8457 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8458 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8459 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8460 if(tofs0.size()!=1 || tofs1.size()!=1)
8461 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8464 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8465 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8468 { tof0=tofs0[0]; tof1=tofs1[0]; }
8469 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8471 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() << ") !";
8472 throw INTERP_KERNEL::Exception(oss.str().c_str());
8474 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8476 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() << ") !";
8477 throw INTERP_KERNEL::Exception(oss.str().c_str());
8479 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8481 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() << ") !";
8482 throw INTERP_KERNEL::Exception(oss.str().c_str());
8488 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8490 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8493 //= MEDFileFieldMultiTS
8496 * Returns a new empty instance of MEDFileFieldMultiTS.
8497 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8498 * is to delete this field using decrRef() as it is no more needed.
8500 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8502 return new MEDFileFieldMultiTS;
8506 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8507 * that has been read from a specified MED file.
8508 * \param [in] fileName - the name of the MED file to read.
8509 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8510 * is to delete this field using decrRef() as it is no more needed.
8511 * \throw If reading the file fails.
8513 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, bool loadAll)
8515 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll);
8516 ret->contentNotNull();//to check that content type matches with \a this type.
8521 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8522 * that has been read from a specified MED file.
8523 * \param [in] fileName - the name of the MED file to read.
8524 * \param [in] fieldName - the name of the field to read.
8525 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8526 * is to delete this field using decrRef() as it is no more needed.
8527 * \throw If reading the file fails.
8528 * \throw If there is no field named \a fieldName in the file.
8530 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll)
8532 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll);
8533 ret->contentNotNull();//to check that content type matches with \a this type.
8538 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8539 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8541 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8542 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8543 * \warning this is a shallow copy constructor
8544 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8545 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8546 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8547 * is to delete this field using decrRef() as it is no more needed.
8549 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8551 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8554 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8556 return new MEDFileFieldMultiTS(*this);
8559 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
8562 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8563 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
8565 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8569 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
8570 * following the given input policy.
8572 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
8573 * By default (true) the globals are deeply copied.
8574 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
8576 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool deepCpyGlobs) const
8578 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
8579 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8582 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
8584 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
8585 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
8586 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
8589 ret=MEDFileIntFieldMultiTS::New();
8591 ret->deepCpyGlobs(*this);
8593 ret->shallowCpyGlobs(*this);
8598 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
8599 * \param [in] pos - a time step id.
8600 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8601 * delete this field using decrRef() as it is no more needed.
8602 * \throw If \a pos is not a valid time step id.
8604 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
8606 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
8609 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
8610 throw INTERP_KERNEL::Exception(oss.str().c_str());
8612 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
8615 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
8616 ret->shallowCpyGlobs(*this);
8619 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
8620 throw INTERP_KERNEL::Exception(oss.str().c_str());
8624 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8625 * mesh entities of a given dimension of the first mesh in MED file.
8626 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8627 * \param [in] type - a spatial discretization of interest.
8628 * \param [in] iteration - the iteration number of a required time step.
8629 * \param [in] order - the iteration order number of required time step.
8630 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8631 * \param [in] renumPol - specifies how to permute values of the result field according to
8632 * the optional numbers of cells and nodes, if any. The valid values are
8633 * - 0 - do not permute.
8634 * - 1 - permute cells.
8635 * - 2 - permute nodes.
8636 * - 3 - permute cells and nodes.
8638 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8639 * caller is to delete this field using decrRef() as it is no more needed.
8640 * \throw If the MED file is not readable.
8641 * \throw If there is no mesh in the MED file.
8642 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8643 * \throw If no field values of the required parameters are available.
8645 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
8647 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8648 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8650 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
8651 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8652 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arrOut,*contentNotNullBase());
8653 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8658 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8659 * the top level cells of the first mesh in MED file.
8660 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8661 * \param [in] type - a spatial discretization of interest.
8662 * \param [in] iteration - the iteration number of a required time step.
8663 * \param [in] order - the iteration order number of required time step.
8664 * \param [in] renumPol - specifies how to permute values of the result field according to
8665 * the optional numbers of cells and nodes, if any. The valid values are
8666 * - 0 - do not permute.
8667 * - 1 - permute cells.
8668 * - 2 - permute nodes.
8669 * - 3 - permute cells and nodes.
8671 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8672 * caller is to delete this field using decrRef() as it is no more needed.
8673 * \throw If the MED file is not readable.
8674 * \throw If there is no mesh in the MED file.
8675 * \throw If no field values of the required parameters are available.
8677 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
8679 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8680 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8682 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
8683 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8684 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arrOut,*contentNotNullBase());
8685 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8690 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
8692 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8693 * \param [in] type - a spatial discretization of interest.
8694 * \param [in] iteration - the iteration number of a required time step.
8695 * \param [in] order - the iteration order number of required time step.
8696 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8697 * \param [in] mesh - the supporting mesh.
8698 * \param [in] renumPol - specifies how to permute values of the result field according to
8699 * the optional numbers of cells and nodes, if any. The valid values are
8700 * - 0 - do not permute.
8701 * - 1 - permute cells.
8702 * - 2 - permute nodes.
8703 * - 3 - permute cells and nodes.
8705 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8706 * caller is to delete this field using decrRef() as it is no more needed.
8707 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
8708 * \throw If no field of \a this is lying on \a mesh.
8709 * \throw If no field values of the required parameters are available.
8711 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
8713 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8714 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8716 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8717 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8718 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
8719 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8724 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
8726 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8727 * \param [in] type - a spatial discretization of the new field.
8728 * \param [in] iteration - the iteration number of a required time step.
8729 * \param [in] order - the iteration order number of required time step.
8730 * \param [in] mesh - the supporting mesh.
8731 * \param [in] renumPol - specifies how to permute values of the result field according to
8732 * the optional numbers of cells and nodes, if any. The valid values are
8733 * - 0 - do not permute.
8734 * - 1 - permute cells.
8735 * - 2 - permute nodes.
8736 * - 3 - permute cells and nodes.
8738 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
8739 * caller is to delete this field using decrRef() as it is no more needed.
8740 * \throw If no field of \a this is lying on \a mesh.
8741 * \throw If no field values of the required parameters are available.
8743 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
8745 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8746 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8748 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
8749 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8750 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
8751 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8756 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
8757 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
8758 * This method is useful for MED2 file format when field on different mesh was autorized.
8760 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
8762 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8763 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8765 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
8766 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
8767 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
8768 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
8773 * Returns values and a profile of the field of a given type, of a given time step,
8774 * lying on a given support.
8775 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8776 * \param [in] type - a spatial discretization of the field.
8777 * \param [in] iteration - the iteration number of a required time step.
8778 * \param [in] order - the iteration order number of required time step.
8779 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
8780 * \param [in] mesh - the supporting mesh.
8781 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
8782 * field of interest lies on. If the field lies on all entities of the given
8783 * dimension, all ids in \a pfl are zero. The caller is to delete this array
8784 * using decrRef() as it is no more needed.
8785 * \param [in] glob - the global data storing profiles and localization.
8786 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
8787 * field. The caller is to delete this array using decrRef() as it is no more needed.
8788 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8789 * \throw If no field of \a this is lying on \a mesh.
8790 * \throw If no field values of the required parameters are available.
8792 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
8794 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
8795 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8797 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
8798 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
8799 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
8802 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
8804 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8806 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
8807 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
8809 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 !");
8813 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
8815 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
8817 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
8818 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
8820 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 !");
8825 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
8826 * the given field is checked if its elements are sorted suitable for writing to MED file
8827 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
8828 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8829 * \param [in] field - the field to add to \a this.
8830 * \throw If the name of \a field is empty.
8831 * \throw If the data array of \a field is not set.
8832 * \throw If existing time steps have different name or number of components than \a field.
8833 * \throw If the underlying mesh of \a field has no name.
8834 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
8836 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
8838 const DataArrayDouble *arr=0;
8840 arr=field->getArray();
8841 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
8845 * Adds a MEDCouplingFieldDouble to \a this as another time step.
8846 * The mesh support of input parameter \a field is ignored here, it can be NULL.
8847 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
8850 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
8851 * A new profile is added only if no equal profile is missing.
8852 * For more info, see \ref AdvMEDLoaderAPIFieldRW
8853 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
8854 * \param [in] mesh - the supporting mesh of \a field.
8855 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
8856 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
8857 * \throw If either \a field or \a mesh or \a profile has an empty name.
8858 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
8859 * \throw If the data array of \a field is not set.
8860 * \throw If the data array of \a this is already allocated but has different number of
8861 * components than \a field.
8862 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
8863 * \sa setFieldNoProfileSBT()
8865 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
8867 const DataArrayDouble *arr=0;
8869 arr=field->getArray();
8870 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
8873 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
8875 _content=new MEDFileFieldMultiTSWithoutSDA;
8878 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, bool loadAll)
8879 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
8882 catch(INTERP_KERNEL::Exception& e)
8885 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll)
8886 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
8889 catch(INTERP_KERNEL::Exception& e)
8892 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
8896 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
8898 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
8901 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
8903 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
8906 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
8908 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
8911 //= MEDFileAnyTypeFieldMultiTSIterator
8913 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
8918 _nb_iter=fmts->getNumberOfTS();
8922 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
8926 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
8928 if(_iter_id<_nb_iter)
8930 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
8932 return fmts->getTimeStepAtPos(_iter_id++);
8940 //= MEDFileIntFieldMultiTS
8943 * Returns a new empty instance of MEDFileFieldMultiTS.
8944 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8945 * is to delete this field using decrRef() as it is no more needed.
8947 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
8949 return new MEDFileIntFieldMultiTS;
8953 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
8954 * that has been read from a specified MED file.
8955 * \param [in] fileName - the name of the MED file to read.
8956 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8957 * is to delete this field using decrRef() as it is no more needed.
8958 * \throw If reading the file fails.
8960 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, bool loadAll)
8962 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll);
8963 ret->contentNotNull();//to check that content type matches with \a this type.
8968 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
8969 * that has been read from a specified MED file.
8970 * \param [in] fileName - the name of the MED file to read.
8971 * \param [in] fieldName - the name of the field to read.
8972 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8973 * is to delete this field using decrRef() as it is no more needed.
8974 * \throw If reading the file fails.
8975 * \throw If there is no field named \a fieldName in the file.
8977 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll)
8979 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll);
8980 ret->contentNotNull();//to check that content type matches with \a this type.
8985 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8986 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8988 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
8989 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8990 * \warning this is a shallow copy constructor
8991 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
8992 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8993 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
8994 * is to delete this field using decrRef() as it is no more needed.
8996 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8998 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9002 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9003 * following the given input policy.
9005 * \param [in] deepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9006 * By default (true) the globals are deeply copied.
9007 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9009 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool deepCpyGlobs) const
9011 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9012 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9015 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9017 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9018 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9019 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9022 ret=MEDFileFieldMultiTS::New();
9024 ret->deepCpyGlobs(*this);
9026 ret->shallowCpyGlobs(*this);
9030 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9032 return new MEDFileIntFieldMultiTS(*this);
9035 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9038 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9039 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9041 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9045 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9046 * mesh entities of a given dimension of the first mesh in MED file.
9047 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9048 * \param [in] type - a spatial discretization of interest.
9049 * \param [in] iteration - the iteration number of a required time step.
9050 * \param [in] order - the iteration order number of required time step.
9051 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9052 * \param [out] arrOut - the DataArrayInt containing values of field.
9053 * \param [in] renumPol - specifies how to permute values of the result field according to
9054 * the optional numbers of cells and nodes, if any. The valid values are
9055 * - 0 - do not permute.
9056 * - 1 - permute cells.
9057 * - 2 - permute nodes.
9058 * - 3 - permute cells and nodes.
9060 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9061 * caller is to delete this field using decrRef() as it is no more needed.
9062 * \throw If the MED file is not readable.
9063 * \throw If there is no mesh in the MED file.
9064 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9065 * \throw If no field values of the required parameters are available.
9067 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9069 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9070 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9072 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9073 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9074 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,0,renumPol,this,arr,*contentNotNullBase());
9075 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9080 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9081 * the top level cells of the first mesh in MED file.
9082 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9083 * \param [in] type - a spatial discretization of interest.
9084 * \param [in] iteration - the iteration number of a required time step.
9085 * \param [in] order - the iteration order number of required time step.
9086 * \param [out] arrOut - the DataArrayInt containing values of field.
9087 * \param [in] renumPol - specifies how to permute values of the result field according to
9088 * the optional numbers of cells and nodes, if any. The valid values are
9089 * - 0 - do not permute.
9090 * - 1 - permute cells.
9091 * - 2 - permute nodes.
9092 * - 3 - permute cells and nodes.
9094 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9095 * caller is to delete this field using decrRef() as it is no more needed.
9096 * \throw If the MED file is not readable.
9097 * \throw If there is no mesh in the MED file.
9098 * \throw If no field values of the required parameters are available.
9100 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9102 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9103 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9105 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9106 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9107 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,0,renumPol,this,arr,*contentNotNullBase());
9108 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9113 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9115 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9116 * \param [in] type - a spatial discretization of interest.
9117 * \param [in] iteration - the iteration number of a required time step.
9118 * \param [in] order - the iteration order number of required time step.
9119 * \param [out] arrOut - the DataArrayInt containing values of field.
9120 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9121 * \param [in] mesh - the supporting mesh.
9122 * \param [in] renumPol - specifies how to permute values of the result field according to
9123 * the optional numbers of cells and nodes, if any. The valid values are
9124 * - 0 - do not permute.
9125 * - 1 - permute cells.
9126 * - 2 - permute nodes.
9127 * - 3 - permute cells and nodes.
9129 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9130 * caller is to delete this field using decrRef() as it is no more needed.
9131 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9132 * \throw If no field of \a this is lying on \a mesh.
9133 * \throw If no field values of the required parameters are available.
9135 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9137 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9138 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9140 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9141 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9142 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9143 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9148 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9150 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9151 * \param [in] type - a spatial discretization of the new field.
9152 * \param [in] iteration - the iteration number of a required time step.
9153 * \param [in] order - the iteration order number of required time step.
9154 * \param [in] mesh - the supporting mesh.
9155 * \param [out] arrOut - the DataArrayInt containing values of field.
9156 * \param [in] renumPol - specifies how to permute values of the result field according to
9157 * the optional numbers of cells and nodes, if any. The valid values are
9158 * - 0 - do not permute.
9159 * - 1 - permute cells.
9160 * - 2 - permute nodes.
9161 * - 3 - permute cells and nodes.
9163 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9164 * caller is to delete this field using decrRef() as it is no more needed.
9165 * \throw If no field of \a this is lying on \a mesh.
9166 * \throw If no field values of the required parameters are available.
9168 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9170 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9171 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9173 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9174 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9175 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9176 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9181 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9182 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9183 * This method is useful for MED2 file format when field on different mesh was autorized.
9185 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9187 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9188 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9190 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9191 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9192 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9193 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9198 * Returns values and a profile of the field of a given type, of a given time step,
9199 * lying on a given support.
9200 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9201 * \param [in] type - a spatial discretization of the field.
9202 * \param [in] iteration - the iteration number of a required time step.
9203 * \param [in] order - the iteration order number of required time step.
9204 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9205 * \param [in] mesh - the supporting mesh.
9206 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9207 * field of interest lies on. If the field lies on all entities of the given
9208 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9209 * using decrRef() as it is no more needed.
9210 * \param [in] glob - the global data storing profiles and localization.
9211 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9212 * field. The caller is to delete this array using decrRef() as it is no more needed.
9213 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9214 * \throw If no field of \a this is lying on \a mesh.
9215 * \throw If no field values of the required parameters are available.
9217 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9219 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9220 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9222 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9223 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9224 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9228 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9229 * \param [in] pos - a time step id.
9230 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9231 * delete this field using decrRef() as it is no more needed.
9232 * \throw If \a pos is not a valid time step id.
9234 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9236 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9239 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9240 throw INTERP_KERNEL::Exception(oss.str().c_str());
9242 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9245 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9246 ret->shallowCpyGlobs(*this);
9249 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9250 throw INTERP_KERNEL::Exception(oss.str().c_str());
9254 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9255 * the given field is checked if its elements are sorted suitable for writing to MED file
9256 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9257 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9258 * \param [in] field - the field to add to \a this.
9259 * \throw If the name of \a field is empty.
9260 * \throw If the data array of \a field is not set.
9261 * \throw If existing time steps have different name or number of components than \a field.
9262 * \throw If the underlying mesh of \a field has no name.
9263 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9265 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9267 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9271 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9272 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9273 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9276 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9277 * A new profile is added only if no equal profile is missing.
9278 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9279 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9280 * \param [in] arrOfVals - the values of the field \a field used.
9281 * \param [in] mesh - the supporting mesh of \a field.
9282 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9283 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9284 * \throw If either \a field or \a mesh or \a profile has an empty name.
9285 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9286 * \throw If the data array of \a field is not set.
9287 * \throw If the data array of \a this is already allocated but has different number of
9288 * components than \a field.
9289 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9290 * \sa setFieldNoProfileSBT()
9292 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9294 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9297 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9299 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9301 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9302 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9304 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 !");
9308 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9310 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9312 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9313 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9315 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 !");
9319 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9321 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9324 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9328 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, bool loadAll)
9329 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll)
9332 catch(INTERP_KERNEL::Exception& e)
9335 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll)
9336 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll)
9339 catch(INTERP_KERNEL::Exception& e)
9342 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9344 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9349 MEDFileFields *MEDFileFields::New()
9351 return new MEDFileFields;
9354 MEDFileFields *MEDFileFields::New(const char *fileName, bool loadAll)
9356 return new MEDFileFields(fileName,loadAll);
9359 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9361 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9362 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9366 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildren() const
9368 std::vector<const BigMemoryObject *> ret;
9369 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9371 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9378 MEDFileFields *MEDFileFields::deepCpy() const
9380 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9382 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9384 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9385 ret->_fields[i]=(*it)->deepCpy();
9387 ret->deepCpyGlobs(*this);
9391 MEDFileFields *MEDFileFields::shallowCpy() const
9393 return new MEDFileFields(*this);
9397 * 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
9398 * 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.
9399 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9401 * \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.
9402 * \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.
9404 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9406 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9408 std::set< std::pair<int,int> > s;
9409 bool firstShot=true;
9410 areThereSomeForgottenTS=false;
9411 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9413 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9415 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9416 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9418 { s=s1; firstShot=false; }
9421 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9423 areThereSomeForgottenTS=true;
9427 std::vector< std::pair<int,int> > ret;
9428 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9432 int MEDFileFields::getNumberOfFields() const
9434 return _fields.size();
9437 std::vector<std::string> MEDFileFields::getFieldsNames() const
9439 std::vector<std::string> ret(_fields.size());
9441 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9443 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9446 ret[i]=f->getName();
9450 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9451 throw INTERP_KERNEL::Exception(oss.str().c_str());
9457 std::vector<std::string> MEDFileFields::getMeshesNames() const
9459 std::vector<std::string> ret;
9460 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9462 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9464 ret.push_back(cur->getMeshName());
9469 std::string MEDFileFields::simpleRepr() const
9471 std::ostringstream oss;
9472 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9477 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9479 int nbOfFields=getNumberOfFields();
9480 std::string startLine(bkOffset,' ');
9481 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9483 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9485 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9488 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9492 oss << startLine << " - not defined !" << std::endl;
9496 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9498 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9499 std::string chapter(17,'0'+i);
9500 oss << startLine << chapter << std::endl;
9503 cur->simpleRepr(bkOffset+2,oss,i);
9507 oss << startLine << " - not defined !" << std::endl;
9509 oss << startLine << chapter << std::endl;
9511 simpleReprGlobs(oss);
9514 MEDFileFields::MEDFileFields()
9518 MEDFileFields::MEDFileFields(const char *fileName, bool loadAll)
9519 try:MEDFileFieldGlobsReal(fileName)
9521 MEDFileUtilities::CheckFileForRead(fileName);
9522 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
9523 int nbFields=MEDnField(fid);
9524 _fields.resize(nbFields);
9525 med_field_type typcha;
9526 for(int i=0;i<nbFields;i++)
9528 std::vector<std::string> infos;
9529 std::string fieldName,dtunit;
9530 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit);
9535 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9540 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll);
9545 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] !";
9546 throw INTERP_KERNEL::Exception(oss.str().c_str());
9550 loadAllGlobals(fid);
9552 catch(INTERP_KERNEL::Exception& e)
9557 void MEDFileFields::writeLL(med_idt fid) const
9560 writeGlobals(fid,*this);
9561 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9563 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
9566 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
9567 throw INTERP_KERNEL::Exception(oss.str().c_str());
9569 elt->writeLL(fid,*this);
9573 void MEDFileFields::write(const char *fileName, int mode) const
9575 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
9576 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,medmod);
9581 * This method alloc the arrays and load potentially huge arrays contained in this field.
9582 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9583 * This method can be also called to refresh or reinit values from a file.
9585 * \throw If the fileName is not set or points to a non readable MED file.
9587 void MEDFileFields::loadArrays()
9589 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9590 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9592 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9594 elt->loadBigArraysRecursively(fid,*elt);
9599 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9600 * But once data loaded once, this method does nothing.
9602 * \throw If the fileName is not set or points to a non readable MED file.
9603 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
9605 void MEDFileFields::loadArraysIfNecessary()
9607 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9608 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9610 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9612 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
9617 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9618 * This method does not release arrays set outside the context of a MED file.
9620 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary
9622 void MEDFileFields::unloadArrays()
9624 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY);
9625 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9627 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
9629 elt->unloadArrays();
9633 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
9635 std::vector<std::string> ret;
9636 std::set<std::string> ret2;
9637 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9639 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
9640 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9641 if(ret2.find(*it2)==ret2.end())
9643 ret.push_back(*it2);
9650 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
9652 std::vector<std::string> ret;
9653 std::set<std::string> ret2;
9654 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9656 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9657 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
9658 if(ret2.find(*it2)==ret2.end())
9660 ret.push_back(*it2);
9667 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
9669 std::vector<std::string> ret;
9670 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9672 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
9673 ret.insert(ret.end(),tmp.begin(),tmp.end());
9678 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
9680 std::vector<std::string> ret;
9681 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9683 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
9684 ret.insert(ret.end(),tmp.begin(),tmp.end());
9689 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9691 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9692 (*it)->changePflsRefsNamesGen2(mapOfModif);
9695 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
9697 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
9698 (*it)->changeLocsRefsNamesGen2(mapOfModif);
9701 void MEDFileFields::resize(int newSize)
9703 _fields.resize(newSize);
9706 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
9708 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
9712 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
9715 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
9716 _fields.push_back(field->getContent());
9717 appendGlobs(*field,1e-12);
9720 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
9723 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
9724 if(i>=(int)_fields.size())
9725 _fields.resize(i+1);
9726 _fields[i]=field->getContent();
9727 appendGlobs(*field,1e-12);
9730 void MEDFileFields::destroyFieldAtPos(int i)
9732 destroyFieldsAtPos(&i,&i+1);
9735 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
9737 std::vector<bool> b(_fields.size(),true);
9738 for(const int *i=startIds;i!=endIds;i++)
9740 if(*i<0 || *i>=(int)_fields.size())
9742 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9743 throw INTERP_KERNEL::Exception(oss.str().c_str());
9747 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9749 for(std::size_t i=0;i<_fields.size();i++)
9751 fields[j++]=_fields[i];
9755 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
9757 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
9758 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
9759 std::vector<bool> b(_fields.size(),true);
9761 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
9763 if(k<0 || k>=(int)_fields.size())
9765 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
9766 throw INTERP_KERNEL::Exception(oss.str().c_str());
9770 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
9772 for(std::size_t i=0;i<_fields.size();i++)
9774 fields[j++]=_fields[i];
9778 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9781 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9783 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9785 ret=cur->changeMeshNames(modifTab) || ret;
9791 * \param [in] meshName the name of the mesh that will be renumbered.
9792 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
9793 * This code corresponds to the distribution of types in the corresponding mesh.
9794 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
9795 * \param [in] renumO2N the old to new renumber array.
9796 * \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
9799 bool MEDFileFields::renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
9802 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
9804 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
9807 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
9813 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
9815 if(i<0 || i>=(int)_fields.size())
9817 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
9818 throw INTERP_KERNEL::Exception(oss.str().c_str());
9820 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
9823 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
9824 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
9825 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
9827 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
9829 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
9832 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
9833 throw INTERP_KERNEL::Exception(oss.str().c_str());
9835 ret->shallowCpyGlobs(*this);
9840 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
9841 * This method is accessible in python using __getitem__ with a list in input.
9842 * \return a new object that the caller should deal with.
9844 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
9846 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9847 std::size_t sz=std::distance(startIds,endIds);
9848 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
9850 for(const int *i=startIds;i!=endIds;i++,j++)
9852 if(*i<0 || *i>=(int)_fields.size())
9854 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
9855 throw INTERP_KERNEL::Exception(oss.str().c_str());
9857 fields[j]=_fields[*i];
9859 ret->_fields=fields;
9863 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const char *fieldName) const
9865 return getFieldAtPos(getPosFromFieldName(fieldName));
9869 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
9870 * This method can be seen as a filter applied on \a this, that returns an object containing
9871 * 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
9872 * shallow copied from \a this.
9874 * \param [in] meshName - the name of the mesh on w
9875 * \return a new object that the caller should deal with.
9877 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const char *meshName) const
9879 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9880 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9882 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9885 if(cur->getMeshName()==meshName)
9888 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
9889 ret->_fields.push_back(cur2);
9892 ret->shallowCpyOnlyUsedGlobs(*this);
9897 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
9898 * Input time steps are specified using a pair of integer (iteration, order).
9899 * 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,
9900 * but for each multitimestep only the time steps in \a timeSteps are kept.
9901 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
9903 * The returned object points to shallow copy of elements in \a this.
9905 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
9906 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
9907 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9909 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9911 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9912 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9914 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9917 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
9918 ret->_fields.push_back(elt);
9920 ret->shallowCpyOnlyUsedGlobs(*this);
9925 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
9927 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
9929 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
9930 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9932 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9935 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
9936 if(elt->getNumberOfTS()!=0)
9937 ret->_fields.push_back(elt);
9939 ret->shallowCpyOnlyUsedGlobs(*this);
9943 MEDFileFieldsIterator *MEDFileFields::iterator()
9945 return new MEDFileFieldsIterator(this);
9948 int MEDFileFields::getPosFromFieldName(const char *fieldName) const
9950 std::string tmp(fieldName);
9951 std::vector<std::string> poss;
9952 for(std::size_t i=0;i<_fields.size();i++)
9954 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
9957 std::string fname(f->getName());
9961 poss.push_back(fname);
9964 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
9965 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
9967 throw INTERP_KERNEL::Exception(oss.str().c_str());
9970 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
9975 _nb_iter=fs->getNumberOfFields();
9979 MEDFileFieldsIterator::~MEDFileFieldsIterator()
9983 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
9985 if(_iter_id<_nb_iter)
9987 MEDFileFields *fs(_fs);
9989 return fs->getFieldAtPos(_iter_id++);