1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldDiscretization.hxx"
31 #include "InterpKernelAutoPtr.hxx"
32 #include "CellModel.hxx"
37 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
38 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
39 extern med_geometry_type typmainoeud[1];
40 extern med_geometry_type typmai3[34];
42 using namespace ParaMEDMEM;
44 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
45 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
47 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
49 return new MEDFileFieldLoc(fid,locName);
52 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
54 return new MEDFileFieldLoc(fid,id);
57 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
59 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
62 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
64 med_geometry_type geotype;
65 med_geometry_type sectiongeotype;
67 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
68 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
69 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
70 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
71 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
72 _nb_node_per_cell=cm.getNumberOfNodes();
73 _ref_coo.resize(_dim*_nb_node_per_cell);
74 _gs_coo.resize(_dim*_nb_gauss_pt);
75 _w.resize(_nb_gauss_pt);
76 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
79 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
81 med_geometry_type geotype;
82 med_geometry_type sectiongeotype;
84 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
87 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
89 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
90 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
91 _nb_node_per_cell=cm.getNumberOfNodes();
92 _ref_coo.resize(_dim*_nb_node_per_cell);
93 _gs_coo.resize(_dim*_nb_gauss_pt);
94 _w.resize(_nb_gauss_pt);
95 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
98 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
99 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),
102 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
103 _dim=cm.getDimension();
104 _nb_node_per_cell=cm.getNumberOfNodes();
105 _nb_gauss_pt=_w.size();
108 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
110 return new MEDFileFieldLoc(*this);
113 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
115 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
118 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
120 return std::vector<const BigMemoryObject *>();
123 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
125 static const char OFF7[]="\n ";
126 oss << "\"" << _name << "\"" << OFF7;
127 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
128 oss << "Dimension=" << _dim << OFF7;
129 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
130 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
131 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
132 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
133 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
136 void MEDFileFieldLoc::setName(const std::string& name)
141 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
143 if(_name!=other._name)
147 if(_nb_gauss_pt!=other._nb_gauss_pt)
149 if(_nb_node_per_cell!=other._nb_node_per_cell)
151 if(_geo_type!=other._geo_type)
153 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
155 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
157 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
163 void MEDFileFieldLoc::writeLL(med_idt fid) const
165 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);
168 std::string MEDFileFieldLoc::repr() const
170 std::ostringstream oss; oss.precision(15);
171 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
172 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
173 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
174 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
175 oss << "\n - Ref coords are : ";
176 int sz=_ref_coo.size();
179 int nbOfTuples=sz/_dim;
180 for(int i=0;i<nbOfTuples;i++)
183 for(int j=0;j<_dim;j++)
184 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
189 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
190 oss << "\n - Gauss coords in reference element : ";
194 int nbOfTuples=sz/_dim;
195 for(int i=0;i<nbOfTuples;i++)
198 for(int j=0;j<_dim;j++)
199 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
204 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
205 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
209 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
211 _type=field->getTypeOfField();
217 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
218 _end=_start+nbOfCells;
224 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
225 const int *arrPtr=arr->getConstPointer();
226 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
227 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
233 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
234 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
235 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
237 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
238 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
239 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
240 const int *dai2Ptr=dai2->getConstPointer();
241 int nbi=gsLoc.getWeights().size();
242 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
243 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
244 const int *da3Ptr=da3->getConstPointer();
245 if(da3->getNumberOfTuples()!=nbOfCells)
246 {//profile : for gauss even in NoProfile !!!
247 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
249 da3->setName(_profile.c_str());
250 glob.appendProfile(da3);
252 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
253 _nval=da3->getNbOfElems();
254 da4->alloc(_nval*nbi,1);
255 int *da4Ptr=da4->getPointer();
256 for(int i=0;i<_nval;i++)
258 int ref=dai2Ptr[offset+da3Ptr[i]];
259 for(int j=0;j<nbi;j++)
262 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
263 _localization=oss2.str();
264 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
265 _end=_start+_nval*nbi;
266 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
270 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
276 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
277 * \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).
278 * \param [in] multiTypePfl is the end user profile specified in high level API
279 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
280 * \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.
281 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
282 * \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.
284 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
287 _type=field->getTypeOfField();
288 std::string pflName(multiTypePfl->getName());
289 std::ostringstream oss; oss << pflName;
293 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
300 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
301 if(_type!=ON_GAUSS_PT)
303 locIds->setName(oss.str().c_str());
304 glob.appendProfile(locIds);
313 _nval=idsInPfl->getNumberOfTuples();
314 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
320 _nval=idsInPfl->getNumberOfTuples();
321 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
327 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
328 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
329 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
330 arr3->computeOffsets2();
331 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
332 int trueNval=tmp->getNumberOfTuples();
333 _nval=idsInPfl->getNumberOfTuples();
334 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
335 _end=_start+trueNval;
340 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
342 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
343 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
344 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
345 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
346 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
347 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
349 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
350 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
352 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
354 for(const int *pt=da4->begin();pt!=da4->end();pt++)
355 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
356 tmp->alloc(trueNval,1);
357 int *tmpPtr=tmp->getPointer();
358 for(const int *pt=da4->begin();pt!=da4->end();pt++)
359 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
362 _nval=da4->getNumberOfTuples();
363 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
364 _end=_start+trueNval;
365 oss << "_loc_" << _loc_id;
368 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
369 da5->setName(oss.str().c_str());
370 glob.appendProfile(da5);
375 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
377 da3->setName(oss.str().c_str());
378 glob.appendProfile(da3);
382 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
383 _localization=oss2.str();
384 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
388 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
393 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
396 _nval=arrr->getNumberOfTuples();
397 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
402 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
404 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
407 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
409 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
412 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
414 return new MEDFileFieldPerMeshPerTypePerDisc(other);
417 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
419 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
422 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
424 std::vector<const BigMemoryObject *> ret(1);
425 ret[0]=(const PartDefinition*)_pd;
429 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const
431 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
436 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
437 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
442 catch(INTERP_KERNEL::Exception& e)
447 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
451 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
455 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
456 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
460 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
462 const PartDefinition *pd(_pd);
465 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
467 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
468 if(_end-_start!=nbValsInFile*nbi)
470 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
471 throw INTERP_KERNEL::Exception(oss.str().c_str());
473 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
477 if(!_profile.empty())
478 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
479 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
481 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
482 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
486 spd->getSlice(start,stop,step);
487 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
488 med_filter filter=MED_FILTER_INIT;
489 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
490 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
491 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
492 /*lastblocksize=useless because count=1*/0,&filter);
493 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
494 MEDfilterClose(&filter);
497 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
500 dpd->checkCoherency();
501 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> myIds(dpd->toDAI());
502 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
503 myIds->applyLin(1,-a);
504 int nbOfEltsToLoad(b-a+1);
505 med_filter filter=MED_FILTER_INIT;
506 {//TODO : manage int32 !
507 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp(DataArrayDouble::New());
508 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
509 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
510 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
511 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
512 /*lastblocksize=useless because count=1*/0,&filter);
513 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
514 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> feeder(DataArrayDouble::New());
515 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
516 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
518 MEDfilterClose(&filter);
521 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
525 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
530 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
532 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
533 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
534 std::string fieldName(nasc.getName()),meshName(getMeshName());
535 int iteration(getIteration()),order(getOrder());
536 TypeOfField type(getType());
537 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
539 med_geometry_type mgeoti;
540 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
541 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
542 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
543 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
544 const PartDefinition *pd(_pd);
551 if(!_profile.empty())
552 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
553 _nval=pd->getNumberOfElems();
556 _end=start+_nval*nbi;
558 if(type==ON_CELLS && !_localization.empty())
560 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
561 setType(ON_GAUSS_PT);
564 setType(ON_GAUSS_NE);
565 _localization.clear();
570 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
572 std::string fieldName(nasc.getName()),meshName(getMeshName());
573 int iteration(getIteration()),order(getOrder());
574 TypeOfField type(getType());
575 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
576 med_geometry_type mgeoti;
577 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
579 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
582 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
583 if(_start<0 || _start>=arr->getNumberOfTuples())
585 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
586 throw INTERP_KERNEL::Exception(oss.str().c_str());
588 if(_end<0 || _end>arr->getNumberOfTuples())
590 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
591 throw INTERP_KERNEL::Exception(oss.str().c_str());
593 int nbOfCompo(arr->getNumberOfComponents());
594 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
597 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
598 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
601 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
604 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
605 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
608 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
612 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
614 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
616 int delta=_end-_start;
617 _start=newValueOfStart;
621 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
623 return _father->getIteration();
626 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
628 return _father->getOrder();
631 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
633 return _father->getTime();
636 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
638 return _father->getMeshName();
641 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
643 const char startLine[]=" ## ";
644 std::string startLine2(bkOffset,' ');
645 startLine2+=startLine;
646 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
647 oss << startLine2 << "Localization #" << id << "." << std::endl;
648 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
650 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
651 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
652 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
655 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
660 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
665 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
670 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
672 return _father->getGeoType();
675 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
677 return _father->getNumberOfComponents();
680 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
685 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
687 return _father->getOrCreateAndGetArray();
690 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
692 const MEDFileFieldPerMeshPerType *fath=_father;
693 return fath->getOrCreateAndGetArray();
696 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
698 return _father->getInfo();
701 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
706 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
711 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
713 return _localization;
716 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
718 _localization=newLocName;
721 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
723 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
725 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
727 _profile=(*it2).second;
733 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
735 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
737 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
739 _localization=(*it2).second;
745 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
749 dads.push_back(std::pair<int,int>(_start,_end));
750 geoTypes.push_back(getGeoType());
755 pfls.push_back(glob->getProfile(_profile.c_str()));
757 if(_localization.empty())
761 locs.push_back(glob->getLocalizationId(_localization.c_str()));
765 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
767 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));
771 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
773 TypeOfField type=getType();
774 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
775 med_geometry_type mgeoti;
776 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
777 const DataArray *arr=getOrCreateAndGetArray();
779 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
780 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
781 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
782 const unsigned char *locToWrite=0;
784 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
786 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
788 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
789 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
790 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
794 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
799 dad.first=_start; dad.second=_end;
803 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
804 * This code corresponds to the distribution of types in the corresponding mesh.
805 * \param [out] ptToFill memory zone where the output will be stored.
806 * \return the size of data pushed into output param \a ptToFill
808 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
811 std::ostringstream oss;
812 std::size_t nbOfType=codeOfMesh.size()/3;
814 for(std::size_t i=0;i<nbOfType && found==-1;i++)
815 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
819 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
820 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
821 throw INTERP_KERNEL::Exception(oss.str().c_str());
826 if(_nval!=codeOfMesh[3*found+1])
828 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
829 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
830 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
831 throw INTERP_KERNEL::Exception(oss.str().c_str());
833 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
838 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
839 if(pfl->getNumberOfTuples()!=_nval)
841 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
842 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
844 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
845 throw INTERP_KERNEL::Exception(oss.str().c_str());
847 int offset2=codeOfMesh[3*found+2];
848 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
850 if(*pflId<codeOfMesh[3*found+1])
851 *work++=offset2+*pflId;
857 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
859 for(int i=_start;i<_end;i++)
864 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
875 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
879 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
882 std::map<std::pair<std::string,TypeOfField>,int> m;
883 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
884 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
885 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
886 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
888 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
889 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
894 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
896 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
897 * \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.
898 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
899 * \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)
900 * \param [in,out] glob if necessary by the method, new profiles can be added to it
901 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
902 * \param [out] result All new entries will be appended on it.
903 * \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 !)
905 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
906 const DataArrayInt *explicitIdsInMesh,
907 const std::vector<int>& newCode,
908 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
909 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
911 if(entriesOnSameDisc.empty())
913 TypeOfField type=entriesOnSameDisc[0]->getType();
914 int szEntities=0,szTuples=0;
915 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
916 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
917 int nbi=szTuples/szEntities;
918 if(szTuples%szEntities!=0)
919 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
920 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
921 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
922 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
923 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
924 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
925 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
926 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
928 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
930 int startOfEltIdOfChunk=(*it)->_start;
931 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
932 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
933 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
935 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
936 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
938 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
939 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
941 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
942 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
943 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
944 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
946 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
948 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
949 arrPart->renumberInPlace(renumTupleIds->begin());
950 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
952 const int *idIt=diffVals->begin();
953 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
955 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
957 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
958 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
959 int nbEntityElts=subIds->getNumberOfTuples();
961 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
962 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
966 result.push_back(eltToAdd);
967 offset2+=nbEntityElts*nbi;
969 ret=ret || li.empty();
974 * \param [in] typeF type of field of new chunk
975 * \param [in] geoType the geometric type of the chunk
976 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
977 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
978 * \param [in] nbi number of integration points
979 * \param [in] offset The offset in the **global array of data**.
980 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
981 * to the new chunk to create.
982 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
983 * \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
984 * and corresponding entry erased from \a entriesOnSameDisc.
985 * \return a newly allocated chunk
987 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
988 bool isPfl, int nbi, int offset,
989 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
990 MEDFileFieldGlobsReal& glob,
993 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
994 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
995 for(;it!=entriesOnSameDisc.end();it++)
997 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1001 if((*it)->_profile.empty())
1004 if(!(*it)->_profile.empty())
1006 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1007 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1013 if(it==entriesOnSameDisc.end())
1016 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1018 ret->_loc_id=(int)geoType;
1019 ret->_nval=nbMeshEntities;
1021 ret->_end=ret->_start+ret->_nval*nbi;
1024 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1025 glob.appendProfile(idsOfMeshElt);
1026 ret->_profile=idsOfMeshElt->getName();
1028 //tony treatment of localization
1033 notInExisting=false;
1034 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1035 ret->_loc_id=(int)geoType;
1036 ret->setNewStart(offset);
1037 entriesOnSameDisc.erase(it);
1043 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1045 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1048 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1050 return new MEDFileFieldPerMeshPerType(fath,geoType);
1053 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1055 return _field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
1058 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1060 std::vector<const BigMemoryObject *> ret;
1061 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1062 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1066 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const
1068 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1069 ret->_father=father;
1071 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1073 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1074 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
1079 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1081 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1082 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1083 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1087 * This method is the most general one. No optimization is done here.
1088 * \param [in] multiTypePfl is the end user profile specified in high level API
1089 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1090 * \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.
1091 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1092 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1093 * \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.
1095 void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1097 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1098 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1099 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1102 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1104 _field_pm_pt_pd.resize(1);
1105 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1106 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1109 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1111 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1112 if(!arr || !arr->isAllocated())
1113 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1114 _field_pm_pt_pd.resize(1);
1115 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1116 _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1119 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1121 TypeOfField type=field->getTypeOfField();
1122 if(type!=ON_GAUSS_PT)
1124 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1125 int sz=_field_pm_pt_pd.size();
1127 for(int j=0;j<sz && !found;j++)
1129 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1131 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1137 _field_pm_pt_pd.resize(sz+1);
1138 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1140 std::vector<int> ret(1,(int)sz);
1145 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1146 int sz2=ret2.size();
1147 std::vector<int> ret3(sz2);
1149 for(int i=0;i<sz2;i++)
1151 int sz=_field_pm_pt_pd.size();
1152 int locIdToFind=ret2[i];
1154 for(int j=0;j<sz && !found;j++)
1156 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1158 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1165 _field_pm_pt_pd.resize(sz+1);
1166 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1174 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1176 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1177 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1179 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1180 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1182 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1183 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1184 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1185 if(retTmp->presenceOfValue(-1))
1186 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1187 std::vector<int> ret(retTmp->begin(),retTmp->end());
1191 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1193 TypeOfField type=field->getTypeOfField();
1194 if(type!=ON_GAUSS_PT)
1196 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1197 int sz=_field_pm_pt_pd.size();
1199 for(int j=0;j<sz && !found;j++)
1201 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1203 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1209 _field_pm_pt_pd.resize(sz+1);
1210 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1212 std::vector<int> ret(1,0);
1217 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1218 int sz2=ret2.size();
1219 std::vector<int> ret3(sz2);
1221 for(int i=0;i<sz2;i++)
1223 int sz=_field_pm_pt_pd.size();
1224 int locIdToFind=ret2[i];
1226 for(int j=0;j<sz && !found;j++)
1228 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1230 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1237 _field_pm_pt_pd.resize(sz+1);
1238 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1246 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1248 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1249 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1251 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1252 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1254 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1255 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1256 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1257 if(retTmp->presenceOfValue(-1))
1258 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1259 std::vector<int> ret(retTmp->begin(),retTmp->end());
1263 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1268 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1270 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1271 int curDim=(int)cm.getDimension();
1272 dim=std::max(dim,curDim);
1275 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1277 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1279 (*it)->fillTypesOfFieldAvailable(types);
1283 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
1285 int sz=_field_pm_pt_pd.size();
1286 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1287 for(int i=0;i<sz;i++)
1289 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1293 int MEDFileFieldPerMeshPerType::getIteration() const
1295 return _father->getIteration();
1298 int MEDFileFieldPerMeshPerType::getOrder() const
1300 return _father->getOrder();
1303 double MEDFileFieldPerMeshPerType::getTime() const
1305 return _father->getTime();
1308 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1310 return _father->getMeshName();
1313 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1315 const char startLine[]=" ## ";
1316 std::string startLine2(bkOffset,' ');
1317 std::string startLine3(startLine2);
1318 startLine3+=startLine;
1319 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1321 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1322 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1325 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1326 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1328 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1330 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1332 cur->simpleRepr(bkOffset,oss,i);
1335 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1340 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1342 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1344 globalSz+=(*it)->getNumberOfTuples();
1346 nbOfEntries+=(int)_field_pm_pt_pd.size();
1349 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1355 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1357 return _father->getNumberOfComponents();
1360 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1363 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1365 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1372 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1374 return _father->getOrCreateAndGetArray();
1377 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1379 const MEDFileFieldPerMesh *fath=_father;
1380 return fath->getOrCreateAndGetArray();
1383 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1385 return _father->getInfo();
1388 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1390 std::vector<std::string> ret;
1391 std::set<std::string> ret2;
1392 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1394 std::string tmp=(*it1)->getProfile();
1396 if(ret2.find(tmp)==ret2.end())
1405 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1407 std::vector<std::string> ret;
1408 std::set<std::string> ret2;
1409 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1411 std::string tmp=(*it1)->getLocalization();
1412 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1413 if(ret2.find(tmp)==ret2.end())
1422 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1424 std::vector<std::string> ret;
1425 std::set<std::string> ret2;
1426 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1428 std::string tmp=(*it1)->getProfile();
1435 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1437 std::vector<std::string> ret;
1438 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1440 std::string tmp=(*it1)->getLocalization();
1441 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1447 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1449 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1450 (*it1)->changePflsRefsNamesGen(mapOfModif);
1453 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1455 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1456 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1459 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1461 if(_field_pm_pt_pd.empty())
1463 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1464 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1465 throw INTERP_KERNEL::Exception(oss.str().c_str());
1467 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1468 return _field_pm_pt_pd[locId];
1469 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1470 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1471 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1472 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1473 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1476 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1478 if(_field_pm_pt_pd.empty())
1480 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1481 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1482 throw INTERP_KERNEL::Exception(oss.str().c_str());
1484 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1485 return _field_pm_pt_pd[locId];
1486 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1487 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1488 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1489 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1490 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1493 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
1495 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1497 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1498 if(meshDim!=(int)cm.getDimension())
1501 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1502 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1505 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1508 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1510 (*it)->fillValues(i,startEntryId,entries);
1514 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1516 _field_pm_pt_pd=leaves;
1517 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1518 (*it)->setFather(this);
1522 * \param [in,out] globalNum a global numbering counter for the renumbering.
1523 * \param [out] its - list of pair (start,stop) kept
1524 * \return bool - false if the type of field \a tof is not contained in \a this.
1526 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1529 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1530 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1531 if((*it)->getType()==tof)
1533 newPmPtPd.push_back(*it);
1534 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1535 (*it)->setNewStart(globalNum);
1536 globalNum=(*it)->getEnd();
1537 its.push_back(bgEnd);
1541 _field_pm_pt_pd=newPmPtPd;
1546 * \param [in,out] globalNum a global numbering counter for the renumbering.
1547 * \param [out] its - list of pair (start,stop) kept
1548 * \return bool - false if the type of field \a tof is not contained in \a this.
1550 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1552 if(_field_pm_pt_pd.size()<=idOfDisc)
1554 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1555 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1556 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1557 elt->setNewStart(globalNum);
1558 globalNum=elt->getEnd();
1559 its.push_back(bgEnd);
1560 _field_pm_pt_pd=newPmPtPd;
1564 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1568 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1570 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1571 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1572 med_geometry_type mgeoti;
1573 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1574 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1575 _field_pm_pt_pd.resize(nbProfiles);
1576 for(int i=0;i<nbProfiles;i++)
1578 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1582 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1583 for(int i=0;i<nbProfiles2;i++)
1584 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1588 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1590 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1591 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1594 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1596 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1597 (*it)->loadBigArray(fid,nasc);
1600 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1602 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1604 (*it)->copyOptionsFrom(*this);
1605 (*it)->writeLL(fid,nasc);
1609 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1614 medfGeoType=typmai3[(int)ikGeoType];
1617 medfGeoType=MED_NONE;
1620 medfGeoType=typmai3[(int)ikGeoType];
1621 return MED_NODE_ELEMENT;
1623 medfGeoType=typmai3[(int)ikGeoType];
1626 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1628 return MED_UNDEF_ENTITY_TYPE;
1631 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
1633 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1636 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1638 return new MEDFileFieldPerMesh(fath,mesh);
1641 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1643 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1646 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1648 std::vector<const BigMemoryObject *> ret;
1649 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1650 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1654 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1656 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1657 ret->_father=father;
1659 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1661 if((const MEDFileFieldPerMeshPerType *)*it)
1662 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1667 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1669 std::string startLine(bkOffset,' ');
1670 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1671 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1673 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1675 const MEDFileFieldPerMeshPerType *cur=*it;
1677 cur->simpleRepr(bkOffset,oss,i);
1680 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1685 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1687 _mesh_name=mesh->getName();
1688 mesh->getTime(_mesh_iteration,_mesh_order);
1691 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1693 int nbOfTypes=code.size()/3;
1695 for(int i=0;i<nbOfTypes;i++)
1697 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1698 int nbOfCells=code[3*i+1];
1699 int pos=addNewEntryIfNecessary(type);
1700 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1706 * This method is the most general one. No optimization is done here.
1707 * \param [in] multiTypePfl is the end user profile specified in high level API
1708 * \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].
1709 * \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.
1710 * \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.
1711 * \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.
1712 * \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.
1714 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)
1716 int nbOfTypes(code.size()/3);
1717 for(int i=0;i<nbOfTypes;i++)
1719 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1720 int pos=addNewEntryIfNecessary(type);
1721 DataArrayInt *pfl=0;
1723 pfl=idsPerType[code[3*i+2]];
1724 int nbOfTupes2=code2.size()/3;
1726 for(;found<nbOfTupes2;found++)
1727 if(code[3*i]==code2[3*found])
1729 if(found==nbOfTupes2)
1730 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1731 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1735 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1737 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1738 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1741 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1743 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1744 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1747 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1749 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1750 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1753 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1755 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1756 (*it)->loadBigArraysRecursively(fid,nasc);
1759 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1761 int nbOfTypes=_field_pm_pt.size();
1762 for(int i=0;i<nbOfTypes;i++)
1764 _field_pm_pt[i]->copyOptionsFrom(*this);
1765 _field_pm_pt[i]->writeLL(fid,nasc);
1769 void MEDFileFieldPerMesh::getDimension(int& dim) const
1771 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1772 (*it)->getDimension(dim);
1775 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1777 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1778 (*it)->fillTypesOfFieldAvailable(types);
1781 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
1783 int sz=_field_pm_pt.size();
1784 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1785 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1786 for(int i=0;i<sz;i++)
1788 types[i]=_field_pm_pt[i]->getGeoType();
1789 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1794 double MEDFileFieldPerMesh::getTime() const
1797 return _father->getTime(tmp1,tmp2);
1800 int MEDFileFieldPerMesh::getIteration() const
1802 return _father->getIteration();
1805 int MEDFileFieldPerMesh::getOrder() const
1807 return _father->getOrder();
1810 int MEDFileFieldPerMesh::getNumberOfComponents() const
1812 return _father->getNumberOfComponents();
1815 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1817 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1819 const MEDFileFieldPerMeshPerType *fpmt(*it);
1822 if(fpmt->presenceOfMultiDiscPerGeoType())
1828 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1831 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1832 return _father->getOrCreateAndGetArray();
1835 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1838 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1839 return _father->getOrCreateAndGetArray();
1842 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1844 return _father->getInfo();
1848 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1849 * 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.
1850 * It returns 2 output vectors :
1851 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1852 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1853 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1855 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)
1857 int notNullPflsSz=0;
1858 int nbOfArrs=geoTypes.size();
1859 for(int i=0;i<nbOfArrs;i++)
1862 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1863 int nbOfDiffGeoTypes=geoTypes3.size();
1864 code.resize(3*nbOfDiffGeoTypes);
1865 notNullPfls.resize(notNullPflsSz);
1868 for(int i=0;i<nbOfDiffGeoTypes;i++)
1871 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1872 std::vector<const DataArrayInt *> notNullTmp;
1874 notNullTmp.push_back(pfls[j]);
1876 for(;j<nbOfArrs;j++)
1877 if(geoTypes[j]==refType)
1880 notNullTmp.push_back(pfls[j]);
1884 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1885 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1886 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1887 code[3*i]=(int)refType;
1888 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1889 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1890 if(notNullTmp.empty())
1894 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1895 code[3*i+2]=notNullPflsSz++;
1901 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1903 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)
1907 for(int i=0;i<sz;i++)
1911 if(type!=ON_GAUSS_NE)
1912 ret+=dads[i].second-dads[i].first;
1915 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1916 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1921 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1922 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1928 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1930 std::vector<std::string> ret;
1931 std::set<std::string> ret2;
1932 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1934 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1935 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1936 if(ret2.find(*it2)==ret2.end())
1938 ret.push_back(*it2);
1945 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1947 std::vector<std::string> ret;
1948 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1950 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1951 ret.insert(ret.end(),tmp.begin(),tmp.end());
1956 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1958 std::vector<std::string> ret;
1959 std::set<std::string> ret2;
1960 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1962 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1963 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1964 if(ret2.find(*it2)==ret2.end())
1966 ret.push_back(*it2);
1973 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1975 std::vector<std::string> ret;
1976 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1978 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1979 ret.insert(ret.end(),tmp.begin(),tmp.end());
1984 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1986 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1988 if((*it).first==_mesh_name)
1990 _mesh_name=(*it).second;
1997 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1998 MEDFileFieldGlobsReal& glob)
2000 if(_mesh_name!=meshName)
2002 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2003 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2004 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2005 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2006 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2007 getUndergroundDataArrayExt(entries);
2008 DataArray *arr0=getOrCreateAndGetArray();//tony
2010 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2011 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
2013 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2016 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2017 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2019 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2021 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2022 sz+=(*it).second.second-(*it).second.first;
2025 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2027 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2028 ////////////////////
2029 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2030 int *workI2=explicitIdsOldInMesh->getPointer();
2031 int sz1=0,sz2=0,sid=1;
2032 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2033 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2034 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2036 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2037 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2038 int *workI=explicitIdsOldInArr->getPointer();
2039 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2041 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2042 (*itL2)->setLocId(sz2);
2043 (*itL2)->_tmp_work1=(*itL2)->getStart();
2044 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2046 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2048 explicitIdsOldInMesh->reAlloc(sz2);
2049 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2050 ////////////////////
2051 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2052 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2053 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2054 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2056 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2057 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2058 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2060 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2061 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2062 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2064 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2065 int newStart=elt->getLocId();
2066 elt->setLocId((*it)->getGeoType());
2067 elt->setNewStart(newStart);
2068 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2069 entriesKeptNew.push_back(elt);
2070 entriesKeptNew2.push_back(elt);
2072 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2073 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2074 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2075 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2077 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2080 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2082 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2083 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2085 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2086 glob,arr2,otherEntriesNew) || ret;
2090 // Assign new dispatching
2091 assignNewLeaves(otherEntriesNew);
2092 arr->cpyFrom(*arr2);
2097 * \param [in,out] globalNum a global numbering counter for the renumbering.
2098 * \param [out] its - list of pair (start,stop) kept
2100 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2102 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2103 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2105 std::vector< std::pair<int,int> > its2;
2106 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2109 its.insert(its.end(),its2.begin(),its2.end());
2116 * \param [in,out] globalNum a global numbering counter for the renumbering.
2117 * \param [out] its - list of pair (start,stop) kept
2119 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2121 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2122 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2124 std::vector< std::pair<int,int> > its2;
2125 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2128 its.insert(its.end(),its2.begin(),its2.end());
2134 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2136 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2137 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2138 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2140 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2141 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2142 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2143 for(;it1!=types.end();it1++,it2++)
2145 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2146 elt->setLeaves((*it1).second);
2149 _field_pm_pt=fieldPmPt;
2152 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2154 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2155 (*it)->changePflsRefsNamesGen(mapOfModif);
2158 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2160 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2161 (*it)->changeLocsRefsNamesGen(mapOfModif);
2165 * \param [in] mesh is the whole mesh
2167 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2169 if(_field_pm_pt.empty())
2170 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2172 std::vector< std::pair<int,int> > dads;
2173 std::vector<const DataArrayInt *> pfls;
2174 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2175 std::vector<int> locs,code;
2176 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2177 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2178 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2180 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2183 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2184 throw INTERP_KERNEL::Exception(oss.str().c_str());
2187 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2188 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2191 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2193 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2196 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2197 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2203 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2207 if(nb!=mesh->getNumberOfNodes())
2209 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2210 oss << " nodes in mesh !";
2211 throw INTERP_KERNEL::Exception(oss.str().c_str());
2213 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2216 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2220 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2222 if(_field_pm_pt.empty())
2223 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2225 std::vector<std::pair<int,int> > dads;
2226 std::vector<const DataArrayInt *> pfls;
2227 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2228 std::vector<int> locs,code;
2229 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2230 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2231 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2233 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2236 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2237 throw INTERP_KERNEL::Exception(oss.str().c_str());
2239 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2240 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2243 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2244 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2249 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2253 if(nb!=mesh->getNumberOfNodes())
2255 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2256 oss << " nodes in mesh !";
2257 throw INTERP_KERNEL::Exception(oss.str().c_str());
2260 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2266 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2270 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2272 (*it)->getSizes(globalSz,nbOfEntries);
2274 entries.resize(nbOfEntries);
2276 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2278 (*it)->fillValues(nbOfEntries,entries);
2282 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2284 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2286 if((*it)->getGeoType()==typ)
2287 return (*it)->getLeafGivenLocId(locId);
2289 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2290 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2291 oss << "Possiblities are : ";
2292 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2294 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2295 oss << "\"" << cm2.getRepr() << "\", ";
2297 throw INTERP_KERNEL::Exception(oss.str().c_str());
2300 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2302 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2304 if((*it)->getGeoType()==typ)
2305 return (*it)->getLeafGivenLocId(locId);
2307 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2308 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2309 oss << "Possiblities are : ";
2310 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2312 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2313 oss << "\"" << cm2.getRepr() << "\", ";
2315 throw INTERP_KERNEL::Exception(oss.str().c_str());
2318 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2321 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2322 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2323 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2325 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2330 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2335 int ret=std::distance(_field_pm_pt.begin(),it2);
2336 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2341 * 'dads' and 'locs' input parameters have the same number of elements
2342 * \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
2344 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2345 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2346 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2349 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2350 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2351 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2352 const std::vector<std::string>& infos=getInfo();
2353 da->setInfoOnComponents(infos);
2355 if(type==ON_GAUSS_PT)
2358 int nbOfArrs=dads.size();
2359 for(int i=0;i<nbOfArrs;i++)
2361 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2362 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2363 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2364 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2365 di->alloc(nbOfElems,1);
2367 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2368 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2377 * 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.
2378 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2379 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2380 * The order of cells in the returned field is those imposed by the profile.
2381 * \param [in] mesh is the global mesh.
2383 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2384 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2385 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2386 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2388 if(da->isIdentity())
2390 int nbOfTuples=da->getNumberOfTuples();
2391 if(nbOfTuples==mesh->getNumberOfCells())
2392 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2394 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2395 m2->setName(mesh->getName().c_str());
2396 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2402 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2404 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2405 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2406 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2408 if(da->isIdentity())
2410 int nbOfTuples=da->getNumberOfTuples();
2411 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2412 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2414 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2415 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2418 if(meshu->getNodalConnectivity()==0)
2420 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2421 int nb=da->getNbOfElems();
2422 const int *ptr=da->getConstPointer();
2423 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2424 meshuc->allocateCells(nb);
2425 for(int i=0;i<nb;i++)
2426 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2427 meshuc->finishInsertingCells();
2428 ret->setMesh(meshuc);
2429 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2430 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2431 disc->checkCoherencyBetween(meshuc,arrOut);
2436 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2438 DataArrayInt *arr2=0;
2439 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2440 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2441 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2442 int nnodes=mesh2->getNumberOfNodes();
2443 if(nnodes==(int)da->getNbOfElems())
2445 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2446 arrOut->renumberInPlace(da3->getConstPointer());
2447 mesh2->setName(mesh->getName().c_str());
2448 ret->setMesh(mesh2);
2453 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 !!!";
2454 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2455 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2456 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2457 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2458 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2459 throw INTERP_KERNEL::Exception(oss.str().c_str());
2465 * This method is the most light method of field retrieving.
2467 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2471 pflOut=DataArrayInt::New();
2472 pflOut->alloc(nbOfElems,1);
2477 pflOut=const_cast<DataArrayInt*>(pflIn);
2480 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2481 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2482 const std::vector<std::string>& infos=getInfo();
2483 int nbOfComp=infos.size();
2484 for(int i=0;i<nbOfComp;i++)
2485 da->setInfoOnComponent(i,infos[i].c_str());
2496 static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2497 static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2498 virtual ~MFFPMIter() { }
2499 virtual void begin() = 0;
2500 virtual bool finished() const = 0;
2501 virtual void next() = 0;
2502 virtual int current() const = 0;
2505 class MFFPMIterSimple : public MFFPMIter
2508 MFFPMIterSimple():_pos(0) { }
2509 void begin() { _pos=0; }
2510 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2511 void next() { _pos++; }
2512 int current() const { return _pos; }
2517 class MFFPMIter2 : public MFFPMIter
2520 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2521 void begin() { _it=_ids.begin(); }
2522 bool finished() const { return _it==_ids.end(); }
2523 void next() { _it++; }
2524 int current() const { return *_it; }
2526 std::vector<int> _ids;
2527 std::vector<int>::const_iterator _it;
2530 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2533 return new MFFPMIterSimple;
2536 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2537 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2539 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2540 tmp.push_back((*it).second);
2542 return new MFFPMIter2(tmp);
2546 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2552 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2553 if((*it).first==ON_NODES)
2559 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2561 std::size_t sz(cts.size());
2563 for(std::size_t i=0;i<sz;i++)
2565 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2566 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2567 _ids[i]=(int)std::distance(typmai2,loc);
2569 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2575 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2578 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2579 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2580 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2581 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2582 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2583 for(iter0->begin();!iter0->finished();iter0->next())
2585 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2586 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2587 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2588 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2589 if(nbProfile>0 || nbProfile2>0)
2591 const PartDefinition *pd(0);
2593 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2594 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2601 if(MFFPMIter::IsPresenceOfNode(entities))
2603 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2606 const PartDefinition *pd(0);
2608 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2609 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2610 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2615 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2617 copyTinyInfoFrom(mesh);
2620 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2622 if(id>=(int)_pfls.size())
2624 _pfls[id]=DataArrayInt::New();
2625 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2626 _pfls[id]->setName(pflName);
2627 _pfls[id]->alloc(lgth,1);
2628 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2629 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2632 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2634 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2636 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2637 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2638 if(i>=(int)_pfls.size())
2640 _pfls[i]=DataArrayInt::New();
2641 _pfls[i]->alloc(sz,1);
2642 _pfls[i]->setName(pflCpp.c_str());
2643 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2644 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2647 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2649 int nbOfPfls=_pfls.size();
2650 for(int i=0;i<nbOfPfls;i++)
2652 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2653 cpy->applyLin(1,1,0);
2654 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2655 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2656 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2659 int nbOfLocs=_locs.size();
2660 for(int i=0;i<nbOfLocs;i++)
2661 _locs[i]->writeLL(fid);
2664 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2666 std::vector<std::string> pfls=getPfls();
2667 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2669 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2672 _pfls.push_back(*it);
2676 int id=std::distance(pfls.begin(),it2);
2677 if(!(*it)->isEqual(*_pfls[id]))
2679 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2680 throw INTERP_KERNEL::Exception(oss.str().c_str());
2684 std::vector<std::string> locs=getLocs();
2685 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2687 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2690 _locs.push_back(*it);
2694 int id=std::distance(locs.begin(),it2);
2695 if(!(*it)->isEqual(*_locs[id],eps))
2697 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2698 throw INTERP_KERNEL::Exception(oss.str().c_str());
2704 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2706 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2707 getProfile((*it).c_str());
2710 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2712 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2713 getLocalization((*it).c_str());
2716 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2718 std::vector<std::string> profiles=real.getPflsReallyUsed();
2719 int sz=profiles.size();
2721 for(int i=0;i<sz;i++)
2722 loadProfileInFile(fid,i,profiles[i].c_str());
2724 std::vector<std::string> locs=real.getLocsReallyUsed();
2727 for(int i=0;i<sz;i++)
2728 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2731 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2733 int nProfil=MEDnProfile(fid);
2734 for(int i=0;i<nProfil;i++)
2735 loadProfileInFile(fid,i);
2736 int sz=MEDnLocalization(fid);
2738 for(int i=0;i<sz;i++)
2740 _locs[i]=MEDFileFieldLoc::New(fid,i);
2744 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2746 return new MEDFileFieldGlobs(fname);
2749 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2751 return new MEDFileFieldGlobs;
2754 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2756 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2759 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2761 std::vector<const BigMemoryObject *> ret;
2762 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2763 ret.push_back((const DataArrayInt *)*it);
2764 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2765 ret.push_back((const MEDFileFieldLoc *)*it);
2769 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2771 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2773 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2775 if((const DataArrayInt *)*it)
2776 ret->_pfls[i]=(*it)->deepCpy();
2779 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2781 if((const MEDFileFieldLoc*)*it)
2782 ret->_locs[i]=(*it)->deepCpy();
2788 * \throw if a profile in \a pfls in not in \a this.
2789 * \throw if a localization in \a locs in not in \a this.
2790 * \sa MEDFileFieldGlobs::deepCpyPart
2792 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2794 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2795 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2797 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2799 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2801 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2802 ret->_pfls.push_back(pfl2);
2804 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2806 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2808 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2810 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2811 ret->_locs.push_back(loc2);
2813 ret->setFileName(getFileName());
2818 * \throw if a profile in \a pfls in not in \a this.
2819 * \throw if a localization in \a locs in not in \a this.
2820 * \sa MEDFileFieldGlobs::shallowCpyPart
2822 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2824 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2825 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2827 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2829 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2830 ret->_pfls.push_back(pfl->deepCpy());
2832 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2834 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2836 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2837 ret->_locs.push_back(loc->deepCpy());
2839 ret->setFileName(getFileName());
2843 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2847 MEDFileFieldGlobs::MEDFileFieldGlobs()
2851 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2855 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2857 oss << "Profiles :\n";
2858 std::size_t n=_pfls.size();
2859 for(std::size_t i=0;i<n;i++)
2861 oss << " - #" << i << " ";
2862 const DataArrayInt *pfl=_pfls[i];
2864 oss << "\"" << pfl->getName() << "\"\n";
2869 oss << "Localizations :\n";
2870 for(std::size_t i=0;i<n;i++)
2872 oss << " - #" << i << " ";
2873 const MEDFileFieldLoc *loc=_locs[i];
2875 loc->simpleRepr(oss);
2881 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2883 _file_name=fileName;
2886 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2888 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2890 DataArrayInt *elt(*it);
2893 std::string name(elt->getName());
2894 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2896 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2898 elt->setName((*it2).second.c_str());
2906 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2908 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2910 MEDFileFieldLoc *elt(*it);
2913 std::string name(elt->getName());
2914 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2916 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2918 elt->setName((*it2).second.c_str());
2926 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2928 if(locId<0 || locId>=(int)_locs.size())
2929 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2930 return _locs[locId]->getNbOfGaussPtPerCell();
2933 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2935 return getLocalizationFromId(getLocalizationId(locName));
2938 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2940 if(locId<0 || locId>=(int)_locs.size())
2941 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2942 return *_locs[locId];
2945 namespace ParaMEDMEMImpl
2950 LocFinder(const std::string& loc):_loc(loc) { }
2951 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2953 const std::string &_loc;
2959 PflFinder(const std::string& pfl):_pfl(pfl) { }
2960 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2962 const std::string& _pfl;
2966 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2968 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2971 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2972 for(it=_locs.begin();it!=_locs.end();it++)
2973 oss << "\"" << (*it)->getName() << "\", ";
2974 throw INTERP_KERNEL::Exception(oss.str().c_str());
2976 return std::distance(_locs.begin(),it);
2980 * The returned value is never null.
2982 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2984 std::string pflNameCpp(pflName);
2985 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2988 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2989 for(it=_pfls.begin();it!=_pfls.end();it++)
2990 oss << "\"" << (*it)->getName() << "\", ";
2991 throw INTERP_KERNEL::Exception(oss.str().c_str());
2996 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2998 if(pflId<0 || pflId>=(int)_pfls.size())
2999 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3000 return _pfls[pflId];
3003 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3005 if(locId<0 || locId>=(int)_locs.size())
3006 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3007 return *_locs[locId];
3010 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3012 return getLocalizationFromId(getLocalizationId(locName));
3016 * The returned value is never null.
3018 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3020 std::string pflNameCpp(pflName);
3021 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
3024 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3025 for(it=_pfls.begin();it!=_pfls.end();it++)
3026 oss << "\"" << (*it)->getName() << "\", ";
3027 throw INTERP_KERNEL::Exception(oss.str().c_str());
3032 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3034 if(pflId<0 || pflId>=(int)_pfls.size())
3035 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3036 return _pfls[pflId];
3039 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3041 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
3043 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3045 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3046 newPfls.push_back(*it);
3051 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3053 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
3055 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3057 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3058 newLocs.push_back(*it);
3063 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3065 int sz=_pfls.size();
3066 std::vector<std::string> ret(sz);
3067 for(int i=0;i<sz;i++)
3068 ret[i]=_pfls[i]->getName();
3072 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3074 int sz=_locs.size();
3075 std::vector<std::string> ret(sz);
3076 for(int i=0;i<sz;i++)
3077 ret[i]=_locs[i]->getName();
3081 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3083 std::vector<std::string> v=getPfls();
3084 std::string s(pflName);
3085 return std::find(v.begin(),v.end(),s)!=v.end();
3088 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3090 std::vector<std::string> v=getLocs();
3091 std::string s(locName);
3092 return std::find(v.begin(),v.end(),s)!=v.end();
3095 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3097 std::map<int,std::vector<int> > m;
3099 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3101 const DataArrayInt *tmp=(*it);
3104 m[tmp->getHashCode()].push_back(i);
3107 std::vector< std::vector<int> > ret;
3108 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3110 if((*it2).second.size()>1)
3112 std::vector<int> ret0;
3113 bool equalityOrNot=false;
3114 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3116 std::vector<int>::const_iterator it4=it3; it4++;
3117 for(;it4!=(*it2).second.end();it4++)
3119 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3122 ret0.push_back(*it3);
3123 ret0.push_back(*it4);
3129 ret.push_back(ret0);
3135 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3137 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3140 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3142 std::string name(pfl->getName());
3144 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3145 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3146 if(name==(*it)->getName())
3148 if(!pfl->isEqual(*(*it)))
3150 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3151 throw INTERP_KERNEL::Exception(oss.str().c_str());
3155 _pfls.push_back(pfl);
3158 void MEDFileFieldGlobs::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
3160 std::string name(locName);
3162 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3163 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3164 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3165 if((*it)->isName(locName))
3167 if(!(*it)->isEqual(*obj,1e-12))
3169 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3170 throw INTERP_KERNEL::Exception(oss.str().c_str());
3173 _locs.push_back(obj);
3176 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3178 std::vector<std::string> names=getPfls();
3179 return CreateNewNameNotIn("NewPfl_",names);
3182 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3184 std::vector<std::string> names=getLocs();
3185 return CreateNewNameNotIn("NewLoc_",names);
3188 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3190 for(std::size_t sz=0;sz<100000;sz++)
3192 std::ostringstream tryName;
3193 tryName << prefix << sz;
3194 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3195 return tryName.str();
3197 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3201 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3202 * \param [in] fname - the file name.
3204 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3209 * Creates an empty MEDFileFieldGlobsReal.
3211 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3215 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3220 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3222 std::vector<const BigMemoryObject *> ret;
3223 ret.push_back((const MEDFileFieldGlobs *)_globals);
3228 * Returns a string describing profiles and Gauss points held in \a this.
3229 * \return std::string - the description string.
3231 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3233 const MEDFileFieldGlobs *glob=_globals;
3234 std::ostringstream oss2; oss2 << glob;
3235 std::string stars(oss2.str().length(),'*');
3236 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3238 glob->simpleRepr(oss);
3240 oss << "NO GLOBAL INFORMATION !\n";
3243 void MEDFileFieldGlobsReal::resetContent()
3245 _globals=MEDFileFieldGlobs::New();
3248 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3253 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3254 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3256 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3258 _globals=other._globals;
3262 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3263 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3265 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3267 const MEDFileFieldGlobs *otherg(other._globals);
3270 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3274 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3275 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3277 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3279 const MEDFileFieldGlobs *otherg(other._globals);
3282 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3285 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3287 _globals=other._globals;
3288 if((const MEDFileFieldGlobs *)_globals)
3289 _globals=other._globals->deepCpy();
3293 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3294 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3295 * \param [in] eps - a precision used to compare Gauss points with same name held by
3296 * \a this and \a other MEDFileFieldGlobsReal.
3297 * \throw If \a this and \a other hold profiles with equal names but different ids.
3298 * \throw If \a this and \a other hold different Gauss points with equal names.
3300 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3302 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3303 if(thisGlobals==otherGlobals)
3307 _globals=other._globals;
3310 _globals->appendGlobs(*other._globals,eps);
3313 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3315 checkGlobsPflsPartCoherency();
3316 checkGlobsLocsPartCoherency();
3319 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3321 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3324 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3326 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3329 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3331 contentNotNull()->loadProfileInFile(fid,id,pflName);
3334 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3336 contentNotNull()->loadProfileInFile(fid,id);
3339 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3341 contentNotNull()->loadGlobals(fid,*this);
3344 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3346 contentNotNull()->loadAllGlobals(fid);
3349 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3351 contentNotNull()->writeGlobals(fid,opt);
3355 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3356 * or getPflsReallyUsedMulti().
3357 * \return std::vector<std::string> - a sequence of names of all profiles.
3359 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3361 return contentNotNull()->getPfls();
3365 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3366 * or getLocsReallyUsedMulti().
3367 * \return std::vector<std::string> - a sequence of names of all localizations.
3369 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3371 return contentNotNull()->getLocs();
3375 * Checks if the profile with a given name exists.
3376 * \param [in] pflName - the profile name of interest.
3377 * \return bool - \c true if the profile named \a pflName exists.
3379 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3381 return contentNotNull()->existsPfl(pflName);
3385 * Checks if the localization with a given name exists.
3386 * \param [in] locName - the localization name of interest.
3387 * \return bool - \c true if the localization named \a locName exists.
3389 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3391 return contentNotNull()->existsLoc(locName);
3394 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3396 return contentNotNull()->createNewNameOfPfl();
3399 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3401 return contentNotNull()->createNewNameOfLoc();
3405 * Sets the name of a MED file.
3406 * \param [inout] fileName - the file name.
3408 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3410 contentNotNull()->setFileName(fileName);
3414 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3415 * in the same order.
3416 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3417 * Each item of this sequence is a vector containing ids of equal profiles.
3419 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3421 return contentNotNull()->whichAreEqualProfiles();
3425 * Finds equal localizations.
3426 * \param [in] eps - a precision used to compare real values of the localizations.
3427 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3428 * Each item of this sequence is a vector containing ids of equal localizations.
3430 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3432 return contentNotNull()->whichAreEqualLocs(eps);
3436 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3437 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3438 * this sequence is a pair whose
3439 * - the first item is a vector of profile names to replace by the second item,
3440 * - the second item is a profile name to replace every profile name of the first item.
3442 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3444 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3448 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3449 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3450 * this sequence is a pair whose
3451 * - the first item is a vector of localization names to replace by the second item,
3452 * - the second item is a localization name to replace every localization name of the first item.
3454 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3456 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3460 * Replaces references to some profiles (a reference is a profile name) by references
3461 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3462 * them-selves accordingly. <br>
3463 * This method is a generalization of changePflName().
3464 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3465 * this sequence is a pair whose
3466 * - the first item is a vector of profile names to replace by the second item,
3467 * - the second item is a profile name to replace every profile of the first item.
3468 * \sa changePflsRefsNamesGen()
3469 * \sa changePflName()
3471 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3473 changePflsRefsNamesGen(mapOfModif);
3474 changePflsNamesInStruct(mapOfModif);
3478 * Replaces references to some localizations (a reference is a localization name) by references
3479 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3480 * them-selves accordingly. <br>
3481 * This method is a generalization of changeLocName().
3482 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3483 * this sequence is a pair whose
3484 * - the first item is a vector of localization names to replace by the second item,
3485 * - the second item is a localization name to replace every localization of the first item.
3486 * \sa changeLocsRefsNamesGen()
3487 * \sa changeLocName()
3489 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3491 changeLocsRefsNamesGen(mapOfModif);
3492 changeLocsNamesInStruct(mapOfModif);
3496 * Renames the profile having a given name and updates references to this profile.
3497 * \param [in] oldName - the name of the profile to rename.
3498 * \param [in] newName - a new name of the profile.
3499 * \sa changePflsNames().
3501 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3503 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3504 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3506 changePflsNames(mapOfModif);
3510 * Renames the localization having a given name and updates references to this localization.
3511 * \param [in] oldName - the name of the localization to rename.
3512 * \param [in] newName - a new name of the localization.
3513 * \sa changeLocsNames().
3515 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3517 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3518 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3520 changeLocsNames(mapOfModif);
3524 * Removes duplicated profiles. Returns a map used to update references to removed
3525 * profiles via changePflsRefsNamesGen().
3526 * Equal profiles are found using whichAreEqualProfiles().
3527 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3528 * a sequence describing the performed replacements of profiles. Each element of
3529 * this sequence is a pair whose
3530 * - the first item is a vector of profile names replaced by the second item,
3531 * - the second item is a profile name replacing every profile of the first item.
3533 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3535 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3536 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3538 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3540 std::vector< std::string > tmp((*it).size());
3542 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3543 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3544 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3546 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3547 killProfileIds(tmp2);
3549 changePflsRefsNamesGen(ret);
3554 * Removes duplicated localizations. Returns a map used to update references to removed
3555 * localizations via changeLocsRefsNamesGen().
3556 * Equal localizations are found using whichAreEqualLocs().
3557 * \param [in] eps - a precision used to compare real values of the localizations.
3558 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3559 * a sequence describing the performed replacements of localizations. Each element of
3560 * this sequence is a pair whose
3561 * - the first item is a vector of localization names replaced by the second item,
3562 * - the second item is a localization name replacing every localization of the first item.
3564 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3566 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3567 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3569 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3571 std::vector< std::string > tmp((*it).size());
3573 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3574 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3575 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3577 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3578 killLocalizationIds(tmp2);
3580 changeLocsRefsNamesGen(ret);
3585 * Returns number of Gauss points per cell in a given localization.
3586 * \param [in] locId - an id of the localization of interest.
3587 * \return int - the number of the Gauss points per cell.
3589 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3591 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3595 * Returns an id of a localization by its name.
3596 * \param [in] loc - the localization name of interest.
3597 * \return int - the id of the localization.
3598 * \throw If there is no a localization named \a loc.
3600 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3602 return contentNotNull()->getLocalizationId(loc);
3606 * Returns the name of the MED file.
3607 * \return const std::string& - the MED file name.
3609 std::string MEDFileFieldGlobsReal::getFileName() const
3611 return contentNotNull()->getFileName();
3615 * Returns a localization object by its name.
3616 * \param [in] locName - the name of the localization of interest.
3617 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3618 * \throw If there is no a localization named \a locName.
3620 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3622 return contentNotNull()->getLocalization(locName);
3626 * Returns a localization object by its id.
3627 * \param [in] locId - the id of the localization of interest.
3628 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3629 * \throw If there is no a localization with id \a locId.
3631 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3633 return contentNotNull()->getLocalizationFromId(locId);
3637 * Returns a profile array by its name.
3638 * \param [in] pflName - the name of the profile of interest.
3639 * \return const DataArrayInt * - the profile array having the name \a pflName.
3640 * \throw If there is no a profile named \a pflName.
3642 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3644 return contentNotNull()->getProfile(pflName);
3648 * Returns a profile array by its id.
3649 * \param [in] pflId - the id of the profile of interest.
3650 * \return const DataArrayInt * - the profile array having the id \a pflId.
3651 * \throw If there is no a profile with id \a pflId.
3653 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3655 return contentNotNull()->getProfileFromId(pflId);
3659 * Returns a localization object, apt for modification, by its id.
3660 * \param [in] locId - the id of the localization of interest.
3661 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3662 * having the id \a locId.
3663 * \throw If there is no a localization with id \a locId.
3665 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3667 return contentNotNull()->getLocalizationFromId(locId);
3671 * Returns a localization object, apt for modification, by its name.
3672 * \param [in] locName - the name of the localization of interest.
3673 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3674 * having the name \a locName.
3675 * \throw If there is no a localization named \a locName.
3677 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3679 return contentNotNull()->getLocalization(locName);
3683 * Returns a profile array, apt for modification, by its name.
3684 * \param [in] pflName - the name of the profile of interest.
3685 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3686 * \throw If there is no a profile named \a pflName.
3688 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3690 return contentNotNull()->getProfile(pflName);
3694 * Returns a profile array, apt for modification, by its id.
3695 * \param [in] pflId - the id of the profile of interest.
3696 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3697 * \throw If there is no a profile with id \a pflId.
3699 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3701 return contentNotNull()->getProfileFromId(pflId);
3705 * Removes profiles given by their ids. No data is updated to track this removal.
3706 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3708 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3710 contentNotNull()->killProfileIds(pflIds);
3714 * Removes localizations given by their ids. No data is updated to track this removal.
3715 * \param [in] locIds - a sequence of ids of the localizations to remove.
3717 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3719 contentNotNull()->killLocalizationIds(locIds);
3723 * Stores a profile array.
3724 * \param [in] pfl - the profile array to store.
3725 * \throw If the name of \a pfl is empty.
3726 * \throw If a profile with the same name as that of \a pfl already exists but contains
3729 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3731 contentNotNull()->appendProfile(pfl);
3735 * Adds a new localization of Gauss points.
3736 * \param [in] locName - the name of the new localization.
3737 * \param [in] geoType - a geometrical type of the reference cell.
3738 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3739 * must be \c nbOfNodesPerCell * \c dimOfType.
3740 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3741 * must be _wg_.size() * \c dimOfType.
3742 * \param [in] w - the weights of Gauss points.
3743 * \throw If \a locName is empty.
3744 * \throw If a localization with the name \a locName already exists but is
3745 * different form the new one.
3747 void MEDFileFieldGlobsReal::appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
3749 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3752 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3754 MEDFileFieldGlobs *g(_globals);
3756 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3760 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3762 const MEDFileFieldGlobs *g(_globals);
3764 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3768 //= MEDFileFieldNameScope
3770 MEDFileFieldNameScope::MEDFileFieldNameScope()
3774 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3779 * Returns the name of \a this field.
3780 * \return std::string - a string containing the field name.
3782 std::string MEDFileFieldNameScope::getName() const
3788 * Sets name of \a this field
3789 * \param [in] name - the new field name.
3791 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3796 std::string MEDFileFieldNameScope::getDtUnit() const
3801 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3806 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3809 _dt_unit=other._dt_unit;
3812 //= MEDFileAnyTypeField1TSWithoutSDA
3814 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3816 _field_per_mesh.resize(other._field_per_mesh.size());
3818 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3820 if((const MEDFileFieldPerMesh *)*it)
3821 _field_per_mesh[i]=(*it)->deepCpy(this);
3826 * Prints a string describing \a this field into a stream. This string is outputted
3827 * by \c print Python command.
3828 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3829 * \param [in,out] oss - the out stream.
3830 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3831 * info id printed, else, not.
3833 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3835 std::string startOfLine(bkOffset,' ');
3836 oss << startOfLine << "Field ";
3838 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3839 oss << "on one time Step ";
3841 oss << "(" << f1tsId << ") ";
3842 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3843 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3844 const DataArray *arr=getUndergroundDataArray();
3847 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3850 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3851 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3852 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3854 if(arr->isAllocated())
3856 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3859 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3863 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3865 oss << startOfLine << "----------------------" << std::endl;
3866 if(!_field_per_mesh.empty())
3869 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3871 const MEDFileFieldPerMesh *cur=(*it2);
3873 cur->simpleRepr(bkOffset,oss,i);
3875 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3880 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3882 oss << startOfLine << "----------------------" << std::endl;
3885 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3887 const DataArray *arr(getUndergroundDataArray());
3889 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3890 int nbOfCompo=arr->getNumberOfComponents();
3891 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3892 for(int i=0;i<nbOfCompo;i++)
3895 std::vector<int> v(1,i);
3896 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3897 ret[i]->setArray(arr2);
3902 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
3906 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3911 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3912 * empty. Returns -1 if this in on nodes.
3913 * \return int - the dimension of \a this.
3915 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3918 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3919 (*it)->getDimension(ret);
3924 * Returns the mesh name.
3925 * \return std::string - a string holding the mesh name.
3926 * \throw If \c _field_per_mesh.empty()
3928 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3930 if(_field_per_mesh.empty())
3931 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3932 return _field_per_mesh[0]->getMeshName();
3935 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3937 std::string oldName(getMeshName());
3938 std::vector< std::pair<std::string,std::string> > v(1);
3939 v[0].first=oldName; v[0].second=newMeshName;
3943 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3946 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3948 MEDFileFieldPerMesh *cur(*it);
3950 ret=cur->changeMeshNames(modifTab) || ret;
3956 * Returns the number of iteration of the state of underlying mesh.
3957 * \return int - the iteration number.
3958 * \throw If \c _field_per_mesh.empty()
3960 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3962 if(_field_per_mesh.empty())
3963 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3964 return _field_per_mesh[0]->getMeshIteration();
3968 * Returns the order number of iteration of the state of underlying mesh.
3969 * \return int - the order number.
3970 * \throw If \c _field_per_mesh.empty()
3972 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3974 if(_field_per_mesh.empty())
3975 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3976 return _field_per_mesh[0]->getMeshOrder();
3980 * Checks if \a this field is tagged by a given iteration number and a given
3981 * iteration order number.
3982 * \param [in] iteration - the iteration number of interest.
3983 * \param [in] order - the iteration order number of interest.
3984 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3985 * \a this->getOrder() == \a order.
3987 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3989 return iteration==_iteration && order==_order;
3993 * Returns number of iteration and order number of iteration when
3994 * \a this field has been calculated.
3995 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3998 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4000 std::pair<int,int> p;
4006 * Returns number of iteration and order number of iteration when
4007 * \a this field has been calculated.
4008 * \param [in,out] p - a pair returning the iteration number and the iteration
4011 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4018 * Returns all types of spatial discretization of \a this field.
4019 * \param [in,out] types - a sequence of types of \a this field.
4021 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4023 std::set<TypeOfField> types2;
4024 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4026 (*it)->fillTypesOfFieldAvailable(types2);
4028 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4029 std::copy(types2.begin(),types2.end(),bi);
4033 * Returns all types of spatial discretization of \a this field.
4034 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4037 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4039 std::vector<TypeOfField> ret;
4040 fillTypesOfFieldAvailable(ret);
4044 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4046 std::vector<std::string> ret;
4047 std::set<std::string> ret2;
4048 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4050 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4051 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4052 if(ret2.find(*it2)==ret2.end())
4054 ret.push_back(*it2);
4061 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4063 std::vector<std::string> ret;
4064 std::set<std::string> ret2;
4065 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4067 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4068 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4069 if(ret2.find(*it2)==ret2.end())
4071 ret.push_back(*it2);
4078 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4080 std::vector<std::string> ret;
4081 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4083 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4084 ret.insert(ret.end(),tmp.begin(),tmp.end());
4089 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4091 std::vector<std::string> ret;
4092 std::set<std::string> ret2;
4093 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4095 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4096 ret.insert(ret.end(),tmp.begin(),tmp.end());
4101 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4103 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4104 (*it)->changePflsRefsNamesGen(mapOfModif);
4107 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4109 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4110 (*it)->changeLocsRefsNamesGen(mapOfModif);
4114 * Returns all attributes of parts of \a this field lying on a given mesh.
4115 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4116 * item of every of returned sequences refers to the _i_-th part of \a this field.
4117 * Thus all sequences returned by this method are of the same length equal to number
4118 * of different types of supporting entities.<br>
4119 * A field part can include sub-parts with several different spatial discretizations,
4120 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4121 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4122 * of a nested sequence corresponds to a type of spatial discretization.<br>
4123 * This method allows for iteration over MEDFile DataStructure without any overhead.
4124 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4125 * for the case with only one underlying mesh. (Actually, the number of meshes is
4126 * not checked if \a mname == \c NULL).
4127 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4128 * a field part is returned.
4129 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4130 * This sequence is of the same length as \a types.
4131 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4132 * discretization. A profile name can be empty.
4133 * Length of this and of nested sequences is the same as that of \a typesF.
4134 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4135 * discretization. A localization name can be empty.
4136 * Length of this and of nested sequences is the same as that of \a typesF.
4137 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4138 * of ids of tuples within the data array, per each type of spatial
4139 * discretization within one mesh entity type.
4140 * Length of this and of nested sequences is the same as that of \a typesF.
4141 * \throw If no field is lying on \a mname.
4143 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeField1TSWithoutSDA::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
4147 meshId=getMeshIdFromMeshName(mname);
4149 if(_field_per_mesh.empty())
4150 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4151 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4155 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4156 * maximal absolute dimension and values returned via the out parameter \a levs are
4157 * dimensions relative to the maximal absolute dimension. <br>
4158 * This method is designed for MEDFileField1TS instances that have a discretization
4159 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
4160 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
4161 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
4162 * Only these 3 discretizations will be taken into account here. If \a this is
4163 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4164 * This method is useful to make the link between the dimension of the underlying mesh
4165 * and the levels of \a this, because it is possible that the highest dimension of \a this
4166 * field is not equal to the dimension of the underlying mesh.
4168 * Let's consider the following case:
4169 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4170 * TETRA4, HEXA8, TRI3 and SEG2.
4171 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4172 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4174 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4175 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4176 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4177 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4178 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4179 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4181 * to retrieve the highest level of
4182 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4183 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4184 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4185 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4186 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4187 * for the case with only one underlying mesh. (Actually, the number of meshes is
4188 * not checked if \a mname == \c NULL).
4189 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4190 * absolute one. They are in decreasing order. This sequence is cleared before
4192 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4193 * \throw If no field is lying on \a mname.
4195 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4198 int meshId=getMeshIdFromMeshName(mname);
4199 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4200 std::vector< std::vector<TypeOfField> > typesF;
4201 std::vector< std::vector<std::string> > pfls, locs;
4202 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4204 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4205 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4206 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4208 st.erase(INTERP_KERNEL::NORM_ERROR);
4210 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4212 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4213 ret1.insert((int)cm.getDimension());
4215 int ret=*std::max_element(ret1.begin(),ret1.end());
4216 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4217 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4222 * \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.
4223 * \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.
4224 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4225 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4227 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4229 int mid=getMeshIdFromMeshName(mName);
4230 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4234 * \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.
4235 * \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.
4236 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4237 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4239 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4241 int mid=getMeshIdFromMeshName(mName);
4242 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4246 * \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.
4248 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4250 if(_field_per_mesh.empty())
4251 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4254 std::string mName2(mName);
4256 std::vector<std::string> msg;
4257 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4258 if(mName2==(*it)->getMeshName())
4261 msg.push_back((*it)->getMeshName());
4262 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4263 oss << "Possible meshes are : ";
4264 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4265 oss << "\"" << (*it2) << "\" ";
4266 throw INTERP_KERNEL::Exception(oss.str().c_str());
4269 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4272 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4273 std::string tmp(mesh->getName());
4275 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4276 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4278 for(;it!=_field_per_mesh.end();it++,i++)
4280 if((*it)->getMeshName()==tmp)
4283 int sz=_field_per_mesh.size();
4284 _field_per_mesh.resize(sz+1);
4285 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4289 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4290 MEDFileFieldGlobsReal& glob)
4293 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4295 MEDFileFieldPerMesh *fpm(*it);
4297 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4303 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4304 * splitting that leads to single spatial discretization of this.
4306 * \sa splitMultiDiscrPerGeoTypes
4308 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4310 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4311 std::vector< std::vector<TypeOfField> > typesF;
4312 std::vector< std::vector<std::string> > pfls,locs;
4313 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4314 std::set<TypeOfField> allEnt;
4315 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4316 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4317 allEnt.insert(*it2);
4318 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4319 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4320 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4322 std::vector< std::pair<int,int> > its;
4323 ret[i]=shallowCpy();
4324 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4325 ret[i]->updateData(newLgth,its);
4331 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4332 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4334 * \sa splitDiscretizations
4336 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4338 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4339 std::vector< std::vector<TypeOfField> > typesF;
4340 std::vector< std::vector<std::string> > pfls,locs;
4341 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4342 std::set<TypeOfField> allEnt;
4343 std::size_t nbOfMDPGT(0),ii(0);
4344 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4346 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4347 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4348 allEnt.insert(*it2);
4350 if(allEnt.size()!=1)
4351 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4353 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4356 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4357 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4360 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4361 for(std::size_t i=0;i<nbOfMDPGT;i++)
4363 std::vector< std::pair<int,int> > its;
4364 ret[i]=shallowCpy();
4365 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4366 ret[i]->updateData(newLgth,its);
4371 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4373 int globalCounter(0);
4374 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4375 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4376 return globalCounter;
4379 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4381 int globalCounter(0);
4382 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4383 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4384 return globalCounter;
4387 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4389 if(_nb_of_tuples_to_be_allocated>=0)
4391 _nb_of_tuples_to_be_allocated=newLgth;
4392 const DataArray *oldArr(getUndergroundDataArray());
4395 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4396 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4398 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4402 if(_nb_of_tuples_to_be_allocated==-1)
4404 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4406 const DataArray *oldArr(getUndergroundDataArray());
4407 if(!oldArr || !oldArr->isAllocated())
4408 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4409 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4410 newArr->alloc(newLgth,getNumberOfComponents());
4412 newArr->copyStringInfoFrom(*oldArr);
4414 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4416 if((*it).second<(*it).first)
4417 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4418 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4419 pos+=(*it).second-(*it).first;
4424 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4427 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4429 if(_field_per_mesh.empty())
4430 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4431 if(_field_per_mesh.size()>1)
4432 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4433 _field_per_mesh[0]->copyOptionsFrom(opts);
4434 _field_per_mesh[0]->writeLL(fid,nasc);
4438 * 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.
4439 * If false is returned the memory allocation is not required.
4441 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4443 if(_nb_of_tuples_to_be_allocated>=0)
4445 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4446 _nb_of_tuples_to_be_allocated=-2;
4449 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4451 if(_nb_of_tuples_to_be_allocated==-1)
4452 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4453 if(_nb_of_tuples_to_be_allocated<-3)
4454 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4455 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4458 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4460 med_int numdt,numit;
4464 med_int meshnumdt,meshnumit;
4465 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4466 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4467 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4468 if(_iteration!=numdt || _order!=numit)
4469 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4470 _field_per_mesh.resize(nmesh);
4475 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4476 mm=ms->getMeshWithName(meshNameCpp);
4479 for(int i=0;i<nmesh;i++)
4480 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4481 _nb_of_tuples_to_be_allocated=0;
4482 for(int i=0;i<nmesh;i++)
4483 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4486 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4488 allocIfNecessaryTheArrayToReceiveDataFromFile();
4489 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4490 (*it)->loadBigArraysRecursively(fid,nasc);
4493 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4495 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4496 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4497 (*it)->loadBigArraysRecursively(fid,nasc);
4500 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4502 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4503 loadBigArraysRecursively(fid,nasc);
4506 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4508 DataArray *thisArr(getUndergroundDataArray());
4509 if(thisArr && thisArr->isAllocated())
4511 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4512 thisArr->desallocate();
4516 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4518 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4521 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4523 std::vector<const BigMemoryObject *> ret;
4524 if(getUndergroundDataArray())
4525 ret.push_back(getUndergroundDataArray());
4526 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4527 ret.push_back((const MEDFileFieldPerMesh *)*it);
4532 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4533 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4534 * "Sort By Type"), if not, an exception is thrown.
4535 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4536 * \param [in] arr - the array of values.
4537 * \param [in,out] glob - the global data where profiles and localization present in
4538 * \a field, if any, are added.
4539 * \throw If the name of \a field is empty.
4540 * \throw If the data array of \a field is not set.
4541 * \throw If \a this->_arr is already allocated but has different number of components
4543 * \throw If the underlying mesh of \a field has no name.
4544 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4546 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4548 const MEDCouplingMesh *mesh=field->getMesh();
4550 TypeOfField type=field->getTypeOfField();
4551 std::vector<DataArrayInt *> dummy;
4552 int start=copyTinyInfoFrom(field,arr);
4553 int pos=addNewEntryIfNecessary(mesh);
4556 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4557 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4560 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4564 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4565 * of a given mesh are used as the support of the given field (a real support is not used).
4566 * Elements of the given mesh must be sorted suitable for writing to MED file.
4567 * Order of underlying mesh entities of the given field specified by \a profile parameter
4568 * is not prescribed; this method permutes field values to have them sorted by element
4569 * type as required for writing to MED file. A new profile is added only if no equal
4570 * profile is missing.
4571 * \param [in] field - the field to add to \a this. The field double values are ignored.
4572 * \param [in] arrOfVals - the values of the field \a field used.
4573 * \param [in] mesh - the supporting mesh of \a field.
4574 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4575 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4576 * \param [in,out] glob - the global data where profiles and localization present in
4577 * \a field, if any, are added.
4578 * \throw If either \a field or \a mesh or \a profile has an empty name.
4579 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4580 * \throw If the data array of \a field is not set.
4581 * \throw If \a this->_arr is already allocated but has different number of components
4583 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4584 * \sa setFieldNoProfileSBT()
4586 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4589 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4590 if(!arrOfVals || !arrOfVals->isAllocated())
4591 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4592 TypeOfField type=field->getTypeOfField();
4593 std::vector<DataArrayInt *> idsInPflPerType;
4594 std::vector<DataArrayInt *> idsPerType;
4595 std::vector<int> code,code2;
4596 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4599 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4600 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4601 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4602 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4604 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4605 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4606 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4608 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4609 throw INTERP_KERNEL::Exception(oss.str().c_str());
4612 int start=copyTinyInfoFrom(field,arrOfVals);
4613 code2=m->getDistributionOfTypes();
4615 int pos=addNewEntryIfNecessary(m);
4616 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4620 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4621 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4622 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4623 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4624 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4625 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4627 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4628 throw INTERP_KERNEL::Exception(oss.str().c_str());
4630 int start=copyTinyInfoFrom(field,arrOfVals);
4631 int pos=addNewEntryIfNecessary(m);
4632 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4637 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4639 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4641 if(_nb_of_tuples_to_be_allocated>=0)
4642 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 !");
4643 DataArray *arr(getOrCreateAndGetArray());
4644 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4645 _nb_of_tuples_to_be_allocated=-3;
4649 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4650 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4651 * larger by the size of \a field. Returns an id of the first not filled
4652 * tuple of \a this->_arr.
4653 * \param [in] field - the field to copy the info on components and the name from.
4654 * \return int - the id of first not initialized tuple of \a this->_arr.
4655 * \throw If the name of \a field is empty.
4656 * \throw If the data array of \a field is not set.
4657 * \throw If \a this->_arr is already allocated but has different number of components
4660 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4663 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4664 std::string name(field->getName());
4665 setName(name.c_str());
4666 setDtUnit(field->getTimeUnit());
4668 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4670 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4671 if(!arr->isAllocated())
4672 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4673 _dt=field->getTime(_iteration,_order);
4674 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4675 if(!getOrCreateAndGetArray()->isAllocated())
4677 allocNotFromFile(arr->getNumberOfTuples());
4682 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4683 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4684 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4685 _nb_of_tuples_to_be_allocated=-3;
4686 return oldNbOfTuples;
4691 * Returns number of components in \a this field
4692 * \return int - the number of components.
4694 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4696 return getOrCreateAndGetArray()->getNumberOfComponents();
4700 * Change info on components in \a this.
4701 * \throw If size of \a infos is not equal to the number of components already in \a this.
4703 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4705 DataArray *arr=getOrCreateAndGetArray();
4706 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4710 * Returns info on components of \a this field.
4711 * \return const std::vector<std::string>& - a sequence of strings each being an
4712 * information on _i_-th component.
4714 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4716 const DataArray *arr=getOrCreateAndGetArray();
4717 return arr->getInfoOnComponents();
4721 * Returns a mutable info on components of \a this field.
4722 * \return std::vector<std::string>& - a sequence of strings each being an
4723 * information on _i_-th component.
4725 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4727 DataArray *arr=getOrCreateAndGetArray();
4728 return arr->getInfoOnComponents();
4731 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4733 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4735 const MEDFileFieldPerMesh *fpm(*it);
4738 if(fpm->presenceOfMultiDiscPerGeoType())
4745 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4746 * \param [in] type - a spatial discretization of the new field.
4747 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4748 * \param [in] mName - a name of the supporting mesh.
4749 * \param [in] renumPol - specifies how to permute values of the result field according to
4750 * the optional numbers of cells and nodes, if any. The valid values are
4751 * - 0 - do not permute.
4752 * - 1 - permute cells.
4753 * - 2 - permute nodes.
4754 * - 3 - permute cells and nodes.
4756 * \param [in] glob - the global data storing profiles and localization.
4757 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4758 * caller is to delete this field using decrRef() as it is no more needed.
4759 * \throw If the MED file is not readable.
4760 * \throw If there is no mesh named \a mName in the MED file.
4761 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4762 * \throw If no field of \a this is lying on the mesh \a mName.
4763 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4765 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4767 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4769 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4771 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4772 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4776 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4777 * \param [in] type - a spatial discretization of the new field.
4778 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4779 * \param [in] renumPol - specifies how to permute values of the result field according to
4780 * the optional numbers of cells and nodes, if any. The valid values are
4781 * - 0 - do not permute.
4782 * - 1 - permute cells.
4783 * - 2 - permute nodes.
4784 * - 3 - permute cells and nodes.
4786 * \param [in] glob - the global data storing profiles and localization.
4787 * \param [in] mesh - the supporting mesh.
4788 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4789 * caller is to delete this field using decrRef() as it is no more needed.
4790 * \throw If the MED file is not readable.
4791 * \throw If no field of \a this is lying on \a mesh.
4792 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4793 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4795 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4797 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4798 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4799 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4800 if(meshDimRelToMax==1)
4801 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4802 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4806 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4808 * \param [in] type - a spatial discretization of the new field.
4809 * \param [in] mName - a name of the supporting mesh.
4810 * \param [in] renumPol - specifies how to permute values of the result field according to
4811 * the optional numbers of cells and nodes, if any. The valid values are
4812 * - 0 - do not permute.
4813 * - 1 - permute cells.
4814 * - 2 - permute nodes.
4815 * - 3 - permute cells and nodes.
4817 * \param [in] glob - the global data storing profiles and localization.
4818 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4819 * caller is to delete this field using decrRef() as it is no more needed.
4820 * \throw If the MED file is not readable.
4821 * \throw If there is no mesh named \a mName in the MED file.
4822 * \throw If there are no mesh entities in the mesh.
4823 * \throw If no field values of the given \a type are available.
4825 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4827 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4829 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4831 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4832 int absDim=getDimension();
4833 int meshDimRelToMax=absDim-mm->getMeshDimension();
4834 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4838 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4839 * \param [in] type - a spatial discretization of the new field.
4840 * \param [in] renumPol - specifies how to permute values of the result field according to
4841 * the optional numbers of cells and nodes, if any. The valid values are
4842 * - 0 - do not permute.
4843 * - 1 - permute cells.
4844 * - 2 - permute nodes.
4845 * - 3 - permute cells and nodes.
4847 * \param [in] glob - the global data storing profiles and localization.
4848 * \param [in] mesh - the supporting mesh.
4849 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4850 * field according to \a renumPol.
4851 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4852 * field according to \a renumPol.
4853 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4854 * caller is to delete this field using decrRef() as it is no more needed.
4855 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4856 * \throw If no field of \a this is lying on \a mesh.
4857 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4859 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
4861 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4862 int meshId=getMeshIdFromMeshName(mesh->getName());
4864 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4869 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4876 throw INTERP_KERNEL::Exception(msg1);
4877 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4880 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4882 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4883 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4884 throw INTERP_KERNEL::Exception(oss.str().c_str());
4886 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4887 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4888 std::vector<DataArray *> arrOut2(1,arrOut);
4889 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4890 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4891 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4898 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4900 throw INTERP_KERNEL::Exception(msg1);
4903 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4905 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4906 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4907 throw INTERP_KERNEL::Exception(oss.str().c_str());
4909 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4910 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4911 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4912 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4917 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4922 * Returns values and a profile of the field of a given type lying on a given support.
4923 * \param [in] type - a spatial discretization of the field.
4924 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4925 * \param [in] mesh - the supporting mesh.
4926 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4927 * field of interest lies on. If the field lies on all entities of the given
4928 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4929 * using decrRef() as it is no more needed.
4930 * \param [in] glob - the global data storing profiles and localization.
4931 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4932 * field. The caller is to delete this array using decrRef() as it is no more needed.
4933 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4934 * \throw If no field of \a this is lying on \a mesh.
4935 * \throw If no field values of the given \a type are available.
4937 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4939 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4940 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4941 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4942 ret->setName(nasc.getName().c_str());
4946 //= MEDFileField1TSWithoutSDA
4949 * Throws if a given value is not a valid (non-extended) relative dimension.
4950 * \param [in] meshDimRelToMax - the relative dimension value.
4951 * \throw If \a meshDimRelToMax > 0.
4953 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4955 if(meshDimRelToMax>0)
4956 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4960 * Checks if elements of a given mesh are in the order suitable for writing
4961 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4962 * vector describing types of elements and their number.
4963 * \param [in] mesh - the mesh to check.
4964 * \return std::vector<int> - a vector holding for each element type (1) item of
4965 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4966 * These values are in full-interlace mode.
4967 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4969 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4972 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4973 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4974 int nbOfTypes=geoTypes.size();
4975 std::vector<int> code(3*nbOfTypes);
4976 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4977 arr1->alloc(nbOfTypes,1);
4978 int *arrPtr=arr1->getPointer();
4979 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4980 for(int i=0;i<nbOfTypes;i++,it++)
4981 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4982 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4983 const int *arrPtr2=arr2->getConstPointer();
4985 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4988 int nbCells=mesh->getNumberOfCellsWithType(*it);
4989 code[3*pos]=(int)(*it);
4990 code[3*pos+1]=nbCells;
4991 code[3*pos+2]=-1;//no profiles
4993 std::vector<const DataArrayInt *> idsPerType;//no profiles
4994 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4998 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5003 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5005 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5009 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5010 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5011 * item of every of returned sequences refers to the _i_-th part of \a this field.
5012 * Thus all sequences returned by this method are of the same length equal to number
5013 * of different types of supporting entities.<br>
5014 * A field part can include sub-parts with several different spatial discretizations,
5015 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
5016 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5017 * of a nested sequence corresponds to a type of spatial discretization.<br>
5018 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5019 * The overhead is due to selecting values into new instances of DataArrayDouble.
5020 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5021 * for the case with only one underlying mesh. (Actually, the number of meshes is
5022 * not checked if \a mname == \c NULL).
5023 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5024 * a field part is returned.
5025 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5026 * A field part can include sub-parts with several different spatial discretizations,
5027 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
5028 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5029 * This sequence is of the same length as \a types.
5030 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5031 * discretization. A profile name can be empty.
5032 * Length of this and of nested sequences is the same as that of \a typesF.
5033 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5034 * discretization. A localization name can be empty.
5035 * Length of this and of nested sequences is the same as that of \a typesF.
5036 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5037 * per each type of spatial discretization within one mesh entity type.
5038 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5039 * Length of this and of nested sequences is the same as that of \a typesF.
5040 * \throw If no field is lying on \a mname.
5042 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TSWithoutSDA::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
5046 meshId=getMeshIdFromMeshName(mname);
5048 if(_field_per_mesh.empty())
5049 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5050 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5051 int nbOfRet=ret0.size();
5052 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5053 for(int i=0;i<nbOfRet;i++)
5055 const std::vector< std::pair<int,int> >& p=ret0[i];
5056 int nbOfRet1=p.size();
5057 ret[i].resize(nbOfRet1);
5058 for(int j=0;j<nbOfRet1;j++)
5060 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
5068 * Returns a pointer to the underground DataArrayDouble instance. So the
5069 * caller should not decrRef() it. This method allows for a direct access to the field
5070 * values. This method is quite unusable if there is more than a nodal field or a cell
5071 * field on single geometric cell type.
5072 * \return DataArrayDouble * - the pointer to the field values array.
5074 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
5076 const DataArrayDouble *ret=_arr;
5078 return const_cast<DataArrayDouble *>(ret);
5083 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5088 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5090 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5091 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5092 ret->deepCpyLeavesFrom(*this);
5093 const DataArrayDouble *arr(_arr);
5096 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
5097 ret->setArray(arr2);
5103 * Returns a pointer to the underground DataArrayDouble instance. So the
5104 * caller should not decrRef() it. This method allows for a direct access to the field
5105 * values. This method is quite unusable if there is more than a nodal field or a cell
5106 * field on single geometric cell type.
5107 * \return DataArrayDouble * - the pointer to the field values array.
5109 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5111 return getUndergroundDataArrayDouble();
5115 * Returns a pointer to the underground DataArrayDouble instance and a
5116 * sequence describing parameters of a support of each part of \a this field. The
5117 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5118 * direct access to the field values. This method is intended for the field lying on one
5120 * \param [in,out] entries - the sequence describing parameters of a support of each
5121 * part of \a this field. Each item of this sequence consists of two parts. The
5122 * first part describes a type of mesh entity and an id of discretization of a
5123 * current field part. The second part describes a range of values [begin,end)
5124 * within the returned array relating to the current field part.
5125 * \return DataArrayDouble * - the pointer to the field values array.
5126 * \throw If the number of underlying meshes is not equal to 1.
5127 * \throw If no field values are available.
5128 * \sa getUndergroundDataArray()
5130 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5132 if(_field_per_mesh.size()!=1)
5133 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5134 if(_field_per_mesh[0]==0)
5135 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5136 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5137 return getUndergroundDataArrayDouble();
5141 * Returns a pointer to the underground DataArrayDouble instance and a
5142 * sequence describing parameters of a support of each part of \a this field. The
5143 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5144 * direct access to the field values. This method is intended for the field lying on one
5146 * \param [in,out] entries - the sequence describing parameters of a support of each
5147 * part of \a this field. Each item of this sequence consists of two parts. The
5148 * first part describes a type of mesh entity and an id of discretization of a
5149 * current field part. The second part describes a range of values [begin,end)
5150 * within the returned array relating to the current field part.
5151 * \return DataArrayDouble * - the pointer to the field values array.
5152 * \throw If the number of underlying meshes is not equal to 1.
5153 * \throw If no field values are available.
5154 * \sa getUndergroundDataArray()
5156 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5158 return getUndergroundDataArrayDoubleExt(entries);
5161 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5163 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5164 arr->setInfoAndChangeNbOfCompo(infos);
5167 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5171 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5173 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5174 ret->deepCpyLeavesFrom(*this);
5178 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
5180 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5181 if((const DataArrayDouble *)_arr)
5182 ret->_arr=_arr->deepCpy();
5186 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5190 _nb_of_tuples_to_be_allocated=-1;
5194 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5196 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5198 _nb_of_tuples_to_be_allocated=-3;
5203 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5205 return DataArrayDouble::New();
5208 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5210 DataArrayDouble *ret=_arr;
5213 _arr=DataArrayDouble::New();
5217 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5219 return getOrCreateAndGetArrayDouble();
5222 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5224 const DataArrayDouble *ret=_arr;
5227 DataArrayDouble *ret2=DataArrayDouble::New();
5228 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5232 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5234 return getOrCreateAndGetArrayDouble();
5237 //= MEDFileIntField1TSWithoutSDA
5239 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5241 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5244 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5248 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5249 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5251 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5252 arr->setInfoAndChangeNbOfCompo(infos);
5255 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5260 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5262 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5263 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5264 ret->deepCpyLeavesFrom(*this);
5265 const DataArrayInt *arr(_arr);
5268 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
5269 ret->setArray(arr2);
5275 * Returns a pointer to the underground DataArrayInt instance. So the
5276 * caller should not decrRef() it. This method allows for a direct access to the field
5277 * values. This method is quite unusable if there is more than a nodal field or a cell
5278 * field on single geometric cell type.
5279 * \return DataArrayInt * - the pointer to the field values array.
5281 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5283 return getUndergroundDataArrayInt();
5287 * Returns a pointer to the underground DataArrayInt instance. So the
5288 * caller should not decrRef() it. This method allows for a direct access to the field
5289 * values. This method is quite unusable if there is more than a nodal field or a cell
5290 * field on single geometric cell type.
5291 * \return DataArrayInt * - the pointer to the field values array.
5293 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5295 const DataArrayInt *ret=_arr;
5297 return const_cast<DataArrayInt *>(ret);
5303 * Returns a pointer to the underground DataArrayInt instance and a
5304 * sequence describing parameters of a support of each part of \a this field. The
5305 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5306 * direct access to the field values. This method is intended for the field lying on one
5308 * \param [in,out] entries - the sequence describing parameters of a support of each
5309 * part of \a this field. Each item of this sequence consists of two parts. The
5310 * first part describes a type of mesh entity and an id of discretization of a
5311 * current field part. The second part describes a range of values [begin,end)
5312 * within the returned array relating to the current field part.
5313 * \return DataArrayInt * - the pointer to the field values array.
5314 * \throw If the number of underlying meshes is not equal to 1.
5315 * \throw If no field values are available.
5316 * \sa getUndergroundDataArray()
5318 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5320 return getUndergroundDataArrayIntExt(entries);
5324 * Returns a pointer to the underground DataArrayInt instance and a
5325 * sequence describing parameters of a support of each part of \a this field. The
5326 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5327 * direct access to the field values. This method is intended for the field lying on one
5329 * \param [in,out] entries - the sequence describing parameters of a support of each
5330 * part of \a this field. Each item of this sequence consists of two parts. The
5331 * first part describes a type of mesh entity and an id of discretization of a
5332 * current field part. The second part describes a range of values [begin,end)
5333 * within the returned array relating to the current field part.
5334 * \return DataArrayInt * - the pointer to the field values array.
5335 * \throw If the number of underlying meshes is not equal to 1.
5336 * \throw If no field values are available.
5337 * \sa getUndergroundDataArray()
5339 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5341 if(_field_per_mesh.size()!=1)
5342 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5343 if(_field_per_mesh[0]==0)
5344 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5345 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5346 return getUndergroundDataArrayInt();
5349 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5351 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5352 ret->deepCpyLeavesFrom(*this);
5356 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5358 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5359 if((const DataArrayInt *)_arr)
5360 ret->_arr=_arr->deepCpy();
5364 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5368 _nb_of_tuples_to_be_allocated=-1;
5372 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5374 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5376 _nb_of_tuples_to_be_allocated=-3;
5381 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5383 return DataArrayInt::New();
5386 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5388 DataArrayInt *ret=_arr;
5391 _arr=DataArrayInt::New();
5395 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5397 return getOrCreateAndGetArrayInt();
5400 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5402 const DataArrayInt *ret=_arr;
5405 DataArrayInt *ret2=DataArrayInt::New();
5406 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5410 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5412 return getOrCreateAndGetArrayInt();
5415 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5419 //= MEDFileAnyTypeField1TS
5421 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5423 med_field_type typcha;
5425 std::vector<std::string> infos;
5426 std::string dtunit,fieldName;
5427 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5428 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5433 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5438 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5443 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] !";
5444 throw INTERP_KERNEL::Exception(oss.str().c_str());
5447 ret->setDtUnit(dtunit.c_str());
5448 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5450 med_int numdt,numit;
5452 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5453 ret->setTime(numdt,numit,dt);
5456 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5458 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5462 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5463 try:MEDFileFieldGlobsReal(fileName)
5465 MEDFileUtilities::CheckFileForRead(fileName);
5466 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5467 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5470 catch(INTERP_KERNEL::Exception& e)
5475 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5477 med_field_type typcha;
5478 std::vector<std::string> infos;
5481 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5482 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5487 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5492 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5497 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] !";
5498 throw INTERP_KERNEL::Exception(oss.str().c_str());
5501 ret->setDtUnit(dtunit.c_str());
5502 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5506 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5507 throw INTERP_KERNEL::Exception(oss.str().c_str());
5510 med_int numdt,numit;
5512 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5513 ret->setTime(numdt,numit,dt);
5516 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5518 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5522 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5523 try:MEDFileFieldGlobsReal(fileName)
5525 MEDFileUtilities::CheckFileForRead(fileName);
5526 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5527 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5530 catch(INTERP_KERNEL::Exception& e)
5535 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5538 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5539 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5541 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5542 ret->setFileName(fileName);
5543 ret->_content=c; c->incrRef();
5546 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5548 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5549 ret->setFileName(fileName);
5550 ret->_content=c; c->incrRef();
5553 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5556 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5558 MEDFileUtilities::CheckFileForRead(fileName);
5559 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5560 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5561 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5562 ret->loadGlobals(fid);
5566 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5568 MEDFileUtilities::CheckFileForRead(fileName);
5569 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5570 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5571 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5572 ret->loadGlobals(fid);
5576 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5578 MEDFileUtilities::CheckFileForRead(fileName);
5579 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5580 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5581 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5582 ret->loadGlobals(fid);
5586 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5588 med_field_type typcha;
5589 std::vector<std::string> infos;
5592 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5593 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5598 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5603 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5608 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] !";
5609 throw INTERP_KERNEL::Exception(oss.str().c_str());
5612 ret->setDtUnit(dtunit.c_str());
5613 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5616 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5617 for(int i=0;i<nbOfStep2 && !found;i++)
5619 med_int numdt,numit;
5621 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5622 if(numdt==iteration && numit==order)
5628 dtits[i]=std::pair<int,int>(numdt,numit);
5632 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5633 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5634 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5635 throw INTERP_KERNEL::Exception(oss.str().c_str());
5638 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5640 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5644 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5645 try:MEDFileFieldGlobsReal(fileName)
5647 MEDFileUtilities::CheckFileForRead(fileName);
5648 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5649 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5652 catch(INTERP_KERNEL::Exception& e)
5658 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5659 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5661 * \warning this is a shallow copy constructor
5663 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5665 if(!shallowCopyOfContent)
5667 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5668 otherPtr->incrRef();
5669 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5673 _content=other.shallowCpy();
5677 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, const std::string& fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5681 int nbFields=MEDnField(fid);
5682 if(fieldIdCFormat>=nbFields)
5684 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5685 throw INTERP_KERNEL::Exception(oss.str().c_str());
5688 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5689 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5690 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5691 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5692 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5693 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5696 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5697 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5698 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5699 infos.clear(); infos.resize(ncomp);
5700 for(int j=0;j<ncomp;j++)
5701 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5706 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5709 * \return in case of success the number of time steps available for the field with name \a fieldName.
5711 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fileName, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5713 int nbFields=MEDnField(fid);
5715 std::vector<std::string> fns(nbFields);
5717 for(int i=0;i<nbFields && !found;i++)
5720 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5722 found=(tmp==fieldName);
5728 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5729 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5730 oss << "\"" << *it << "\" ";
5731 throw INTERP_KERNEL::Exception(oss.str().c_str());
5737 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5738 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5739 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5740 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5741 * to keep a valid instance.
5742 * 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.
5743 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5744 * 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.
5746 * \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.
5747 * \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.
5748 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5749 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5750 * \param [in] newLocName is the new localization name.
5751 * \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.
5752 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5754 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5756 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5757 std::string oldPflName=disc->getProfile();
5758 std::vector<std::string> vv=getPflsReallyUsedMulti();
5759 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5760 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5762 disc->setProfile(newPflName);
5763 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5764 pfl->setName(newPflName);
5768 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5769 throw INTERP_KERNEL::Exception(oss.str().c_str());
5774 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5775 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5776 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5777 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5778 * to keep a valid instance.
5779 * 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.
5780 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5781 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5782 * 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.
5784 * \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.
5785 * \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.
5786 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5787 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5788 * \param [in] newLocName is the new localization name.
5789 * \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.
5790 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5792 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5794 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5795 std::string oldLocName=disc->getLocalization();
5796 std::vector<std::string> vv=getLocsReallyUsedMulti();
5797 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5798 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5800 disc->setLocalization(newLocName);
5801 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5802 loc.setName(newLocName);
5806 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5807 throw INTERP_KERNEL::Exception(oss.str().c_str());
5811 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5813 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5815 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5819 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5821 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5823 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5828 * Writes \a this field into a MED file specified by its name.
5829 * \param [in] fileName - the MED file name.
5830 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5831 * - 2 - erase; an existing file is removed.
5832 * - 1 - append; same data should not be present in an existing file.
5833 * - 0 - overwrite; same data present in an existing file is overwritten.
5834 * \throw If the field name is not set.
5835 * \throw If no field data is set.
5836 * \throw If \a mode == 1 and the same data is present in an existing file.
5838 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5840 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5841 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5846 * This method alloc the arrays and load potentially huge arrays contained in this field.
5847 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5848 * This method can be also called to refresh or reinit values from a file.
5850 * \throw If the fileName is not set or points to a non readable MED file.
5851 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5853 void MEDFileAnyTypeField1TS::loadArrays()
5855 if(getFileName().empty())
5856 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5857 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5858 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5862 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5863 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5864 * this method does not throw if \a this does not come from file read.
5866 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5868 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5870 if(!getFileName().empty())
5872 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5873 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5878 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5879 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5880 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5882 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5884 void MEDFileAnyTypeField1TS::unloadArrays()
5886 contentNotNullBase()->unloadArrays();
5890 * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
5891 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5892 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5894 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5896 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5898 if(!getFileName().empty())
5899 contentNotNullBase()->unloadArrays();
5902 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5904 int nbComp=getNumberOfComponents();
5905 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5906 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5907 for(int i=0;i<nbComp;i++)
5909 std::string info=getInfo()[i];
5911 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5912 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5913 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5915 if(getName().empty())
5916 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5917 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5918 writeGlobals(fid,*this);
5919 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5922 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5924 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5927 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5929 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5930 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5935 * Returns a string describing \a this field. This string is outputted
5936 * by \c print Python command.
5938 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5940 std::ostringstream oss;
5941 contentNotNullBase()->simpleRepr(0,oss,-1);
5942 simpleReprGlobs(oss);
5947 * This method returns all profiles whose name is non empty used.
5948 * \b WARNING If profile is used several times it will be reported \b only \b once.
5949 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5951 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5953 return contentNotNullBase()->getPflsReallyUsed2();
5957 * This method returns all localizations whose name is non empty used.
5958 * \b WARNING If localization is used several times it will be reported \b only \b once.
5960 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5962 return contentNotNullBase()->getLocsReallyUsed2();
5966 * This method returns all profiles whose name is non empty used.
5967 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5969 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5971 return contentNotNullBase()->getPflsReallyUsedMulti2();
5975 * This method returns all localizations whose name is non empty used.
5976 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5978 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5980 return contentNotNullBase()->getLocsReallyUsedMulti2();
5983 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5985 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5988 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5990 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5993 int MEDFileAnyTypeField1TS::getDimension() const
5995 return contentNotNullBase()->getDimension();
5998 int MEDFileAnyTypeField1TS::getIteration() const
6000 return contentNotNullBase()->getIteration();
6003 int MEDFileAnyTypeField1TS::getOrder() const
6005 return contentNotNullBase()->getOrder();
6008 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6010 return contentNotNullBase()->getTime(iteration,order);
6013 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6015 contentNotNullBase()->setTime(iteration,order,val);
6018 std::string MEDFileAnyTypeField1TS::getName() const
6020 return contentNotNullBase()->getName();
6023 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6025 contentNotNullBase()->setName(name);
6028 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6030 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6033 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6035 return contentNotNullBase()->getDtUnit();
6038 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6040 contentNotNullBase()->setDtUnit(dtUnit);
6043 std::string MEDFileAnyTypeField1TS::getMeshName() const
6045 return contentNotNullBase()->getMeshName();
6048 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6050 contentNotNullBase()->setMeshName(newMeshName);
6053 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6055 return contentNotNullBase()->changeMeshNames(modifTab);
6058 int MEDFileAnyTypeField1TS::getMeshIteration() const
6060 return contentNotNullBase()->getMeshIteration();
6063 int MEDFileAnyTypeField1TS::getMeshOrder() const
6065 return contentNotNullBase()->getMeshOrder();
6068 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6070 return contentNotNullBase()->getNumberOfComponents();
6073 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6075 return contentNotNullBase()->isDealingTS(iteration,order);
6078 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6080 return contentNotNullBase()->getDtIt();
6083 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6085 contentNotNullBase()->fillIteration(p);
6088 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6090 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6093 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6095 contentNotNullBase()->setInfo(infos);
6098 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6100 return contentNotNullBase()->getInfo();
6102 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6104 return contentNotNullBase()->getInfo();
6107 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6109 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6112 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6114 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6117 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6119 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6122 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6124 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6127 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6129 return contentNotNullBase()->getTypesOfFieldAvailable();
6132 std::vector< std::vector<std::pair<int,int> > > MEDFileAnyTypeField1TS::getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6133 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6135 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6139 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6140 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6141 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6143 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6145 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6147 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6148 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6149 std::size_t sz(contentsSplit.size());
6150 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6151 for(std::size_t i=0;i<sz;i++)
6153 ret[i]=shallowCpy();
6154 ret[i]->_content=contentsSplit[i];
6160 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6161 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6163 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6165 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6167 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6168 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6169 std::size_t sz(contentsSplit.size());
6170 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6171 for(std::size_t i=0;i<sz;i++)
6173 ret[i]=shallowCpy();
6174 ret[i]->_content=contentsSplit[i];
6180 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6181 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6183 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6185 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6187 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6188 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6189 std::size_t sz(contentsSplit.size());
6190 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6191 for(std::size_t i=0;i<sz;i++)
6193 ret[i]=shallowCpy();
6194 ret[i]->_content=contentsSplit[i];
6199 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
6201 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
6202 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6203 ret->_content=_content->deepCpy();
6204 ret->deepCpyGlobs(*this);
6208 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6210 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6216 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6217 * the first field that has been read from a specified MED file.
6218 * \param [in] fileName - the name of the MED file to read.
6219 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6220 * is to delete this field using decrRef() as it is no more needed.
6221 * \throw If reading the file fails.
6223 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6225 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6226 ret->contentNotNull();
6231 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6232 * a given field that has been read from a specified MED file.
6233 * \param [in] fileName - the name of the MED file to read.
6234 * \param [in] fieldName - the name of the field to read.
6235 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6236 * is to delete this field using decrRef() as it is no more needed.
6237 * \throw If reading the file fails.
6238 * \throw If there is no field named \a fieldName in the file.
6240 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6242 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6243 ret->contentNotNull();
6248 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6249 * a given field that has been read from a specified MED file.
6250 * \param [in] fileName - the name of the MED file to read.
6251 * \param [in] fieldName - the name of the field to read.
6252 * \param [in] iteration - the iteration number of a required time step.
6253 * \param [in] order - the iteration order number of required time step.
6254 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6255 * is to delete this field using decrRef() as it is no more needed.
6256 * \throw If reading the file fails.
6257 * \throw If there is no field named \a fieldName in the file.
6258 * \throw If the required time step is missing from the file.
6260 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6262 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6263 ret->contentNotNull();
6268 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6269 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6271 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6272 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6273 * \warning this is a shallow copy constructor
6274 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6275 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6276 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6277 * is to delete this field using decrRef() as it is no more needed.
6279 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6281 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6282 ret->contentNotNull();
6287 * Returns a new empty instance of MEDFileField1TS.
6288 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6289 * is to delete this field using decrRef() as it is no more needed.
6291 MEDFileField1TS *MEDFileField1TS::New()
6293 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
6294 ret->contentNotNull();
6299 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6300 * following the given input policy.
6302 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6303 * By default (true) the globals are deeply copied.
6304 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6306 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6308 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
6309 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6312 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6314 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6315 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6316 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6319 ret=MEDFileIntField1TS::New();
6321 ret->deepCpyGlobs(*this);
6323 ret->shallowCpyGlobs(*this);
6327 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6329 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6331 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6332 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6334 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 !");
6338 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6340 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6342 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6343 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6345 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 !");
6349 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6352 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6353 if(!((DataArray*)arr))
6354 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6355 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6357 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6358 f->setArray(arrOutC);
6361 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6363 if(!((DataArray*)arr))
6364 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6365 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6367 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6372 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6373 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6376 catch(INTERP_KERNEL::Exception& e)
6379 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6380 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6383 catch(INTERP_KERNEL::Exception& e)
6386 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6387 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6390 catch(INTERP_KERNEL::Exception& e)
6394 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6395 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6397 * \warning this is a shallow copy constructor
6399 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6400 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6403 catch(INTERP_KERNEL::Exception& e)
6406 MEDFileField1TS::MEDFileField1TS()
6408 _content=new MEDFileField1TSWithoutSDA;
6412 * Returns a new MEDCouplingFieldDouble of a given type lying on
6413 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6414 * has not been constructed via file reading, an exception is thrown.
6415 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6416 * \param [in] type - a spatial discretization of interest.
6417 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6418 * \param [in] renumPol - specifies how to permute values of the result field according to
6419 * the optional numbers of cells and nodes, if any. The valid values are
6420 * - 0 - do not permute.
6421 * - 1 - permute cells.
6422 * - 2 - permute nodes.
6423 * - 3 - permute cells and nodes.
6425 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6426 * caller is to delete this field using decrRef() as it is no more needed.
6427 * \throw If \a this field has not been constructed via file reading.
6428 * \throw If the MED file is not readable.
6429 * \throw If there is no mesh in the MED file.
6430 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6431 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6432 * \sa getFieldOnMeshAtLevel()
6434 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6436 if(getFileName().empty())
6437 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6438 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6439 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6440 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6445 * Returns a new MEDCouplingFieldDouble of a given type lying on
6446 * the top level cells of the first mesh in MED file. If \a this field
6447 * has not been constructed via file reading, an exception is thrown.
6448 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6449 * \param [in] type - a spatial discretization of interest.
6450 * \param [in] renumPol - specifies how to permute values of the result field according to
6451 * the optional numbers of cells and nodes, if any. The valid values are
6452 * - 0 - do not permute.
6453 * - 1 - permute cells.
6454 * - 2 - permute nodes.
6455 * - 3 - permute cells and nodes.
6457 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6458 * caller is to delete this field using decrRef() as it is no more needed.
6459 * \throw If \a this field has not been constructed via file reading.
6460 * \throw If the MED file is not readable.
6461 * \throw If there is no mesh in the MED file.
6462 * \throw If no field values of the given \a type.
6463 * \throw If no field values lying on the top level support.
6464 * \sa getFieldAtLevel()
6466 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6468 if(getFileName().empty())
6469 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6470 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6471 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6472 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6477 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6478 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6479 * \param [in] type - a spatial discretization of the new field.
6480 * \param [in] mesh - the supporting mesh.
6481 * \param [in] renumPol - specifies how to permute values of the result field according to
6482 * the optional numbers of cells and nodes, if any. The valid values are
6483 * - 0 - do not permute.
6484 * - 1 - permute cells.
6485 * - 2 - permute nodes.
6486 * - 3 - permute cells and nodes.
6488 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6489 * caller is to delete this field using decrRef() as it is no more needed.
6490 * \throw If no field of \a this is lying on \a mesh.
6491 * \throw If the mesh is empty.
6492 * \throw If no field values of the given \a type are available.
6493 * \sa getFieldAtLevel()
6494 * \sa getFieldOnMeshAtLevel()
6496 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6498 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6499 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6500 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6505 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6506 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6507 * \param [in] type - a spatial discretization of interest.
6508 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6509 * \param [in] mesh - the supporting mesh.
6510 * \param [in] renumPol - specifies how to permute values of the result field according to
6511 * the optional numbers of cells and nodes, if any. The valid values are
6512 * - 0 - do not permute.
6513 * - 1 - permute cells.
6514 * - 2 - permute nodes.
6515 * - 3 - permute cells and nodes.
6517 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6518 * caller is to delete this field using decrRef() as it is no more needed.
6519 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6520 * \throw If no field of \a this is lying on \a mesh.
6521 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6522 * \sa getFieldAtLevel()
6523 * \sa getFieldOnMeshAtLevel()
6525 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6527 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6528 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6529 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6534 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6535 * This method is called "Old" because in MED3 norm a field has only one meshName
6536 * attached, so this method is for readers of MED2 files. If \a this field
6537 * has not been constructed via file reading, an exception is thrown.
6538 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6539 * \param [in] type - a spatial discretization of interest.
6540 * \param [in] mName - a name of the supporting mesh.
6541 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6542 * \param [in] renumPol - specifies how to permute values of the result field according to
6543 * the optional numbers of cells and nodes, if any. The valid values are
6544 * - 0 - do not permute.
6545 * - 1 - permute cells.
6546 * - 2 - permute nodes.
6547 * - 3 - permute cells and nodes.
6549 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6550 * caller is to delete this field using decrRef() as it is no more needed.
6551 * \throw If the MED file is not readable.
6552 * \throw If there is no mesh named \a mName in the MED file.
6553 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6554 * \throw If \a this field has not been constructed via file reading.
6555 * \throw If no field of \a this is lying on the mesh named \a mName.
6556 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6557 * \sa getFieldAtLevel()
6559 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6561 if(getFileName().empty())
6562 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6563 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6564 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6565 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6570 * Returns values and a profile of the field of a given type lying on a given support.
6571 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6572 * \param [in] type - a spatial discretization of the field.
6573 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6574 * \param [in] mesh - the supporting mesh.
6575 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6576 * field of interest lies on. If the field lies on all entities of the given
6577 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6578 * using decrRef() as it is no more needed.
6579 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6580 * field. The caller is to delete this array using decrRef() as it is no more needed.
6581 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6582 * \throw If no field of \a this is lying on \a mesh.
6583 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6585 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6587 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6588 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6592 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6593 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6594 * "Sort By Type"), if not, an exception is thrown.
6595 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6596 * \param [in] field - the field to add to \a this.
6597 * \throw If the name of \a field is empty.
6598 * \throw If the data array of \a field is not set.
6599 * \throw If the data array is already allocated but has different number of components
6601 * \throw If the underlying mesh of \a field has no name.
6602 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6604 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6607 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6611 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6612 * can be an aggregation of several MEDCouplingFieldDouble instances.
6613 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6614 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6617 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6618 * A new profile is added only if no equal profile is missing.
6619 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6620 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6621 * \param [in] mesh - the supporting mesh of \a field.
6622 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6623 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6624 * \throw If either \a field or \a mesh or \a profile has an empty name.
6625 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6626 * \throw If the data array of \a field is not set.
6627 * \throw If the data array of \a this is already allocated but has different number of
6628 * components than \a field.
6629 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6630 * \sa setFieldNoProfileSBT()
6632 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6635 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6638 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6640 return new MEDFileField1TS(*this);
6643 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6645 return contentNotNull()->getUndergroundDataArrayDouble();
6648 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6650 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6653 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6654 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6656 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6659 //= MEDFileIntField1TS
6661 MEDFileIntField1TS *MEDFileIntField1TS::New()
6663 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6664 ret->contentNotNull();
6668 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6670 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6671 ret->contentNotNull();
6675 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6677 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6678 ret->contentNotNull();
6682 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6684 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6685 ret->contentNotNull();
6689 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6691 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6692 ret->contentNotNull();
6696 MEDFileIntField1TS::MEDFileIntField1TS()
6698 _content=new MEDFileIntField1TSWithoutSDA;
6701 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6702 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6705 catch(INTERP_KERNEL::Exception& e)
6708 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6709 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6712 catch(INTERP_KERNEL::Exception& e)
6715 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6716 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6719 catch(INTERP_KERNEL::Exception& e)
6723 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6724 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6726 * \warning this is a shallow copy constructor
6728 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6732 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6734 return new MEDFileIntField1TS(*this);
6738 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6739 * following the given input policy.
6741 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6742 * By default (true) the globals are deeply copied.
6743 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6745 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6747 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6748 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6751 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6753 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6754 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6755 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6758 ret=MEDFileField1TS::New();
6760 ret->deepCpyGlobs(*this);
6762 ret->shallowCpyGlobs(*this);
6767 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6768 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6769 * "Sort By Type"), if not, an exception is thrown.
6770 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6771 * \param [in] field - the field to add to \a this. The field double values are ignored.
6772 * \param [in] arrOfVals - the values of the field \a field used.
6773 * \throw If the name of \a field is empty.
6774 * \throw If the data array of \a field is not set.
6775 * \throw If the data array is already allocated but has different number of components
6777 * \throw If the underlying mesh of \a field has no name.
6778 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6780 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6783 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6787 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6788 * can be an aggregation of several MEDCouplingFieldDouble instances.
6789 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6790 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6793 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6794 * A new profile is added only if no equal profile is missing.
6795 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6796 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6797 * \param [in] arrOfVals - the values of the field \a field used.
6798 * \param [in] mesh - the supporting mesh of \a field.
6799 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6800 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6801 * \throw If either \a field or \a mesh or \a profile has an empty name.
6802 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6803 * \throw If the data array of \a field is not set.
6804 * \throw If the data array of \a this is already allocated but has different number of
6805 * components than \a field.
6806 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6807 * \sa setFieldNoProfileSBT()
6809 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6812 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6815 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6817 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6819 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6820 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6822 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 !");
6826 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6828 if(getFileName().empty())
6829 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6830 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6831 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6832 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6834 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6836 arrOut->incrRef(); // arrOut2 dies at the end of the func
6840 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6842 if(!((DataArray *)arr))
6843 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6844 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6846 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6852 * Returns a new MEDCouplingFieldDouble of a given type lying on
6853 * the top level cells of the first mesh in MED file. If \a this field
6854 * has not been constructed via file reading, an exception is thrown.
6855 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6856 * \param [in] type - a spatial discretization of interest.
6857 * \param [out] arrOut - the DataArrayInt containing values of field.
6858 * \param [in] renumPol - specifies how to permute values of the result field according to
6859 * the optional numbers of cells and nodes, if any. The valid values are
6860 * - 0 - do not permute.
6861 * - 1 - permute cells.
6862 * - 2 - permute nodes.
6863 * - 3 - permute cells and nodes.
6865 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6866 * caller is to delete this field using decrRef() as it is no more needed.
6867 * \throw If \a this field has not been constructed via file reading.
6868 * \throw If the MED file is not readable.
6869 * \throw If there is no mesh in the MED file.
6870 * \throw If no field values of the given \a type.
6871 * \throw If no field values lying on the top level support.
6872 * \sa getFieldAtLevel()
6874 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6876 if(getFileName().empty())
6877 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6878 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6879 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6880 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6885 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6886 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6887 * \param [in] type - a spatial discretization of the new field.
6888 * \param [in] mesh - the supporting mesh.
6889 * \param [out] arrOut - the DataArrayInt containing values of field.
6890 * \param [in] renumPol - specifies how to permute values of the result field according to
6891 * the optional numbers of cells and nodes, if any. The valid values are
6892 * - 0 - do not permute.
6893 * - 1 - permute cells.
6894 * - 2 - permute nodes.
6895 * - 3 - permute cells and nodes.
6897 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6898 * caller is to delete this field using decrRef() as it is no more needed.
6899 * \throw If no field of \a this is lying on \a mesh.
6900 * \throw If the mesh is empty.
6901 * \throw If no field values of the given \a type are available.
6902 * \sa getFieldAtLevel()
6903 * \sa getFieldOnMeshAtLevel()
6905 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6907 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6908 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6909 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6914 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6915 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6916 * \param [in] type - a spatial discretization of interest.
6917 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6918 * \param [out] arrOut - the DataArrayInt containing values of field.
6919 * \param [in] mesh - the supporting mesh.
6920 * \param [in] renumPol - specifies how to permute values of the result field according to
6921 * the optional numbers of cells and nodes, if any. The valid values are
6922 * - 0 - do not permute.
6923 * - 1 - permute cells.
6924 * - 2 - permute nodes.
6925 * - 3 - permute cells and nodes.
6927 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6928 * caller is to delete this field using decrRef() as it is no more needed.
6929 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6930 * \throw If no field of \a this is lying on \a mesh.
6931 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6932 * \sa getFieldAtLevel()
6933 * \sa getFieldOnMeshAtLevel()
6935 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6937 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6938 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6939 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6944 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6945 * This method is called "Old" because in MED3 norm a field has only one meshName
6946 * attached, so this method is for readers of MED2 files. If \a this field
6947 * has not been constructed via file reading, an exception is thrown.
6948 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6949 * \param [in] type - a spatial discretization of interest.
6950 * \param [in] mName - a name of the supporting mesh.
6951 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6952 * \param [out] arrOut - the DataArrayInt containing values of field.
6953 * \param [in] renumPol - specifies how to permute values of the result field according to
6954 * the optional numbers of cells and nodes, if any. The valid values are
6955 * - 0 - do not permute.
6956 * - 1 - permute cells.
6957 * - 2 - permute nodes.
6958 * - 3 - permute cells and nodes.
6960 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6961 * caller is to delete this field using decrRef() as it is no more needed.
6962 * \throw If the MED file is not readable.
6963 * \throw If there is no mesh named \a mName in the MED file.
6964 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6965 * \throw If \a this field has not been constructed via file reading.
6966 * \throw If no field of \a this is lying on the mesh named \a mName.
6967 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6968 * \sa getFieldAtLevel()
6970 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6972 if(getFileName().empty())
6973 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6974 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6975 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6976 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6981 * Returns values and a profile of the field of a given type lying on a given support.
6982 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6983 * \param [in] type - a spatial discretization of the field.
6984 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6985 * \param [in] mesh - the supporting mesh.
6986 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6987 * field of interest lies on. If the field lies on all entities of the given
6988 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6989 * using decrRef() as it is no more needed.
6990 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6991 * field. The caller is to delete this array using decrRef() as it is no more needed.
6992 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6993 * \throw If no field of \a this is lying on \a mesh.
6994 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6996 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6998 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6999 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7002 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7004 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7006 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7007 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7009 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 !");
7013 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7015 return contentNotNull()->getUndergroundDataArrayInt();
7018 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7020 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7024 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7029 * \param [in] fieldId field id in C mode
7031 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7033 med_field_type typcha;
7034 std::string dtunitOut;
7035 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
7036 setDtUnit(dtunitOut.c_str());
7037 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7040 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7041 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7043 setDtUnit(dtunit.c_str());
7044 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7046 catch(INTERP_KERNEL::Exception& e)
7051 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7053 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
7054 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7055 ret+=(*it).capacity();
7059 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7061 std::vector<const BigMemoryObject *> ret;
7062 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7063 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7068 * 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
7071 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7073 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7074 ret->setInfo(_infos);
7075 int sz=(int)_time_steps.size();
7076 for(const int *id=startIds;id!=endIds;id++)
7078 if(*id>=0 && *id<sz)
7080 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7081 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7085 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7087 ret->pushBackTimeStep(tse2);
7091 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7092 oss << " ! Should be in [0," << sz << ") !";
7093 throw INTERP_KERNEL::Exception(oss.str().c_str());
7096 if(ret->getNumberOfTS()>0)
7097 ret->synchronizeNameScope();
7098 ret->copyNameScope(*this);
7103 * 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
7106 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7108 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7109 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7110 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7111 ret->setInfo(_infos);
7112 int sz=(int)_time_steps.size();
7114 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7118 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7119 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7123 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7125 ret->pushBackTimeStep(tse2);
7129 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7130 oss << " ! Should be in [0," << sz << ") !";
7131 throw INTERP_KERNEL::Exception(oss.str().c_str());
7134 if(ret->getNumberOfTS()>0)
7135 ret->synchronizeNameScope();
7136 ret->copyNameScope(*this);
7140 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7143 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7144 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7146 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7149 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7150 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7151 ids->pushBackSilent(id);
7153 return buildFromTimeStepIds(ids->begin(),ids->end());
7156 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7159 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7160 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7162 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7165 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7166 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7167 ids->pushBackSilent(id);
7169 return buildFromTimeStepIds(ids->begin(),ids->end());
7172 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7174 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7176 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7179 if(cur->presenceOfMultiDiscPerGeoType())
7185 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7190 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7195 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7198 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7200 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7201 if(pt->isDealingTS(iteration,order))
7204 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7205 std::vector< std::pair<int,int> > vp=getIterations();
7206 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7207 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7208 throw INTERP_KERNEL::Exception(oss.str().c_str());
7211 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7213 return *_time_steps[getTimeStepPos(iteration,order)];
7216 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7218 return *_time_steps[getTimeStepPos(iteration,order)];
7221 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7223 if(_time_steps.empty())
7224 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7225 return _time_steps[0]->getMeshName();
7228 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7230 std::string oldName(getMeshName());
7231 std::vector< std::pair<std::string,std::string> > v(1);
7232 v[0].first=oldName; v[0].second=newMeshName;
7236 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7239 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7241 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7243 ret=cur->changeMeshNames(modifTab) || ret;
7249 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7251 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7253 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7257 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7259 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7261 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7264 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7265 MEDFileFieldGlobsReal& glob)
7268 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7270 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7272 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7277 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7279 std::string startLine(bkOffset,' ');
7280 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7282 oss << " (" << fmtsId << ")";
7283 oss << " has the following name: \"" << _name << "\"." << std::endl;
7284 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7285 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7287 oss << startLine << " - \"" << *it << "\"" << std::endl;
7290 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7292 std::string chapter(17,'0'+i);
7293 oss << startLine << chapter << std::endl;
7294 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7296 cur->simpleRepr(bkOffset+2,oss,i);
7298 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7299 oss << startLine << chapter << std::endl;
7303 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7305 std::size_t sz=_time_steps.size();
7306 std::vector< std::pair<int,int> > ret(sz);
7308 for(std::size_t i=0;i<sz;i++)
7310 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7313 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7317 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7318 throw INTERP_KERNEL::Exception(oss.str().c_str());
7324 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7326 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7328 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7329 checkCoherencyOfType(tse2);
7330 if(_time_steps.empty())
7332 setName(tse2->getName().c_str());
7333 setInfo(tse2->getInfo());
7335 checkThatComponentsMatch(tse2->getInfo());
7336 _time_steps.push_back(tse);
7339 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7341 std::size_t nbOfCompo=_infos.size();
7342 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7344 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7347 if((cur->getInfo()).size()!=nbOfCompo)
7349 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7350 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7351 throw INTERP_KERNEL::Exception(oss.str().c_str());
7353 cur->copyNameScope(*this);
7358 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7360 _time_steps.resize(nbPdt);
7361 for(int i=0;i<nbPdt;i++)
7363 std::vector< std::pair<int,int> > ts;
7364 med_int numdt=0,numo=0;
7365 med_int meshIt=0,meshOrder=0;
7367 MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7372 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7377 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7381 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7384 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7386 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7390 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7392 if(_time_steps.empty())
7393 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7394 checkThatNbOfCompoOfTSMatchThis();
7395 std::vector<std::string> infos(getInfo());
7396 int nbComp=infos.size();
7397 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7398 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7399 for(int i=0;i<nbComp;i++)
7401 std::string info=infos[i];
7403 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7404 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7405 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7408 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7409 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7410 int nbOfTS=_time_steps.size();
7411 for(int i=0;i<nbOfTS;i++)
7412 _time_steps[i]->writeLL(fid,opts,*this);
7415 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7417 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7419 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7421 elt->loadBigArraysRecursively(fid,nasc);
7425 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7427 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7429 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7431 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7435 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7437 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7439 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7441 elt->unloadArrays();
7445 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7447 return _time_steps.size();
7450 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7452 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7453 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7455 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7457 newTS.push_back(*it);
7462 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7464 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7465 int maxId=(int)_time_steps.size();
7467 std::set<int> idsToDel;
7468 for(const int *id=startIds;id!=endIds;id++,ii++)
7470 if(*id>=0 && *id<maxId)
7472 idsToDel.insert(*id);
7476 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7477 throw INTERP_KERNEL::Exception(oss.str().c_str());
7480 for(int iii=0;iii<maxId;iii++)
7481 if(idsToDel.find(iii)==idsToDel.end())
7482 newTS.push_back(_time_steps[iii]);
7486 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7488 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7489 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7490 if(nbOfEntriesToKill==0)
7492 std::size_t sz=_time_steps.size();
7493 std::vector<bool> b(sz,true);
7495 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7497 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7498 for(std::size_t i=0;i<sz;i++)
7500 newTS.push_back(_time_steps[i]);
7504 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7507 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7508 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7510 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7514 tmp->getTime(it2,ord);
7515 if(it2==iteration && order==ord)
7518 oss << "(" << it2 << "," << ord << "), ";
7521 throw INTERP_KERNEL::Exception(oss.str().c_str());
7524 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7527 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7529 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7531 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7535 double ti=tmp->getTime(it2,ord);
7536 if(fabs(time-ti)<eps)
7542 throw INTERP_KERNEL::Exception(oss.str().c_str());
7545 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7547 int lgth=_time_steps.size();
7548 std::vector< std::pair<int,int> > ret(lgth);
7549 for(int i=0;i<lgth;i++)
7550 _time_steps[i]->fillIteration(ret[i]);
7555 * 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'
7556 * This method returns two things.
7557 * - The absolute dimension of 'this' in first parameter.
7558 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7559 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7561 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7562 * Only these 3 discretizations will be taken into account here.
7564 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7565 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7566 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7568 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7569 * 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'.
7571 * Let's consider the typical following case :
7572 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7573 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7574 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7576 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7578 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7580 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7581 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7582 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7583 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7585 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7587 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7590 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7592 if(pos<0 || pos>=(int)_time_steps.size())
7594 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7595 throw INTERP_KERNEL::Exception(oss.str().c_str());
7597 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7600 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7601 oss << "\nTry to use following method eraseEmptyTS !";
7602 throw INTERP_KERNEL::Exception(oss.str().c_str());
7607 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7609 if(pos<0 || pos>=(int)_time_steps.size())
7611 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7612 throw INTERP_KERNEL::Exception(oss.str().c_str());
7614 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7617 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7618 oss << "\nTry to use following method eraseEmptyTS !";
7619 throw INTERP_KERNEL::Exception(oss.str().c_str());
7624 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7626 std::vector<std::string> ret;
7627 std::set<std::string> ret2;
7628 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7630 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7631 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7632 if(ret2.find(*it2)==ret2.end())
7634 ret.push_back(*it2);
7641 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7643 std::vector<std::string> ret;
7644 std::set<std::string> ret2;
7645 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7647 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7648 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7649 if(ret2.find(*it2)==ret2.end())
7651 ret.push_back(*it2);
7658 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7660 std::vector<std::string> ret;
7661 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7663 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7664 ret.insert(ret.end(),tmp.begin(),tmp.end());
7669 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7671 std::vector<std::string> ret;
7672 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7674 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7675 ret.insert(ret.end(),tmp.begin(),tmp.end());
7680 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7682 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7683 (*it)->changePflsRefsNamesGen2(mapOfModif);
7686 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7688 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7689 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7692 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7694 int lgth=_time_steps.size();
7695 std::vector< std::vector<TypeOfField> > ret(lgth);
7696 for(int i=0;i<lgth;i++)
7697 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7702 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7704 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTSWithoutSDA::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7706 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7709 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7711 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7713 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7715 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7716 ret->_time_steps[i]=(*it)->deepCpy();
7721 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7723 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7724 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7725 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7726 for(std::size_t i=0;i<sz;i++)
7728 ret[i]=shallowCpy();
7729 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7731 for(std::size_t i=0;i<sz2;i++)
7733 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7736 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7737 throw INTERP_KERNEL::Exception(oss.str().c_str());
7741 for(std::size_t i=0;i<sz;i++)
7742 for(std::size_t j=0;j<sz2;j++)
7743 ret[i]->_time_steps[j]=ts[j][i];
7748 * This method splits into discretization each time steps in \a this.
7749 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7751 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7753 std::size_t sz(_time_steps.size());
7754 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7755 for(std::size_t i=0;i<sz;i++)
7757 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7760 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7761 throw INTERP_KERNEL::Exception(oss.str().c_str());
7763 items[i]=timeStep->splitDiscretizations();
7766 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7767 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7768 std::vector< TypeOfField > types;
7769 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7770 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7772 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7774 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7775 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7776 if(it2==types.end())
7777 types.push_back(ts[0]);
7779 ret.resize(types.size()); ret2.resize(types.size());
7780 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7781 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7783 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7784 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7785 ret2[pos].push_back(*it1);
7787 for(std::size_t i=0;i<types.size();i++)
7789 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7790 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7791 elt->pushBackTimeStep(*it1);//also updates infos in elt
7793 elt->MEDFileFieldNameScope::operator=(*this);
7799 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7801 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7803 std::size_t sz(_time_steps.size());
7804 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7805 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7806 for(std::size_t i=0;i<sz;i++)
7808 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7811 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7812 throw INTERP_KERNEL::Exception(oss.str().c_str());
7814 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7815 if(szOut==std::numeric_limits<std::size_t>::max())
7816 szOut=items[i].size();
7818 if(items[i].size()!=szOut)
7819 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7821 if(szOut==std::numeric_limits<std::size_t>::max())
7822 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7823 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7824 for(std::size_t i=0;i<szOut;i++)
7826 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7827 for(std::size_t j=0;j<sz;j++)
7828 elt->pushBackTimeStep(items[j][i]);
7830 elt->MEDFileFieldNameScope::operator=(*this);
7835 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7837 _name=field->getName();
7839 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7841 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7842 _infos=arr->getInfoOnComponents();
7845 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7847 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7848 if(_name!=field->getName())
7850 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7851 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7852 throw INTERP_KERNEL::Exception(oss.str().c_str());
7855 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7856 checkThatComponentsMatch(arr->getInfoOnComponents());
7859 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7861 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7862 if(getInfo().size()!=compos.size())
7864 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7865 oss << " number of components of element to append (" << compos.size() << ") !";
7866 throw INTERP_KERNEL::Exception(oss.str().c_str());
7870 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7871 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7872 oss << " But compo in input fields are : ";
7873 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7875 throw INTERP_KERNEL::Exception(oss.str().c_str());
7879 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7881 std::size_t sz=_infos.size();
7883 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7885 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7887 if(elt->getInfo().size()!=sz)
7889 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7890 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7891 throw INTERP_KERNEL::Exception(oss.str().c_str());
7896 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7899 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7900 if(!_time_steps.empty())
7901 checkCoherencyOfTinyInfo(field,arr);
7902 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7903 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7904 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7905 copyTinyInfoFrom(field,arr);
7906 _time_steps.push_back(obj);
7909 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7912 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7913 if(!_time_steps.empty())
7914 checkCoherencyOfTinyInfo(field,arr);
7915 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7916 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7917 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7918 copyTinyInfoFrom(field,arr);
7919 _time_steps.push_back(obj);
7922 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7924 int sz=(int)_time_steps.size();
7927 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7928 throw INTERP_KERNEL::Exception(oss.str().c_str());
7930 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7933 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7935 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7936 throw INTERP_KERNEL::Exception(oss.str().c_str());
7942 //= MEDFileFieldMultiTSWithoutSDA
7944 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7946 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
7949 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7953 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7958 * \param [in] fieldId field id in C mode
7960 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7961 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
7964 catch(INTERP_KERNEL::Exception& e)
7967 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7968 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
7971 catch(INTERP_KERNEL::Exception& e)
7974 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7976 return new MEDFileField1TSWithoutSDA;
7979 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7982 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7983 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7985 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7988 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7990 return MEDFileField1TSWithoutSDA::TYPE_STR;
7993 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7995 return new MEDFileFieldMultiTSWithoutSDA(*this);
7998 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8000 return new MEDFileFieldMultiTSWithoutSDA;
8004 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8005 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8007 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
8009 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8010 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8012 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8013 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8016 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8018 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8019 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8021 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8023 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8026 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8028 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8029 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8030 ret->setIteration(i,elt);
8036 //= MEDFileAnyTypeFieldMultiTS
8038 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8042 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8043 try:MEDFileFieldGlobsReal(fileName)
8045 MEDFileUtilities::CheckFileForRead(fileName);
8046 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8047 _content=BuildContentFrom(fid,fileName,loadAll,ms);
8050 catch(INTERP_KERNEL::Exception& e)
8055 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8057 med_field_type typcha;
8058 std::vector<std::string> infos;
8061 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
8062 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8067 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8072 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8077 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] !";
8078 throw INTERP_KERNEL::Exception(oss.str().c_str());
8081 ret->setDtUnit(dtunit.c_str());
8085 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8087 med_field_type typcha;
8089 std::vector<std::string> infos;
8090 std::string dtunit,fieldName;
8091 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8092 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8097 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8102 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8107 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] !";
8108 throw INTERP_KERNEL::Exception(oss.str().c_str());
8111 ret->setDtUnit(dtunit.c_str());
8115 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8118 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8119 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8121 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8122 ret->setFileName(fileName);
8123 ret->_content=c; c->incrRef();
8126 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8128 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8129 ret->setFileName(fileName);
8130 ret->_content=c; c->incrRef();
8133 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8136 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8137 try:MEDFileFieldGlobsReal(fileName)
8139 MEDFileUtilities::CheckFileForRead(fileName);
8140 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8141 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
8144 catch(INTERP_KERNEL::Exception& e)
8149 //= MEDFileIntFieldMultiTSWithoutSDA
8151 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8153 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8156 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8160 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8164 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8165 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8168 catch(INTERP_KERNEL::Exception& e)
8172 * \param [in] fieldId field id in C mode
8174 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8175 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8178 catch(INTERP_KERNEL::Exception& e)
8181 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8183 return new MEDFileIntField1TSWithoutSDA;
8186 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8189 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8190 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8192 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8195 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8197 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8200 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8202 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8205 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8207 return new MEDFileIntFieldMultiTSWithoutSDA;
8210 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8212 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8213 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8215 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8217 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8220 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8222 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8223 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8224 ret->setIteration(i,elt);
8230 //= MEDFileAnyTypeFieldMultiTS
8233 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8234 * that has been read from a specified MED file.
8235 * \param [in] fileName - the name of the MED file to read.
8236 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8237 * is to delete this field using decrRef() as it is no more needed.
8238 * \throw If reading the file fails.
8240 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8242 MEDFileUtilities::CheckFileForRead(fileName);
8243 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8244 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8245 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8246 ret->loadGlobals(fid);
8251 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8252 * that has been read from a specified MED file.
8253 * \param [in] fileName - the name of the MED file to read.
8254 * \param [in] fieldName - the name of the field to read.
8255 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8256 * is to delete this field using decrRef() as it is no more needed.
8257 * \throw If reading the file fails.
8258 * \throw If there is no field named \a fieldName in the file.
8260 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8262 MEDFileUtilities::CheckFileForRead(fileName);
8263 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8264 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
8265 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8266 ret->loadGlobals(fid);
8271 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8272 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8274 * \warning this is a shallow copy constructor
8276 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8278 if(!shallowCopyOfContent)
8280 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8281 otherPtr->incrRef();
8282 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8286 _content=other.shallowCpy();
8290 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8292 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8294 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8298 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8300 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8302 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8306 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8308 return contentNotNullBase()->getPflsReallyUsed2();
8311 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8313 return contentNotNullBase()->getLocsReallyUsed2();
8316 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8318 return contentNotNullBase()->getPflsReallyUsedMulti2();
8321 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8323 return contentNotNullBase()->getLocsReallyUsedMulti2();
8326 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8328 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8331 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8333 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8336 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8338 return contentNotNullBase()->getNumberOfTS();
8341 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8343 contentNotNullBase()->eraseEmptyTS();
8346 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8348 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8351 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8353 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8356 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8358 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8359 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8364 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8366 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8367 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8372 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8374 return contentNotNullBase()->getIterations();
8377 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8379 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8380 pushBackTimeStep(*it);
8383 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8386 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8387 int nbOfTS(fmts->getNumberOfTS());
8388 for(int i=0;i<nbOfTS;i++)
8390 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8391 pushBackTimeStep(elt);
8395 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8398 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8399 checkCoherencyOfType(f1ts);
8401 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8402 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8404 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8405 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8406 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8407 _content->pushBackTimeStep(cSafe);
8408 appendGlobs(*f1ts,1e-12);
8411 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8413 contentNotNullBase()->synchronizeNameScope();
8416 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8418 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8421 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8423 return contentNotNullBase()->getPosGivenTime(time,eps);
8426 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8428 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8431 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8433 return contentNotNullBase()->getTypesOfFieldAvailable();
8436 std::vector< std::vector< std::pair<int,int> > > MEDFileAnyTypeFieldMultiTS::getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
8438 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8441 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8443 return contentNotNullBase()->getName();
8446 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8448 contentNotNullBase()->setName(name);
8451 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8453 return contentNotNullBase()->getDtUnit();
8456 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8458 contentNotNullBase()->setDtUnit(dtUnit);
8461 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8463 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8466 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8468 return contentNotNullBase()->getTimeSteps(ret1);
8471 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8473 return contentNotNullBase()->getMeshName();
8476 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8478 contentNotNullBase()->setMeshName(newMeshName);
8481 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8483 return contentNotNullBase()->changeMeshNames(modifTab);
8486 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8488 return contentNotNullBase()->getInfo();
8491 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8493 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8496 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8498 return contentNotNullBase()->setInfo(info);
8501 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8503 const std::vector<std::string> ret=getInfo();
8504 return (int)ret.size();
8507 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8509 writeGlobals(fid,*this);
8510 contentNotNullBase()->writeLL(fid,*this);
8514 * Writes \a this field into a MED file specified by its name.
8515 * \param [in] fileName - the MED file name.
8516 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8517 * - 2 - erase; an existing file is removed.
8518 * - 1 - append; same data should not be present in an existing file.
8519 * - 0 - overwrite; same data present in an existing file is overwritten.
8520 * \throw If the field name is not set.
8521 * \throw If no field data is set.
8522 * \throw If \a mode == 1 and the same data is present in an existing file.
8524 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8526 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8527 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8532 * This method alloc the arrays and load potentially huge arrays contained in this field.
8533 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8534 * This method can be also called to refresh or reinit values from a file.
8536 * \throw If the fileName is not set or points to a non readable MED file.
8538 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8540 if(getFileName().empty())
8541 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8542 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8543 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8547 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8548 * But once data loaded once, this method does nothing.
8550 * \throw If the fileName is not set or points to a non readable MED file.
8551 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8553 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8555 if(!getFileName().empty())
8557 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8558 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8563 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8564 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8565 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8567 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8569 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8571 contentNotNullBase()->unloadArrays();
8575 * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
8576 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8577 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8579 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8581 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8583 if(!getFileName().empty())
8584 contentNotNullBase()->unloadArrays();
8587 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8589 std::ostringstream oss;
8590 contentNotNullBase()->simpleRepr(0,oss,-1);
8591 simpleReprGlobs(oss);
8595 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8597 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8600 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8602 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8603 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8608 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8609 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8610 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8612 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8614 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8616 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8617 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8618 std::size_t sz(contentsSplit.size());
8619 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8620 for(std::size_t i=0;i<sz;i++)
8622 ret[i]=shallowCpy();
8623 ret[i]->_content=contentsSplit[i];
8629 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8630 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8632 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8634 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8636 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8637 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8638 std::size_t sz(contentsSplit.size());
8639 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8640 for(std::size_t i=0;i<sz;i++)
8642 ret[i]=shallowCpy();
8643 ret[i]->_content=contentsSplit[i];
8649 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8650 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8652 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8654 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8656 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8657 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8658 std::size_t sz(contentsSplit.size());
8659 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8660 for(std::size_t i=0;i<sz;i++)
8662 ret[i]=shallowCpy();
8663 ret[i]->_content=contentsSplit[i];
8668 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8670 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8671 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8672 ret->_content=_content->deepCpy();
8673 ret->deepCpyGlobs(*this);
8677 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8683 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8684 * \param [in] iteration - the iteration number of a required time step.
8685 * \param [in] order - the iteration order number of required time step.
8686 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8687 * delete this field using decrRef() as it is no more needed.
8688 * \throw If there is no required time step in \a this field.
8690 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8692 int pos=getPosOfTimeStep(iteration,order);
8693 return getTimeStepAtPos(pos);
8697 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8698 * \param [in] time - the time of the time step of interest.
8699 * \param [in] eps - a precision used to compare time values.
8700 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8701 * delete this field using decrRef() as it is no more needed.
8702 * \throw If there is no required time step in \a this field.
8704 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8706 int pos=getPosGivenTime(time,eps);
8707 return getTimeStepAtPos(pos);
8711 * 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.
8712 * The float64 value of time attached to the pair of integers are not considered here.
8713 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8715 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8716 * \throw If there is a null pointer in \a vectFMTS.
8718 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8720 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8721 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8722 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8723 while(!lstFMTS.empty())
8725 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8726 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8728 throw INTERP_KERNEL::Exception(msg);
8729 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8730 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8731 elt.push_back(curIt); it=lstFMTS.erase(it);
8732 while(it!=lstFMTS.end())
8736 throw INTERP_KERNEL::Exception(msg);
8737 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8739 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8749 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8750 * All returned instances in a subvector can be safely loaded, rendered along time
8751 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8752 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8753 * 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).
8754 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8755 * 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.
8757 * \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().
8758 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8759 * \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.
8760 * \return - A vector of vector of objects that contains the same pointers (objects) than thoose in \a vectFMTS except that there are organized differently. So pointers included in returned vector of vector should \b not been dealt by the caller.
8762 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8763 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8764 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8765 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8766 * \throw If mesh is null.
8767 * \throw If an element in \a vectFMTS is null.
8768 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8770 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8772 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8774 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8775 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8776 if(vectFMTS.empty())
8778 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8779 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8781 throw INTERP_KERNEL::Exception(msg);
8783 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8784 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8785 for(;it!=vectFMTS.end();it++,i++)
8788 throw INTERP_KERNEL::Exception(msg);
8789 TypeOfField tof0,tof1;
8790 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8793 vectFMTSNotNodes.push_back(*it);
8795 vectFMTSNodes.push_back(*it);
8798 vectFMTSNotNodes.push_back(*it);
8800 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8801 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8803 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8806 bool isFetched(false);
8807 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8810 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8811 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8812 { ret[i].push_back(*it2); isFetched=true; }
8816 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8817 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8818 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8826 * 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.
8827 * \param [out] cmps - same size than the returned vector.
8829 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8831 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8832 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8833 while(!lstFMTS.empty())
8835 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8836 MEDFileAnyTypeFieldMultiTS *ref(*it);
8837 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8838 elt.push_back(ref); it=lstFMTS.erase(it);
8839 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8840 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8841 while(it!=lstFMTS.end())
8843 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8844 if(cmp->isEqual(curIt))
8845 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8849 ret.push_back(elt); cmps.push_back(cmp);
8855 * 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.
8856 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8858 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8859 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8860 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8861 * \thorw If \a f0 and \a f1 do not have the same times steps.
8862 * \throw If mesh is null.
8863 * \throw If \a f0 or \a f1 is null.
8864 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8866 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8869 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8871 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8872 if(f0->getMeshName()!=mesh->getName())
8874 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8875 throw INTERP_KERNEL::Exception(oss.str().c_str());
8877 if(f1->getMeshName()!=mesh->getName())
8879 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8880 throw INTERP_KERNEL::Exception(oss.str().c_str());
8882 int nts=f0->getNumberOfTS();
8883 if(nts!=f1->getNumberOfTS())
8884 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8887 for(int i=0;i<nts;i++)
8889 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8890 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8891 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8892 if(tofs0.size()!=1 || tofs1.size()!=1)
8893 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8896 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8897 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8900 { tof0=tofs0[0]; tof1=tofs1[0]; }
8901 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8903 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() << ") !";
8904 throw INTERP_KERNEL::Exception(oss.str().c_str());
8906 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8908 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() << ") !";
8909 throw INTERP_KERNEL::Exception(oss.str().c_str());
8911 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8913 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() << ") !";
8914 throw INTERP_KERNEL::Exception(oss.str().c_str());
8920 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8922 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8925 //= MEDFileFieldMultiTS
8928 * Returns a new empty instance of MEDFileFieldMultiTS.
8929 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8930 * is to delete this field using decrRef() as it is no more needed.
8932 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8934 return new MEDFileFieldMultiTS;
8938 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8939 * that has been read from a specified MED file.
8940 * \param [in] fileName - the name of the MED file to read.
8941 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8942 * is to delete this field using decrRef() as it is no more needed.
8943 * \throw If reading the file fails.
8945 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8947 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8948 ret->contentNotNull();//to check that content type matches with \a this type.
8953 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8954 * that has been read from a specified MED file.
8955 * \param [in] fileName - the name of the MED file to read.
8956 * \param [in] fieldName - the name of the field to read.
8957 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8958 * is to delete this field using decrRef() as it is no more needed.
8959 * \throw If reading the file fails.
8960 * \throw If there is no field named \a fieldName in the file.
8962 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8964 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
8965 ret->contentNotNull();//to check that content type matches with \a this type.
8970 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8971 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8973 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8974 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8975 * \warning this is a shallow copy constructor
8976 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8977 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8978 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8979 * is to delete this field using decrRef() as it is no more needed.
8981 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8983 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8986 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
8988 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities));
8989 ret->contentNotNull();//to check that content type matches with \a this type.
8993 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8995 return new MEDFileFieldMultiTS(*this);
8998 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9001 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9002 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9004 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9008 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9009 * following the given input policy.
9011 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9012 * By default (true) the globals are deeply copied.
9013 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9015 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9017 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
9018 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9021 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9023 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9024 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9025 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
9028 ret=MEDFileIntFieldMultiTS::New();
9030 ret->deepCpyGlobs(*this);
9032 ret->shallowCpyGlobs(*this);
9037 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9038 * \param [in] pos - a time step id.
9039 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9040 * delete this field using decrRef() as it is no more needed.
9041 * \throw If \a pos is not a valid time step id.
9043 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9045 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9048 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9049 throw INTERP_KERNEL::Exception(oss.str().c_str());
9051 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9054 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9055 ret->shallowCpyGlobs(*this);
9058 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9059 throw INTERP_KERNEL::Exception(oss.str().c_str());
9063 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9064 * mesh entities of a given dimension of the first mesh in MED file.
9065 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9066 * \param [in] type - a spatial discretization of interest.
9067 * \param [in] iteration - the iteration number of a required time step.
9068 * \param [in] order - the iteration order number of required time step.
9069 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9070 * \param [in] renumPol - specifies how to permute values of the result field according to
9071 * the optional numbers of cells and nodes, if any. The valid values are
9072 * - 0 - do not permute.
9073 * - 1 - permute cells.
9074 * - 2 - permute nodes.
9075 * - 3 - permute cells and nodes.
9077 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9078 * caller is to delete this field using decrRef() as it is no more needed.
9079 * \throw If the MED file is not readable.
9080 * \throw If there is no mesh in the MED file.
9081 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9082 * \throw If no field values of the required parameters are available.
9084 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9086 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9087 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9089 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9090 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9091 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9092 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9097 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9098 * the top level cells of the first mesh in MED file.
9099 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9100 * \param [in] type - a spatial discretization of interest.
9101 * \param [in] iteration - the iteration number of a required time step.
9102 * \param [in] order - the iteration order number of required time step.
9103 * \param [in] renumPol - specifies how to permute values of the result field according to
9104 * the optional numbers of cells and nodes, if any. The valid values are
9105 * - 0 - do not permute.
9106 * - 1 - permute cells.
9107 * - 2 - permute nodes.
9108 * - 3 - permute cells and nodes.
9110 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9111 * caller is to delete this field using decrRef() as it is no more needed.
9112 * \throw If the MED file is not readable.
9113 * \throw If there is no mesh in the MED file.
9114 * \throw If no field values of the required parameters are available.
9116 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9118 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9119 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9121 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9122 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9123 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9124 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9129 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9131 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9132 * \param [in] type - a spatial discretization of interest.
9133 * \param [in] iteration - the iteration number of a required time step.
9134 * \param [in] order - the iteration order number of required time step.
9135 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9136 * \param [in] mesh - the supporting mesh.
9137 * \param [in] renumPol - specifies how to permute values of the result field according to
9138 * the optional numbers of cells and nodes, if any. The valid values are
9139 * - 0 - do not permute.
9140 * - 1 - permute cells.
9141 * - 2 - permute nodes.
9142 * - 3 - permute cells and nodes.
9144 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9145 * caller is to delete this field using decrRef() as it is no more needed.
9146 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9147 * \throw If no field of \a this is lying on \a mesh.
9148 * \throw If no field values of the required parameters are available.
9150 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9152 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9153 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9155 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9156 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9157 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9158 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9163 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9165 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9166 * \param [in] type - a spatial discretization of the new field.
9167 * \param [in] iteration - the iteration number of a required time step.
9168 * \param [in] order - the iteration order number of required time step.
9169 * \param [in] mesh - the supporting mesh.
9170 * \param [in] renumPol - specifies how to permute values of the result field according to
9171 * the optional numbers of cells and nodes, if any. The valid values are
9172 * - 0 - do not permute.
9173 * - 1 - permute cells.
9174 * - 2 - permute nodes.
9175 * - 3 - permute cells and nodes.
9177 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9178 * caller is to delete this field using decrRef() as it is no more needed.
9179 * \throw If no field of \a this is lying on \a mesh.
9180 * \throw If no field values of the required parameters are available.
9182 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9184 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9185 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9187 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9188 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9189 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9190 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9195 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9196 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9197 * This method is useful for MED2 file format when field on different mesh was autorized.
9199 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9201 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9202 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9204 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9205 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9206 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9207 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9212 * Returns values and a profile of the field of a given type, of a given time step,
9213 * lying on a given support.
9214 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9215 * \param [in] type - a spatial discretization of the field.
9216 * \param [in] iteration - the iteration number of a required time step.
9217 * \param [in] order - the iteration order number of required time step.
9218 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9219 * \param [in] mesh - the supporting mesh.
9220 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9221 * field of interest lies on. If the field lies on all entities of the given
9222 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9223 * using decrRef() as it is no more needed.
9224 * \param [in] glob - the global data storing profiles and localization.
9225 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9226 * field. The caller is to delete this array using decrRef() as it is no more needed.
9227 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9228 * \throw If no field of \a this is lying on \a mesh.
9229 * \throw If no field values of the required parameters are available.
9231 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9233 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9234 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9236 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9237 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9238 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9241 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9243 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9245 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9246 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9248 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 !");
9252 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9254 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9256 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9257 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9259 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 !");
9264 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9265 * the given field is checked if its elements are sorted suitable for writing to MED file
9266 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9267 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9268 * \param [in] field - the field to add to \a this.
9269 * \throw If the name of \a field is empty.
9270 * \throw If the data array of \a field is not set.
9271 * \throw If existing time steps have different name or number of components than \a field.
9272 * \throw If the underlying mesh of \a field has no name.
9273 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9275 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9277 const DataArrayDouble *arr=0;
9279 arr=field->getArray();
9280 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9284 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9285 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9286 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9289 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9290 * A new profile is added only if no equal profile is missing.
9291 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9292 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9293 * \param [in] mesh - the supporting mesh of \a field.
9294 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9295 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9296 * \throw If either \a field or \a mesh or \a profile has an empty name.
9297 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9298 * \throw If the data array of \a field is not set.
9299 * \throw If the data array of \a this is already allocated but has different number of
9300 * components than \a field.
9301 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9302 * \sa setFieldNoProfileSBT()
9304 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9306 const DataArrayDouble *arr=0;
9308 arr=field->getArray();
9309 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9312 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9314 _content=new MEDFileFieldMultiTSWithoutSDA;
9317 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9318 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9321 catch(INTERP_KERNEL::Exception& e)
9324 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9325 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9328 catch(INTERP_KERNEL::Exception& e)
9331 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9335 std::vector< std::vector<DataArrayDouble *> > MEDFileFieldMultiTS::getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
9337 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9340 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9342 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9345 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9347 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9350 //= MEDFileAnyTypeFieldMultiTSIterator
9352 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9357 _nb_iter=fmts->getNumberOfTS();
9361 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9365 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9367 if(_iter_id<_nb_iter)
9369 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9371 return fmts->getTimeStepAtPos(_iter_id++);
9379 //= MEDFileIntFieldMultiTS
9382 * Returns a new empty instance of MEDFileFieldMultiTS.
9383 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9384 * is to delete this field using decrRef() as it is no more needed.
9386 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9388 return new MEDFileIntFieldMultiTS;
9392 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9393 * that has been read from a specified MED file.
9394 * \param [in] fileName - the name of the MED file to read.
9395 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9396 * is to delete this field using decrRef() as it is no more needed.
9397 * \throw If reading the file fails.
9399 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9401 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9402 ret->contentNotNull();//to check that content type matches with \a this type.
9407 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9408 * that has been read from a specified MED file.
9409 * \param [in] fileName - the name of the MED file to read.
9410 * \param [in] fieldName - the name of the field to read.
9411 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9412 * is to delete this field using decrRef() as it is no more needed.
9413 * \throw If reading the file fails.
9414 * \throw If there is no field named \a fieldName in the file.
9416 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9418 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9419 ret->contentNotNull();//to check that content type matches with \a this type.
9424 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9425 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9427 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9428 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9429 * \warning this is a shallow copy constructor
9430 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9431 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9432 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9433 * is to delete this field using decrRef() as it is no more needed.
9435 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9437 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9440 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9442 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities);
9443 ret->contentNotNull();//to check that content type matches with \a this type.
9448 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9449 * following the given input policy.
9451 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9452 * By default (true) the globals are deeply copied.
9453 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9455 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9457 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9458 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9461 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9463 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9464 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9465 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9468 ret=MEDFileFieldMultiTS::New();
9470 ret->deepCpyGlobs(*this);
9472 ret->shallowCpyGlobs(*this);
9476 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9478 return new MEDFileIntFieldMultiTS(*this);
9481 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9484 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9485 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9487 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9491 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9492 * mesh entities of a given dimension of the first mesh in MED file.
9493 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9494 * \param [in] type - a spatial discretization of interest.
9495 * \param [in] iteration - the iteration number of a required time step.
9496 * \param [in] order - the iteration order number of required time step.
9497 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9498 * \param [out] arrOut - the DataArrayInt containing values of field.
9499 * \param [in] renumPol - specifies how to permute values of the result field according to
9500 * the optional numbers of cells and nodes, if any. The valid values are
9501 * - 0 - do not permute.
9502 * - 1 - permute cells.
9503 * - 2 - permute nodes.
9504 * - 3 - permute cells and nodes.
9506 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9507 * caller is to delete this field using decrRef() as it is no more needed.
9508 * \throw If the MED file is not readable.
9509 * \throw If there is no mesh in the MED file.
9510 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9511 * \throw If no field values of the required parameters are available.
9513 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9515 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9516 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9518 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9519 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9520 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9521 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9526 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9527 * the top level cells of the first mesh in MED file.
9528 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9529 * \param [in] type - a spatial discretization of interest.
9530 * \param [in] iteration - the iteration number of a required time step.
9531 * \param [in] order - the iteration order number of required time step.
9532 * \param [out] arrOut - the DataArrayInt containing values of field.
9533 * \param [in] renumPol - specifies how to permute values of the result field according to
9534 * the optional numbers of cells and nodes, if any. The valid values are
9535 * - 0 - do not permute.
9536 * - 1 - permute cells.
9537 * - 2 - permute nodes.
9538 * - 3 - permute cells and nodes.
9540 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9541 * caller is to delete this field using decrRef() as it is no more needed.
9542 * \throw If the MED file is not readable.
9543 * \throw If there is no mesh in the MED file.
9544 * \throw If no field values of the required parameters are available.
9546 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9548 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9549 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9551 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9552 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9553 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9554 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9559 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9561 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9562 * \param [in] type - a spatial discretization of interest.
9563 * \param [in] iteration - the iteration number of a required time step.
9564 * \param [in] order - the iteration order number of required time step.
9565 * \param [out] arrOut - the DataArrayInt containing values of field.
9566 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9567 * \param [in] mesh - the supporting mesh.
9568 * \param [in] renumPol - specifies how to permute values of the result field according to
9569 * the optional numbers of cells and nodes, if any. The valid values are
9570 * - 0 - do not permute.
9571 * - 1 - permute cells.
9572 * - 2 - permute nodes.
9573 * - 3 - permute cells and nodes.
9575 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9576 * caller is to delete this field using decrRef() as it is no more needed.
9577 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9578 * \throw If no field of \a this is lying on \a mesh.
9579 * \throw If no field values of the required parameters are available.
9581 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9583 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9584 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9586 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9587 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9588 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9589 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9594 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9596 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9597 * \param [in] type - a spatial discretization of the new field.
9598 * \param [in] iteration - the iteration number of a required time step.
9599 * \param [in] order - the iteration order number of required time step.
9600 * \param [in] mesh - the supporting mesh.
9601 * \param [out] arrOut - the DataArrayInt containing values of field.
9602 * \param [in] renumPol - specifies how to permute values of the result field according to
9603 * the optional numbers of cells and nodes, if any. The valid values are
9604 * - 0 - do not permute.
9605 * - 1 - permute cells.
9606 * - 2 - permute nodes.
9607 * - 3 - permute cells and nodes.
9609 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9610 * caller is to delete this field using decrRef() as it is no more needed.
9611 * \throw If no field of \a this is lying on \a mesh.
9612 * \throw If no field values of the required parameters are available.
9614 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9616 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9617 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9619 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9620 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9621 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9622 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9627 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9628 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9629 * This method is useful for MED2 file format when field on different mesh was autorized.
9631 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9633 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9634 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9636 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9637 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9638 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9639 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9644 * Returns values and a profile of the field of a given type, of a given time step,
9645 * lying on a given support.
9646 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9647 * \param [in] type - a spatial discretization of the field.
9648 * \param [in] iteration - the iteration number of a required time step.
9649 * \param [in] order - the iteration order number of required time step.
9650 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9651 * \param [in] mesh - the supporting mesh.
9652 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9653 * field of interest lies on. If the field lies on all entities of the given
9654 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9655 * using decrRef() as it is no more needed.
9656 * \param [in] glob - the global data storing profiles and localization.
9657 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9658 * field. The caller is to delete this array using decrRef() as it is no more needed.
9659 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9660 * \throw If no field of \a this is lying on \a mesh.
9661 * \throw If no field values of the required parameters are available.
9663 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9665 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9666 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9668 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9669 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9670 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9674 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9675 * \param [in] pos - a time step id.
9676 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9677 * delete this field using decrRef() as it is no more needed.
9678 * \throw If \a pos is not a valid time step id.
9680 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9682 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9685 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9686 throw INTERP_KERNEL::Exception(oss.str().c_str());
9688 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9691 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9692 ret->shallowCpyGlobs(*this);
9695 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9696 throw INTERP_KERNEL::Exception(oss.str().c_str());
9700 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9701 * the given field is checked if its elements are sorted suitable for writing to MED file
9702 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9703 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9704 * \param [in] field - the field to add to \a this.
9705 * \throw If the name of \a field is empty.
9706 * \throw If the data array of \a field is not set.
9707 * \throw If existing time steps have different name or number of components than \a field.
9708 * \throw If the underlying mesh of \a field has no name.
9709 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9711 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9713 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9717 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9718 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9719 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9722 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9723 * A new profile is added only if no equal profile is missing.
9724 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9725 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9726 * \param [in] arrOfVals - the values of the field \a field used.
9727 * \param [in] mesh - the supporting mesh of \a field.
9728 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9729 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9730 * \throw If either \a field or \a mesh or \a profile has an empty name.
9731 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9732 * \throw If the data array of \a field is not set.
9733 * \throw If the data array of \a this is already allocated but has different number of
9734 * components than \a field.
9735 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9736 * \sa setFieldNoProfileSBT()
9738 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9740 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9743 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9745 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9747 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9748 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9750 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 !");
9754 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9756 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9758 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9759 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9761 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 !");
9765 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9767 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9770 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9774 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9775 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9778 catch(INTERP_KERNEL::Exception& e)
9781 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9782 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9785 catch(INTERP_KERNEL::Exception& e)
9788 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9790 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9795 MEDFileFields *MEDFileFields::New()
9797 return new MEDFileFields;
9800 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9802 return new MEDFileFields(fileName,loadAll,0,0);
9805 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9807 return new MEDFileFields(fileName,loadAll,ms,0);
9810 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9812 return new MEDFileFields(fileName,loadAll,0,&entities);
9815 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9817 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9818 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9822 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9824 std::vector<const BigMemoryObject *> ret;
9825 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9826 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9830 MEDFileFields *MEDFileFields::deepCpy() const
9832 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9834 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9836 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9837 ret->_fields[i]=(*it)->deepCpy();
9839 ret->deepCpyGlobs(*this);
9843 MEDFileFields *MEDFileFields::shallowCpy() const
9845 return new MEDFileFields(*this);
9849 * 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
9850 * 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.
9851 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9853 * \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.
9854 * \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.
9856 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9858 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9860 std::set< std::pair<int,int> > s;
9861 bool firstShot=true;
9862 areThereSomeForgottenTS=false;
9863 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9865 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9867 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9868 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9870 { s=s1; firstShot=false; }
9873 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9875 areThereSomeForgottenTS=true;
9879 std::vector< std::pair<int,int> > ret;
9880 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9884 int MEDFileFields::getNumberOfFields() const
9886 return _fields.size();
9889 std::vector<std::string> MEDFileFields::getFieldsNames() const
9891 std::vector<std::string> ret(_fields.size());
9893 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9895 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9898 ret[i]=f->getName();
9902 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9903 throw INTERP_KERNEL::Exception(oss.str().c_str());
9909 std::vector<std::string> MEDFileFields::getMeshesNames() const
9911 std::vector<std::string> ret;
9912 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9914 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9916 ret.push_back(cur->getMeshName());
9921 std::string MEDFileFields::simpleRepr() const
9923 std::ostringstream oss;
9924 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9929 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9931 int nbOfFields=getNumberOfFields();
9932 std::string startLine(bkOffset,' ');
9933 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9935 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9937 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9940 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9944 oss << startLine << " - not defined !" << std::endl;
9948 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9950 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9951 std::string chapter(17,'0'+i);
9952 oss << startLine << chapter << std::endl;
9955 cur->simpleRepr(bkOffset+2,oss,i);
9959 oss << startLine << " - not defined !" << std::endl;
9961 oss << startLine << chapter << std::endl;
9963 simpleReprGlobs(oss);
9966 MEDFileFields::MEDFileFields()
9970 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9971 try:MEDFileFieldGlobsReal(fileName)
9973 MEDFileUtilities::CheckFileForRead(fileName);
9974 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
9975 int nbFields(MEDnField(fid));
9976 _fields.resize(nbFields);
9977 med_field_type typcha;
9978 for(int i=0;i<nbFields;i++)
9980 std::vector<std::string> infos;
9981 std::string fieldName,dtunit;
9982 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
9987 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9992 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9997 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] !";
9998 throw INTERP_KERNEL::Exception(oss.str().c_str());
10002 loadAllGlobals(fid);
10004 catch(INTERP_KERNEL::Exception& e)
10009 void MEDFileFields::writeLL(med_idt fid) const
10012 writeGlobals(fid,*this);
10013 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10015 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10018 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10019 throw INTERP_KERNEL::Exception(oss.str().c_str());
10021 elt->writeLL(fid,*this);
10025 void MEDFileFields::write(const std::string& fileName, int mode) const
10027 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
10028 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
10033 * This method alloc the arrays and load potentially huge arrays contained in this field.
10034 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10035 * This method can be also called to refresh or reinit values from a file.
10037 * \throw If the fileName is not set or points to a non readable MED file.
10039 void MEDFileFields::loadArrays()
10041 if(getFileName().empty())
10042 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10043 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10044 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10046 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10048 elt->loadBigArraysRecursively(fid,*elt);
10053 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10054 * But once data loaded once, this method does nothing.
10056 * \throw If the fileName is not set or points to a non readable MED file.
10057 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10059 void MEDFileFields::loadArraysIfNecessary()
10061 if(!getFileName().empty())
10063 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10064 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10066 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10068 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10074 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10075 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10076 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10078 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10080 void MEDFileFields::unloadArrays()
10082 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10084 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10086 elt->unloadArrays();
10091 * This method potentially releases big data arrays if \a this is coming from a file. If \a this has been built from scratch this method will have no effect.
10092 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10093 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10095 * \sa MEDFileFields::loadArraysIfNecessary
10097 void MEDFileFields::unloadArraysWithoutDataLoss()
10099 if(!getFileName().empty())
10103 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10105 std::vector<std::string> ret;
10106 std::set<std::string> ret2;
10107 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10109 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10110 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10111 if(ret2.find(*it2)==ret2.end())
10113 ret.push_back(*it2);
10120 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10122 std::vector<std::string> ret;
10123 std::set<std::string> ret2;
10124 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10126 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10127 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10128 if(ret2.find(*it2)==ret2.end())
10130 ret.push_back(*it2);
10137 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10139 std::vector<std::string> ret;
10140 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10142 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10143 ret.insert(ret.end(),tmp.begin(),tmp.end());
10148 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10150 std::vector<std::string> ret;
10151 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10153 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10154 ret.insert(ret.end(),tmp.begin(),tmp.end());
10159 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10161 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10162 (*it)->changePflsRefsNamesGen2(mapOfModif);
10165 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10167 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10168 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10171 void MEDFileFields::resize(int newSize)
10173 _fields.resize(newSize);
10176 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10178 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10182 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10185 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10186 _fields.push_back(field->getContent());
10187 appendGlobs(*field,1e-12);
10190 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10193 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10194 if(i>=(int)_fields.size())
10195 _fields.resize(i+1);
10196 _fields[i]=field->getContent();
10197 appendGlobs(*field,1e-12);
10200 void MEDFileFields::destroyFieldAtPos(int i)
10202 destroyFieldsAtPos(&i,&i+1);
10205 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10207 std::vector<bool> b(_fields.size(),true);
10208 for(const int *i=startIds;i!=endIds;i++)
10210 if(*i<0 || *i>=(int)_fields.size())
10212 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10213 throw INTERP_KERNEL::Exception(oss.str().c_str());
10217 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10219 for(std::size_t i=0;i<_fields.size();i++)
10221 fields[j++]=_fields[i];
10225 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10227 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10228 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10229 std::vector<bool> b(_fields.size(),true);
10231 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10233 if(k<0 || k>=(int)_fields.size())
10235 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10236 throw INTERP_KERNEL::Exception(oss.str().c_str());
10240 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10242 for(std::size_t i=0;i<_fields.size();i++)
10244 fields[j++]=_fields[i];
10248 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10251 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10253 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10255 ret=cur->changeMeshNames(modifTab) || ret;
10261 * \param [in] meshName the name of the mesh that will be renumbered.
10262 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10263 * This code corresponds to the distribution of types in the corresponding mesh.
10264 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10265 * \param [in] renumO2N the old to new renumber array.
10266 * \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
10267 * field in \a this.
10269 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10272 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10274 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10277 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10283 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10285 if(i<0 || i>=(int)_fields.size())
10287 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10288 throw INTERP_KERNEL::Exception(oss.str().c_str());
10290 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10293 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
10294 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10295 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10297 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10299 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10302 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10303 throw INTERP_KERNEL::Exception(oss.str().c_str());
10305 ret->shallowCpyGlobs(*this);
10310 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10311 * This method is accessible in python using __getitem__ with a list in input.
10312 * \return a new object that the caller should deal with.
10314 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10316 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
10317 std::size_t sz=std::distance(startIds,endIds);
10318 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10320 for(const int *i=startIds;i!=endIds;i++,j++)
10322 if(*i<0 || *i>=(int)_fields.size())
10324 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10325 throw INTERP_KERNEL::Exception(oss.str().c_str());
10327 fields[j]=_fields[*i];
10329 ret->_fields=fields;
10333 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10335 return getFieldAtPos(getPosFromFieldName(fieldName));
10339 * This method removes, if any, fields in \a this having no time steps.
10340 * If there is one or more than one such field in \a this true is returned and those fields will not be referenced anymore in \a this.
10342 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10344 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10346 std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10347 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10349 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10352 if(elt->getNumberOfTS()>0)
10353 newFields.push_back(*it);
10356 if(_fields.size()==newFields.size())
10363 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10364 * This method can be seen as a filter applied on \a this, that returns an object containing
10365 * 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
10366 * shallow copied from \a this.
10368 * \param [in] meshName - the name of the mesh on w
10369 * \return a new object that the caller should deal with.
10371 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10373 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10374 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10376 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10379 if(cur->getMeshName()==meshName)
10382 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10383 ret->_fields.push_back(cur2);
10386 ret->shallowCpyOnlyUsedGlobs(*this);
10391 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10392 * Input time steps are specified using a pair of integer (iteration, order).
10393 * 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,
10394 * but for each multitimestep only the time steps in \a timeSteps are kept.
10395 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10397 * The returned object points to shallow copy of elements in \a this.
10399 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10400 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10401 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10403 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10405 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10406 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10408 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10411 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10412 ret->_fields.push_back(elt);
10414 ret->shallowCpyOnlyUsedGlobs(*this);
10419 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10421 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10423 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10424 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10426 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10429 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10430 if(elt->getNumberOfTS()!=0)
10431 ret->_fields.push_back(elt);
10433 ret->shallowCpyOnlyUsedGlobs(*this);
10437 MEDFileFieldsIterator *MEDFileFields::iterator()
10439 return new MEDFileFieldsIterator(this);
10442 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10444 std::string tmp(fieldName);
10445 std::vector<std::string> poss;
10446 for(std::size_t i=0;i<_fields.size();i++)
10448 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10451 std::string fname(f->getName());
10455 poss.push_back(fname);
10458 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10459 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10461 throw INTERP_KERNEL::Exception(oss.str().c_str());
10464 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10469 _nb_iter=fs->getNumberOfFields();
10473 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10477 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10479 if(_iter_id<_nb_iter)
10481 MEDFileFields *fs(_fs);
10483 return fs->getFieldAtPos(_iter_id++);