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 MEDCoupling;
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::deepCopy() 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()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
218 _end=_start+nbOfCells;
224 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
225 const int *arrPtr=arr->getConstPointer();
226 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_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 MCAuto<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
240 const int *dai2Ptr=dai2->getConstPointer();
241 int nbi=gsLoc.getWeights().size();
242 MCAuto<DataArrayInt> da2=dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
243 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_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 MCAuto<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()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
320 _nval=idsInPfl->getNumberOfTuples();
321 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
327 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
328 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
329 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
330 arr3->computeOffsetsFull();
331 MCAuto<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 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
346 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
347 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
349 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
350 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
352 MCAuto<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 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
369 da5->setName(oss.str().c_str());
370 glob.appendProfile(da5);
375 if(!da3->isIota(nbOfEltsInWholeMesh))
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()->setContigPartOfSelectedValuesSlice(_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::deepCopy(MEDFileFieldPerMeshPerType *father) const
431 MCAuto<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->checkConsistencyLight();
501 MCAuto<DataArrayInt> myIds(dpd->toDAI());
502 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
503 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
504 myIds->applyLin(1,-a);
505 int nbOfEltsToLoad(b-a+1);
506 med_filter filter=MED_FILTER_INIT;
507 {//TODO : manage int32 !
508 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
509 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
510 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
511 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
512 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
513 /*lastblocksize=useless because count=1*/0,&filter);
514 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
515 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
516 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
517 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
519 MEDfilterClose(&filter);
522 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
526 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
531 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
533 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
534 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
535 std::string fieldName(nasc.getName()),meshName(getMeshName());
536 int iteration(getIteration()),order(getOrder());
537 TypeOfField type(getType());
538 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
540 med_geometry_type mgeoti;
541 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
542 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
543 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
544 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
545 const PartDefinition *pd(_pd);
552 if(!_profile.empty())
553 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
554 _nval=pd->getNumberOfElems();
557 _end=start+_nval*nbi;
559 if(type==ON_CELLS && !_localization.empty())
561 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
562 setType(ON_GAUSS_PT);
565 setType(ON_GAUSS_NE);
566 _localization.clear();
571 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
573 std::string fieldName(nasc.getName()),meshName(getMeshName());
574 int iteration(getIteration()),order(getOrder());
575 TypeOfField type(getType());
576 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
577 med_geometry_type mgeoti;
578 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
580 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
583 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
584 if(_start<0 || _start>=arr->getNumberOfTuples())
586 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
587 throw INTERP_KERNEL::Exception(oss.str().c_str());
589 if(_end<0 || _end>arr->getNumberOfTuples())
591 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
592 throw INTERP_KERNEL::Exception(oss.str().c_str());
594 int nbOfCompo(arr->getNumberOfComponents());
595 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
598 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
599 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
602 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
605 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
606 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
609 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
613 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
615 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
617 int delta=_end-_start;
618 _start=newValueOfStart;
622 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
624 return _father->getIteration();
627 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
629 return _father->getOrder();
632 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
634 return _father->getTime();
637 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
639 return _father->getMeshName();
642 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
644 const char startLine[]=" ## ";
645 std::string startLine2(bkOffset,' ');
646 startLine2+=startLine;
647 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
648 oss << startLine2 << "Localization #" << id << "." << std::endl;
649 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
651 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
652 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
653 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
656 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
661 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
666 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
671 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
673 return _father->getGeoType();
676 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
678 return _father->getNumberOfComponents();
681 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
686 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
688 return _father->getOrCreateAndGetArray();
691 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
693 const MEDFileFieldPerMeshPerType *fath=_father;
694 return fath->getOrCreateAndGetArray();
697 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
699 return _father->getInfo();
702 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
707 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
712 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
714 return _localization;
717 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
719 _localization=newLocName;
722 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
724 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
726 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
728 _profile=(*it2).second;
734 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
736 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
738 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
740 _localization=(*it2).second;
746 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
750 dads.push_back(std::pair<int,int>(_start,_end));
751 geoTypes.push_back(getGeoType());
756 pfls.push_back(glob->getProfile(_profile.c_str()));
758 if(_localization.empty())
762 locs.push_back(glob->getLocalizationId(_localization.c_str()));
766 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
768 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));
772 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
774 TypeOfField type=getType();
775 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
776 med_geometry_type mgeoti;
777 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
778 const DataArray *arr=getOrCreateAndGetArray();
780 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
781 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
782 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
783 const unsigned char *locToWrite=0;
785 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
787 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
789 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
790 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
791 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
795 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
800 dad.first=_start; dad.second=_end;
804 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
805 * This code corresponds to the distribution of types in the corresponding mesh.
806 * \param [out] ptToFill memory zone where the output will be stored.
807 * \return the size of data pushed into output param \a ptToFill
809 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
812 std::ostringstream oss;
813 std::size_t nbOfType=codeOfMesh.size()/3;
815 for(std::size_t i=0;i<nbOfType && found==-1;i++)
816 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
820 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
821 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
822 throw INTERP_KERNEL::Exception(oss.str().c_str());
827 if(_nval!=codeOfMesh[3*found+1])
829 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
830 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
831 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
832 throw INTERP_KERNEL::Exception(oss.str().c_str());
834 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
839 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
840 if(pfl->getNumberOfTuples()!=_nval)
842 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
843 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
845 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
846 throw INTERP_KERNEL::Exception(oss.str().c_str());
848 int offset2=codeOfMesh[3*found+2];
849 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
851 if(*pflId<codeOfMesh[3*found+1])
852 *work++=offset2+*pflId;
858 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
860 for(int i=_start;i<_end;i++)
865 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
876 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
880 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
883 std::map<std::pair<std::string,TypeOfField>,int> m;
884 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
885 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
886 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
887 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
889 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
890 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
895 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
897 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
898 * \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.
899 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
900 * \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)
901 * \param [in,out] glob if necessary by the method, new profiles can be added to it
902 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
903 * \param [out] result All new entries will be appended on it.
904 * \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 !)
906 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
907 const DataArrayInt *explicitIdsInMesh,
908 const std::vector<int>& newCode,
909 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
910 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
912 if(entriesOnSameDisc.empty())
914 TypeOfField type=entriesOnSameDisc[0]->getType();
915 int szEntities=0,szTuples=0;
916 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
917 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
918 int nbi=szTuples/szEntities;
919 if(szTuples%szEntities!=0)
920 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
921 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
922 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
923 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
924 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
925 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
926 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
927 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
929 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
931 int startOfEltIdOfChunk=(*it)->_start;
932 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
933 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
934 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
936 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
937 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
939 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
940 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
942 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
943 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
944 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
945 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
947 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
949 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
950 arrPart->renumberInPlace(renumTupleIds->begin());
951 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
953 const int *idIt=diffVals->begin();
954 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
956 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
958 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
959 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
960 int nbEntityElts=subIds->getNumberOfTuples();
962 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
963 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
967 result.push_back(eltToAdd);
968 offset2+=nbEntityElts*nbi;
970 ret=ret || li.empty();
975 * \param [in] typeF type of field of new chunk
976 * \param [in] geoType the geometric type of the chunk
977 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
978 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
979 * \param [in] nbi number of integration points
980 * \param [in] offset The offset in the **global array of data**.
981 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
982 * to the new chunk to create.
983 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
984 * \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
985 * and corresponding entry erased from \a entriesOnSameDisc.
986 * \return a newly allocated chunk
988 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
989 bool isPfl, int nbi, int offset,
990 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
991 MEDFileFieldGlobsReal& glob,
994 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
995 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
996 for(;it!=entriesOnSameDisc.end();it++)
998 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1002 if((*it)->_profile.empty())
1005 if(!(*it)->_profile.empty())
1007 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1008 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1014 if(it==entriesOnSameDisc.end())
1017 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1019 ret->_loc_id=(int)geoType;
1020 ret->_nval=nbMeshEntities;
1022 ret->_end=ret->_start+ret->_nval*nbi;
1025 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1026 glob.appendProfile(idsOfMeshElt);
1027 ret->_profile=idsOfMeshElt->getName();
1029 //tony treatment of localization
1034 notInExisting=false;
1035 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1036 ret->_loc_id=(int)geoType;
1037 ret->setNewStart(offset);
1038 entriesOnSameDisc.erase(it);
1044 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1046 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1049 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1051 return new MEDFileFieldPerMeshPerType(fath,geoType);
1054 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1056 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1059 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1061 std::vector<const BigMemoryObject *> ret;
1062 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1063 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1067 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1069 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1070 ret->_father=father;
1072 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1074 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1075 ret->_field_pm_pt_pd[i]=(*it)->deepCopy((MEDFileFieldPerMeshPerType *)ret);
1080 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1082 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1083 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1084 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1088 * This method is the most general one. No optimization is done here.
1089 * \param [in] multiTypePfl is the end user profile specified in high level API
1090 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1091 * \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.
1092 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1093 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1094 * \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.
1096 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)
1098 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1099 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1100 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1103 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1105 _field_pm_pt_pd.resize(1);
1106 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1107 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1110 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1112 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1113 if(!arr || !arr->isAllocated())
1114 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1115 _field_pm_pt_pd.resize(1);
1116 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1117 _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.
1120 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1122 TypeOfField type=field->getTypeOfField();
1123 if(type!=ON_GAUSS_PT)
1125 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1126 int sz=_field_pm_pt_pd.size();
1128 for(int j=0;j<sz && !found;j++)
1130 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1132 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1138 _field_pm_pt_pd.resize(sz+1);
1139 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1141 std::vector<int> ret(1,(int)sz);
1146 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1147 int sz2=ret2.size();
1148 std::vector<int> ret3(sz2);
1150 for(int i=0;i<sz2;i++)
1152 int sz=_field_pm_pt_pd.size();
1153 int locIdToFind=ret2[i];
1155 for(int j=0;j<sz && !found;j++)
1157 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1159 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1166 _field_pm_pt_pd.resize(sz+1);
1167 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1175 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1177 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1178 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1180 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1181 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1183 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1184 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1185 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1186 if(retTmp->presenceOfValue(-1))
1187 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1188 std::vector<int> ret(retTmp->begin(),retTmp->end());
1192 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1194 TypeOfField type=field->getTypeOfField();
1195 if(type!=ON_GAUSS_PT)
1197 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1198 int sz=_field_pm_pt_pd.size();
1200 for(int j=0;j<sz && !found;j++)
1202 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1204 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1210 _field_pm_pt_pd.resize(sz+1);
1211 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1213 std::vector<int> ret(1,0);
1218 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1219 int sz2=ret2.size();
1220 std::vector<int> ret3(sz2);
1222 for(int i=0;i<sz2;i++)
1224 int sz=_field_pm_pt_pd.size();
1225 int locIdToFind=ret2[i];
1227 for(int j=0;j<sz && !found;j++)
1229 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1231 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1238 _field_pm_pt_pd.resize(sz+1);
1239 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1247 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1249 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1250 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1252 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1253 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1255 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1256 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1257 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1258 if(retTmp->presenceOfValue(-1))
1259 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1260 std::vector<int> ret(retTmp->begin(),retTmp->end());
1264 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1269 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1271 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1272 int curDim=(int)cm.getDimension();
1273 dim=std::max(dim,curDim);
1276 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1278 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1280 (*it)->fillTypesOfFieldAvailable(types);
1284 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
1286 int sz=_field_pm_pt_pd.size();
1287 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1288 for(int i=0;i<sz;i++)
1290 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1294 int MEDFileFieldPerMeshPerType::getIteration() const
1296 return _father->getIteration();
1299 int MEDFileFieldPerMeshPerType::getOrder() const
1301 return _father->getOrder();
1304 double MEDFileFieldPerMeshPerType::getTime() const
1306 return _father->getTime();
1309 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1311 return _father->getMeshName();
1314 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1316 const char startLine[]=" ## ";
1317 std::string startLine2(bkOffset,' ');
1318 std::string startLine3(startLine2);
1319 startLine3+=startLine;
1320 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1322 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1323 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1326 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1327 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1329 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1331 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1333 cur->simpleRepr(bkOffset,oss,i);
1336 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1341 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1343 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1345 globalSz+=(*it)->getNumberOfTuples();
1347 nbOfEntries+=(int)_field_pm_pt_pd.size();
1350 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1356 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1358 return _father->getNumberOfComponents();
1361 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1364 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1366 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1373 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1375 return _father->getOrCreateAndGetArray();
1378 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1380 const MEDFileFieldPerMesh *fath=_father;
1381 return fath->getOrCreateAndGetArray();
1384 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1386 return _father->getInfo();
1389 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1391 std::vector<std::string> ret;
1392 std::set<std::string> ret2;
1393 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1395 std::string tmp=(*it1)->getProfile();
1397 if(ret2.find(tmp)==ret2.end())
1406 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1408 std::vector<std::string> ret;
1409 std::set<std::string> ret2;
1410 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1412 std::string tmp=(*it1)->getLocalization();
1413 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1414 if(ret2.find(tmp)==ret2.end())
1423 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1425 std::vector<std::string> ret;
1426 std::set<std::string> ret2;
1427 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1429 std::string tmp=(*it1)->getProfile();
1436 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1438 std::vector<std::string> ret;
1439 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1441 std::string tmp=(*it1)->getLocalization();
1442 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1448 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1450 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1451 (*it1)->changePflsRefsNamesGen(mapOfModif);
1454 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1456 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1457 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1460 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1462 if(_field_pm_pt_pd.empty())
1464 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1465 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1466 throw INTERP_KERNEL::Exception(oss.str().c_str());
1468 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1469 return _field_pm_pt_pd[locId];
1470 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1471 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1472 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1473 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1474 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1477 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1479 if(_field_pm_pt_pd.empty())
1481 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1482 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1483 throw INTERP_KERNEL::Exception(oss.str().c_str());
1485 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1486 return _field_pm_pt_pd[locId];
1487 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1488 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1489 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1490 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1491 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1494 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
1496 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1498 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1499 if(meshDim!=(int)cm.getDimension())
1502 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1503 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1506 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1509 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1511 (*it)->fillValues(i,startEntryId,entries);
1515 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1517 _field_pm_pt_pd=leaves;
1518 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1519 (*it)->setFather(this);
1523 * \param [in,out] globalNum a global numbering counter for the renumbering.
1524 * \param [out] its - list of pair (start,stop) kept
1525 * \return bool - false if the type of field \a tof is not contained in \a this.
1527 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1530 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1531 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1532 if((*it)->getType()==tof)
1534 newPmPtPd.push_back(*it);
1535 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1536 (*it)->setNewStart(globalNum);
1537 globalNum=(*it)->getEnd();
1538 its.push_back(bgEnd);
1542 _field_pm_pt_pd=newPmPtPd;
1547 * \param [in,out] globalNum a global numbering counter for the renumbering.
1548 * \param [out] its - list of pair (start,stop) kept
1549 * \return bool - false if the type of field \a tof is not contained in \a this.
1551 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1553 if(_field_pm_pt_pd.size()<=idOfDisc)
1555 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1556 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1557 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1558 elt->setNewStart(globalNum);
1559 globalNum=elt->getEnd();
1560 its.push_back(bgEnd);
1561 _field_pm_pt_pd=newPmPtPd;
1565 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1569 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1571 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1572 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1573 med_geometry_type mgeoti;
1574 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1575 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1576 _field_pm_pt_pd.resize(nbProfiles);
1577 for(int i=0;i<nbProfiles;i++)
1579 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1583 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1584 for(int i=0;i<nbProfiles2;i++)
1585 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1589 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1591 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1592 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1595 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1597 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1598 (*it)->loadBigArray(fid,nasc);
1601 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1603 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1605 (*it)->copyOptionsFrom(*this);
1606 (*it)->writeLL(fid,nasc);
1610 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1615 medfGeoType=typmai3[(int)ikGeoType];
1618 medfGeoType=MED_NONE;
1621 medfGeoType=typmai3[(int)ikGeoType];
1622 return MED_NODE_ELEMENT;
1624 medfGeoType=typmai3[(int)ikGeoType];
1627 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1629 return MED_UNDEF_ENTITY_TYPE;
1632 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)
1634 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1637 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1639 return new MEDFileFieldPerMesh(fath,mesh);
1642 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1644 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1647 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1649 std::vector<const BigMemoryObject *> ret;
1650 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1651 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1655 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1657 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1658 ret->_father=father;
1660 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1662 if((const MEDFileFieldPerMeshPerType *)*it)
1663 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1668 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1670 std::string startLine(bkOffset,' ');
1671 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1672 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1674 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1676 const MEDFileFieldPerMeshPerType *cur=*it;
1678 cur->simpleRepr(bkOffset,oss,i);
1681 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1686 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1688 _mesh_name=mesh->getName();
1689 mesh->getTime(_mesh_iteration,_mesh_order);
1692 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1694 int nbOfTypes=code.size()/3;
1696 for(int i=0;i<nbOfTypes;i++)
1698 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1699 int nbOfCells=code[3*i+1];
1700 int pos=addNewEntryIfNecessary(type);
1701 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1707 * This method is the most general one. No optimization is done here.
1708 * \param [in] multiTypePfl is the end user profile specified in high level API
1709 * \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].
1710 * \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.
1711 * \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.
1712 * \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.
1713 * \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.
1715 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)
1717 int nbOfTypes(code.size()/3);
1718 for(int i=0;i<nbOfTypes;i++)
1720 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1721 int pos=addNewEntryIfNecessary(type);
1722 DataArrayInt *pfl=0;
1724 pfl=idsPerType[code[3*i+2]];
1725 int nbOfTupes2=code2.size()/3;
1727 for(;found<nbOfTupes2;found++)
1728 if(code[3*i]==code2[3*found])
1730 if(found==nbOfTupes2)
1731 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1732 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1736 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1738 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1739 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1742 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1744 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1745 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1748 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1750 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1751 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1754 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1756 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1757 (*it)->loadBigArraysRecursively(fid,nasc);
1760 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1762 int nbOfTypes=_field_pm_pt.size();
1763 for(int i=0;i<nbOfTypes;i++)
1765 _field_pm_pt[i]->copyOptionsFrom(*this);
1766 _field_pm_pt[i]->writeLL(fid,nasc);
1770 void MEDFileFieldPerMesh::getDimension(int& dim) const
1772 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1773 (*it)->getDimension(dim);
1776 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1778 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1779 (*it)->fillTypesOfFieldAvailable(types);
1782 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
1784 int sz=_field_pm_pt.size();
1785 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1786 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1787 for(int i=0;i<sz;i++)
1789 types[i]=_field_pm_pt[i]->getGeoType();
1790 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1795 double MEDFileFieldPerMesh::getTime() const
1798 return _father->getTime(tmp1,tmp2);
1801 int MEDFileFieldPerMesh::getIteration() const
1803 return _father->getIteration();
1806 int MEDFileFieldPerMesh::getOrder() const
1808 return _father->getOrder();
1811 int MEDFileFieldPerMesh::getNumberOfComponents() const
1813 return _father->getNumberOfComponents();
1816 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1818 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1820 const MEDFileFieldPerMeshPerType *fpmt(*it);
1823 if(fpmt->presenceOfMultiDiscPerGeoType())
1829 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1832 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1833 return _father->getOrCreateAndGetArray();
1836 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1839 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1840 return _father->getOrCreateAndGetArray();
1843 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1845 return _father->getInfo();
1849 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1850 * 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.
1851 * It returns 2 output vectors :
1852 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1853 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1854 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1856 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)
1858 int notNullPflsSz=0;
1859 int nbOfArrs=geoTypes.size();
1860 for(int i=0;i<nbOfArrs;i++)
1863 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1864 int nbOfDiffGeoTypes=geoTypes3.size();
1865 code.resize(3*nbOfDiffGeoTypes);
1866 notNullPfls.resize(notNullPflsSz);
1869 for(int i=0;i<nbOfDiffGeoTypes;i++)
1872 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1873 std::vector<const DataArrayInt *> notNullTmp;
1875 notNullTmp.push_back(pfls[j]);
1877 for(;j<nbOfArrs;j++)
1878 if(geoTypes[j]==refType)
1881 notNullTmp.push_back(pfls[j]);
1885 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1886 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1887 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1888 code[3*i]=(int)refType;
1889 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1890 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1891 if(notNullTmp.empty())
1895 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1896 code[3*i+2]=notNullPflsSz++;
1902 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1904 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)
1908 for(int i=0;i<sz;i++)
1912 if(type!=ON_GAUSS_NE)
1913 ret+=dads[i].second-dads[i].first;
1916 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1917 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1922 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1923 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1929 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1931 std::vector<std::string> ret;
1932 std::set<std::string> ret2;
1933 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1935 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1936 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1937 if(ret2.find(*it2)==ret2.end())
1939 ret.push_back(*it2);
1946 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1948 std::vector<std::string> ret;
1949 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1951 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1952 ret.insert(ret.end(),tmp.begin(),tmp.end());
1957 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1959 std::vector<std::string> ret;
1960 std::set<std::string> ret2;
1961 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1963 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1964 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1965 if(ret2.find(*it2)==ret2.end())
1967 ret.push_back(*it2);
1974 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1976 std::vector<std::string> ret;
1977 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1979 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1980 ret.insert(ret.end(),tmp.begin(),tmp.end());
1985 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1987 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1989 if((*it).first==_mesh_name)
1991 _mesh_name=(*it).second;
1998 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1999 MEDFileFieldGlobsReal& glob)
2001 if(_mesh_name!=meshName)
2003 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2004 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2005 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2006 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2007 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2008 getUndergroundDataArrayExt(entries);
2009 DataArray *arr0=getOrCreateAndGetArray();//tony
2011 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2012 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
2014 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2017 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2018 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2020 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2022 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2023 sz+=(*it).second.second-(*it).second.first;
2026 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2028 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2029 ////////////////////
2030 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2031 int *workI2=explicitIdsOldInMesh->getPointer();
2032 int sz1=0,sz2=0,sid=1;
2033 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2034 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2035 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2037 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2038 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2039 int *workI=explicitIdsOldInArr->getPointer();
2040 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2042 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2043 (*itL2)->setLocId(sz2);
2044 (*itL2)->_tmp_work1=(*itL2)->getStart();
2045 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2047 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2049 explicitIdsOldInMesh->reAlloc(sz2);
2050 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2051 ////////////////////
2052 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2053 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2054 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2055 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2057 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2058 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2059 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2061 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2062 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2063 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2065 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2066 int newStart=elt->getLocId();
2067 elt->setLocId((*it)->getGeoType());
2068 elt->setNewStart(newStart);
2069 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2070 entriesKeptNew.push_back(elt);
2071 entriesKeptNew2.push_back(elt);
2073 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2074 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2075 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2076 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2078 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2081 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2083 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2084 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2086 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2087 glob,arr2,otherEntriesNew) || ret;
2091 // Assign new dispatching
2092 assignNewLeaves(otherEntriesNew);
2093 arr->deepCopyFrom(*arr2);
2098 * \param [in,out] globalNum a global numbering counter for the renumbering.
2099 * \param [out] its - list of pair (start,stop) kept
2101 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2103 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2104 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2106 std::vector< std::pair<int,int> > its2;
2107 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2110 its.insert(its.end(),its2.begin(),its2.end());
2117 * \param [in,out] globalNum a global numbering counter for the renumbering.
2118 * \param [out] its - list of pair (start,stop) kept
2120 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2122 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2123 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2125 std::vector< std::pair<int,int> > its2;
2126 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2129 its.insert(its.end(),its2.begin(),its2.end());
2135 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2137 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2138 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2139 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2141 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2142 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2143 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2144 for(;it1!=types.end();it1++,it2++)
2146 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2147 elt->setLeaves((*it1).second);
2150 _field_pm_pt=fieldPmPt;
2153 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2155 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2156 (*it)->changePflsRefsNamesGen(mapOfModif);
2159 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2161 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2162 (*it)->changeLocsRefsNamesGen(mapOfModif);
2166 * \param [in] mesh is the whole mesh
2168 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2170 if(_field_pm_pt.empty())
2171 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2173 std::vector< std::pair<int,int> > dads;
2174 std::vector<const DataArrayInt *> pfls;
2175 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2176 std::vector<int> locs,code;
2177 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2178 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2179 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2181 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2184 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2185 throw INTERP_KERNEL::Exception(oss.str().c_str());
2188 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2189 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2192 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2194 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2197 MCAuto<DataArrayInt> arr2(arr);
2198 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2204 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2208 if(nb!=mesh->getNumberOfNodes())
2210 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2211 oss << " nodes in mesh !";
2212 throw INTERP_KERNEL::Exception(oss.str().c_str());
2214 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2217 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2221 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2223 if(_field_pm_pt.empty())
2224 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2226 std::vector<std::pair<int,int> > dads;
2227 std::vector<const DataArrayInt *> pfls;
2228 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2229 std::vector<int> locs,code;
2230 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2231 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2232 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2234 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2237 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2238 throw INTERP_KERNEL::Exception(oss.str().c_str());
2240 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2241 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2244 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2245 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2250 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2254 if(nb!=mesh->getNumberOfNodes())
2256 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2257 oss << " nodes in mesh !";
2258 throw INTERP_KERNEL::Exception(oss.str().c_str());
2261 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2267 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2271 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2273 (*it)->getSizes(globalSz,nbOfEntries);
2275 entries.resize(nbOfEntries);
2277 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2279 (*it)->fillValues(nbOfEntries,entries);
2283 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2285 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2287 if((*it)->getGeoType()==typ)
2288 return (*it)->getLeafGivenLocId(locId);
2290 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2291 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2292 oss << "Possiblities are : ";
2293 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2295 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2296 oss << "\"" << cm2.getRepr() << "\", ";
2298 throw INTERP_KERNEL::Exception(oss.str().c_str());
2301 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2303 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2305 if((*it)->getGeoType()==typ)
2306 return (*it)->getLeafGivenLocId(locId);
2308 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2309 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2310 oss << "Possiblities are : ";
2311 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2313 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2314 oss << "\"" << cm2.getRepr() << "\", ";
2316 throw INTERP_KERNEL::Exception(oss.str().c_str());
2319 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2322 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2323 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2324 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2326 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2331 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2336 int ret=std::distance(_field_pm_pt.begin(),it2);
2337 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2342 * 'dads' and 'locs' input parameters have the same number of elements
2343 * \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
2345 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2346 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2347 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2350 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2351 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2352 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2353 const std::vector<std::string>& infos=getInfo();
2354 da->setInfoOnComponents(infos);
2356 if(type==ON_GAUSS_PT)
2359 int nbOfArrs=dads.size();
2360 for(int i=0;i<nbOfArrs;i++)
2362 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2363 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2364 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2365 MCAuto<DataArrayInt> di=DataArrayInt::New();
2366 di->alloc(nbOfElems,1);
2368 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2369 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2378 * 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.
2379 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2380 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2381 * The order of cells in the returned field is those imposed by the profile.
2382 * \param [in] mesh is the global mesh.
2384 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2385 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2386 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2387 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2389 if(da->isIota(mesh->getNumberOfCells()))
2390 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2391 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2392 m2->setName(mesh->getName().c_str());
2393 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2399 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2401 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2402 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2403 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2405 if(da->isIota(mesh->getNumberOfNodes()))
2406 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2407 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2408 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2411 if(meshu->getNodalConnectivity()==0)
2413 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2414 int nb=da->getNbOfElems();
2415 const int *ptr=da->getConstPointer();
2416 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2417 meshuc->allocateCells(nb);
2418 for(int i=0;i<nb;i++)
2419 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2420 meshuc->finishInsertingCells();
2421 ret->setMesh(meshuc);
2422 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2423 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2424 disc->checkCoherencyBetween(meshuc,arrOut);
2429 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2431 DataArrayInt *arr2=0;
2432 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2433 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2434 MCAuto<DataArrayInt> arr3(arr2);
2435 int nnodes=mesh2->getNumberOfNodes();
2436 if(nnodes==(int)da->getNbOfElems())
2438 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2439 arrOut->renumberInPlace(da3->getConstPointer());
2440 mesh2->setName(mesh->getName().c_str());
2441 ret->setMesh(mesh2);
2446 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 !!!";
2447 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2448 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2449 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2450 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2451 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2452 throw INTERP_KERNEL::Exception(oss.str().c_str());
2458 * This method is the most light method of field retrieving.
2460 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2464 pflOut=DataArrayInt::New();
2465 pflOut->alloc(nbOfElems,1);
2470 pflOut=const_cast<DataArrayInt*>(pflIn);
2473 MCAuto<DataArrayInt> safePfl(pflOut);
2474 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2475 const std::vector<std::string>& infos=getInfo();
2476 int nbOfComp=infos.size();
2477 for(int i=0;i<nbOfComp;i++)
2478 da->setInfoOnComponent(i,infos[i].c_str());
2489 static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2490 static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2491 virtual ~MFFPMIter() { }
2492 virtual void begin() = 0;
2493 virtual bool finished() const = 0;
2494 virtual void next() = 0;
2495 virtual int current() const = 0;
2498 class MFFPMIterSimple : public MFFPMIter
2501 MFFPMIterSimple():_pos(0) { }
2502 void begin() { _pos=0; }
2503 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2504 void next() { _pos++; }
2505 int current() const { return _pos; }
2510 class MFFPMIter2 : public MFFPMIter
2513 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2514 void begin() { _it=_ids.begin(); }
2515 bool finished() const { return _it==_ids.end(); }
2516 void next() { _it++; }
2517 int current() const { return *_it; }
2519 std::vector<int> _ids;
2520 std::vector<int>::const_iterator _it;
2523 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2526 return new MFFPMIterSimple;
2529 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2530 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2532 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2533 tmp.push_back((*it).second);
2535 return new MFFPMIter2(tmp);
2539 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2545 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2546 if((*it).first==ON_NODES)
2552 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2554 std::size_t sz(cts.size());
2556 for(std::size_t i=0;i<sz;i++)
2558 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2559 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2560 _ids[i]=(int)std::distance(typmai2,loc);
2562 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2568 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),
2571 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2572 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2573 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2574 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2575 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2576 for(iter0->begin();!iter0->finished();iter0->next())
2578 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2579 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2580 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2581 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2582 if(nbProfile>0 || nbProfile2>0)
2584 const PartDefinition *pd(0);
2586 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2587 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2594 if(MFFPMIter::IsPresenceOfNode(entities))
2596 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2599 const PartDefinition *pd(0);
2601 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2602 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2603 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2608 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2610 copyTinyInfoFrom(mesh);
2613 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2615 if(id>=(int)_pfls.size())
2617 _pfls[id]=DataArrayInt::New();
2618 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2619 _pfls[id]->setName(pflName);
2620 _pfls[id]->alloc(lgth,1);
2621 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2622 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2625 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2627 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2629 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2630 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2631 if(i>=(int)_pfls.size())
2633 _pfls[i]=DataArrayInt::New();
2634 _pfls[i]->alloc(sz,1);
2635 _pfls[i]->setName(pflCpp.c_str());
2636 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2637 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2640 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2642 int nbOfPfls=_pfls.size();
2643 for(int i=0;i<nbOfPfls;i++)
2645 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2646 cpy->applyLin(1,1,0);
2647 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2648 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2649 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2652 int nbOfLocs=_locs.size();
2653 for(int i=0;i<nbOfLocs;i++)
2654 _locs[i]->writeLL(fid);
2657 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2659 std::vector<std::string> pfls=getPfls();
2660 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2662 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2665 _pfls.push_back(*it);
2669 int id=std::distance(pfls.begin(),it2);
2670 if(!(*it)->isEqual(*_pfls[id]))
2672 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2673 throw INTERP_KERNEL::Exception(oss.str().c_str());
2677 std::vector<std::string> locs=getLocs();
2678 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2680 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2683 _locs.push_back(*it);
2687 int id=std::distance(locs.begin(),it2);
2688 if(!(*it)->isEqual(*_locs[id],eps))
2690 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2691 throw INTERP_KERNEL::Exception(oss.str().c_str());
2697 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2699 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2700 getProfile((*it).c_str());
2703 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2705 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2706 getLocalization((*it).c_str());
2709 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2711 std::vector<std::string> profiles=real.getPflsReallyUsed();
2712 int sz=profiles.size();
2714 for(int i=0;i<sz;i++)
2715 loadProfileInFile(fid,i,profiles[i].c_str());
2717 std::vector<std::string> locs=real.getLocsReallyUsed();
2720 for(int i=0;i<sz;i++)
2721 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2724 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2726 int nProfil=MEDnProfile(fid);
2727 for(int i=0;i<nProfil;i++)
2728 loadProfileInFile(fid,i);
2729 int sz=MEDnLocalization(fid);
2731 for(int i=0;i<sz;i++)
2733 _locs[i]=MEDFileFieldLoc::New(fid,i);
2737 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2739 return new MEDFileFieldGlobs(fname);
2742 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2744 return new MEDFileFieldGlobs;
2747 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2749 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2752 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2754 std::vector<const BigMemoryObject *> ret;
2755 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2756 ret.push_back((const DataArrayInt *)*it);
2757 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2758 ret.push_back((const MEDFileFieldLoc *)*it);
2762 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2764 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2766 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2768 if((const DataArrayInt *)*it)
2769 ret->_pfls[i]=(*it)->deepCopy();
2772 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2774 if((const MEDFileFieldLoc*)*it)
2775 ret->_locs[i]=(*it)->deepCopy();
2781 * \throw if a profile in \a pfls in not in \a this.
2782 * \throw if a localization in \a locs in not in \a this.
2783 * \sa MEDFileFieldGlobs::deepCpyPart
2785 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2787 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2788 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2790 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2792 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2794 MCAuto<DataArrayInt> pfl2(pfl);
2795 ret->_pfls.push_back(pfl2);
2797 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2799 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2801 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2803 MCAuto<MEDFileFieldLoc> loc2(loc);
2804 ret->_locs.push_back(loc2);
2806 ret->setFileName(getFileName());
2811 * \throw if a profile in \a pfls in not in \a this.
2812 * \throw if a localization in \a locs in not in \a this.
2813 * \sa MEDFileFieldGlobs::shallowCpyPart
2815 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2817 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2818 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2820 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2822 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2823 ret->_pfls.push_back(pfl->deepCopy());
2825 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2827 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2829 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2830 ret->_locs.push_back(loc->deepCopy());
2832 ret->setFileName(getFileName());
2836 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2840 MEDFileFieldGlobs::MEDFileFieldGlobs()
2844 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2848 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2850 oss << "Profiles :\n";
2851 std::size_t n=_pfls.size();
2852 for(std::size_t i=0;i<n;i++)
2854 oss << " - #" << i << " ";
2855 const DataArrayInt *pfl=_pfls[i];
2857 oss << "\"" << pfl->getName() << "\"\n";
2862 oss << "Localizations :\n";
2863 for(std::size_t i=0;i<n;i++)
2865 oss << " - #" << i << " ";
2866 const MEDFileFieldLoc *loc=_locs[i];
2868 loc->simpleRepr(oss);
2874 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2876 _file_name=fileName;
2879 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2881 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2883 DataArrayInt *elt(*it);
2886 std::string name(elt->getName());
2887 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2889 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2891 elt->setName((*it2).second.c_str());
2899 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2901 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2903 MEDFileFieldLoc *elt(*it);
2906 std::string name(elt->getName());
2907 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2909 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2911 elt->setName((*it2).second.c_str());
2919 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2921 if(locId<0 || locId>=(int)_locs.size())
2922 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2923 return _locs[locId]->getNbOfGaussPtPerCell();
2926 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2928 return getLocalizationFromId(getLocalizationId(locName));
2931 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2933 if(locId<0 || locId>=(int)_locs.size())
2934 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2935 return *_locs[locId];
2939 namespace MEDCouplingImpl
2944 LocFinder(const std::string& loc):_loc(loc) { }
2945 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2947 const std::string &_loc;
2953 PflFinder(const std::string& pfl):_pfl(pfl) { }
2954 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2956 const std::string& _pfl;
2961 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2963 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
2966 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2967 for(it=_locs.begin();it!=_locs.end();it++)
2968 oss << "\"" << (*it)->getName() << "\", ";
2969 throw INTERP_KERNEL::Exception(oss.str().c_str());
2971 return std::distance(_locs.begin(),it);
2975 * The returned value is never null.
2977 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2979 std::string pflNameCpp(pflName);
2980 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
2983 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2984 for(it=_pfls.begin();it!=_pfls.end();it++)
2985 oss << "\"" << (*it)->getName() << "\", ";
2986 throw INTERP_KERNEL::Exception(oss.str().c_str());
2991 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2993 if(pflId<0 || pflId>=(int)_pfls.size())
2994 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2995 return _pfls[pflId];
2998 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3000 if(locId<0 || locId>=(int)_locs.size())
3001 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3002 return *_locs[locId];
3005 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3007 return getLocalizationFromId(getLocalizationId(locName));
3011 * The returned value is never null.
3013 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3015 std::string pflNameCpp(pflName);
3016 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3019 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3020 for(it=_pfls.begin();it!=_pfls.end();it++)
3021 oss << "\"" << (*it)->getName() << "\", ";
3022 throw INTERP_KERNEL::Exception(oss.str().c_str());
3027 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3029 if(pflId<0 || pflId>=(int)_pfls.size())
3030 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3031 return _pfls[pflId];
3034 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3036 std::vector< MCAuto<DataArrayInt> > newPfls;
3038 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3040 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3041 newPfls.push_back(*it);
3046 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3048 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3050 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3052 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3053 newLocs.push_back(*it);
3058 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3060 int sz=_pfls.size();
3061 std::vector<std::string> ret(sz);
3062 for(int i=0;i<sz;i++)
3063 ret[i]=_pfls[i]->getName();
3067 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3069 int sz=_locs.size();
3070 std::vector<std::string> ret(sz);
3071 for(int i=0;i<sz;i++)
3072 ret[i]=_locs[i]->getName();
3076 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3078 std::vector<std::string> v=getPfls();
3079 std::string s(pflName);
3080 return std::find(v.begin(),v.end(),s)!=v.end();
3083 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3085 std::vector<std::string> v=getLocs();
3086 std::string s(locName);
3087 return std::find(v.begin(),v.end(),s)!=v.end();
3090 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3092 std::map<int,std::vector<int> > m;
3094 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3096 const DataArrayInt *tmp=(*it);
3099 m[tmp->getHashCode()].push_back(i);
3102 std::vector< std::vector<int> > ret;
3103 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3105 if((*it2).second.size()>1)
3107 std::vector<int> ret0;
3108 bool equalityOrNot=false;
3109 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3111 std::vector<int>::const_iterator it4=it3; it4++;
3112 for(;it4!=(*it2).second.end();it4++)
3114 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3117 ret0.push_back(*it3);
3118 ret0.push_back(*it4);
3124 ret.push_back(ret0);
3130 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3132 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3135 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3137 std::string name(pfl->getName());
3139 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3140 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3141 if(name==(*it)->getName())
3143 if(!pfl->isEqual(*(*it)))
3145 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3146 throw INTERP_KERNEL::Exception(oss.str().c_str());
3150 _pfls.push_back(pfl);
3153 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)
3155 std::string name(locName);
3157 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3158 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3159 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3160 if((*it)->isName(locName))
3162 if(!(*it)->isEqual(*obj,1e-12))
3164 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3165 throw INTERP_KERNEL::Exception(oss.str().c_str());
3168 _locs.push_back(obj);
3171 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3173 std::vector<std::string> names=getPfls();
3174 return CreateNewNameNotIn("NewPfl_",names);
3177 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3179 std::vector<std::string> names=getLocs();
3180 return CreateNewNameNotIn("NewLoc_",names);
3183 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3185 for(std::size_t sz=0;sz<100000;sz++)
3187 std::ostringstream tryName;
3188 tryName << prefix << sz;
3189 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3190 return tryName.str();
3192 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3196 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3197 * \param [in] fname - the file name.
3199 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3204 * Creates an empty MEDFileFieldGlobsReal.
3206 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3210 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3215 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3217 std::vector<const BigMemoryObject *> ret;
3218 ret.push_back((const MEDFileFieldGlobs *)_globals);
3223 * Returns a string describing profiles and Gauss points held in \a this.
3224 * \return std::string - the description string.
3226 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3228 const MEDFileFieldGlobs *glob=_globals;
3229 std::ostringstream oss2; oss2 << glob;
3230 std::string stars(oss2.str().length(),'*');
3231 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3233 glob->simpleRepr(oss);
3235 oss << "NO GLOBAL INFORMATION !\n";
3238 void MEDFileFieldGlobsReal::resetContent()
3240 _globals=MEDFileFieldGlobs::New();
3243 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3248 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3249 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3251 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3253 _globals=other._globals;
3257 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3258 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3260 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3262 const MEDFileFieldGlobs *otherg(other._globals);
3265 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3269 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3270 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3272 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3274 const MEDFileFieldGlobs *otherg(other._globals);
3277 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3280 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3282 _globals=other._globals;
3283 if((const MEDFileFieldGlobs *)_globals)
3284 _globals=other._globals->deepCopy();
3288 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3289 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3290 * \param [in] eps - a precision used to compare Gauss points with same name held by
3291 * \a this and \a other MEDFileFieldGlobsReal.
3292 * \throw If \a this and \a other hold profiles with equal names but different ids.
3293 * \throw If \a this and \a other hold different Gauss points with equal names.
3295 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3297 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3298 if(thisGlobals==otherGlobals)
3302 _globals=other._globals;
3305 _globals->appendGlobs(*other._globals,eps);
3308 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3310 checkGlobsPflsPartCoherency();
3311 checkGlobsLocsPartCoherency();
3314 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3316 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3319 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3321 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3324 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3326 contentNotNull()->loadProfileInFile(fid,id,pflName);
3329 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3331 contentNotNull()->loadProfileInFile(fid,id);
3334 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3336 contentNotNull()->loadGlobals(fid,*this);
3339 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3341 contentNotNull()->loadAllGlobals(fid);
3344 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3346 contentNotNull()->writeGlobals(fid,opt);
3350 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3351 * or getPflsReallyUsedMulti().
3352 * \return std::vector<std::string> - a sequence of names of all profiles.
3354 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3356 return contentNotNull()->getPfls();
3360 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3361 * or getLocsReallyUsedMulti().
3362 * \return std::vector<std::string> - a sequence of names of all localizations.
3364 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3366 return contentNotNull()->getLocs();
3370 * Checks if the profile with a given name exists.
3371 * \param [in] pflName - the profile name of interest.
3372 * \return bool - \c true if the profile named \a pflName exists.
3374 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3376 return contentNotNull()->existsPfl(pflName);
3380 * Checks if the localization with a given name exists.
3381 * \param [in] locName - the localization name of interest.
3382 * \return bool - \c true if the localization named \a locName exists.
3384 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3386 return contentNotNull()->existsLoc(locName);
3389 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3391 return contentNotNull()->createNewNameOfPfl();
3394 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3396 return contentNotNull()->createNewNameOfLoc();
3400 * Sets the name of a MED file.
3401 * \param [inout] fileName - the file name.
3403 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3405 contentNotNull()->setFileName(fileName);
3409 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3410 * in the same order.
3411 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3412 * Each item of this sequence is a vector containing ids of equal profiles.
3414 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3416 return contentNotNull()->whichAreEqualProfiles();
3420 * Finds equal localizations.
3421 * \param [in] eps - a precision used to compare real values of the localizations.
3422 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3423 * Each item of this sequence is a vector containing ids of equal localizations.
3425 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3427 return contentNotNull()->whichAreEqualLocs(eps);
3431 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3432 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3433 * this sequence is a pair whose
3434 * - the first item is a vector of profile names to replace by the second item,
3435 * - the second item is a profile name to replace every profile name of the first item.
3437 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3439 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3443 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3444 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3445 * this sequence is a pair whose
3446 * - the first item is a vector of localization names to replace by the second item,
3447 * - the second item is a localization name to replace every localization name of the first item.
3449 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3451 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3455 * Replaces references to some profiles (a reference is a profile name) by references
3456 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3457 * them-selves accordingly. <br>
3458 * This method is a generalization of changePflName().
3459 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3460 * this sequence is a pair whose
3461 * - the first item is a vector of profile names to replace by the second item,
3462 * - the second item is a profile name to replace every profile of the first item.
3463 * \sa changePflsRefsNamesGen()
3464 * \sa changePflName()
3466 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3468 changePflsRefsNamesGen(mapOfModif);
3469 changePflsNamesInStruct(mapOfModif);
3473 * Replaces references to some localizations (a reference is a localization name) by references
3474 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3475 * them-selves accordingly. <br>
3476 * This method is a generalization of changeLocName().
3477 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3478 * this sequence is a pair whose
3479 * - the first item is a vector of localization names to replace by the second item,
3480 * - the second item is a localization name to replace every localization of the first item.
3481 * \sa changeLocsRefsNamesGen()
3482 * \sa changeLocName()
3484 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3486 changeLocsRefsNamesGen(mapOfModif);
3487 changeLocsNamesInStruct(mapOfModif);
3491 * Renames the profile having a given name and updates references to this profile.
3492 * \param [in] oldName - the name of the profile to rename.
3493 * \param [in] newName - a new name of the profile.
3494 * \sa changePflsNames().
3496 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3498 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3499 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3501 changePflsNames(mapOfModif);
3505 * Renames the localization having a given name and updates references to this localization.
3506 * \param [in] oldName - the name of the localization to rename.
3507 * \param [in] newName - a new name of the localization.
3508 * \sa changeLocsNames().
3510 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3512 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3513 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3515 changeLocsNames(mapOfModif);
3519 * Removes duplicated profiles. Returns a map used to update references to removed
3520 * profiles via changePflsRefsNamesGen().
3521 * Equal profiles are found using whichAreEqualProfiles().
3522 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3523 * a sequence describing the performed replacements of profiles. Each element of
3524 * this sequence is a pair whose
3525 * - the first item is a vector of profile names replaced by the second item,
3526 * - the second item is a profile name replacing every profile of the first item.
3528 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3530 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3531 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3533 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3535 std::vector< std::string > tmp((*it).size());
3537 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3538 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3539 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3541 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3542 killProfileIds(tmp2);
3544 changePflsRefsNamesGen(ret);
3549 * Removes duplicated localizations. Returns a map used to update references to removed
3550 * localizations via changeLocsRefsNamesGen().
3551 * Equal localizations are found using whichAreEqualLocs().
3552 * \param [in] eps - a precision used to compare real values of the localizations.
3553 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3554 * a sequence describing the performed replacements of localizations. Each element of
3555 * this sequence is a pair whose
3556 * - the first item is a vector of localization names replaced by the second item,
3557 * - the second item is a localization name replacing every localization of the first item.
3559 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3561 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3562 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3564 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3566 std::vector< std::string > tmp((*it).size());
3568 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3569 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3570 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3572 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3573 killLocalizationIds(tmp2);
3575 changeLocsRefsNamesGen(ret);
3580 * Returns number of Gauss points per cell in a given localization.
3581 * \param [in] locId - an id of the localization of interest.
3582 * \return int - the number of the Gauss points per cell.
3584 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3586 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3590 * Returns an id of a localization by its name.
3591 * \param [in] loc - the localization name of interest.
3592 * \return int - the id of the localization.
3593 * \throw If there is no a localization named \a loc.
3595 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3597 return contentNotNull()->getLocalizationId(loc);
3601 * Returns the name of the MED file.
3602 * \return const std::string& - the MED file name.
3604 std::string MEDFileFieldGlobsReal::getFileName() const
3606 return contentNotNull()->getFileName();
3610 * Returns a localization object by its name.
3611 * \param [in] locName - the name of the localization of interest.
3612 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3613 * \throw If there is no a localization named \a locName.
3615 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3617 return contentNotNull()->getLocalization(locName);
3621 * Returns a localization object by its id.
3622 * \param [in] locId - the id of the localization of interest.
3623 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3624 * \throw If there is no a localization with id \a locId.
3626 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3628 return contentNotNull()->getLocalizationFromId(locId);
3632 * Returns a profile array by its name.
3633 * \param [in] pflName - the name of the profile of interest.
3634 * \return const DataArrayInt * - the profile array having the name \a pflName.
3635 * \throw If there is no a profile named \a pflName.
3637 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3639 return contentNotNull()->getProfile(pflName);
3643 * Returns a profile array by its id.
3644 * \param [in] pflId - the id of the profile of interest.
3645 * \return const DataArrayInt * - the profile array having the id \a pflId.
3646 * \throw If there is no a profile with id \a pflId.
3648 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3650 return contentNotNull()->getProfileFromId(pflId);
3654 * Returns a localization object, apt for modification, by its id.
3655 * \param [in] locId - the id of the localization of interest.
3656 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3657 * having the id \a locId.
3658 * \throw If there is no a localization with id \a locId.
3660 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3662 return contentNotNull()->getLocalizationFromId(locId);
3666 * Returns a localization object, apt for modification, by its name.
3667 * \param [in] locName - the name of the localization of interest.
3668 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3669 * having the name \a locName.
3670 * \throw If there is no a localization named \a locName.
3672 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3674 return contentNotNull()->getLocalization(locName);
3678 * Returns a profile array, apt for modification, by its name.
3679 * \param [in] pflName - the name of the profile of interest.
3680 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3681 * \throw If there is no a profile named \a pflName.
3683 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3685 return contentNotNull()->getProfile(pflName);
3689 * Returns a profile array, apt for modification, by its id.
3690 * \param [in] pflId - the id of the profile of interest.
3691 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3692 * \throw If there is no a profile with id \a pflId.
3694 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3696 return contentNotNull()->getProfileFromId(pflId);
3700 * Removes profiles given by their ids. No data is updated to track this removal.
3701 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3703 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3705 contentNotNull()->killProfileIds(pflIds);
3709 * Removes localizations given by their ids. No data is updated to track this removal.
3710 * \param [in] locIds - a sequence of ids of the localizations to remove.
3712 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3714 contentNotNull()->killLocalizationIds(locIds);
3718 * Stores a profile array.
3719 * \param [in] pfl - the profile array to store.
3720 * \throw If the name of \a pfl is empty.
3721 * \throw If a profile with the same name as that of \a pfl already exists but contains
3724 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3726 contentNotNull()->appendProfile(pfl);
3730 * Adds a new localization of Gauss points.
3731 * \param [in] locName - the name of the new localization.
3732 * \param [in] geoType - a geometrical type of the reference cell.
3733 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3734 * must be \c nbOfNodesPerCell * \c dimOfType.
3735 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3736 * must be _wg_.size() * \c dimOfType.
3737 * \param [in] w - the weights of Gauss points.
3738 * \throw If \a locName is empty.
3739 * \throw If a localization with the name \a locName already exists but is
3740 * different form the new one.
3742 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)
3744 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3747 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3749 MEDFileFieldGlobs *g(_globals);
3751 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3755 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3757 const MEDFileFieldGlobs *g(_globals);
3759 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3763 //= MEDFileFieldNameScope
3765 MEDFileFieldNameScope::MEDFileFieldNameScope()
3769 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3774 * Returns the name of \a this field.
3775 * \return std::string - a string containing the field name.
3777 std::string MEDFileFieldNameScope::getName() const
3783 * Sets name of \a this field
3784 * \param [in] name - the new field name.
3786 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3791 std::string MEDFileFieldNameScope::getDtUnit() const
3796 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3801 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3804 _dt_unit=other._dt_unit;
3807 //= MEDFileAnyTypeField1TSWithoutSDA
3809 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3811 _field_per_mesh.resize(other._field_per_mesh.size());
3813 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3815 if((const MEDFileFieldPerMesh *)*it)
3816 _field_per_mesh[i]=(*it)->deepCopy(this);
3821 * Prints a string describing \a this field into a stream. This string is outputted
3822 * by \c print Python command.
3823 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3824 * \param [in,out] oss - the out stream.
3825 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3826 * info id printed, else, not.
3828 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3830 std::string startOfLine(bkOffset,' ');
3831 oss << startOfLine << "Field ";
3833 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3834 oss << "on one time Step ";
3836 oss << "(" << f1tsId << ") ";
3837 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3838 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3839 const DataArray *arr=getUndergroundDataArray();
3842 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3845 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3846 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3847 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3849 if(arr->isAllocated())
3851 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3854 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3858 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3860 oss << startOfLine << "----------------------" << std::endl;
3861 if(!_field_per_mesh.empty())
3864 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3866 const MEDFileFieldPerMesh *cur=(*it2);
3868 cur->simpleRepr(bkOffset,oss,i);
3870 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3875 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3877 oss << startOfLine << "----------------------" << std::endl;
3880 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3882 const DataArray *arr(getUndergroundDataArray());
3884 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3885 int nbOfCompo=arr->getNumberOfComponents();
3886 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3887 for(int i=0;i<nbOfCompo;i++)
3890 std::vector<int> v(1,i);
3891 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
3892 ret[i]->setArray(arr2);
3897 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)
3901 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3906 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3907 * empty. Returns -1 if this in on nodes.
3908 * \return int - the dimension of \a this.
3910 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3913 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3914 (*it)->getDimension(ret);
3919 * Returns the mesh name.
3920 * \return std::string - a string holding the mesh name.
3921 * \throw If \c _field_per_mesh.empty()
3923 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3925 if(_field_per_mesh.empty())
3926 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3927 return _field_per_mesh[0]->getMeshName();
3930 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3932 std::string oldName(getMeshName());
3933 std::vector< std::pair<std::string,std::string> > v(1);
3934 v[0].first=oldName; v[0].second=newMeshName;
3938 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3941 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3943 MEDFileFieldPerMesh *cur(*it);
3945 ret=cur->changeMeshNames(modifTab) || ret;
3951 * Returns the number of iteration of the state of underlying mesh.
3952 * \return int - the iteration number.
3953 * \throw If \c _field_per_mesh.empty()
3955 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3957 if(_field_per_mesh.empty())
3958 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3959 return _field_per_mesh[0]->getMeshIteration();
3963 * Returns the order number of iteration of the state of underlying mesh.
3964 * \return int - the order number.
3965 * \throw If \c _field_per_mesh.empty()
3967 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3969 if(_field_per_mesh.empty())
3970 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3971 return _field_per_mesh[0]->getMeshOrder();
3975 * Checks if \a this field is tagged by a given iteration number and a given
3976 * iteration order number.
3977 * \param [in] iteration - the iteration number of interest.
3978 * \param [in] order - the iteration order number of interest.
3979 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3980 * \a this->getOrder() == \a order.
3982 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3984 return iteration==_iteration && order==_order;
3988 * Returns number of iteration and order number of iteration when
3989 * \a this field has been calculated.
3990 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3993 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3995 std::pair<int,int> p;
4001 * Returns number of iteration and order number of iteration when
4002 * \a this field has been calculated.
4003 * \param [in,out] p - a pair returning the iteration number and the iteration
4006 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4013 * Returns all types of spatial discretization of \a this field.
4014 * \param [in,out] types - a sequence of types of \a this field.
4016 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4018 std::set<TypeOfField> types2;
4019 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4021 (*it)->fillTypesOfFieldAvailable(types2);
4023 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4024 std::copy(types2.begin(),types2.end(),bi);
4028 * Returns all types of spatial discretization of \a this field.
4029 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4032 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4034 std::vector<TypeOfField> ret;
4035 fillTypesOfFieldAvailable(ret);
4039 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4041 std::vector<std::string> ret;
4042 std::set<std::string> ret2;
4043 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4045 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4046 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4047 if(ret2.find(*it2)==ret2.end())
4049 ret.push_back(*it2);
4056 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4058 std::vector<std::string> ret;
4059 std::set<std::string> ret2;
4060 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4062 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4063 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4064 if(ret2.find(*it2)==ret2.end())
4066 ret.push_back(*it2);
4073 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4075 std::vector<std::string> ret;
4076 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4078 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4079 ret.insert(ret.end(),tmp.begin(),tmp.end());
4084 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4086 std::vector<std::string> ret;
4087 std::set<std::string> ret2;
4088 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4090 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4091 ret.insert(ret.end(),tmp.begin(),tmp.end());
4096 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4098 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4099 (*it)->changePflsRefsNamesGen(mapOfModif);
4102 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4104 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4105 (*it)->changeLocsRefsNamesGen(mapOfModif);
4109 * Returns all attributes of parts of \a this field lying on a given mesh.
4110 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4111 * item of every of returned sequences refers to the _i_-th part of \a this field.
4112 * Thus all sequences returned by this method are of the same length equal to number
4113 * of different types of supporting entities.<br>
4114 * A field part can include sub-parts with several different spatial discretizations,
4115 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4116 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4117 * of a nested sequence corresponds to a type of spatial discretization.<br>
4118 * This method allows for iteration over MEDFile DataStructure without any overhead.
4119 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4120 * for the case with only one underlying mesh. (Actually, the number of meshes is
4121 * not checked if \a mname == \c NULL).
4122 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4123 * a field part is returned.
4124 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4125 * This sequence is of the same length as \a types.
4126 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4127 * discretization. A profile name can be empty.
4128 * Length of this and of nested sequences is the same as that of \a typesF.
4129 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4130 * discretization. A localization name can be empty.
4131 * Length of this and of nested sequences is the same as that of \a typesF.
4132 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4133 * of ids of tuples within the data array, per each type of spatial
4134 * discretization within one mesh entity type.
4135 * Length of this and of nested sequences is the same as that of \a typesF.
4136 * \throw If no field is lying on \a mname.
4138 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
4142 meshId=getMeshIdFromMeshName(mname);
4144 if(_field_per_mesh.empty())
4145 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4146 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4150 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4151 * maximal absolute dimension and values returned via the out parameter \a levs are
4152 * dimensions relative to the maximal absolute dimension. <br>
4153 * This method is designed for MEDFileField1TS instances that have a discretization
4154 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4155 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4156 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4157 * Only these 3 discretizations will be taken into account here. If \a this is
4158 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4159 * This method is useful to make the link between the dimension of the underlying mesh
4160 * and the levels of \a this, because it is possible that the highest dimension of \a this
4161 * field is not equal to the dimension of the underlying mesh.
4163 * Let's consider the following case:
4164 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4165 * TETRA4, HEXA8, TRI3 and SEG2.
4166 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4167 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4169 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4170 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4171 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4172 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4173 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4174 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4176 * to retrieve the highest level of
4177 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4178 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4179 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4180 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4181 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4182 * for the case with only one underlying mesh. (Actually, the number of meshes is
4183 * not checked if \a mname == \c NULL).
4184 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4185 * absolute one. They are in decreasing order. This sequence is cleared before
4187 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4188 * \throw If no field is lying on \a mname.
4190 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4193 int meshId=getMeshIdFromMeshName(mname);
4194 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4195 std::vector< std::vector<TypeOfField> > typesF;
4196 std::vector< std::vector<std::string> > pfls, locs;
4197 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4199 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4200 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4201 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4203 st.erase(INTERP_KERNEL::NORM_ERROR);
4205 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4207 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4208 ret1.insert((int)cm.getDimension());
4210 int ret=*std::max_element(ret1.begin(),ret1.end());
4211 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4212 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4217 * \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.
4218 * \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.
4219 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4220 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4222 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4224 int mid=getMeshIdFromMeshName(mName);
4225 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4229 * \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.
4230 * \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.
4231 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4232 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4234 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4236 int mid=getMeshIdFromMeshName(mName);
4237 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4241 * \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.
4243 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4245 if(_field_per_mesh.empty())
4246 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4249 std::string mName2(mName);
4251 std::vector<std::string> msg;
4252 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4253 if(mName2==(*it)->getMeshName())
4256 msg.push_back((*it)->getMeshName());
4257 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4258 oss << "Possible meshes are : ";
4259 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4260 oss << "\"" << (*it2) << "\" ";
4261 throw INTERP_KERNEL::Exception(oss.str().c_str());
4264 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4267 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4268 std::string tmp(mesh->getName());
4270 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4271 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4273 for(;it!=_field_per_mesh.end();it++,i++)
4275 if((*it)->getMeshName()==tmp)
4278 int sz=_field_per_mesh.size();
4279 _field_per_mesh.resize(sz+1);
4280 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4284 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4285 MEDFileFieldGlobsReal& glob)
4288 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4290 MEDFileFieldPerMesh *fpm(*it);
4292 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4298 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4299 * splitting that leads to single spatial discretization of this.
4301 * \sa splitMultiDiscrPerGeoTypes
4303 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4305 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4306 std::vector< std::vector<TypeOfField> > typesF;
4307 std::vector< std::vector<std::string> > pfls,locs;
4308 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4309 std::set<TypeOfField> allEnt;
4310 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4311 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4312 allEnt.insert(*it2);
4313 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4314 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4315 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4317 std::vector< std::pair<int,int> > its;
4318 ret[i]=shallowCpy();
4319 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4320 ret[i]->updateData(newLgth,its);
4326 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4327 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4329 * \sa splitDiscretizations
4331 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4333 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4334 std::vector< std::vector<TypeOfField> > typesF;
4335 std::vector< std::vector<std::string> > pfls,locs;
4336 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4337 std::set<TypeOfField> allEnt;
4338 std::size_t nbOfMDPGT(0),ii(0);
4339 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4341 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4342 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4343 allEnt.insert(*it2);
4345 if(allEnt.size()!=1)
4346 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4348 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4351 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4352 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4355 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4356 for(std::size_t i=0;i<nbOfMDPGT;i++)
4358 std::vector< std::pair<int,int> > its;
4359 ret[i]=shallowCpy();
4360 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4361 ret[i]->updateData(newLgth,its);
4366 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4368 int globalCounter(0);
4369 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4370 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4371 return globalCounter;
4374 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4376 int globalCounter(0);
4377 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4378 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4379 return globalCounter;
4382 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4384 if(_nb_of_tuples_to_be_allocated>=0)
4386 _nb_of_tuples_to_be_allocated=newLgth;
4387 const DataArray *oldArr(getUndergroundDataArray());
4390 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4391 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4393 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4397 if(_nb_of_tuples_to_be_allocated==-1)
4399 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4401 const DataArray *oldArr(getUndergroundDataArray());
4402 if(!oldArr || !oldArr->isAllocated())
4403 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4404 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4405 newArr->alloc(newLgth,getNumberOfComponents());
4407 newArr->copyStringInfoFrom(*oldArr);
4409 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4411 if((*it).second<(*it).first)
4412 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4413 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4414 pos+=(*it).second-(*it).first;
4419 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4422 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4424 if(_field_per_mesh.empty())
4425 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4426 if(_field_per_mesh.size()>1)
4427 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4428 _field_per_mesh[0]->copyOptionsFrom(opts);
4429 _field_per_mesh[0]->writeLL(fid,nasc);
4433 * 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.
4434 * If false is returned the memory allocation is not required.
4436 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4438 if(_nb_of_tuples_to_be_allocated>=0)
4440 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4441 _nb_of_tuples_to_be_allocated=-2;
4444 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4446 if(_nb_of_tuples_to_be_allocated==-1)
4447 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4448 if(_nb_of_tuples_to_be_allocated<-3)
4449 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4450 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4453 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4455 med_int numdt,numit;
4459 med_int meshnumdt,meshnumit;
4460 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4461 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4462 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4463 if(_iteration!=numdt || _order!=numit)
4464 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4465 _field_per_mesh.resize(nmesh);
4470 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4471 mm=ms->getMeshWithName(meshNameCpp);
4474 for(int i=0;i<nmesh;i++)
4475 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4476 _nb_of_tuples_to_be_allocated=0;
4477 for(int i=0;i<nmesh;i++)
4478 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4481 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4483 allocIfNecessaryTheArrayToReceiveDataFromFile();
4484 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4485 (*it)->loadBigArraysRecursively(fid,nasc);
4488 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4490 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4491 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4492 (*it)->loadBigArraysRecursively(fid,nasc);
4495 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4497 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4498 loadBigArraysRecursively(fid,nasc);
4501 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4503 DataArray *thisArr(getUndergroundDataArray());
4504 if(thisArr && thisArr->isAllocated())
4506 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4507 thisArr->desallocate();
4511 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4513 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4516 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4518 std::vector<const BigMemoryObject *> ret;
4519 if(getUndergroundDataArray())
4520 ret.push_back(getUndergroundDataArray());
4521 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4522 ret.push_back((const MEDFileFieldPerMesh *)*it);
4527 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4528 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4529 * "Sort By Type"), if not, an exception is thrown.
4530 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4531 * \param [in] arr - the array of values.
4532 * \param [in,out] glob - the global data where profiles and localization present in
4533 * \a field, if any, are added.
4534 * \throw If the name of \a field is empty.
4535 * \throw If the data array of \a field is not set.
4536 * \throw If \a this->_arr is already allocated but has different number of components
4538 * \throw If the underlying mesh of \a field has no name.
4539 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4541 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4543 const MEDCouplingMesh *mesh=field->getMesh();
4545 TypeOfField type=field->getTypeOfField();
4546 std::vector<DataArrayInt *> dummy;
4547 int start=copyTinyInfoFrom(field,arr);
4548 int pos=addNewEntryIfNecessary(mesh);
4551 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4552 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4555 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4559 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4560 * of a given mesh are used as the support of the given field (a real support is not used).
4561 * Elements of the given mesh must be sorted suitable for writing to MED file.
4562 * Order of underlying mesh entities of the given field specified by \a profile parameter
4563 * is not prescribed; this method permutes field values to have them sorted by element
4564 * type as required for writing to MED file. A new profile is added only if no equal
4565 * profile is missing.
4566 * \param [in] field - the field to add to \a this. The field double values are ignored.
4567 * \param [in] arrOfVals - the values of the field \a field used.
4568 * \param [in] mesh - the supporting mesh of \a field.
4569 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4570 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4571 * \param [in,out] glob - the global data where profiles and localization present in
4572 * \a field, if any, are added.
4573 * \throw If either \a field or \a mesh or \a profile has an empty name.
4574 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4575 * \throw If the data array of \a field is not set.
4576 * \throw If \a this->_arr is already allocated but has different number of components
4578 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4579 * \sa setFieldNoProfileSBT()
4581 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4584 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4585 if(!arrOfVals || !arrOfVals->isAllocated())
4586 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4587 TypeOfField type=field->getTypeOfField();
4588 std::vector<DataArrayInt *> idsInPflPerType;
4589 std::vector<DataArrayInt *> idsPerType;
4590 std::vector<int> code,code2;
4591 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4594 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4595 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4596 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4597 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4599 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4600 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4601 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4603 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4604 throw INTERP_KERNEL::Exception(oss.str().c_str());
4607 int start=copyTinyInfoFrom(field,arrOfVals);
4608 code2=m->getDistributionOfTypes();
4610 int pos=addNewEntryIfNecessary(m);
4611 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4615 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4616 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4617 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4618 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4619 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4620 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4622 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4623 throw INTERP_KERNEL::Exception(oss.str().c_str());
4625 int start=copyTinyInfoFrom(field,arrOfVals);
4626 int pos=addNewEntryIfNecessary(m);
4627 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4632 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4634 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4636 if(_nb_of_tuples_to_be_allocated>=0)
4637 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 !");
4638 DataArray *arr(getOrCreateAndGetArray());
4639 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4640 _nb_of_tuples_to_be_allocated=-3;
4644 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4645 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4646 * larger by the size of \a field. Returns an id of the first not filled
4647 * tuple of \a this->_arr.
4648 * \param [in] field - the field to copy the info on components and the name from.
4649 * \return int - the id of first not initialized tuple of \a this->_arr.
4650 * \throw If the name of \a field is empty.
4651 * \throw If the data array of \a field is not set.
4652 * \throw If \a this->_arr is already allocated but has different number of components
4655 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4658 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4659 std::string name(field->getName());
4660 setName(name.c_str());
4661 setDtUnit(field->getTimeUnit());
4663 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4665 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4666 if(!arr->isAllocated())
4667 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4668 _dt=field->getTime(_iteration,_order);
4669 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4670 if(!getOrCreateAndGetArray()->isAllocated())
4672 allocNotFromFile(arr->getNumberOfTuples());
4677 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4678 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4679 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4680 _nb_of_tuples_to_be_allocated=-3;
4681 return oldNbOfTuples;
4686 * Returns number of components in \a this field
4687 * \return int - the number of components.
4689 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4691 return getOrCreateAndGetArray()->getNumberOfComponents();
4695 * Change info on components in \a this.
4696 * \throw If size of \a infos is not equal to the number of components already in \a this.
4698 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4700 DataArray *arr=getOrCreateAndGetArray();
4701 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4705 * Returns info on components of \a this field.
4706 * \return const std::vector<std::string>& - a sequence of strings each being an
4707 * information on _i_-th component.
4709 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4711 const DataArray *arr=getOrCreateAndGetArray();
4712 return arr->getInfoOnComponents();
4716 * Returns a mutable info on components of \a this field.
4717 * \return std::vector<std::string>& - a sequence of strings each being an
4718 * information on _i_-th component.
4720 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4722 DataArray *arr=getOrCreateAndGetArray();
4723 return arr->getInfoOnComponents();
4726 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4728 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4730 const MEDFileFieldPerMesh *fpm(*it);
4733 if(fpm->presenceOfMultiDiscPerGeoType())
4740 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4741 * \param [in] type - a spatial discretization of the new field.
4742 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4743 * \param [in] mName - a name of the supporting mesh.
4744 * \param [in] renumPol - specifies how to permute values of the result field according to
4745 * the optional numbers of cells and nodes, if any. The valid values are
4746 * - 0 - do not permute.
4747 * - 1 - permute cells.
4748 * - 2 - permute nodes.
4749 * - 3 - permute cells and nodes.
4751 * \param [in] glob - the global data storing profiles and localization.
4752 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4753 * caller is to delete this field using decrRef() as it is no more needed.
4754 * \throw If the MED file is not readable.
4755 * \throw If there is no mesh named \a mName in the MED file.
4756 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4757 * \throw If no field of \a this is lying on the mesh \a mName.
4758 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4760 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4762 MCAuto<MEDFileMesh> mm;
4764 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4766 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4767 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4771 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4772 * \param [in] type - a spatial discretization of the new field.
4773 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4774 * \param [in] renumPol - specifies how to permute values of the result field according to
4775 * the optional numbers of cells and nodes, if any. The valid values are
4776 * - 0 - do not permute.
4777 * - 1 - permute cells.
4778 * - 2 - permute nodes.
4779 * - 3 - permute cells and nodes.
4781 * \param [in] glob - the global data storing profiles and localization.
4782 * \param [in] mesh - the supporting mesh.
4783 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4784 * caller is to delete this field using decrRef() as it is no more needed.
4785 * \throw If the MED file is not readable.
4786 * \throw If no field of \a this is lying on \a mesh.
4787 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4788 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4790 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4792 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4793 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4794 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4795 if(meshDimRelToMax==1)
4796 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4797 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4801 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4803 * \param [in] type - a spatial discretization of the new field.
4804 * \param [in] mName - a name of the supporting mesh.
4805 * \param [in] renumPol - specifies how to permute values of the result field according to
4806 * the optional numbers of cells and nodes, if any. The valid values are
4807 * - 0 - do not permute.
4808 * - 1 - permute cells.
4809 * - 2 - permute nodes.
4810 * - 3 - permute cells and nodes.
4812 * \param [in] glob - the global data storing profiles and localization.
4813 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4814 * caller is to delete this field using decrRef() as it is no more needed.
4815 * \throw If the MED file is not readable.
4816 * \throw If there is no mesh named \a mName in the MED file.
4817 * \throw If there are no mesh entities in the mesh.
4818 * \throw If no field values of the given \a type are available.
4820 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4822 MCAuto<MEDFileMesh> mm;
4824 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4826 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4827 int absDim=getDimension();
4828 int meshDimRelToMax=absDim-mm->getMeshDimension();
4829 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4833 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4834 * \param [in] type - a spatial discretization of the new field.
4835 * \param [in] renumPol - specifies how to permute values of the result field according to
4836 * the optional numbers of cells and nodes, if any. The valid values are
4837 * - 0 - do not permute.
4838 * - 1 - permute cells.
4839 * - 2 - permute nodes.
4840 * - 3 - permute cells and nodes.
4842 * \param [in] glob - the global data storing profiles and localization.
4843 * \param [in] mesh - the supporting mesh.
4844 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4845 * field according to \a renumPol.
4846 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4847 * field according to \a renumPol.
4848 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4849 * caller is to delete this field using decrRef() as it is no more needed.
4850 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4851 * \throw If no field of \a this is lying on \a mesh.
4852 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4854 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4856 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4857 int meshId=getMeshIdFromMeshName(mesh->getName());
4859 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4864 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4871 throw INTERP_KERNEL::Exception(msg1);
4872 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4875 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4877 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4878 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4879 throw INTERP_KERNEL::Exception(oss.str().c_str());
4881 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4882 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4883 std::vector<DataArray *> arrOut2(1,arrOut);
4884 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4885 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4886 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4893 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4895 throw INTERP_KERNEL::Exception(msg1);
4898 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4900 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4901 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4902 throw INTERP_KERNEL::Exception(oss.str().c_str());
4904 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4905 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4906 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4907 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4912 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4917 * Returns values and a profile of the field of a given type lying on a given support.
4918 * \param [in] type - a spatial discretization of the field.
4919 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4920 * \param [in] mesh - the supporting mesh.
4921 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4922 * field of interest lies on. If the field lies on all entities of the given
4923 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4924 * using decrRef() as it is no more needed.
4925 * \param [in] glob - the global data storing profiles and localization.
4926 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4927 * field. The caller is to delete this array using decrRef() as it is no more needed.
4928 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4929 * \throw If no field of \a this is lying on \a mesh.
4930 * \throw If no field values of the given \a type are available.
4932 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4934 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4935 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4936 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4937 ret->setName(nasc.getName().c_str());
4941 //= MEDFileField1TSWithoutSDA
4944 * Throws if a given value is not a valid (non-extended) relative dimension.
4945 * \param [in] meshDimRelToMax - the relative dimension value.
4946 * \throw If \a meshDimRelToMax > 0.
4948 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4950 if(meshDimRelToMax>0)
4951 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4955 * Checks if elements of a given mesh are in the order suitable for writing
4956 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4957 * vector describing types of elements and their number.
4958 * \param [in] mesh - the mesh to check.
4959 * \return std::vector<int> - a vector holding for each element type (1) item of
4960 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4961 * These values are in full-interlace mode.
4962 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4964 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4967 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4968 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4969 int nbOfTypes=geoTypes.size();
4970 std::vector<int> code(3*nbOfTypes);
4971 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
4972 arr1->alloc(nbOfTypes,1);
4973 int *arrPtr=arr1->getPointer();
4974 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4975 for(int i=0;i<nbOfTypes;i++,it++)
4976 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4977 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4978 const int *arrPtr2=arr2->getConstPointer();
4980 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4983 int nbCells=mesh->getNumberOfCellsWithType(*it);
4984 code[3*pos]=(int)(*it);
4985 code[3*pos+1]=nbCells;
4986 code[3*pos+2]=-1;//no profiles
4988 std::vector<const DataArrayInt *> idsPerType;//no profiles
4989 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4993 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
4998 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5000 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5004 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5005 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5006 * item of every of returned sequences refers to the _i_-th part of \a this field.
5007 * Thus all sequences returned by this method are of the same length equal to number
5008 * of different types of supporting entities.<br>
5009 * A field part can include sub-parts with several different spatial discretizations,
5010 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5011 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5012 * of a nested sequence corresponds to a type of spatial discretization.<br>
5013 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5014 * The overhead is due to selecting values into new instances of DataArrayDouble.
5015 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5016 * for the case with only one underlying mesh. (Actually, the number of meshes is
5017 * not checked if \a mname == \c NULL).
5018 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5019 * a field part is returned.
5020 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5021 * A field part can include sub-parts with several different spatial discretizations,
5022 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5023 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5024 * This sequence is of the same length as \a types.
5025 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5026 * discretization. A profile name can be empty.
5027 * Length of this and of nested sequences is the same as that of \a typesF.
5028 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5029 * discretization. A localization name can be empty.
5030 * Length of this and of nested sequences is the same as that of \a typesF.
5031 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5032 * per each type of spatial discretization within one mesh entity type.
5033 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5034 * Length of this and of nested sequences is the same as that of \a typesF.
5035 * \throw If no field is lying on \a mname.
5037 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
5041 meshId=getMeshIdFromMeshName(mname);
5043 if(_field_per_mesh.empty())
5044 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5045 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5046 int nbOfRet=ret0.size();
5047 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5048 for(int i=0;i<nbOfRet;i++)
5050 const std::vector< std::pair<int,int> >& p=ret0[i];
5051 int nbOfRet1=p.size();
5052 ret[i].resize(nbOfRet1);
5053 for(int j=0;j<nbOfRet1;j++)
5055 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5063 * Returns a pointer to the underground DataArrayDouble instance. So the
5064 * caller should not decrRef() it. This method allows for a direct access to the field
5065 * values. This method is quite unusable if there is more than a nodal field or a cell
5066 * field on single geometric cell type.
5067 * \return DataArrayDouble * - the pointer to the field values array.
5069 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
5071 const DataArrayDouble *ret=_arr;
5073 return const_cast<DataArrayDouble *>(ret);
5078 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5083 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5085 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5086 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5087 ret->deepCpyLeavesFrom(*this);
5088 const DataArrayDouble *arr(_arr);
5091 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5092 ret->setArray(arr2);
5098 * Returns a pointer to the underground DataArrayDouble instance. So the
5099 * caller should not decrRef() it. This method allows for a direct access to the field
5100 * values. This method is quite unusable if there is more than a nodal field or a cell
5101 * field on single geometric cell type.
5102 * \return DataArrayDouble * - the pointer to the field values array.
5104 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5106 return getUndergroundDataArrayDouble();
5110 * Returns a pointer to the underground DataArrayDouble instance and a
5111 * sequence describing parameters of a support of each part of \a this field. The
5112 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5113 * direct access to the field values. This method is intended for the field lying on one
5115 * \param [in,out] entries - the sequence describing parameters of a support of each
5116 * part of \a this field. Each item of this sequence consists of two parts. The
5117 * first part describes a type of mesh entity and an id of discretization of a
5118 * current field part. The second part describes a range of values [begin,end)
5119 * within the returned array relating to the current field part.
5120 * \return DataArrayDouble * - the pointer to the field values array.
5121 * \throw If the number of underlying meshes is not equal to 1.
5122 * \throw If no field values are available.
5123 * \sa getUndergroundDataArray()
5125 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5127 if(_field_per_mesh.size()!=1)
5128 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5129 if(_field_per_mesh[0]==0)
5130 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5131 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5132 return getUndergroundDataArrayDouble();
5136 * Returns a pointer to the underground DataArrayDouble instance and a
5137 * sequence describing parameters of a support of each part of \a this field. The
5138 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5139 * direct access to the field values. This method is intended for the field lying on one
5141 * \param [in,out] entries - the sequence describing parameters of a support of each
5142 * part of \a this field. Each item of this sequence consists of two parts. The
5143 * first part describes a type of mesh entity and an id of discretization of a
5144 * current field part. The second part describes a range of values [begin,end)
5145 * within the returned array relating to the current field part.
5146 * \return DataArrayDouble * - the pointer to the field values array.
5147 * \throw If the number of underlying meshes is not equal to 1.
5148 * \throw If no field values are available.
5149 * \sa getUndergroundDataArray()
5151 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5153 return getUndergroundDataArrayDoubleExt(entries);
5156 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5158 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5159 arr->setInfoAndChangeNbOfCompo(infos);
5162 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5166 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5168 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5169 ret->deepCpyLeavesFrom(*this);
5173 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5175 MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5176 if((const DataArrayDouble *)_arr)
5177 ret->_arr=_arr->deepCopy();
5181 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5185 _nb_of_tuples_to_be_allocated=-1;
5189 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5191 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5193 _nb_of_tuples_to_be_allocated=-3;
5198 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5200 return DataArrayDouble::New();
5203 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5205 DataArrayDouble *ret=_arr;
5208 _arr=DataArrayDouble::New();
5212 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5214 return getOrCreateAndGetArrayDouble();
5217 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5219 const DataArrayDouble *ret=_arr;
5222 DataArrayDouble *ret2=DataArrayDouble::New();
5223 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5227 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5229 return getOrCreateAndGetArrayDouble();
5232 //= MEDFileIntField1TSWithoutSDA
5234 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5236 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5239 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5243 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5244 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5246 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5247 arr->setInfoAndChangeNbOfCompo(infos);
5250 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5255 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5257 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5258 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5259 ret->deepCpyLeavesFrom(*this);
5260 const DataArrayInt *arr(_arr);
5263 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5264 ret->setArray(arr2);
5270 * Returns a pointer to the underground DataArrayInt instance. So the
5271 * caller should not decrRef() it. This method allows for a direct access to the field
5272 * values. This method is quite unusable if there is more than a nodal field or a cell
5273 * field on single geometric cell type.
5274 * \return DataArrayInt * - the pointer to the field values array.
5276 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5278 return getUndergroundDataArrayInt();
5282 * Returns a pointer to the underground DataArrayInt instance. So the
5283 * caller should not decrRef() it. This method allows for a direct access to the field
5284 * values. This method is quite unusable if there is more than a nodal field or a cell
5285 * field on single geometric cell type.
5286 * \return DataArrayInt * - the pointer to the field values array.
5288 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5290 const DataArrayInt *ret=_arr;
5292 return const_cast<DataArrayInt *>(ret);
5298 * Returns a pointer to the underground DataArrayInt instance and a
5299 * sequence describing parameters of a support of each part of \a this field. The
5300 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5301 * direct access to the field values. This method is intended for the field lying on one
5303 * \param [in,out] entries - the sequence describing parameters of a support of each
5304 * part of \a this field. Each item of this sequence consists of two parts. The
5305 * first part describes a type of mesh entity and an id of discretization of a
5306 * current field part. The second part describes a range of values [begin,end)
5307 * within the returned array relating to the current field part.
5308 * \return DataArrayInt * - the pointer to the field values array.
5309 * \throw If the number of underlying meshes is not equal to 1.
5310 * \throw If no field values are available.
5311 * \sa getUndergroundDataArray()
5313 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5315 return getUndergroundDataArrayIntExt(entries);
5319 * Returns a pointer to the underground DataArrayInt instance and a
5320 * sequence describing parameters of a support of each part of \a this field. The
5321 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5322 * direct access to the field values. This method is intended for the field lying on one
5324 * \param [in,out] entries - the sequence describing parameters of a support of each
5325 * part of \a this field. Each item of this sequence consists of two parts. The
5326 * first part describes a type of mesh entity and an id of discretization of a
5327 * current field part. The second part describes a range of values [begin,end)
5328 * within the returned array relating to the current field part.
5329 * \return DataArrayInt * - the pointer to the field values array.
5330 * \throw If the number of underlying meshes is not equal to 1.
5331 * \throw If no field values are available.
5332 * \sa getUndergroundDataArray()
5334 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5336 if(_field_per_mesh.size()!=1)
5337 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5338 if(_field_per_mesh[0]==0)
5339 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5340 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5341 return getUndergroundDataArrayInt();
5344 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5346 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5347 ret->deepCpyLeavesFrom(*this);
5351 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5353 MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5354 if((const DataArrayInt *)_arr)
5355 ret->_arr=_arr->deepCopy();
5359 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5363 _nb_of_tuples_to_be_allocated=-1;
5367 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5369 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5371 _nb_of_tuples_to_be_allocated=-3;
5376 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5378 return DataArrayInt::New();
5381 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5383 DataArrayInt *ret=_arr;
5386 _arr=DataArrayInt::New();
5390 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5392 return getOrCreateAndGetArrayInt();
5395 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5397 const DataArrayInt *ret=_arr;
5400 DataArrayInt *ret2=DataArrayInt::New();
5401 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5405 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5407 return getOrCreateAndGetArrayInt();
5410 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5414 //= MEDFileAnyTypeField1TS
5416 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5418 med_field_type typcha;
5420 std::vector<std::string> infos;
5421 std::string dtunit,fieldName;
5422 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5423 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5428 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5433 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5438 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] !";
5439 throw INTERP_KERNEL::Exception(oss.str().c_str());
5442 ret->setDtUnit(dtunit.c_str());
5443 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5445 med_int numdt,numit;
5447 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5448 ret->setTime(numdt,numit,dt);
5451 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5453 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5457 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5458 try:MEDFileFieldGlobsReal(fileName)
5460 MEDFileUtilities::CheckFileForRead(fileName);
5461 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5462 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5465 catch(INTERP_KERNEL::Exception& e)
5470 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5472 med_field_type typcha;
5473 std::vector<std::string> infos;
5476 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5477 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5482 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5487 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5492 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] !";
5493 throw INTERP_KERNEL::Exception(oss.str().c_str());
5496 ret->setDtUnit(dtunit.c_str());
5497 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5501 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5502 throw INTERP_KERNEL::Exception(oss.str().c_str());
5505 med_int numdt,numit;
5507 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5508 ret->setTime(numdt,numit,dt);
5511 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5513 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5517 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5518 try:MEDFileFieldGlobsReal(fileName)
5520 MEDFileUtilities::CheckFileForRead(fileName);
5521 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5522 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5525 catch(INTERP_KERNEL::Exception& e)
5530 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5533 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5534 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5536 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New();
5537 ret->setFileName(fileName);
5538 ret->_content=c; c->incrRef();
5541 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5543 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5544 ret->setFileName(fileName);
5545 ret->_content=c; c->incrRef();
5548 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5551 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5553 MEDFileUtilities::CheckFileForRead(fileName);
5554 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5555 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5556 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5557 ret->loadGlobals(fid);
5561 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5563 MEDFileUtilities::CheckFileForRead(fileName);
5564 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5565 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5566 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5567 ret->loadGlobals(fid);
5571 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5573 MEDFileUtilities::CheckFileForRead(fileName);
5574 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5575 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5576 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5577 ret->loadGlobals(fid);
5581 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5583 med_field_type typcha;
5584 std::vector<std::string> infos;
5587 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5588 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5593 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5598 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5603 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] !";
5604 throw INTERP_KERNEL::Exception(oss.str().c_str());
5607 ret->setDtUnit(dtunit.c_str());
5608 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5611 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5612 for(int i=0;i<nbOfStep2 && !found;i++)
5614 med_int numdt,numit;
5616 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5617 if(numdt==iteration && numit==order)
5623 dtits[i]=std::pair<int,int>(numdt,numit);
5627 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5628 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5629 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5630 throw INTERP_KERNEL::Exception(oss.str().c_str());
5633 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5635 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5639 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5640 try:MEDFileFieldGlobsReal(fileName)
5642 MEDFileUtilities::CheckFileForRead(fileName);
5643 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5644 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5647 catch(INTERP_KERNEL::Exception& e)
5653 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5654 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5656 * \warning this is a shallow copy constructor
5658 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5660 if(!shallowCopyOfContent)
5662 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5663 otherPtr->incrRef();
5664 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5668 _content=other.shallowCpy();
5672 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)
5676 int nbFields=MEDnField(fid);
5677 if(fieldIdCFormat>=nbFields)
5679 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5680 throw INTERP_KERNEL::Exception(oss.str().c_str());
5683 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5684 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5685 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5686 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5687 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5688 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5691 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5692 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5693 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5694 infos.clear(); infos.resize(ncomp);
5695 for(int j=0;j<ncomp;j++)
5696 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5701 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5704 * \return in case of success the number of time steps available for the field with name \a fieldName.
5706 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)
5708 int nbFields=MEDnField(fid);
5710 std::vector<std::string> fns(nbFields);
5712 for(int i=0;i<nbFields && !found;i++)
5715 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5717 found=(tmp==fieldName);
5723 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5724 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5725 oss << "\"" << *it << "\" ";
5726 throw INTERP_KERNEL::Exception(oss.str().c_str());
5732 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5733 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5734 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5735 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5736 * to keep a valid instance.
5737 * 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.
5738 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5739 * 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.
5741 * \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.
5742 * \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.
5743 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5744 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5745 * \param [in] newLocName is the new localization name.
5746 * \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.
5747 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5749 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5751 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5752 std::string oldPflName=disc->getProfile();
5753 std::vector<std::string> vv=getPflsReallyUsedMulti();
5754 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5755 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5757 disc->setProfile(newPflName);
5758 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5759 pfl->setName(newPflName);
5763 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5764 throw INTERP_KERNEL::Exception(oss.str().c_str());
5769 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5770 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5771 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5772 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5773 * to keep a valid instance.
5774 * 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.
5775 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5776 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5777 * 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.
5779 * \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.
5780 * \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.
5781 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5782 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5783 * \param [in] newLocName is the new localization name.
5784 * \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.
5785 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5787 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5789 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5790 std::string oldLocName=disc->getLocalization();
5791 std::vector<std::string> vv=getLocsReallyUsedMulti();
5792 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5793 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5795 disc->setLocalization(newLocName);
5796 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5797 loc.setName(newLocName);
5801 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5802 throw INTERP_KERNEL::Exception(oss.str().c_str());
5806 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5808 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5810 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5814 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5816 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5818 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5823 * Writes \a this field into a MED file specified by its name.
5824 * \param [in] fileName - the MED file name.
5825 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5826 * - 2 - erase; an existing file is removed.
5827 * - 1 - append; same data should not be present in an existing file.
5828 * - 0 - overwrite; same data present in an existing file is overwritten.
5829 * \throw If the field name is not set.
5830 * \throw If no field data is set.
5831 * \throw If \a mode == 1 and the same data is present in an existing file.
5833 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5835 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5836 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5841 * This method alloc the arrays and load potentially huge arrays contained in this field.
5842 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5843 * This method can be also called to refresh or reinit values from a file.
5845 * \throw If the fileName is not set or points to a non readable MED file.
5846 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5848 void MEDFileAnyTypeField1TS::loadArrays()
5850 if(getFileName().empty())
5851 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5852 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5853 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5857 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5858 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5859 * this method does not throw if \a this does not come from file read.
5861 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5863 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5865 if(!getFileName().empty())
5867 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5868 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5873 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5874 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5875 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5877 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5879 void MEDFileAnyTypeField1TS::unloadArrays()
5881 contentNotNullBase()->unloadArrays();
5885 * 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.
5886 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5887 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5889 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5891 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5893 if(!getFileName().empty())
5894 contentNotNullBase()->unloadArrays();
5897 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5899 int nbComp=getNumberOfComponents();
5900 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5901 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5902 for(int i=0;i<nbComp;i++)
5904 std::string info=getInfo()[i];
5906 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5907 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5908 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5910 if(getName().empty())
5911 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5912 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5913 writeGlobals(fid,*this);
5914 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5917 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5919 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5922 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5924 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5925 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5930 * Returns a string describing \a this field. This string is outputted
5931 * by \c print Python command.
5933 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5935 std::ostringstream oss;
5936 contentNotNullBase()->simpleRepr(0,oss,-1);
5937 simpleReprGlobs(oss);
5942 * This method returns all profiles whose name is non empty used.
5943 * \b WARNING If profile is used several times it will be reported \b only \b once.
5944 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5946 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5948 return contentNotNullBase()->getPflsReallyUsed2();
5952 * This method returns all localizations whose name is non empty used.
5953 * \b WARNING If localization is used several times it will be reported \b only \b once.
5955 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5957 return contentNotNullBase()->getLocsReallyUsed2();
5961 * This method returns all profiles whose name is non empty used.
5962 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5964 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5966 return contentNotNullBase()->getPflsReallyUsedMulti2();
5970 * This method returns all localizations whose name is non empty used.
5971 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5973 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5975 return contentNotNullBase()->getLocsReallyUsedMulti2();
5978 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5980 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5983 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5985 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5988 int MEDFileAnyTypeField1TS::getDimension() const
5990 return contentNotNullBase()->getDimension();
5993 int MEDFileAnyTypeField1TS::getIteration() const
5995 return contentNotNullBase()->getIteration();
5998 int MEDFileAnyTypeField1TS::getOrder() const
6000 return contentNotNullBase()->getOrder();
6003 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6005 return contentNotNullBase()->getTime(iteration,order);
6008 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6010 contentNotNullBase()->setTime(iteration,order,val);
6013 std::string MEDFileAnyTypeField1TS::getName() const
6015 return contentNotNullBase()->getName();
6018 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6020 contentNotNullBase()->setName(name);
6023 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6025 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6028 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6030 return contentNotNullBase()->getDtUnit();
6033 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6035 contentNotNullBase()->setDtUnit(dtUnit);
6038 std::string MEDFileAnyTypeField1TS::getMeshName() const
6040 return contentNotNullBase()->getMeshName();
6043 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6045 contentNotNullBase()->setMeshName(newMeshName);
6048 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6050 return contentNotNullBase()->changeMeshNames(modifTab);
6053 int MEDFileAnyTypeField1TS::getMeshIteration() const
6055 return contentNotNullBase()->getMeshIteration();
6058 int MEDFileAnyTypeField1TS::getMeshOrder() const
6060 return contentNotNullBase()->getMeshOrder();
6063 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6065 return contentNotNullBase()->getNumberOfComponents();
6068 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6070 return contentNotNullBase()->isDealingTS(iteration,order);
6073 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6075 return contentNotNullBase()->getDtIt();
6078 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6080 contentNotNullBase()->fillIteration(p);
6083 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6085 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6088 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6090 contentNotNullBase()->setInfo(infos);
6093 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6095 return contentNotNullBase()->getInfo();
6097 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6099 return contentNotNullBase()->getInfo();
6102 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6104 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6107 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6109 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6112 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6114 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6117 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6119 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6122 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6124 return contentNotNullBase()->getTypesOfFieldAvailable();
6127 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,
6128 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6130 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6134 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6135 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6136 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6138 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6140 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6142 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6143 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6144 std::size_t sz(contentsSplit.size());
6145 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6146 for(std::size_t i=0;i<sz;i++)
6148 ret[i]=shallowCpy();
6149 ret[i]->_content=contentsSplit[i];
6155 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6156 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6158 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6160 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6162 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6163 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6164 std::size_t sz(contentsSplit.size());
6165 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6166 for(std::size_t i=0;i<sz;i++)
6168 ret[i]=shallowCpy();
6169 ret[i]->_content=contentsSplit[i];
6175 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6176 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6178 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6180 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6182 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6183 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6184 std::size_t sz(contentsSplit.size());
6185 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6186 for(std::size_t i=0;i<sz;i++)
6188 ret[i]=shallowCpy();
6189 ret[i]->_content=contentsSplit[i];
6194 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6196 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6197 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6198 ret->_content=_content->deepCopy();
6199 ret->deepCpyGlobs(*this);
6203 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6205 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6211 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6212 * the first field that has been read from a specified MED file.
6213 * \param [in] fileName - the name of the MED file to read.
6214 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6215 * is to delete this field using decrRef() as it is no more needed.
6216 * \throw If reading the file fails.
6218 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6220 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6221 ret->contentNotNull();
6226 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6227 * a given field that has been read from a specified MED file.
6228 * \param [in] fileName - the name of the MED file to read.
6229 * \param [in] fieldName - the name of the field to read.
6230 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6231 * is to delete this field using decrRef() as it is no more needed.
6232 * \throw If reading the file fails.
6233 * \throw If there is no field named \a fieldName in the file.
6235 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6237 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6238 ret->contentNotNull();
6243 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6244 * a given field that has been read from a specified MED file.
6245 * \param [in] fileName - the name of the MED file to read.
6246 * \param [in] fieldName - the name of the field to read.
6247 * \param [in] iteration - the iteration number of a required time step.
6248 * \param [in] order - the iteration order number of required time step.
6249 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6250 * is to delete this field using decrRef() as it is no more needed.
6251 * \throw If reading the file fails.
6252 * \throw If there is no field named \a fieldName in the file.
6253 * \throw If the required time step is missing from the file.
6255 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6257 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6258 ret->contentNotNull();
6263 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6264 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6266 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6267 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6268 * \warning this is a shallow copy constructor
6269 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6270 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6271 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6272 * is to delete this field using decrRef() as it is no more needed.
6274 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6276 MCAuto<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6277 ret->contentNotNull();
6282 * Returns a new empty instance of MEDFileField1TS.
6283 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6284 * is to delete this field using decrRef() as it is no more needed.
6286 MEDFileField1TS *MEDFileField1TS::New()
6288 MCAuto<MEDFileField1TS> ret=new MEDFileField1TS;
6289 ret->contentNotNull();
6294 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6295 * following the given input policy.
6297 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6298 * By default (true) the globals are deeply copied.
6299 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6301 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6303 MCAuto<MEDFileIntField1TS> ret;
6304 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6307 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6309 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6310 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6311 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6314 ret=MEDFileIntField1TS::New();
6316 ret->deepCpyGlobs(*this);
6318 ret->shallowCpyGlobs(*this);
6322 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6324 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6326 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6327 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6329 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 !");
6333 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6335 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6337 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6338 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6340 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 !");
6344 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6347 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6348 if(!((DataArray*)arr))
6349 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6350 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6352 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6353 f->setArray(arrOutC);
6356 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6358 if(!((DataArray*)arr))
6359 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6360 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6362 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6368 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6369 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6371 * \return A new object that the caller is responsible to deallocate.
6373 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6376 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6377 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6378 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6379 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6381 if((*it0)!=ON_NODES)
6383 std::vector<int> levs;
6384 getNonEmptyLevels(mm->getName(),levs);
6385 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6387 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6388 if(it2!=extractDef.end())
6390 MCAuto<DataArrayInt> t((*it2).second);
6391 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6392 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6393 ret->setFieldNoProfileSBT(fOut);
6399 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6400 if(it2==extractDef.end())
6401 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6402 MCAuto<DataArrayInt> t((*it2).second);
6403 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6404 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6405 DataArrayDouble *arr(f->getArray());
6406 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6407 fOut->setArray(newArr);
6408 ret->setFieldNoProfileSBT(fOut);
6414 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6415 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6418 catch(INTERP_KERNEL::Exception& e)
6421 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6422 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6425 catch(INTERP_KERNEL::Exception& e)
6428 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6429 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6432 catch(INTERP_KERNEL::Exception& e)
6436 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6437 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6439 * \warning this is a shallow copy constructor
6441 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6442 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6445 catch(INTERP_KERNEL::Exception& e)
6448 MEDFileField1TS::MEDFileField1TS()
6450 _content=new MEDFileField1TSWithoutSDA;
6454 * Returns a new MEDCouplingFieldDouble of a given type lying on
6455 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6456 * has not been constructed via file reading, an exception is thrown.
6457 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6458 * \param [in] type - a spatial discretization of interest.
6459 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6460 * \param [in] renumPol - specifies how to permute values of the result field according to
6461 * the optional numbers of cells and nodes, if any. The valid values are
6462 * - 0 - do not permute.
6463 * - 1 - permute cells.
6464 * - 2 - permute nodes.
6465 * - 3 - permute cells and nodes.
6467 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6468 * caller is to delete this field using decrRef() as it is no more needed.
6469 * \throw If \a this field has not been constructed via file reading.
6470 * \throw If the MED file is not readable.
6471 * \throw If there is no mesh in the MED file.
6472 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6473 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6474 * \sa getFieldOnMeshAtLevel()
6476 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6478 if(getFileName().empty())
6479 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6480 MCAuto<DataArray> arrOut;
6481 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6482 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6487 * Returns a new MEDCouplingFieldDouble of a given type lying on
6488 * the top level cells of the first mesh in MED file. If \a this field
6489 * has not been constructed via file reading, an exception is thrown.
6490 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6491 * \param [in] type - a spatial discretization of interest.
6492 * \param [in] renumPol - specifies how to permute values of the result field according to
6493 * the optional numbers of cells and nodes, if any. The valid values are
6494 * - 0 - do not permute.
6495 * - 1 - permute cells.
6496 * - 2 - permute nodes.
6497 * - 3 - permute cells and nodes.
6499 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6500 * caller is to delete this field using decrRef() as it is no more needed.
6501 * \throw If \a this field has not been constructed via file reading.
6502 * \throw If the MED file is not readable.
6503 * \throw If there is no mesh in the MED file.
6504 * \throw If no field values of the given \a type.
6505 * \throw If no field values lying on the top level support.
6506 * \sa getFieldAtLevel()
6508 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6510 if(getFileName().empty())
6511 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6512 MCAuto<DataArray> arrOut;
6513 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6514 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6519 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6520 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6521 * \param [in] type - a spatial discretization of the new field.
6522 * \param [in] mesh - the supporting mesh.
6523 * \param [in] renumPol - specifies how to permute values of the result field according to
6524 * the optional numbers of cells and nodes, if any. The valid values are
6525 * - 0 - do not permute.
6526 * - 1 - permute cells.
6527 * - 2 - permute nodes.
6528 * - 3 - permute cells and nodes.
6530 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6531 * caller is to delete this field using decrRef() as it is no more needed.
6532 * \throw If no field of \a this is lying on \a mesh.
6533 * \throw If the mesh is empty.
6534 * \throw If no field values of the given \a type are available.
6535 * \sa getFieldAtLevel()
6536 * \sa getFieldOnMeshAtLevel()
6538 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6540 MCAuto<DataArray> arrOut;
6541 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6542 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6547 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6548 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6549 * \param [in] type - a spatial discretization of interest.
6550 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6551 * \param [in] mesh - the supporting mesh.
6552 * \param [in] renumPol - specifies how to permute values of the result field according to
6553 * the optional numbers of cells and nodes, if any. The valid values are
6554 * - 0 - do not permute.
6555 * - 1 - permute cells.
6556 * - 2 - permute nodes.
6557 * - 3 - permute cells and nodes.
6559 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6560 * caller is to delete this field using decrRef() as it is no more needed.
6561 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6562 * \throw If no field of \a this is lying on \a mesh.
6563 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6564 * \sa getFieldAtLevel()
6565 * \sa getFieldOnMeshAtLevel()
6567 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6569 MCAuto<DataArray> arrOut;
6570 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6571 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6576 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6577 * This method is called "Old" because in MED3 norm a field has only one meshName
6578 * attached, so this method is for readers of MED2 files. If \a this field
6579 * has not been constructed via file reading, an exception is thrown.
6580 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6581 * \param [in] type - a spatial discretization of interest.
6582 * \param [in] mName - a name of the supporting mesh.
6583 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6584 * \param [in] renumPol - specifies how to permute values of the result field according to
6585 * the optional numbers of cells and nodes, if any. The valid values are
6586 * - 0 - do not permute.
6587 * - 1 - permute cells.
6588 * - 2 - permute nodes.
6589 * - 3 - permute cells and nodes.
6591 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6592 * caller is to delete this field using decrRef() as it is no more needed.
6593 * \throw If the MED file is not readable.
6594 * \throw If there is no mesh named \a mName in the MED file.
6595 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6596 * \throw If \a this field has not been constructed via file reading.
6597 * \throw If no field of \a this is lying on the mesh named \a mName.
6598 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6599 * \sa getFieldAtLevel()
6601 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6603 if(getFileName().empty())
6604 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6605 MCAuto<DataArray> arrOut;
6606 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6607 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6612 * Returns values and a profile of the field of a given type lying on a given support.
6613 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6614 * \param [in] type - a spatial discretization of the field.
6615 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6616 * \param [in] mesh - the supporting mesh.
6617 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6618 * field of interest lies on. If the field lies on all entities of the given
6619 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6620 * using decrRef() as it is no more needed.
6621 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6622 * field. The caller is to delete this array using decrRef() as it is no more needed.
6623 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6624 * \throw If no field of \a this is lying on \a mesh.
6625 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6627 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6629 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6630 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6634 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6635 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6636 * "Sort By Type"), if not, an exception is thrown.
6637 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6638 * \param [in] field - the field to add to \a this.
6639 * \throw If the name of \a field is empty.
6640 * \throw If the data array of \a field is not set.
6641 * \throw If the data array is already allocated but has different number of components
6643 * \throw If the underlying mesh of \a field has no name.
6644 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6646 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6649 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6653 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6654 * can be an aggregation of several MEDCouplingFieldDouble instances.
6655 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6656 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6659 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6660 * A new profile is added only if no equal profile is missing.
6661 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6662 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6663 * \param [in] mesh - the supporting mesh of \a field.
6664 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6665 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6666 * \throw If either \a field or \a mesh or \a profile has an empty name.
6667 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6668 * \throw If the data array of \a field is not set.
6669 * \throw If the data array of \a this is already allocated but has different number of
6670 * components than \a field.
6671 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6672 * \sa setFieldNoProfileSBT()
6674 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6677 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6680 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6682 return new MEDFileField1TS(*this);
6685 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6687 return contentNotNull()->getUndergroundDataArrayDouble();
6690 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6692 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6695 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6696 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6698 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6701 //= MEDFileIntField1TS
6703 MEDFileIntField1TS *MEDFileIntField1TS::New()
6705 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6706 ret->contentNotNull();
6710 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6712 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6713 ret->contentNotNull();
6717 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6719 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6720 ret->contentNotNull();
6724 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6726 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6727 ret->contentNotNull();
6731 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6733 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6734 ret->contentNotNull();
6738 MEDFileIntField1TS::MEDFileIntField1TS()
6740 _content=new MEDFileIntField1TSWithoutSDA;
6743 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6744 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6747 catch(INTERP_KERNEL::Exception& e)
6750 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6751 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6754 catch(INTERP_KERNEL::Exception& e)
6757 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6758 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6761 catch(INTERP_KERNEL::Exception& e)
6765 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6766 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6768 * \warning this is a shallow copy constructor
6770 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6774 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6776 return new MEDFileIntField1TS(*this);
6780 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6781 * following the given input policy.
6783 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6784 * By default (true) the globals are deeply copied.
6785 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6787 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6789 MCAuto<MEDFileField1TS> ret;
6790 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6793 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6795 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6796 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6797 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6800 ret=MEDFileField1TS::New();
6802 ret->deepCpyGlobs(*this);
6804 ret->shallowCpyGlobs(*this);
6809 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6810 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6811 * "Sort By Type"), if not, an exception is thrown.
6812 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6813 * \param [in] field - the field to add to \a this. The field double values are ignored.
6814 * \param [in] arrOfVals - the values of the field \a field used.
6815 * \throw If the name of \a field is empty.
6816 * \throw If the data array of \a field is not set.
6817 * \throw If the data array is already allocated but has different number of components
6819 * \throw If the underlying mesh of \a field has no name.
6820 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6822 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6825 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6829 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6830 * can be an aggregation of several MEDCouplingFieldDouble instances.
6831 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6832 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6835 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6836 * A new profile is added only if no equal profile is missing.
6837 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6838 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6839 * \param [in] arrOfVals - the values of the field \a field used.
6840 * \param [in] mesh - the supporting mesh of \a field.
6841 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6842 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6843 * \throw If either \a field or \a mesh or \a profile has an empty name.
6844 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6845 * \throw If the data array of \a field is not set.
6846 * \throw If the data array of \a this is already allocated but has different number of
6847 * components than \a field.
6848 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6849 * \sa setFieldNoProfileSBT()
6851 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6854 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6857 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6859 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6861 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6862 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6864 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 !");
6868 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6870 if(getFileName().empty())
6871 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6872 MCAuto<DataArray> arrOut2;
6873 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6874 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6876 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6878 arrOut->incrRef(); // arrOut2 dies at the end of the func
6882 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6884 if(!((DataArray *)arr))
6885 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6886 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6888 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6894 * Returns a new MEDCouplingFieldDouble of a given type lying on
6895 * the top level cells of the first mesh in MED file. If \a this field
6896 * has not been constructed via file reading, an exception is thrown.
6897 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6898 * \param [in] type - a spatial discretization of interest.
6899 * \param [out] arrOut - the DataArrayInt containing values of field.
6900 * \param [in] renumPol - specifies how to permute values of the result field according to
6901 * the optional numbers of cells and nodes, if any. The valid values are
6902 * - 0 - do not permute.
6903 * - 1 - permute cells.
6904 * - 2 - permute nodes.
6905 * - 3 - permute cells and nodes.
6907 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6908 * caller is to delete this field using decrRef() as it is no more needed.
6909 * \throw If \a this field has not been constructed via file reading.
6910 * \throw If the MED file is not readable.
6911 * \throw If there is no mesh in the MED file.
6912 * \throw If no field values of the given \a type.
6913 * \throw If no field values lying on the top level support.
6914 * \sa getFieldAtLevel()
6916 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6918 if(getFileName().empty())
6919 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6920 MCAuto<DataArray> arr;
6921 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6922 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6927 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6928 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6929 * \param [in] type - a spatial discretization of the new field.
6930 * \param [in] mesh - the supporting mesh.
6931 * \param [out] arrOut - the DataArrayInt containing values of field.
6932 * \param [in] renumPol - specifies how to permute values of the result field according to
6933 * the optional numbers of cells and nodes, if any. The valid values are
6934 * - 0 - do not permute.
6935 * - 1 - permute cells.
6936 * - 2 - permute nodes.
6937 * - 3 - permute cells and nodes.
6939 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6940 * caller is to delete this field using decrRef() as it is no more needed.
6941 * \throw If no field of \a this is lying on \a mesh.
6942 * \throw If the mesh is empty.
6943 * \throw If no field values of the given \a type are available.
6944 * \sa getFieldAtLevel()
6945 * \sa getFieldOnMeshAtLevel()
6947 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6949 MCAuto<DataArray> arr;
6950 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6951 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6956 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6957 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6958 * \param [in] type - a spatial discretization of interest.
6959 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6960 * \param [out] arrOut - the DataArrayInt containing values of field.
6961 * \param [in] mesh - the supporting mesh.
6962 * \param [in] renumPol - specifies how to permute values of the result field according to
6963 * the optional numbers of cells and nodes, if any. The valid values are
6964 * - 0 - do not permute.
6965 * - 1 - permute cells.
6966 * - 2 - permute nodes.
6967 * - 3 - permute cells and nodes.
6969 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6970 * caller is to delete this field using decrRef() as it is no more needed.
6971 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6972 * \throw If no field of \a this is lying on \a mesh.
6973 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6974 * \sa getFieldAtLevel()
6975 * \sa getFieldOnMeshAtLevel()
6977 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6979 MCAuto<DataArray> arr;
6980 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6981 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6986 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6987 * This method is called "Old" because in MED3 norm a field has only one meshName
6988 * attached, so this method is for readers of MED2 files. If \a this field
6989 * has not been constructed via file reading, an exception is thrown.
6990 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6991 * \param [in] type - a spatial discretization of interest.
6992 * \param [in] mName - a name of the supporting mesh.
6993 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6994 * \param [out] arrOut - the DataArrayInt containing values of field.
6995 * \param [in] renumPol - specifies how to permute values of the result field according to
6996 * the optional numbers of cells and nodes, if any. The valid values are
6997 * - 0 - do not permute.
6998 * - 1 - permute cells.
6999 * - 2 - permute nodes.
7000 * - 3 - permute cells and nodes.
7002 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7003 * caller is to delete this field using decrRef() as it is no more needed.
7004 * \throw If the MED file is not readable.
7005 * \throw If there is no mesh named \a mName in the MED file.
7006 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7007 * \throw If \a this field has not been constructed via file reading.
7008 * \throw If no field of \a this is lying on the mesh named \a mName.
7009 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7010 * \sa getFieldAtLevel()
7012 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
7014 if(getFileName().empty())
7015 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7016 MCAuto<DataArray> arr;
7017 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
7018 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7023 * Returns values and a profile of the field of a given type lying on a given support.
7024 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7025 * \param [in] type - a spatial discretization of the field.
7026 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7027 * \param [in] mesh - the supporting mesh.
7028 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7029 * field of interest lies on. If the field lies on all entities of the given
7030 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7031 * using decrRef() as it is no more needed.
7032 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7033 * field. The caller is to delete this array using decrRef() as it is no more needed.
7034 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7035 * \throw If no field of \a this is lying on \a mesh.
7036 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7038 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7040 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7041 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7044 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7046 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7048 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7049 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7051 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 !");
7055 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7057 return contentNotNull()->getUndergroundDataArrayInt();
7060 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7062 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7066 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7071 * \param [in] fieldId field id in C mode
7073 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7075 med_field_type typcha;
7076 std::string dtunitOut;
7077 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
7078 setDtUnit(dtunitOut.c_str());
7079 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7082 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)
7083 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7085 setDtUnit(dtunit.c_str());
7086 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7088 catch(INTERP_KERNEL::Exception& e)
7093 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7095 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7096 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7097 ret+=(*it).capacity();
7101 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7103 std::vector<const BigMemoryObject *> ret;
7104 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7105 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7110 * 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
7113 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7115 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7116 ret->setInfo(_infos);
7117 int sz=(int)_time_steps.size();
7118 for(const int *id=startIds;id!=endIds;id++)
7120 if(*id>=0 && *id<sz)
7122 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7123 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7127 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7129 ret->pushBackTimeStep(tse2);
7133 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7134 oss << " ! Should be in [0," << sz << ") !";
7135 throw INTERP_KERNEL::Exception(oss.str().c_str());
7138 if(ret->getNumberOfTS()>0)
7139 ret->synchronizeNameScope();
7140 ret->copyNameScope(*this);
7145 * 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
7148 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7150 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7151 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7152 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7153 ret->setInfo(_infos);
7154 int sz=(int)_time_steps.size();
7156 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7160 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7161 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7165 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7167 ret->pushBackTimeStep(tse2);
7171 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7172 oss << " ! Should be in [0," << sz << ") !";
7173 throw INTERP_KERNEL::Exception(oss.str().c_str());
7176 if(ret->getNumberOfTS()>0)
7177 ret->synchronizeNameScope();
7178 ret->copyNameScope(*this);
7182 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7185 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7186 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7188 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7191 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7192 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7193 ids->pushBackSilent(id);
7195 return buildFromTimeStepIds(ids->begin(),ids->end());
7198 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7201 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7202 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7204 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7207 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7208 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7209 ids->pushBackSilent(id);
7211 return buildFromTimeStepIds(ids->begin(),ids->end());
7214 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7216 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7218 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7221 if(cur->presenceOfMultiDiscPerGeoType())
7227 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7232 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7237 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7240 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7242 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7243 if(pt->isDealingTS(iteration,order))
7246 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7247 std::vector< std::pair<int,int> > vp=getIterations();
7248 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7249 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7250 throw INTERP_KERNEL::Exception(oss.str().c_str());
7253 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7255 return *_time_steps[getTimeStepPos(iteration,order)];
7258 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7260 return *_time_steps[getTimeStepPos(iteration,order)];
7263 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7265 if(_time_steps.empty())
7266 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7267 return _time_steps[0]->getMeshName();
7270 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7272 std::string oldName(getMeshName());
7273 std::vector< std::pair<std::string,std::string> > v(1);
7274 v[0].first=oldName; v[0].second=newMeshName;
7278 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7281 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7283 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7285 ret=cur->changeMeshNames(modifTab) || ret;
7291 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7293 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7295 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7299 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7301 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7303 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7306 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7307 MEDFileFieldGlobsReal& glob)
7310 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7312 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7314 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7319 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7321 std::string startLine(bkOffset,' ');
7322 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7324 oss << " (" << fmtsId << ")";
7325 oss << " has the following name: \"" << _name << "\"." << std::endl;
7326 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7327 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7329 oss << startLine << " - \"" << *it << "\"" << std::endl;
7332 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7334 std::string chapter(17,'0'+i);
7335 oss << startLine << chapter << std::endl;
7336 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7338 cur->simpleRepr(bkOffset+2,oss,i);
7340 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7341 oss << startLine << chapter << std::endl;
7345 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7347 std::size_t sz=_time_steps.size();
7348 std::vector< std::pair<int,int> > ret(sz);
7350 for(std::size_t i=0;i<sz;i++)
7352 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7355 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7359 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7360 throw INTERP_KERNEL::Exception(oss.str().c_str());
7366 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7368 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7370 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7371 checkCoherencyOfType(tse2);
7372 if(_time_steps.empty())
7374 setName(tse2->getName().c_str());
7375 setInfo(tse2->getInfo());
7377 checkThatComponentsMatch(tse2->getInfo());
7378 _time_steps.push_back(tse);
7381 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7383 std::size_t nbOfCompo=_infos.size();
7384 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7386 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7389 if((cur->getInfo()).size()!=nbOfCompo)
7391 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7392 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7393 throw INTERP_KERNEL::Exception(oss.str().c_str());
7395 cur->copyNameScope(*this);
7400 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)
7402 _time_steps.resize(nbPdt);
7403 for(int i=0;i<nbPdt;i++)
7405 std::vector< std::pair<int,int> > ts;
7406 med_int numdt=0,numo=0;
7407 med_int meshIt=0,meshOrder=0;
7409 MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7414 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7419 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7423 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7426 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7428 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7432 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7434 if(_time_steps.empty())
7435 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7436 checkThatNbOfCompoOfTSMatchThis();
7437 std::vector<std::string> infos(getInfo());
7438 int nbComp=infos.size();
7439 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7440 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7441 for(int i=0;i<nbComp;i++)
7443 std::string info=infos[i];
7445 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7446 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7447 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7450 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7451 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7452 int nbOfTS=_time_steps.size();
7453 for(int i=0;i<nbOfTS;i++)
7454 _time_steps[i]->writeLL(fid,opts,*this);
7457 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7459 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7461 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7463 elt->loadBigArraysRecursively(fid,nasc);
7467 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7469 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7471 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7473 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7477 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7479 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7481 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7483 elt->unloadArrays();
7487 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7489 return _time_steps.size();
7492 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7494 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7495 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7497 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7499 newTS.push_back(*it);
7504 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7506 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7507 int maxId=(int)_time_steps.size();
7509 std::set<int> idsToDel;
7510 for(const int *id=startIds;id!=endIds;id++,ii++)
7512 if(*id>=0 && *id<maxId)
7514 idsToDel.insert(*id);
7518 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7519 throw INTERP_KERNEL::Exception(oss.str().c_str());
7522 for(int iii=0;iii<maxId;iii++)
7523 if(idsToDel.find(iii)==idsToDel.end())
7524 newTS.push_back(_time_steps[iii]);
7528 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7530 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7531 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7532 if(nbOfEntriesToKill==0)
7534 std::size_t sz=_time_steps.size();
7535 std::vector<bool> b(sz,true);
7537 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7539 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7540 for(std::size_t i=0;i<sz;i++)
7542 newTS.push_back(_time_steps[i]);
7546 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7549 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7550 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7552 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7556 tmp->getTime(it2,ord);
7557 if(it2==iteration && order==ord)
7560 oss << "(" << it2 << "," << ord << "), ";
7563 throw INTERP_KERNEL::Exception(oss.str().c_str());
7566 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7569 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7571 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7573 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7577 double ti=tmp->getTime(it2,ord);
7578 if(fabs(time-ti)<eps)
7584 throw INTERP_KERNEL::Exception(oss.str().c_str());
7587 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7589 int lgth=_time_steps.size();
7590 std::vector< std::pair<int,int> > ret(lgth);
7591 for(int i=0;i<lgth;i++)
7592 _time_steps[i]->fillIteration(ret[i]);
7597 * 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'
7598 * This method returns two things.
7599 * - The absolute dimension of 'this' in first parameter.
7600 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7601 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7603 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7604 * Only these 3 discretizations will be taken into account here.
7606 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7607 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7608 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7610 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7611 * 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'.
7613 * Let's consider the typical following case :
7614 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7615 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7616 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7618 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7620 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7622 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7623 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7624 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7625 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7627 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7629 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7632 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7634 if(pos<0 || pos>=(int)_time_steps.size())
7636 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7637 throw INTERP_KERNEL::Exception(oss.str().c_str());
7639 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7642 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7643 oss << "\nTry to use following method eraseEmptyTS !";
7644 throw INTERP_KERNEL::Exception(oss.str().c_str());
7649 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7651 if(pos<0 || pos>=(int)_time_steps.size())
7653 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7654 throw INTERP_KERNEL::Exception(oss.str().c_str());
7656 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7659 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7660 oss << "\nTry to use following method eraseEmptyTS !";
7661 throw INTERP_KERNEL::Exception(oss.str().c_str());
7666 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7668 std::vector<std::string> ret;
7669 std::set<std::string> ret2;
7670 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7672 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7673 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7674 if(ret2.find(*it2)==ret2.end())
7676 ret.push_back(*it2);
7683 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7685 std::vector<std::string> ret;
7686 std::set<std::string> ret2;
7687 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7689 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7690 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7691 if(ret2.find(*it2)==ret2.end())
7693 ret.push_back(*it2);
7700 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7702 std::vector<std::string> ret;
7703 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7705 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7706 ret.insert(ret.end(),tmp.begin(),tmp.end());
7711 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7713 std::vector<std::string> ret;
7714 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7716 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7717 ret.insert(ret.end(),tmp.begin(),tmp.end());
7722 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7724 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7725 (*it)->changePflsRefsNamesGen2(mapOfModif);
7728 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7730 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7731 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7734 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7736 int lgth=_time_steps.size();
7737 std::vector< std::vector<TypeOfField> > ret(lgth);
7738 for(int i=0;i<lgth;i++)
7739 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7744 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7746 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
7748 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7751 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7753 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7755 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7757 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7758 ret->_time_steps[i]=(*it)->deepCopy();
7763 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7765 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7766 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7767 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7768 for(std::size_t i=0;i<sz;i++)
7770 ret[i]=shallowCpy();
7771 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7773 for(std::size_t i=0;i<sz2;i++)
7775 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7778 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7779 throw INTERP_KERNEL::Exception(oss.str().c_str());
7783 for(std::size_t i=0;i<sz;i++)
7784 for(std::size_t j=0;j<sz2;j++)
7785 ret[i]->_time_steps[j]=ts[j][i];
7790 * This method splits into discretization each time steps in \a this.
7791 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7793 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7795 std::size_t sz(_time_steps.size());
7796 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7797 for(std::size_t i=0;i<sz;i++)
7799 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7802 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7803 throw INTERP_KERNEL::Exception(oss.str().c_str());
7805 items[i]=timeStep->splitDiscretizations();
7808 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7809 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7810 std::vector< TypeOfField > types;
7811 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7812 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7814 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7816 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7817 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7818 if(it2==types.end())
7819 types.push_back(ts[0]);
7821 ret.resize(types.size()); ret2.resize(types.size());
7822 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7823 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7825 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7826 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7827 ret2[pos].push_back(*it1);
7829 for(std::size_t i=0;i<types.size();i++)
7831 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7832 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7833 elt->pushBackTimeStep(*it1);//also updates infos in elt
7835 elt->MEDFileFieldNameScope::operator=(*this);
7841 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7843 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7845 std::size_t sz(_time_steps.size());
7846 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7847 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7848 for(std::size_t i=0;i<sz;i++)
7850 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7853 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7854 throw INTERP_KERNEL::Exception(oss.str().c_str());
7856 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7857 if(szOut==std::numeric_limits<std::size_t>::max())
7858 szOut=items[i].size();
7860 if(items[i].size()!=szOut)
7861 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7863 if(szOut==std::numeric_limits<std::size_t>::max())
7864 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7865 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7866 for(std::size_t i=0;i<szOut;i++)
7868 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7869 for(std::size_t j=0;j<sz;j++)
7870 elt->pushBackTimeStep(items[j][i]);
7872 elt->MEDFileFieldNameScope::operator=(*this);
7877 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7879 _name=field->getName();
7881 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7883 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7884 _infos=arr->getInfoOnComponents();
7887 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7889 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7890 if(_name!=field->getName())
7892 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7893 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7894 throw INTERP_KERNEL::Exception(oss.str().c_str());
7897 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7898 checkThatComponentsMatch(arr->getInfoOnComponents());
7901 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7903 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7904 if(getInfo().size()!=compos.size())
7906 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7907 oss << " number of components of element to append (" << compos.size() << ") !";
7908 throw INTERP_KERNEL::Exception(oss.str().c_str());
7912 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7913 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7914 oss << " But compo in input fields are : ";
7915 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7917 throw INTERP_KERNEL::Exception(oss.str().c_str());
7921 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7923 std::size_t sz=_infos.size();
7925 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7927 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7929 if(elt->getInfo().size()!=sz)
7931 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7932 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7933 throw INTERP_KERNEL::Exception(oss.str().c_str());
7938 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7941 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7942 if(!_time_steps.empty())
7943 checkCoherencyOfTinyInfo(field,arr);
7944 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7945 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7946 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7947 copyTinyInfoFrom(field,arr);
7948 _time_steps.push_back(obj);
7951 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7954 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7955 if(!_time_steps.empty())
7956 checkCoherencyOfTinyInfo(field,arr);
7957 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7958 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7959 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7960 copyTinyInfoFrom(field,arr);
7961 _time_steps.push_back(obj);
7964 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
7966 int sz=(int)_time_steps.size();
7969 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7970 throw INTERP_KERNEL::Exception(oss.str().c_str());
7972 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7975 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7977 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7978 throw INTERP_KERNEL::Exception(oss.str().c_str());
7984 //= MEDFileFieldMultiTSWithoutSDA
7986 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)
7988 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
7991 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7995 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8000 * \param [in] fieldId field id in C mode
8002 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8003 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8006 catch(INTERP_KERNEL::Exception& e)
8009 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)
8010 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8013 catch(INTERP_KERNEL::Exception& e)
8016 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8018 return new MEDFileField1TSWithoutSDA;
8021 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8024 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8025 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8027 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8030 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8032 return MEDFileField1TSWithoutSDA::TYPE_STR;
8035 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8037 return new MEDFileFieldMultiTSWithoutSDA(*this);
8040 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8042 return new MEDFileFieldMultiTSWithoutSDA;
8046 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8047 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8049 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
8051 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8052 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8054 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8055 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8058 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8060 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8061 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8063 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8065 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8068 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8070 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8071 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8072 ret->setIteration(i,elt);
8078 //= MEDFileAnyTypeFieldMultiTS
8080 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8084 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8085 try:MEDFileFieldGlobsReal(fileName)
8087 MEDFileUtilities::CheckFileForRead(fileName);
8088 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8089 _content=BuildContentFrom(fid,fileName,loadAll,ms);
8092 catch(INTERP_KERNEL::Exception& e)
8097 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)
8099 med_field_type typcha;
8100 std::vector<std::string> infos;
8103 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
8104 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8109 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8114 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8119 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] !";
8120 throw INTERP_KERNEL::Exception(oss.str().c_str());
8123 ret->setDtUnit(dtunit.c_str());
8127 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8129 med_field_type typcha;
8131 std::vector<std::string> infos;
8132 std::string dtunit,fieldName;
8133 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8134 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8139 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8144 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8149 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] !";
8150 throw INTERP_KERNEL::Exception(oss.str().c_str());
8153 ret->setDtUnit(dtunit.c_str());
8157 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8160 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8161 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8163 MCAuto<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8164 ret->setFileName(fileName);
8165 ret->_content=c; c->incrRef();
8168 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8170 MCAuto<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8171 ret->setFileName(fileName);
8172 ret->_content=c; c->incrRef();
8175 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8178 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)
8179 try:MEDFileFieldGlobsReal(fileName)
8181 MEDFileUtilities::CheckFileForRead(fileName);
8182 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8183 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
8186 catch(INTERP_KERNEL::Exception& e)
8191 //= MEDFileIntFieldMultiTSWithoutSDA
8193 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)
8195 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8198 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8202 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8206 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)
8207 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8210 catch(INTERP_KERNEL::Exception& e)
8214 * \param [in] fieldId field id in C mode
8216 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8217 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8220 catch(INTERP_KERNEL::Exception& e)
8223 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8225 return new MEDFileIntField1TSWithoutSDA;
8228 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8231 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8232 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8234 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8237 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8239 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8242 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8244 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8247 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8249 return new MEDFileIntFieldMultiTSWithoutSDA;
8252 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8254 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8255 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8257 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8259 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8262 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8264 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8265 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8266 ret->setIteration(i,elt);
8272 //= MEDFileAnyTypeFieldMultiTS
8275 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8276 * that has been read from a specified MED file.
8277 * \param [in] fileName - the name of the MED file to read.
8278 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8279 * is to delete this field using decrRef() as it is no more needed.
8280 * \throw If reading the file fails.
8282 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8284 MEDFileUtilities::CheckFileForRead(fileName);
8285 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8286 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8287 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8288 ret->loadGlobals(fid);
8293 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8294 * that has been read from a specified MED file.
8295 * \param [in] fileName - the name of the MED file to read.
8296 * \param [in] fieldName - the name of the field to read.
8297 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8298 * is to delete this field using decrRef() as it is no more needed.
8299 * \throw If reading the file fails.
8300 * \throw If there is no field named \a fieldName in the file.
8302 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8304 MEDFileUtilities::CheckFileForRead(fileName);
8305 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8306 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
8307 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8308 ret->loadGlobals(fid);
8313 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8314 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8316 * \warning this is a shallow copy constructor
8318 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8320 if(!shallowCopyOfContent)
8322 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8323 otherPtr->incrRef();
8324 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8328 _content=other.shallowCpy();
8332 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8334 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8336 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8340 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8342 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8344 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8348 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8350 return contentNotNullBase()->getPflsReallyUsed2();
8353 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8355 return contentNotNullBase()->getLocsReallyUsed2();
8358 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8360 return contentNotNullBase()->getPflsReallyUsedMulti2();
8363 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8365 return contentNotNullBase()->getLocsReallyUsedMulti2();
8368 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8370 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8373 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8375 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8378 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8380 return contentNotNullBase()->getNumberOfTS();
8383 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8385 contentNotNullBase()->eraseEmptyTS();
8388 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8390 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8393 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8395 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8398 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8400 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8401 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8406 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8408 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8409 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8414 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8416 return contentNotNullBase()->getIterations();
8419 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8421 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8422 pushBackTimeStep(*it);
8425 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8428 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8429 int nbOfTS(fmts->getNumberOfTS());
8430 for(int i=0;i<nbOfTS;i++)
8432 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8433 pushBackTimeStep(elt);
8437 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8440 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8441 checkCoherencyOfType(f1ts);
8443 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8444 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8446 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8447 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8448 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8449 _content->pushBackTimeStep(cSafe);
8450 appendGlobs(*f1ts,1e-12);
8453 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8455 contentNotNullBase()->synchronizeNameScope();
8458 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8460 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8463 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8465 return contentNotNullBase()->getPosGivenTime(time,eps);
8468 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8470 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8473 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8475 return contentNotNullBase()->getTypesOfFieldAvailable();
8478 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
8480 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8483 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8485 return contentNotNullBase()->getName();
8488 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8490 contentNotNullBase()->setName(name);
8493 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8495 return contentNotNullBase()->getDtUnit();
8498 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8500 contentNotNullBase()->setDtUnit(dtUnit);
8503 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8505 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8508 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8510 return contentNotNullBase()->getTimeSteps(ret1);
8513 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8515 return contentNotNullBase()->getMeshName();
8518 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8520 contentNotNullBase()->setMeshName(newMeshName);
8523 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8525 return contentNotNullBase()->changeMeshNames(modifTab);
8528 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8530 return contentNotNullBase()->getInfo();
8533 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8535 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8538 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8540 return contentNotNullBase()->setInfo(info);
8543 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8545 const std::vector<std::string> ret=getInfo();
8546 return (int)ret.size();
8549 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8551 writeGlobals(fid,*this);
8552 contentNotNullBase()->writeLL(fid,*this);
8556 * Writes \a this field into a MED file specified by its name.
8557 * \param [in] fileName - the MED file name.
8558 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8559 * - 2 - erase; an existing file is removed.
8560 * - 1 - append; same data should not be present in an existing file.
8561 * - 0 - overwrite; same data present in an existing file is overwritten.
8562 * \throw If the field name is not set.
8563 * \throw If no field data is set.
8564 * \throw If \a mode == 1 and the same data is present in an existing file.
8566 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8568 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8569 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8574 * This method alloc the arrays and load potentially huge arrays contained in this field.
8575 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8576 * This method can be also called to refresh or reinit values from a file.
8578 * \throw If the fileName is not set or points to a non readable MED file.
8580 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8582 if(getFileName().empty())
8583 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8584 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8585 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8589 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8590 * But once data loaded once, this method does nothing.
8592 * \throw If the fileName is not set or points to a non readable MED file.
8593 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8595 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8597 if(!getFileName().empty())
8599 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8600 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8605 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8606 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8607 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8609 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8611 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8613 contentNotNullBase()->unloadArrays();
8617 * 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.
8618 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8619 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8621 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8623 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8625 if(!getFileName().empty())
8626 contentNotNullBase()->unloadArrays();
8629 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8631 std::ostringstream oss;
8632 contentNotNullBase()->simpleRepr(0,oss,-1);
8633 simpleReprGlobs(oss);
8637 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8639 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8642 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8644 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8645 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8650 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8651 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8652 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8654 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8656 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8658 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8659 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8660 std::size_t sz(contentsSplit.size());
8661 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8662 for(std::size_t i=0;i<sz;i++)
8664 ret[i]=shallowCpy();
8665 ret[i]->_content=contentsSplit[i];
8671 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8672 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8674 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8676 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8678 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8679 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8680 std::size_t sz(contentsSplit.size());
8681 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8682 for(std::size_t i=0;i<sz;i++)
8684 ret[i]=shallowCpy();
8685 ret[i]->_content=contentsSplit[i];
8691 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8692 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8694 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8696 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8698 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8699 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8700 std::size_t sz(contentsSplit.size());
8701 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8702 for(std::size_t i=0;i<sz;i++)
8704 ret[i]=shallowCpy();
8705 ret[i]->_content=contentsSplit[i];
8710 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8712 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8713 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8714 ret->_content=_content->deepCopy();
8715 ret->deepCpyGlobs(*this);
8719 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8725 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8726 * \param [in] iteration - the iteration number of a required time step.
8727 * \param [in] order - the iteration order number of required time step.
8728 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8729 * delete this field using decrRef() as it is no more needed.
8730 * \throw If there is no required time step in \a this field.
8732 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8734 int pos=getPosOfTimeStep(iteration,order);
8735 return getTimeStepAtPos(pos);
8739 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8740 * \param [in] time - the time of the time step of interest.
8741 * \param [in] eps - a precision used to compare time values.
8742 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8743 * delete this field using decrRef() as it is no more needed.
8744 * \throw If there is no required time step in \a this field.
8746 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8748 int pos=getPosGivenTime(time,eps);
8749 return getTimeStepAtPos(pos);
8753 * 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.
8754 * The float64 value of time attached to the pair of integers are not considered here.
8755 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8757 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8758 * \throw If there is a null pointer in \a vectFMTS.
8760 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8762 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8763 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8764 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8765 while(!lstFMTS.empty())
8767 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8768 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8770 throw INTERP_KERNEL::Exception(msg);
8771 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8772 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8773 elt.push_back(curIt); it=lstFMTS.erase(it);
8774 while(it!=lstFMTS.end())
8778 throw INTERP_KERNEL::Exception(msg);
8779 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8781 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8791 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8792 * All returned instances in a subvector can be safely loaded, rendered along time
8793 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8794 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8795 * 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).
8796 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8797 * 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.
8799 * \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().
8800 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8801 * \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.
8802 * \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.
8804 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8805 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8806 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8807 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8808 * \throw If mesh is null.
8809 * \throw If an element in \a vectFMTS is null.
8810 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8812 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8814 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8816 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8817 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8818 if(vectFMTS.empty())
8820 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8821 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8823 throw INTERP_KERNEL::Exception(msg);
8825 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8826 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8827 for(;it!=vectFMTS.end();it++,i++)
8830 throw INTERP_KERNEL::Exception(msg);
8831 TypeOfField tof0,tof1;
8832 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8835 vectFMTSNotNodes.push_back(*it);
8837 vectFMTSNodes.push_back(*it);
8840 vectFMTSNotNodes.push_back(*it);
8842 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8843 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8845 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8848 bool isFetched(false);
8849 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8852 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8853 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8854 { ret[i].push_back(*it2); isFetched=true; }
8858 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8859 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8860 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8868 * 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.
8869 * \param [out] cmps - same size than the returned vector.
8871 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8873 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8874 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8875 while(!lstFMTS.empty())
8877 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8878 MEDFileAnyTypeFieldMultiTS *ref(*it);
8879 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8880 elt.push_back(ref); it=lstFMTS.erase(it);
8881 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8882 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8883 while(it!=lstFMTS.end())
8885 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8886 if(cmp->isEqual(curIt))
8887 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8891 ret.push_back(elt); cmps.push_back(cmp);
8897 * 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.
8898 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8900 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8901 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8902 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8903 * \thorw If \a f0 and \a f1 do not have the same times steps.
8904 * \throw If mesh is null.
8905 * \throw If \a f0 or \a f1 is null.
8906 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8908 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8911 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8913 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8914 if(f0->getMeshName()!=mesh->getName())
8916 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8917 throw INTERP_KERNEL::Exception(oss.str().c_str());
8919 if(f1->getMeshName()!=mesh->getName())
8921 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8922 throw INTERP_KERNEL::Exception(oss.str().c_str());
8924 int nts=f0->getNumberOfTS();
8925 if(nts!=f1->getNumberOfTS())
8926 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8929 for(int i=0;i<nts;i++)
8931 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8932 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8933 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8934 if(tofs0.size()!=1 || tofs1.size()!=1)
8935 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8938 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8939 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8942 { tof0=tofs0[0]; tof1=tofs1[0]; }
8943 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8945 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() << ") !";
8946 throw INTERP_KERNEL::Exception(oss.str().c_str());
8948 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8950 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() << ") !";
8951 throw INTERP_KERNEL::Exception(oss.str().c_str());
8953 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8955 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() << ") !";
8956 throw INTERP_KERNEL::Exception(oss.str().c_str());
8962 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8964 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8967 //= MEDFileFieldMultiTS
8970 * Returns a new empty instance of MEDFileFieldMultiTS.
8971 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8972 * is to delete this field using decrRef() as it is no more needed.
8974 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8976 return new MEDFileFieldMultiTS;
8980 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8981 * that has been read from a specified MED file.
8982 * \param [in] fileName - the name of the MED file to read.
8983 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8984 * is to delete this field using decrRef() as it is no more needed.
8985 * \throw If reading the file fails.
8987 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8989 MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8990 ret->contentNotNull();//to check that content type matches with \a this type.
8995 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8996 * that has been read from a specified MED file.
8997 * \param [in] fileName - the name of the MED file to read.
8998 * \param [in] fieldName - the name of the field to read.
8999 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9000 * is to delete this field using decrRef() as it is no more needed.
9001 * \throw If reading the file fails.
9002 * \throw If there is no field named \a fieldName in the file.
9004 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9006 MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
9007 ret->contentNotNull();//to check that content type matches with \a this type.
9012 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9013 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9015 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9016 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9017 * \warning this is a shallow copy constructor
9018 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9019 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9020 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9021 * is to delete this field using decrRef() as it is no more needed.
9023 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9025 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9028 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9030 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities));
9031 ret->contentNotNull();//to check that content type matches with \a this type.
9035 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9037 return new MEDFileFieldMultiTS(*this);
9040 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9043 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9044 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9046 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9050 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9051 * following the given input policy.
9053 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9054 * By default (true) the globals are deeply copied.
9055 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9057 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9059 MCAuto<MEDFileIntFieldMultiTS> ret;
9060 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9063 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9065 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9066 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9067 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
9070 ret=MEDFileIntFieldMultiTS::New();
9072 ret->deepCpyGlobs(*this);
9074 ret->shallowCpyGlobs(*this);
9079 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9080 * \param [in] pos - a time step id.
9081 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9082 * delete this field using decrRef() as it is no more needed.
9083 * \throw If \a pos is not a valid time step id.
9085 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9087 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9090 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9091 throw INTERP_KERNEL::Exception(oss.str().c_str());
9093 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9096 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9097 ret->shallowCpyGlobs(*this);
9100 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9101 throw INTERP_KERNEL::Exception(oss.str().c_str());
9105 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9106 * mesh entities of a given dimension of the first mesh in MED file.
9107 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9108 * \param [in] type - a spatial discretization of interest.
9109 * \param [in] iteration - the iteration number of a required time step.
9110 * \param [in] order - the iteration order number of required time step.
9111 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9112 * \param [in] renumPol - specifies how to permute values of the result field according to
9113 * the optional numbers of cells and nodes, if any. The valid values are
9114 * - 0 - do not permute.
9115 * - 1 - permute cells.
9116 * - 2 - permute nodes.
9117 * - 3 - permute cells and nodes.
9119 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9120 * caller is to delete this field using decrRef() as it is no more needed.
9121 * \throw If the MED file is not readable.
9122 * \throw If there is no mesh in the MED file.
9123 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9124 * \throw If no field values of the required parameters are available.
9126 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9128 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9129 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9131 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9132 MCAuto<DataArray> arrOut;
9133 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9134 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9139 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9140 * the top level cells of the first mesh in MED file.
9141 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9142 * \param [in] type - a spatial discretization of interest.
9143 * \param [in] iteration - the iteration number of a required time step.
9144 * \param [in] order - the iteration order number of required time step.
9145 * \param [in] renumPol - specifies how to permute values of the result field according to
9146 * the optional numbers of cells and nodes, if any. The valid values are
9147 * - 0 - do not permute.
9148 * - 1 - permute cells.
9149 * - 2 - permute nodes.
9150 * - 3 - permute cells and nodes.
9152 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9153 * caller is to delete this field using decrRef() as it is no more needed.
9154 * \throw If the MED file is not readable.
9155 * \throw If there is no mesh in the MED file.
9156 * \throw If no field values of the required parameters are available.
9158 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9160 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9161 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9163 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9164 MCAuto<DataArray> arrOut;
9165 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9166 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9171 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9173 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9174 * \param [in] type - a spatial discretization of interest.
9175 * \param [in] iteration - the iteration number of a required time step.
9176 * \param [in] order - the iteration order number of required time step.
9177 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9178 * \param [in] mesh - the supporting mesh.
9179 * \param [in] renumPol - specifies how to permute values of the result field according to
9180 * the optional numbers of cells and nodes, if any. The valid values are
9181 * - 0 - do not permute.
9182 * - 1 - permute cells.
9183 * - 2 - permute nodes.
9184 * - 3 - permute cells and nodes.
9186 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9187 * caller is to delete this field using decrRef() as it is no more needed.
9188 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9189 * \throw If no field of \a this is lying on \a mesh.
9190 * \throw If no field values of the required parameters are available.
9192 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9194 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9195 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9197 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9198 MCAuto<DataArray> arrOut;
9199 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9200 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9205 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9207 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9208 * \param [in] type - a spatial discretization of the new field.
9209 * \param [in] iteration - the iteration number of a required time step.
9210 * \param [in] order - the iteration order number of required time step.
9211 * \param [in] mesh - the supporting mesh.
9212 * \param [in] renumPol - specifies how to permute values of the result field according to
9213 * the optional numbers of cells and nodes, if any. The valid values are
9214 * - 0 - do not permute.
9215 * - 1 - permute cells.
9216 * - 2 - permute nodes.
9217 * - 3 - permute cells and nodes.
9219 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9220 * caller is to delete this field using decrRef() as it is no more needed.
9221 * \throw If no field of \a this is lying on \a mesh.
9222 * \throw If no field values of the required parameters are available.
9224 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9226 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9227 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9229 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9230 MCAuto<DataArray> arrOut;
9231 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9232 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9237 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9238 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9239 * This method is useful for MED2 file format when field on different mesh was autorized.
9241 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9243 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9244 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9246 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9247 MCAuto<DataArray> arrOut;
9248 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9249 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9254 * Returns values and a profile of the field of a given type, of a given time step,
9255 * lying on a given support.
9256 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9257 * \param [in] type - a spatial discretization of the field.
9258 * \param [in] iteration - the iteration number of a required time step.
9259 * \param [in] order - the iteration order number of required time step.
9260 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9261 * \param [in] mesh - the supporting mesh.
9262 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9263 * field of interest lies on. If the field lies on all entities of the given
9264 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9265 * using decrRef() as it is no more needed.
9266 * \param [in] glob - the global data storing profiles and localization.
9267 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9268 * field. The caller is to delete this array using decrRef() as it is no more needed.
9269 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9270 * \throw If no field of \a this is lying on \a mesh.
9271 * \throw If no field values of the required parameters are available.
9273 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9275 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9276 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9278 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9279 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9280 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9283 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9285 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9287 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9288 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9290 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 !");
9294 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9296 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9298 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9299 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9301 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 !");
9306 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9307 * the given field is checked if its elements are sorted suitable for writing to MED file
9308 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9309 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9310 * \param [in] field - the field to add to \a this.
9311 * \throw If the name of \a field is empty.
9312 * \throw If the data array of \a field is not set.
9313 * \throw If existing time steps have different name or number of components than \a field.
9314 * \throw If the underlying mesh of \a field has no name.
9315 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9317 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9319 const DataArrayDouble *arr=0;
9321 arr=field->getArray();
9322 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9326 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9327 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9328 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9331 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9332 * A new profile is added only if no equal profile is missing.
9333 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9334 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9335 * \param [in] mesh - the supporting mesh of \a field.
9336 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9337 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9338 * \throw If either \a field or \a mesh or \a profile has an empty name.
9339 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9340 * \throw If the data array of \a field is not set.
9341 * \throw If the data array of \a this is already allocated but has different number of
9342 * components than \a field.
9343 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9344 * \sa setFieldNoProfileSBT()
9346 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9348 const DataArrayDouble *arr=0;
9350 arr=field->getArray();
9351 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9354 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9356 _content=new MEDFileFieldMultiTSWithoutSDA;
9359 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9360 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9363 catch(INTERP_KERNEL::Exception& e)
9366 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)
9367 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9370 catch(INTERP_KERNEL::Exception& e)
9373 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9377 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
9379 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9382 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9384 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9387 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9389 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9393 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9394 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9396 * \return A new object that the caller is responsible to deallocate.
9398 MEDFileFieldMultiTS *MEDFileFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9401 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9402 MCAuto<MEDFileFieldMultiTS> fmtsOut(MEDFileFieldMultiTS::New());
9403 int nbTS(getNumberOfTS());
9404 for(int i=0;i<nbTS;i++)
9406 MCAuto<MEDFileField1TS> f1ts(getTimeStepAtPos(i));
9407 MCAuto<MEDFileField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9408 fmtsOut->pushBackTimeStep(f1tsOut);
9410 return fmtsOut.retn();
9413 //= MEDFileAnyTypeFieldMultiTSIterator
9415 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9420 _nb_iter=fmts->getNumberOfTS();
9424 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9428 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9430 if(_iter_id<_nb_iter)
9432 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9434 return fmts->getTimeStepAtPos(_iter_id++);
9442 //= MEDFileIntFieldMultiTS
9445 * Returns a new empty instance of MEDFileFieldMultiTS.
9446 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9447 * is to delete this field using decrRef() as it is no more needed.
9449 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9451 return new MEDFileIntFieldMultiTS;
9455 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9456 * that has been read from a specified MED file.
9457 * \param [in] fileName - the name of the MED file to read.
9458 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9459 * is to delete this field using decrRef() as it is no more needed.
9460 * \throw If reading the file fails.
9462 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9464 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9465 ret->contentNotNull();//to check that content type matches with \a this type.
9470 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9471 * that has been read from a specified MED file.
9472 * \param [in] fileName - the name of the MED file to read.
9473 * \param [in] fieldName - the name of the field to read.
9474 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9475 * is to delete this field using decrRef() as it is no more needed.
9476 * \throw If reading the file fails.
9477 * \throw If there is no field named \a fieldName in the file.
9479 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9481 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9482 ret->contentNotNull();//to check that content type matches with \a this type.
9487 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9488 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9490 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9491 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9492 * \warning this is a shallow copy constructor
9493 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9494 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9495 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9496 * is to delete this field using decrRef() as it is no more needed.
9498 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9500 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9503 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9505 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities);
9506 ret->contentNotNull();//to check that content type matches with \a this type.
9511 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9512 * following the given input policy.
9514 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9515 * By default (true) the globals are deeply copied.
9516 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9518 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9520 MCAuto<MEDFileFieldMultiTS> ret;
9521 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9524 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9526 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9527 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9528 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9531 ret=MEDFileFieldMultiTS::New();
9533 ret->deepCpyGlobs(*this);
9535 ret->shallowCpyGlobs(*this);
9539 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9541 return new MEDFileIntFieldMultiTS(*this);
9544 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9547 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9548 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9550 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9554 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9555 * mesh entities of a given dimension of the first mesh in MED file.
9556 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9557 * \param [in] type - a spatial discretization of interest.
9558 * \param [in] iteration - the iteration number of a required time step.
9559 * \param [in] order - the iteration order number of required time step.
9560 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9561 * \param [out] arrOut - the DataArrayInt containing values of field.
9562 * \param [in] renumPol - specifies how to permute values of the result field according to
9563 * the optional numbers of cells and nodes, if any. The valid values are
9564 * - 0 - do not permute.
9565 * - 1 - permute cells.
9566 * - 2 - permute nodes.
9567 * - 3 - permute cells and nodes.
9569 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9570 * caller is to delete this field using decrRef() as it is no more needed.
9571 * \throw If the MED file is not readable.
9572 * \throw If there is no mesh in the MED file.
9573 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9574 * \throw If no field values of the required parameters are available.
9576 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9578 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9579 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9581 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9582 MCAuto<DataArray> arr;
9583 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9584 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9589 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9590 * the top level cells of the first mesh in MED file.
9591 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9592 * \param [in] type - a spatial discretization of interest.
9593 * \param [in] iteration - the iteration number of a required time step.
9594 * \param [in] order - the iteration order number of required time step.
9595 * \param [out] arrOut - the DataArrayInt containing values of field.
9596 * \param [in] renumPol - specifies how to permute values of the result field according to
9597 * the optional numbers of cells and nodes, if any. The valid values are
9598 * - 0 - do not permute.
9599 * - 1 - permute cells.
9600 * - 2 - permute nodes.
9601 * - 3 - permute cells and nodes.
9603 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9604 * caller is to delete this field using decrRef() as it is no more needed.
9605 * \throw If the MED file is not readable.
9606 * \throw If there is no mesh in the MED file.
9607 * \throw If no field values of the required parameters are available.
9609 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9611 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9612 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9614 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9615 MCAuto<DataArray> arr;
9616 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9617 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9622 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9624 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9625 * \param [in] type - a spatial discretization of interest.
9626 * \param [in] iteration - the iteration number of a required time step.
9627 * \param [in] order - the iteration order number of required time step.
9628 * \param [out] arrOut - the DataArrayInt containing values of field.
9629 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9630 * \param [in] mesh - the supporting mesh.
9631 * \param [in] renumPol - specifies how to permute values of the result field according to
9632 * the optional numbers of cells and nodes, if any. The valid values are
9633 * - 0 - do not permute.
9634 * - 1 - permute cells.
9635 * - 2 - permute nodes.
9636 * - 3 - permute cells and nodes.
9638 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9639 * caller is to delete this field using decrRef() as it is no more needed.
9640 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9641 * \throw If no field of \a this is lying on \a mesh.
9642 * \throw If no field values of the required parameters are available.
9644 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9646 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9647 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9649 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9650 MCAuto<DataArray> arr;
9651 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9652 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9657 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9659 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9660 * \param [in] type - a spatial discretization of the new field.
9661 * \param [in] iteration - the iteration number of a required time step.
9662 * \param [in] order - the iteration order number of required time step.
9663 * \param [in] mesh - the supporting mesh.
9664 * \param [out] arrOut - the DataArrayInt containing values of field.
9665 * \param [in] renumPol - specifies how to permute values of the result field according to
9666 * the optional numbers of cells and nodes, if any. The valid values are
9667 * - 0 - do not permute.
9668 * - 1 - permute cells.
9669 * - 2 - permute nodes.
9670 * - 3 - permute cells and nodes.
9672 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9673 * caller is to delete this field using decrRef() as it is no more needed.
9674 * \throw If no field of \a this is lying on \a mesh.
9675 * \throw If no field values of the required parameters are available.
9677 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9679 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9680 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9682 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9683 MCAuto<DataArray> arr;
9684 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9685 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9690 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9691 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9692 * This method is useful for MED2 file format when field on different mesh was autorized.
9694 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9696 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9697 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9699 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9700 MCAuto<DataArray> arr;
9701 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9702 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9707 * Returns values and a profile of the field of a given type, of a given time step,
9708 * lying on a given support.
9709 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9710 * \param [in] type - a spatial discretization of the field.
9711 * \param [in] iteration - the iteration number of a required time step.
9712 * \param [in] order - the iteration order number of required time step.
9713 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9714 * \param [in] mesh - the supporting mesh.
9715 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9716 * field of interest lies on. If the field lies on all entities of the given
9717 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9718 * using decrRef() as it is no more needed.
9719 * \param [in] glob - the global data storing profiles and localization.
9720 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9721 * field. The caller is to delete this array using decrRef() as it is no more needed.
9722 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9723 * \throw If no field of \a this is lying on \a mesh.
9724 * \throw If no field values of the required parameters are available.
9726 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9728 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9729 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9731 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9732 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9733 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9737 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9738 * \param [in] pos - a time step id.
9739 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9740 * delete this field using decrRef() as it is no more needed.
9741 * \throw If \a pos is not a valid time step id.
9743 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9745 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9748 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9749 throw INTERP_KERNEL::Exception(oss.str().c_str());
9751 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9754 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9755 ret->shallowCpyGlobs(*this);
9758 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9759 throw INTERP_KERNEL::Exception(oss.str().c_str());
9763 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9764 * the given field is checked if its elements are sorted suitable for writing to MED file
9765 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9766 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9767 * \param [in] field - the field to add to \a this.
9768 * \throw If the name of \a field is empty.
9769 * \throw If the data array of \a field is not set.
9770 * \throw If existing time steps have different name or number of components than \a field.
9771 * \throw If the underlying mesh of \a field has no name.
9772 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9774 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9776 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9780 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9781 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9782 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9785 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9786 * A new profile is added only if no equal profile is missing.
9787 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9788 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9789 * \param [in] arrOfVals - the values of the field \a field used.
9790 * \param [in] mesh - the supporting mesh of \a field.
9791 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9792 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9793 * \throw If either \a field or \a mesh or \a profile has an empty name.
9794 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9795 * \throw If the data array of \a field is not set.
9796 * \throw If the data array of \a this is already allocated but has different number of
9797 * components than \a field.
9798 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9799 * \sa setFieldNoProfileSBT()
9801 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9803 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9806 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9808 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9810 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9811 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9813 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 !");
9817 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9819 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9821 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9822 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9824 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 !");
9828 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9830 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9833 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9837 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9838 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9841 catch(INTERP_KERNEL::Exception& e)
9844 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)
9845 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9848 catch(INTERP_KERNEL::Exception& e)
9851 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9853 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9856 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9858 throw INTERP_KERNEL::Exception("*MEDFileIntFieldMultiTS::extractPart : not implemented yet for int !");
9863 MEDFileFields *MEDFileFields::New()
9865 return new MEDFileFields;
9868 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9870 return new MEDFileFields(fileName,loadAll,0,0);
9873 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9875 return new MEDFileFields(fileName,loadAll,ms,0);
9878 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9880 return new MEDFileFields(fileName,loadAll,0,&entities);
9883 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9885 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9886 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9890 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9892 std::vector<const BigMemoryObject *> ret;
9893 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9894 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9898 MEDFileFields *MEDFileFields::deepCopy() const
9900 MCAuto<MEDFileFields> ret=shallowCpy();
9902 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9904 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9905 ret->_fields[i]=(*it)->deepCopy();
9907 ret->deepCpyGlobs(*this);
9911 MEDFileFields *MEDFileFields::shallowCpy() const
9913 return new MEDFileFields(*this);
9917 * 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
9918 * 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.
9919 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9921 * \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.
9922 * \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.
9924 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9926 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9928 std::set< std::pair<int,int> > s;
9929 bool firstShot=true;
9930 areThereSomeForgottenTS=false;
9931 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9933 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9935 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9936 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9938 { s=s1; firstShot=false; }
9941 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9943 areThereSomeForgottenTS=true;
9947 std::vector< std::pair<int,int> > ret;
9948 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9952 int MEDFileFields::getNumberOfFields() const
9954 return _fields.size();
9957 std::vector<std::string> MEDFileFields::getFieldsNames() const
9959 std::vector<std::string> ret(_fields.size());
9961 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9963 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9966 ret[i]=f->getName();
9970 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9971 throw INTERP_KERNEL::Exception(oss.str().c_str());
9977 std::vector<std::string> MEDFileFields::getMeshesNames() const
9979 std::vector<std::string> ret;
9980 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9982 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9984 ret.push_back(cur->getMeshName());
9989 std::string MEDFileFields::simpleRepr() const
9991 std::ostringstream oss;
9992 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9997 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9999 int nbOfFields=getNumberOfFields();
10000 std::string startLine(bkOffset,' ');
10001 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10003 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10005 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10008 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10012 oss << startLine << " - not defined !" << std::endl;
10016 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10018 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10019 std::string chapter(17,'0'+i);
10020 oss << startLine << chapter << std::endl;
10023 cur->simpleRepr(bkOffset+2,oss,i);
10027 oss << startLine << " - not defined !" << std::endl;
10029 oss << startLine << chapter << std::endl;
10031 simpleReprGlobs(oss);
10034 MEDFileFields::MEDFileFields()
10038 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10039 try:MEDFileFieldGlobsReal(fileName)
10041 MEDFileUtilities::CheckFileForRead(fileName);
10042 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
10043 int nbFields(MEDnField(fid));
10044 _fields.resize(nbFields);
10045 med_field_type typcha;
10046 for(int i=0;i<nbFields;i++)
10048 std::vector<std::string> infos;
10049 std::string fieldName,dtunit;
10050 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
10055 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10060 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10065 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] !";
10066 throw INTERP_KERNEL::Exception(oss.str().c_str());
10070 loadAllGlobals(fid);
10072 catch(INTERP_KERNEL::Exception& e)
10077 void MEDFileFields::writeLL(med_idt fid) const
10080 writeGlobals(fid,*this);
10081 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10083 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10086 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10087 throw INTERP_KERNEL::Exception(oss.str().c_str());
10089 elt->writeLL(fid,*this);
10093 void MEDFileFields::write(const std::string& fileName, int mode) const
10095 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
10096 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
10101 * This method alloc the arrays and load potentially huge arrays contained in this field.
10102 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10103 * This method can be also called to refresh or reinit values from a file.
10105 * \throw If the fileName is not set or points to a non readable MED file.
10107 void MEDFileFields::loadArrays()
10109 if(getFileName().empty())
10110 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10111 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10112 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10114 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10116 elt->loadBigArraysRecursively(fid,*elt);
10121 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10122 * But once data loaded once, this method does nothing.
10124 * \throw If the fileName is not set or points to a non readable MED file.
10125 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10127 void MEDFileFields::loadArraysIfNecessary()
10129 if(!getFileName().empty())
10131 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10132 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10134 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10136 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10142 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10143 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10144 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10146 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10148 void MEDFileFields::unloadArrays()
10150 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10152 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10154 elt->unloadArrays();
10159 * 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.
10160 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10161 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10163 * \sa MEDFileFields::loadArraysIfNecessary
10165 void MEDFileFields::unloadArraysWithoutDataLoss()
10167 if(!getFileName().empty())
10171 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10173 std::vector<std::string> ret;
10174 std::set<std::string> ret2;
10175 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10177 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10178 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10179 if(ret2.find(*it2)==ret2.end())
10181 ret.push_back(*it2);
10188 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10190 std::vector<std::string> ret;
10191 std::set<std::string> ret2;
10192 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10194 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10195 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10196 if(ret2.find(*it2)==ret2.end())
10198 ret.push_back(*it2);
10205 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10207 std::vector<std::string> ret;
10208 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10210 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10211 ret.insert(ret.end(),tmp.begin(),tmp.end());
10216 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10218 std::vector<std::string> ret;
10219 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10221 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10222 ret.insert(ret.end(),tmp.begin(),tmp.end());
10227 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10229 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10230 (*it)->changePflsRefsNamesGen2(mapOfModif);
10233 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10235 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10236 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10239 void MEDFileFields::resize(int newSize)
10241 _fields.resize(newSize);
10244 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10246 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10250 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10253 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10254 _fields.push_back(field->getContent());
10255 appendGlobs(*field,1e-12);
10258 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10261 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10262 if(i>=(int)_fields.size())
10263 _fields.resize(i+1);
10264 _fields[i]=field->getContent();
10265 appendGlobs(*field,1e-12);
10268 void MEDFileFields::destroyFieldAtPos(int i)
10270 destroyFieldsAtPos(&i,&i+1);
10273 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10275 std::vector<bool> b(_fields.size(),true);
10276 for(const int *i=startIds;i!=endIds;i++)
10278 if(*i<0 || *i>=(int)_fields.size())
10280 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10281 throw INTERP_KERNEL::Exception(oss.str().c_str());
10285 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10287 for(std::size_t i=0;i<_fields.size();i++)
10289 fields[j++]=_fields[i];
10293 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10295 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10296 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10297 std::vector<bool> b(_fields.size(),true);
10299 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10301 if(k<0 || k>=(int)_fields.size())
10303 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10304 throw INTERP_KERNEL::Exception(oss.str().c_str());
10308 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10310 for(std::size_t i=0;i<_fields.size();i++)
10312 fields[j++]=_fields[i];
10316 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10319 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10321 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10323 ret=cur->changeMeshNames(modifTab) || ret;
10329 * \param [in] meshName the name of the mesh that will be renumbered.
10330 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10331 * This code corresponds to the distribution of types in the corresponding mesh.
10332 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10333 * \param [in] renumO2N the old to new renumber array.
10334 * \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
10335 * field in \a this.
10337 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10340 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10342 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10345 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10352 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10353 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10355 * \return A new object that the caller is responsible to deallocate.
10357 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10360 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10361 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10362 int nbFields(getNumberOfFields());
10363 for(int i=0;i<nbFields;i++)
10365 MEDFileAnyTypeFieldMultiTS *fmts(getFieldAtPos(i));
10368 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10369 throw INTERP_KERNEL::Exception(oss.str().c_str());
10371 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10372 fsOut->pushField(fmtsOut);
10374 return fsOut.retn();
10377 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10379 if(i<0 || i>=(int)_fields.size())
10381 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10382 throw INTERP_KERNEL::Exception(oss.str().c_str());
10384 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10387 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10388 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10389 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10391 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10393 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10396 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10397 throw INTERP_KERNEL::Exception(oss.str().c_str());
10399 ret->shallowCpyGlobs(*this);
10404 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10405 * This method is accessible in python using __getitem__ with a list in input.
10406 * \return a new object that the caller should deal with.
10408 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10410 MCAuto<MEDFileFields> ret=shallowCpy();
10411 std::size_t sz=std::distance(startIds,endIds);
10412 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10414 for(const int *i=startIds;i!=endIds;i++,j++)
10416 if(*i<0 || *i>=(int)_fields.size())
10418 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10419 throw INTERP_KERNEL::Exception(oss.str().c_str());
10421 fields[j]=_fields[*i];
10423 ret->_fields=fields;
10427 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10429 return getFieldAtPos(getPosFromFieldName(fieldName));
10433 * This method removes, if any, fields in \a this having no time steps.
10434 * 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.
10436 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10438 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10440 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10441 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10443 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10446 if(elt->getNumberOfTS()>0)
10447 newFields.push_back(*it);
10450 if(_fields.size()==newFields.size())
10457 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10458 * This method can be seen as a filter applied on \a this, that returns an object containing
10459 * 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
10460 * shallow copied from \a this.
10462 * \param [in] meshName - the name of the mesh on w
10463 * \return a new object that the caller should deal with.
10465 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10467 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10468 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10470 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10473 if(cur->getMeshName()==meshName)
10476 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10477 ret->_fields.push_back(cur2);
10480 ret->shallowCpyOnlyUsedGlobs(*this);
10485 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10486 * Input time steps are specified using a pair of integer (iteration, order).
10487 * 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,
10488 * but for each multitimestep only the time steps in \a timeSteps are kept.
10489 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10491 * The returned object points to shallow copy of elements in \a this.
10493 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10494 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10495 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10497 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10499 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10500 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10502 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10505 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10506 ret->_fields.push_back(elt);
10508 ret->shallowCpyOnlyUsedGlobs(*this);
10513 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10515 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10517 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10518 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10520 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10523 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10524 if(elt->getNumberOfTS()!=0)
10525 ret->_fields.push_back(elt);
10527 ret->shallowCpyOnlyUsedGlobs(*this);
10531 MEDFileFieldsIterator *MEDFileFields::iterator()
10533 return new MEDFileFieldsIterator(this);
10536 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10538 std::string tmp(fieldName);
10539 std::vector<std::string> poss;
10540 for(std::size_t i=0;i<_fields.size();i++)
10542 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10545 std::string fname(f->getName());
10549 poss.push_back(fname);
10552 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10553 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10555 throw INTERP_KERNEL::Exception(oss.str().c_str());
10558 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10563 _nb_iter=fs->getNumberOfFields();
10567 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10571 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10573 if(_iter_id<_nb_iter)
10575 MEDFileFields *fs(_fs);
10577 return fs->getFieldAtPos(_iter_id++);