1 // Copyright (C) 2007-2016 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 if(!arr->isAllocated())
782 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
783 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
784 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
785 const unsigned char *locToWrite=0;
787 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
789 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
791 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
792 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
793 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
797 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
802 dad.first=_start; dad.second=_end;
806 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
807 * This code corresponds to the distribution of types in the corresponding mesh.
808 * \param [out] ptToFill memory zone where the output will be stored.
809 * \return the size of data pushed into output param \a ptToFill
811 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
814 std::ostringstream oss;
815 std::size_t nbOfType=codeOfMesh.size()/3;
817 for(std::size_t i=0;i<nbOfType && found==-1;i++)
818 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
822 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
823 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
824 throw INTERP_KERNEL::Exception(oss.str().c_str());
829 if(_nval!=codeOfMesh[3*found+1])
831 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
832 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
833 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
834 throw INTERP_KERNEL::Exception(oss.str().c_str());
836 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
841 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
842 if(pfl->getNumberOfTuples()!=_nval)
844 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
845 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
847 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
848 throw INTERP_KERNEL::Exception(oss.str().c_str());
850 int offset2=codeOfMesh[3*found+2];
851 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
853 if(*pflId<codeOfMesh[3*found+1])
854 *work++=offset2+*pflId;
860 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
862 for(int i=_start;i<_end;i++)
867 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
878 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
882 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
885 std::map<std::pair<std::string,TypeOfField>,int> m;
886 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
887 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
888 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
889 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
891 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
892 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
897 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
899 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
900 * \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.
901 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
902 * \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)
903 * \param [in,out] glob if necessary by the method, new profiles can be added to it
904 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
905 * \param [out] result All new entries will be appended on it.
906 * \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 !)
908 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
909 const DataArrayInt *explicitIdsInMesh,
910 const std::vector<int>& newCode,
911 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
912 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
914 if(entriesOnSameDisc.empty())
916 TypeOfField type=entriesOnSameDisc[0]->getType();
917 int szEntities=0,szTuples=0;
918 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
919 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
920 int nbi=szTuples/szEntities;
921 if(szTuples%szEntities!=0)
922 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
923 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
924 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
925 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
926 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
927 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
928 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
929 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
931 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
933 int startOfEltIdOfChunk=(*it)->_start;
934 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
935 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
936 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
938 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
939 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
941 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
942 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
944 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
945 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
946 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
947 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
949 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
951 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
952 arrPart->renumberInPlace(renumTupleIds->begin());
953 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
955 const int *idIt=diffVals->begin();
956 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
958 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
960 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
961 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
962 int nbEntityElts=subIds->getNumberOfTuples();
964 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
965 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
969 result.push_back(eltToAdd);
970 offset2+=nbEntityElts*nbi;
972 ret=ret || li.empty();
977 * \param [in] typeF type of field of new chunk
978 * \param [in] geoType the geometric type of the chunk
979 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
980 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
981 * \param [in] nbi number of integration points
982 * \param [in] offset The offset in the **global array of data**.
983 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
984 * to the new chunk to create.
985 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
986 * \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
987 * and corresponding entry erased from \a entriesOnSameDisc.
988 * \return a newly allocated chunk
990 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
991 bool isPfl, int nbi, int offset,
992 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
993 MEDFileFieldGlobsReal& glob,
996 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
997 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
998 for(;it!=entriesOnSameDisc.end();it++)
1000 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1004 if((*it)->_profile.empty())
1007 if(!(*it)->_profile.empty())
1009 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1010 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1016 if(it==entriesOnSameDisc.end())
1019 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1021 ret->_loc_id=(int)geoType;
1022 ret->_nval=nbMeshEntities;
1024 ret->_end=ret->_start+ret->_nval*nbi;
1027 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1028 glob.appendProfile(idsOfMeshElt);
1029 ret->_profile=idsOfMeshElt->getName();
1031 //tony treatment of localization
1036 notInExisting=false;
1037 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1038 ret->_loc_id=(int)geoType;
1039 ret->setNewStart(offset);
1040 entriesOnSameDisc.erase(it);
1046 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1048 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1051 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1053 return new MEDFileFieldPerMeshPerType(fath,geoType);
1056 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1058 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1061 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1063 std::vector<const BigMemoryObject *> ret;
1064 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1065 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1069 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1071 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1072 ret->_father=father;
1074 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1076 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1077 ret->_field_pm_pt_pd[i]=(*it)->deepCopy((MEDFileFieldPerMeshPerType *)ret);
1082 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1084 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1085 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1086 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1090 * This method is the most general one. No optimization is done here.
1091 * \param [in] multiTypePfl is the end user profile specified in high level API
1092 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1093 * \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.
1094 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1095 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1096 * \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.
1098 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)
1100 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1101 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1102 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1105 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1107 _field_pm_pt_pd.resize(1);
1108 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1109 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1112 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1114 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1115 if(!arr || !arr->isAllocated())
1116 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1117 _field_pm_pt_pd.resize(1);
1118 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1119 _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.
1122 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1124 TypeOfField type=field->getTypeOfField();
1125 if(type!=ON_GAUSS_PT)
1127 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1128 int sz=_field_pm_pt_pd.size();
1130 for(int j=0;j<sz && !found;j++)
1132 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1134 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1140 _field_pm_pt_pd.resize(sz+1);
1141 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1143 std::vector<int> ret(1,(int)sz);
1148 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1149 int sz2=ret2.size();
1150 std::vector<int> ret3(sz2);
1152 for(int i=0;i<sz2;i++)
1154 int sz=_field_pm_pt_pd.size();
1155 int locIdToFind=ret2[i];
1157 for(int j=0;j<sz && !found;j++)
1159 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1161 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1168 _field_pm_pt_pd.resize(sz+1);
1169 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1177 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1179 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1180 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1182 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1183 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1185 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1186 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1187 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1188 if(retTmp->presenceOfValue(-1))
1189 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1190 std::vector<int> ret(retTmp->begin(),retTmp->end());
1194 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1196 TypeOfField type=field->getTypeOfField();
1197 if(type!=ON_GAUSS_PT)
1199 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1200 int sz=_field_pm_pt_pd.size();
1202 for(int j=0;j<sz && !found;j++)
1204 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1206 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1212 _field_pm_pt_pd.resize(sz+1);
1213 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1215 std::vector<int> ret(1,0);
1220 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1221 int sz2=ret2.size();
1222 std::vector<int> ret3(sz2);
1224 for(int i=0;i<sz2;i++)
1226 int sz=_field_pm_pt_pd.size();
1227 int locIdToFind=ret2[i];
1229 for(int j=0;j<sz && !found;j++)
1231 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1233 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1240 _field_pm_pt_pd.resize(sz+1);
1241 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1249 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1251 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1252 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1254 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1255 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1257 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1258 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1259 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1260 if(retTmp->presenceOfValue(-1))
1261 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1262 std::vector<int> ret(retTmp->begin(),retTmp->end());
1266 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1271 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1273 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1274 int curDim=(int)cm.getDimension();
1275 dim=std::max(dim,curDim);
1278 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1280 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1282 (*it)->fillTypesOfFieldAvailable(types);
1286 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
1288 int sz=_field_pm_pt_pd.size();
1289 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1290 for(int i=0;i<sz;i++)
1292 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1296 int MEDFileFieldPerMeshPerType::getIteration() const
1298 return _father->getIteration();
1301 int MEDFileFieldPerMeshPerType::getOrder() const
1303 return _father->getOrder();
1306 double MEDFileFieldPerMeshPerType::getTime() const
1308 return _father->getTime();
1311 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1313 return _father->getMeshName();
1316 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1318 const char startLine[]=" ## ";
1319 std::string startLine2(bkOffset,' ');
1320 std::string startLine3(startLine2);
1321 startLine3+=startLine;
1322 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1324 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1325 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1328 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1329 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1331 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1333 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1335 cur->simpleRepr(bkOffset,oss,i);
1338 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1343 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1345 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1347 globalSz+=(*it)->getNumberOfTuples();
1349 nbOfEntries+=(int)_field_pm_pt_pd.size();
1352 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1358 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1360 return _father->getNumberOfComponents();
1363 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1366 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1368 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1375 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1377 return _father->getOrCreateAndGetArray();
1380 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1382 const MEDFileFieldPerMesh *fath=_father;
1383 return fath->getOrCreateAndGetArray();
1386 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1388 return _father->getInfo();
1391 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1393 std::vector<std::string> ret;
1394 std::set<std::string> ret2;
1395 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1397 std::string tmp=(*it1)->getProfile();
1399 if(ret2.find(tmp)==ret2.end())
1408 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1410 std::vector<std::string> ret;
1411 std::set<std::string> ret2;
1412 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1414 std::string tmp=(*it1)->getLocalization();
1415 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1416 if(ret2.find(tmp)==ret2.end())
1425 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1427 std::vector<std::string> ret;
1428 std::set<std::string> ret2;
1429 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1431 std::string tmp=(*it1)->getProfile();
1438 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1440 std::vector<std::string> ret;
1441 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1443 std::string tmp=(*it1)->getLocalization();
1444 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1450 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1452 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1453 (*it1)->changePflsRefsNamesGen(mapOfModif);
1456 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1458 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1459 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1462 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1464 if(_field_pm_pt_pd.empty())
1466 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1467 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1468 throw INTERP_KERNEL::Exception(oss.str().c_str());
1470 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1471 return _field_pm_pt_pd[locId];
1472 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1473 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1474 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1475 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1476 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1479 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1481 if(_field_pm_pt_pd.empty())
1483 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1484 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1485 throw INTERP_KERNEL::Exception(oss.str().c_str());
1487 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1488 return _field_pm_pt_pd[locId];
1489 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1490 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1491 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1492 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1493 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1496 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
1498 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1500 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1501 if(meshDim!=(int)cm.getDimension())
1504 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1505 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1508 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1511 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1513 (*it)->fillValues(i,startEntryId,entries);
1517 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1519 _field_pm_pt_pd=leaves;
1520 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1521 (*it)->setFather(this);
1525 * \param [in,out] globalNum a global numbering counter for the renumbering.
1526 * \param [out] its - list of pair (start,stop) kept
1527 * \return bool - false if the type of field \a tof is not contained in \a this.
1529 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1532 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1533 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1534 if((*it)->getType()==tof)
1536 newPmPtPd.push_back(*it);
1537 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1538 (*it)->setNewStart(globalNum);
1539 globalNum=(*it)->getEnd();
1540 its.push_back(bgEnd);
1544 _field_pm_pt_pd=newPmPtPd;
1549 * \param [in,out] globalNum a global numbering counter for the renumbering.
1550 * \param [out] its - list of pair (start,stop) kept
1551 * \return bool - false if the type of field \a tof is not contained in \a this.
1553 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1555 if(_field_pm_pt_pd.size()<=idOfDisc)
1557 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1558 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1559 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1560 elt->setNewStart(globalNum);
1561 globalNum=elt->getEnd();
1562 its.push_back(bgEnd);
1563 _field_pm_pt_pd=newPmPtPd;
1567 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1571 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1573 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1574 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1575 med_geometry_type mgeoti;
1576 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1577 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1578 _field_pm_pt_pd.resize(nbProfiles);
1579 for(int i=0;i<nbProfiles;i++)
1581 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1585 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1586 for(int i=0;i<nbProfiles2;i++)
1587 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1591 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1593 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1594 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1597 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1599 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1600 (*it)->loadBigArray(fid,nasc);
1603 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1605 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1607 (*it)->copyOptionsFrom(*this);
1608 (*it)->writeLL(fid,nasc);
1612 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1617 medfGeoType=typmai3[(int)ikGeoType];
1620 medfGeoType=MED_NONE;
1623 medfGeoType=typmai3[(int)ikGeoType];
1624 return MED_NODE_ELEMENT;
1626 medfGeoType=typmai3[(int)ikGeoType];
1629 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1631 return MED_UNDEF_ENTITY_TYPE;
1634 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)
1636 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1639 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1641 return new MEDFileFieldPerMesh(fath,mesh);
1644 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1646 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1649 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1651 std::vector<const BigMemoryObject *> ret;
1652 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1653 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1657 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1659 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1660 ret->_father=father;
1662 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1664 if((const MEDFileFieldPerMeshPerType *)*it)
1665 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1670 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1672 std::string startLine(bkOffset,' ');
1673 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1674 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1676 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1678 const MEDFileFieldPerMeshPerType *cur=*it;
1680 cur->simpleRepr(bkOffset,oss,i);
1683 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1688 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1690 _mesh_name=mesh->getName();
1691 mesh->getTime(_mesh_iteration,_mesh_order);
1694 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1696 int nbOfTypes=code.size()/3;
1698 for(int i=0;i<nbOfTypes;i++)
1700 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1701 int nbOfCells=code[3*i+1];
1702 int pos=addNewEntryIfNecessary(type);
1703 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1709 * This method is the most general one. No optimization is done here.
1710 * \param [in] multiTypePfl is the end user profile specified in high level API
1711 * \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].
1712 * \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.
1713 * \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.
1714 * \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.
1715 * \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.
1717 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)
1719 int nbOfTypes(code.size()/3);
1720 for(int i=0;i<nbOfTypes;i++)
1722 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1723 int pos=addNewEntryIfNecessary(type);
1724 DataArrayInt *pfl=0;
1726 pfl=idsPerType[code[3*i+2]];
1727 int nbOfTupes2=code2.size()/3;
1729 for(;found<nbOfTupes2;found++)
1730 if(code[3*i]==code2[3*found])
1732 if(found==nbOfTupes2)
1733 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1734 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1738 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1740 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1741 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1744 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1746 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1747 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1750 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1752 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1753 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1756 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1758 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1759 (*it)->loadBigArraysRecursively(fid,nasc);
1762 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1764 int nbOfTypes=_field_pm_pt.size();
1765 for(int i=0;i<nbOfTypes;i++)
1767 _field_pm_pt[i]->copyOptionsFrom(*this);
1768 _field_pm_pt[i]->writeLL(fid,nasc);
1772 void MEDFileFieldPerMesh::getDimension(int& dim) const
1774 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1775 (*it)->getDimension(dim);
1778 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1780 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1781 (*it)->fillTypesOfFieldAvailable(types);
1784 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
1786 int sz=_field_pm_pt.size();
1787 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1788 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1789 for(int i=0;i<sz;i++)
1791 types[i]=_field_pm_pt[i]->getGeoType();
1792 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1797 double MEDFileFieldPerMesh::getTime() const
1800 return _father->getTime(tmp1,tmp2);
1803 int MEDFileFieldPerMesh::getIteration() const
1805 return _father->getIteration();
1808 int MEDFileFieldPerMesh::getOrder() const
1810 return _father->getOrder();
1813 int MEDFileFieldPerMesh::getNumberOfComponents() const
1815 return _father->getNumberOfComponents();
1818 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1820 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1822 const MEDFileFieldPerMeshPerType *fpmt(*it);
1825 if(fpmt->presenceOfMultiDiscPerGeoType())
1831 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1834 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1835 return _father->getOrCreateAndGetArray();
1838 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1841 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1842 return _father->getOrCreateAndGetArray();
1845 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1847 return _father->getInfo();
1851 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1852 * 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.
1853 * It returns 2 output vectors :
1854 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1855 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1856 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1858 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)
1860 int notNullPflsSz=0;
1861 int nbOfArrs=geoTypes.size();
1862 for(int i=0;i<nbOfArrs;i++)
1865 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1866 int nbOfDiffGeoTypes=geoTypes3.size();
1867 code.resize(3*nbOfDiffGeoTypes);
1868 notNullPfls.resize(notNullPflsSz);
1871 for(int i=0;i<nbOfDiffGeoTypes;i++)
1874 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1875 std::vector<const DataArrayInt *> notNullTmp;
1877 notNullTmp.push_back(pfls[j]);
1879 for(;j<nbOfArrs;j++)
1880 if(geoTypes[j]==refType)
1883 notNullTmp.push_back(pfls[j]);
1887 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1888 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1889 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1890 code[3*i]=(int)refType;
1891 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1892 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1893 if(notNullTmp.empty())
1897 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1898 code[3*i+2]=notNullPflsSz++;
1904 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1906 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)
1910 for(int i=0;i<sz;i++)
1914 if(type!=ON_GAUSS_NE)
1915 ret+=dads[i].second-dads[i].first;
1918 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1919 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1924 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1925 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1931 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1933 std::vector<std::string> ret;
1934 std::set<std::string> ret2;
1935 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1937 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1938 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1939 if(ret2.find(*it2)==ret2.end())
1941 ret.push_back(*it2);
1948 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1950 std::vector<std::string> ret;
1951 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1953 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1954 ret.insert(ret.end(),tmp.begin(),tmp.end());
1959 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1961 std::vector<std::string> ret;
1962 std::set<std::string> ret2;
1963 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1965 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1966 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1967 if(ret2.find(*it2)==ret2.end())
1969 ret.push_back(*it2);
1976 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1978 std::vector<std::string> ret;
1979 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1981 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1982 ret.insert(ret.end(),tmp.begin(),tmp.end());
1987 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1989 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1991 if((*it).first==_mesh_name)
1993 _mesh_name=(*it).second;
2000 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2001 MEDFileFieldGlobsReal& glob)
2003 if(_mesh_name!=meshName)
2005 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2006 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2007 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2008 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2009 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2010 getUndergroundDataArrayExt(entries);
2011 DataArray *arr0=getOrCreateAndGetArray();//tony
2013 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2014 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
2016 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2019 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2020 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2022 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2024 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2025 sz+=(*it).second.second-(*it).second.first;
2028 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2030 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2031 ////////////////////
2032 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2033 int *workI2=explicitIdsOldInMesh->getPointer();
2034 int sz1=0,sz2=0,sid=1;
2035 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2036 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2037 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2039 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2040 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2041 int *workI=explicitIdsOldInArr->getPointer();
2042 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2044 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2045 (*itL2)->setLocId(sz2);
2046 (*itL2)->_tmp_work1=(*itL2)->getStart();
2047 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2049 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2051 explicitIdsOldInMesh->reAlloc(sz2);
2052 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2053 ////////////////////
2054 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2055 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2056 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2057 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2059 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2060 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2061 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2063 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2064 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2065 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2067 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2068 int newStart=elt->getLocId();
2069 elt->setLocId((*it)->getGeoType());
2070 elt->setNewStart(newStart);
2071 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2072 entriesKeptNew.push_back(elt);
2073 entriesKeptNew2.push_back(elt);
2075 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2076 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2077 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2078 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2080 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2083 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2085 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2086 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2088 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2089 glob,arr2,otherEntriesNew) || ret;
2093 // Assign new dispatching
2094 assignNewLeaves(otherEntriesNew);
2095 arr->deepCopyFrom(*arr2);
2100 * \param [in,out] globalNum a global numbering counter for the renumbering.
2101 * \param [out] its - list of pair (start,stop) kept
2103 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2105 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2106 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2108 std::vector< std::pair<int,int> > its2;
2109 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2112 its.insert(its.end(),its2.begin(),its2.end());
2119 * \param [in,out] globalNum a global numbering counter for the renumbering.
2120 * \param [out] its - list of pair (start,stop) kept
2122 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2124 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2125 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2127 std::vector< std::pair<int,int> > its2;
2128 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2131 its.insert(its.end(),its2.begin(),its2.end());
2137 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2139 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2140 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2141 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2143 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2144 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2145 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2146 for(;it1!=types.end();it1++,it2++)
2148 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2149 elt->setLeaves((*it1).second);
2152 _field_pm_pt=fieldPmPt;
2155 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2157 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2158 (*it)->changePflsRefsNamesGen(mapOfModif);
2161 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2163 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2164 (*it)->changeLocsRefsNamesGen(mapOfModif);
2168 * \param [in] mesh is the whole mesh
2170 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2172 if(_field_pm_pt.empty())
2173 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2175 std::vector< std::pair<int,int> > dads;
2176 std::vector<const DataArrayInt *> pfls;
2177 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2178 std::vector<int> locs,code;
2179 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2180 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2181 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2183 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2186 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2187 throw INTERP_KERNEL::Exception(oss.str().c_str());
2190 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2191 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2194 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2196 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2199 MCAuto<DataArrayInt> arr2(arr);
2200 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2206 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2210 if(nb!=mesh->getNumberOfNodes())
2212 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2213 oss << " nodes in mesh !";
2214 throw INTERP_KERNEL::Exception(oss.str().c_str());
2216 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2219 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2223 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2225 if(_field_pm_pt.empty())
2226 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2228 std::vector<std::pair<int,int> > dads;
2229 std::vector<const DataArrayInt *> pfls;
2230 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2231 std::vector<int> locs,code;
2232 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2233 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2234 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2236 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2239 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2240 throw INTERP_KERNEL::Exception(oss.str().c_str());
2242 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2243 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2246 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2247 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2252 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2256 if(nb!=mesh->getNumberOfNodes())
2258 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2259 oss << " nodes in mesh !";
2260 throw INTERP_KERNEL::Exception(oss.str().c_str());
2263 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2269 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2273 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2275 (*it)->getSizes(globalSz,nbOfEntries);
2277 entries.resize(nbOfEntries);
2279 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2281 (*it)->fillValues(nbOfEntries,entries);
2285 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2287 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2289 if((*it)->getGeoType()==typ)
2290 return (*it)->getLeafGivenLocId(locId);
2292 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2293 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2294 oss << "Possiblities are : ";
2295 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2297 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2298 oss << "\"" << cm2.getRepr() << "\", ";
2300 throw INTERP_KERNEL::Exception(oss.str().c_str());
2303 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2305 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2307 if((*it)->getGeoType()==typ)
2308 return (*it)->getLeafGivenLocId(locId);
2310 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2311 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2312 oss << "Possiblities are : ";
2313 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2315 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2316 oss << "\"" << cm2.getRepr() << "\", ";
2318 throw INTERP_KERNEL::Exception(oss.str().c_str());
2321 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2324 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2325 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2326 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2328 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2333 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2338 int ret=std::distance(_field_pm_pt.begin(),it2);
2339 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2344 * 'dads' and 'locs' input parameters have the same number of elements
2345 * \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
2347 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2348 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2349 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2352 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2353 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2354 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2355 const std::vector<std::string>& infos=getInfo();
2356 da->setInfoOnComponents(infos);
2358 if(type==ON_GAUSS_PT)
2361 int nbOfArrs=dads.size();
2362 for(int i=0;i<nbOfArrs;i++)
2364 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2365 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2366 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2367 MCAuto<DataArrayInt> di=DataArrayInt::New();
2368 di->alloc(nbOfElems,1);
2370 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2371 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2380 * 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.
2381 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2382 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2383 * The order of cells in the returned field is those imposed by the profile.
2384 * \param [in] mesh is the global mesh.
2386 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2387 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2388 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2389 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2391 if(da->isIota(mesh->getNumberOfCells()))
2392 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2393 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2394 m2->setName(mesh->getName().c_str());
2395 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2401 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2403 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2404 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2405 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2407 if(da->isIota(mesh->getNumberOfNodes()))
2408 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2409 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2410 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2413 if(meshu->getNodalConnectivity()==0)
2415 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2416 int nb=da->getNbOfElems();
2417 const int *ptr=da->getConstPointer();
2418 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2419 meshuc->allocateCells(nb);
2420 for(int i=0;i<nb;i++)
2421 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2422 meshuc->finishInsertingCells();
2423 ret->setMesh(meshuc);
2424 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2425 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2426 disc->checkCoherencyBetween(meshuc,arrOut);
2431 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2433 DataArrayInt *arr2=0;
2434 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2435 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2436 MCAuto<DataArrayInt> arr3(arr2);
2437 int nnodes=mesh2->getNumberOfNodes();
2438 if(nnodes==(int)da->getNbOfElems())
2440 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2441 arrOut->renumberInPlace(da3->getConstPointer());
2442 mesh2->setName(mesh->getName().c_str());
2443 ret->setMesh(mesh2);
2448 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 !!!";
2449 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2450 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2451 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2452 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2453 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2454 throw INTERP_KERNEL::Exception(oss.str().c_str());
2460 * This method is the most light method of field retrieving.
2462 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2466 pflOut=DataArrayInt::New();
2467 pflOut->alloc(nbOfElems,1);
2472 pflOut=const_cast<DataArrayInt*>(pflIn);
2475 MCAuto<DataArrayInt> safePfl(pflOut);
2476 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2477 const std::vector<std::string>& infos=getInfo();
2478 int nbOfComp=infos.size();
2479 for(int i=0;i<nbOfComp;i++)
2480 da->setInfoOnComponent(i,infos[i].c_str());
2491 static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2492 static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2493 virtual ~MFFPMIter() { }
2494 virtual void begin() = 0;
2495 virtual bool finished() const = 0;
2496 virtual void next() = 0;
2497 virtual int current() const = 0;
2500 class MFFPMIterSimple : public MFFPMIter
2503 MFFPMIterSimple():_pos(0) { }
2504 void begin() { _pos=0; }
2505 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2506 void next() { _pos++; }
2507 int current() const { return _pos; }
2512 class MFFPMIter2 : public MFFPMIter
2515 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2516 void begin() { _it=_ids.begin(); }
2517 bool finished() const { return _it==_ids.end(); }
2518 void next() { _it++; }
2519 int current() const { return *_it; }
2521 std::vector<int> _ids;
2522 std::vector<int>::const_iterator _it;
2525 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2528 return new MFFPMIterSimple;
2531 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2532 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2534 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2535 tmp.push_back((*it).second);
2537 return new MFFPMIter2(tmp);
2541 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2547 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2548 if((*it).first==ON_NODES)
2554 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2556 std::size_t sz(cts.size());
2558 for(std::size_t i=0;i<sz;i++)
2560 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2561 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2562 _ids[i]=(int)std::distance(typmai2,loc);
2564 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2570 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),
2573 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2574 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2575 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2576 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2577 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2578 for(iter0->begin();!iter0->finished();iter0->next())
2580 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2581 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2582 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2583 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2584 if(nbProfile>0 || nbProfile2>0)
2586 const PartDefinition *pd(0);
2588 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2589 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2596 if(MFFPMIter::IsPresenceOfNode(entities))
2598 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2601 const PartDefinition *pd(0);
2603 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2604 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2605 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2610 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2612 copyTinyInfoFrom(mesh);
2615 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2617 if(id>=(int)_pfls.size())
2619 _pfls[id]=DataArrayInt::New();
2620 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2621 _pfls[id]->setName(pflName);
2622 _pfls[id]->alloc(lgth,1);
2623 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2624 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2627 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2629 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2631 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2632 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2633 if(i>=(int)_pfls.size())
2635 _pfls[i]=DataArrayInt::New();
2636 _pfls[i]->alloc(sz,1);
2637 _pfls[i]->setName(pflCpp.c_str());
2638 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2639 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2642 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2644 int nbOfPfls=_pfls.size();
2645 for(int i=0;i<nbOfPfls;i++)
2647 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2648 cpy->applyLin(1,1,0);
2649 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2650 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2651 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2654 int nbOfLocs=_locs.size();
2655 for(int i=0;i<nbOfLocs;i++)
2656 _locs[i]->writeLL(fid);
2659 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2661 std::vector<std::string> pfls=getPfls();
2662 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2664 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2667 _pfls.push_back(*it);
2671 int id=std::distance(pfls.begin(),it2);
2672 if(!(*it)->isEqual(*_pfls[id]))
2674 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2675 throw INTERP_KERNEL::Exception(oss.str().c_str());
2679 std::vector<std::string> locs=getLocs();
2680 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2682 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2685 _locs.push_back(*it);
2689 int id=std::distance(locs.begin(),it2);
2690 if(!(*it)->isEqual(*_locs[id],eps))
2692 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2693 throw INTERP_KERNEL::Exception(oss.str().c_str());
2699 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2701 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2702 getProfile((*it).c_str());
2705 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2707 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2708 getLocalization((*it).c_str());
2711 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2713 std::vector<std::string> profiles=real.getPflsReallyUsed();
2714 int sz=profiles.size();
2716 for(int i=0;i<sz;i++)
2717 loadProfileInFile(fid,i,profiles[i].c_str());
2719 std::vector<std::string> locs=real.getLocsReallyUsed();
2722 for(int i=0;i<sz;i++)
2723 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2726 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2728 int nProfil=MEDnProfile(fid);
2729 for(int i=0;i<nProfil;i++)
2730 loadProfileInFile(fid,i);
2731 int sz=MEDnLocalization(fid);
2733 for(int i=0;i<sz;i++)
2735 _locs[i]=MEDFileFieldLoc::New(fid,i);
2739 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2741 return new MEDFileFieldGlobs(fname);
2744 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2746 return new MEDFileFieldGlobs;
2749 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2751 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2754 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2756 std::vector<const BigMemoryObject *> ret;
2757 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2758 ret.push_back((const DataArrayInt *)*it);
2759 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2760 ret.push_back((const MEDFileFieldLoc *)*it);
2764 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2766 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2768 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2770 if((const DataArrayInt *)*it)
2771 ret->_pfls[i]=(*it)->deepCopy();
2774 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2776 if((const MEDFileFieldLoc*)*it)
2777 ret->_locs[i]=(*it)->deepCopy();
2783 * \throw if a profile in \a pfls in not in \a this.
2784 * \throw if a localization in \a locs in not in \a this.
2785 * \sa MEDFileFieldGlobs::deepCpyPart
2787 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2789 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2790 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2792 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2794 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2796 MCAuto<DataArrayInt> pfl2(pfl);
2797 ret->_pfls.push_back(pfl2);
2799 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2801 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2803 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2805 MCAuto<MEDFileFieldLoc> loc2(loc);
2806 ret->_locs.push_back(loc2);
2808 ret->setFileName(getFileName());
2813 * \throw if a profile in \a pfls in not in \a this.
2814 * \throw if a localization in \a locs in not in \a this.
2815 * \sa MEDFileFieldGlobs::shallowCpyPart
2817 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2819 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2820 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2822 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2824 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2825 ret->_pfls.push_back(pfl->deepCopy());
2827 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2829 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2831 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2832 ret->_locs.push_back(loc->deepCopy());
2834 ret->setFileName(getFileName());
2838 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2842 MEDFileFieldGlobs::MEDFileFieldGlobs()
2846 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2850 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2852 oss << "Profiles :\n";
2853 std::size_t n=_pfls.size();
2854 for(std::size_t i=0;i<n;i++)
2856 oss << " - #" << i << " ";
2857 const DataArrayInt *pfl=_pfls[i];
2859 oss << "\"" << pfl->getName() << "\"\n";
2864 oss << "Localizations :\n";
2865 for(std::size_t i=0;i<n;i++)
2867 oss << " - #" << i << " ";
2868 const MEDFileFieldLoc *loc=_locs[i];
2870 loc->simpleRepr(oss);
2876 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2878 _file_name=fileName;
2881 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2883 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2885 DataArrayInt *elt(*it);
2888 std::string name(elt->getName());
2889 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2891 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2893 elt->setName((*it2).second.c_str());
2901 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2903 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2905 MEDFileFieldLoc *elt(*it);
2908 std::string name(elt->getName());
2909 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2911 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2913 elt->setName((*it2).second.c_str());
2921 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2923 if(locId<0 || locId>=(int)_locs.size())
2924 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2925 return _locs[locId]->getNbOfGaussPtPerCell();
2928 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2930 return getLocalizationFromId(getLocalizationId(locName));
2933 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2935 if(locId<0 || locId>=(int)_locs.size())
2936 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2937 return *_locs[locId];
2941 namespace MEDCouplingImpl
2946 LocFinder(const std::string& loc):_loc(loc) { }
2947 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2949 const std::string &_loc;
2955 PflFinder(const std::string& pfl):_pfl(pfl) { }
2956 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2958 const std::string& _pfl;
2963 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2965 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
2968 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2969 for(it=_locs.begin();it!=_locs.end();it++)
2970 oss << "\"" << (*it)->getName() << "\", ";
2971 throw INTERP_KERNEL::Exception(oss.str().c_str());
2973 return std::distance(_locs.begin(),it);
2977 * The returned value is never null.
2979 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2981 std::string pflNameCpp(pflName);
2982 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
2985 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2986 for(it=_pfls.begin();it!=_pfls.end();it++)
2987 oss << "\"" << (*it)->getName() << "\", ";
2988 throw INTERP_KERNEL::Exception(oss.str().c_str());
2993 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
2995 if(pflId<0 || pflId>=(int)_pfls.size())
2996 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
2997 return _pfls[pflId];
3000 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3002 if(locId<0 || locId>=(int)_locs.size())
3003 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3004 return *_locs[locId];
3007 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3009 return getLocalizationFromId(getLocalizationId(locName));
3013 * The returned value is never null.
3015 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3017 std::string pflNameCpp(pflName);
3018 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3021 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3022 for(it=_pfls.begin();it!=_pfls.end();it++)
3023 oss << "\"" << (*it)->getName() << "\", ";
3024 throw INTERP_KERNEL::Exception(oss.str().c_str());
3029 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3031 if(pflId<0 || pflId>=(int)_pfls.size())
3032 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3033 return _pfls[pflId];
3036 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3038 std::vector< MCAuto<DataArrayInt> > newPfls;
3040 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3042 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3043 newPfls.push_back(*it);
3048 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3050 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3052 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3054 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3055 newLocs.push_back(*it);
3060 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3062 int sz=_pfls.size();
3063 std::vector<std::string> ret(sz);
3064 for(int i=0;i<sz;i++)
3065 ret[i]=_pfls[i]->getName();
3069 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3071 int sz=_locs.size();
3072 std::vector<std::string> ret(sz);
3073 for(int i=0;i<sz;i++)
3074 ret[i]=_locs[i]->getName();
3078 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3080 std::vector<std::string> v=getPfls();
3081 std::string s(pflName);
3082 return std::find(v.begin(),v.end(),s)!=v.end();
3085 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3087 std::vector<std::string> v=getLocs();
3088 std::string s(locName);
3089 return std::find(v.begin(),v.end(),s)!=v.end();
3092 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3094 std::map<int,std::vector<int> > m;
3096 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3098 const DataArrayInt *tmp=(*it);
3101 m[tmp->getHashCode()].push_back(i);
3104 std::vector< std::vector<int> > ret;
3105 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3107 if((*it2).second.size()>1)
3109 std::vector<int> ret0;
3110 bool equalityOrNot=false;
3111 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3113 std::vector<int>::const_iterator it4=it3; it4++;
3114 for(;it4!=(*it2).second.end();it4++)
3116 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3119 ret0.push_back(*it3);
3120 ret0.push_back(*it4);
3126 ret.push_back(ret0);
3132 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3134 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3137 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3139 std::string name(pfl->getName());
3141 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3142 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3143 if(name==(*it)->getName())
3145 if(!pfl->isEqual(*(*it)))
3147 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3148 throw INTERP_KERNEL::Exception(oss.str().c_str());
3152 _pfls.push_back(pfl);
3155 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)
3157 std::string name(locName);
3159 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3160 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3161 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3162 if((*it)->isName(locName))
3164 if(!(*it)->isEqual(*obj,1e-12))
3166 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3167 throw INTERP_KERNEL::Exception(oss.str().c_str());
3170 _locs.push_back(obj);
3173 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3175 std::vector<std::string> names=getPfls();
3176 return CreateNewNameNotIn("NewPfl_",names);
3179 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3181 std::vector<std::string> names=getLocs();
3182 return CreateNewNameNotIn("NewLoc_",names);
3185 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3187 for(std::size_t sz=0;sz<100000;sz++)
3189 std::ostringstream tryName;
3190 tryName << prefix << sz;
3191 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3192 return tryName.str();
3194 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3198 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3199 * \param [in] fname - the file name.
3201 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3206 * Creates an empty MEDFileFieldGlobsReal.
3208 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3212 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3217 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3219 std::vector<const BigMemoryObject *> ret;
3220 ret.push_back((const MEDFileFieldGlobs *)_globals);
3225 * Returns a string describing profiles and Gauss points held in \a this.
3226 * \return std::string - the description string.
3228 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3230 const MEDFileFieldGlobs *glob=_globals;
3231 std::ostringstream oss2; oss2 << glob;
3232 std::string stars(oss2.str().length(),'*');
3233 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3235 glob->simpleRepr(oss);
3237 oss << "NO GLOBAL INFORMATION !\n";
3240 void MEDFileFieldGlobsReal::resetContent()
3242 _globals=MEDFileFieldGlobs::New();
3245 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3250 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3251 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3253 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3255 _globals=other._globals;
3259 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3260 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3262 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3264 const MEDFileFieldGlobs *otherg(other._globals);
3267 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3271 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3272 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3274 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3276 const MEDFileFieldGlobs *otherg(other._globals);
3279 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3282 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3284 _globals=other._globals;
3285 if((const MEDFileFieldGlobs *)_globals)
3286 _globals=other._globals->deepCopy();
3290 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3291 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3292 * \param [in] eps - a precision used to compare Gauss points with same name held by
3293 * \a this and \a other MEDFileFieldGlobsReal.
3294 * \throw If \a this and \a other hold profiles with equal names but different ids.
3295 * \throw If \a this and \a other hold different Gauss points with equal names.
3297 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3299 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3300 if(thisGlobals==otherGlobals)
3304 _globals=other._globals;
3307 _globals->appendGlobs(*other._globals,eps);
3310 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3312 checkGlobsPflsPartCoherency();
3313 checkGlobsLocsPartCoherency();
3316 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3318 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3321 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3323 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3326 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3328 contentNotNull()->loadProfileInFile(fid,id,pflName);
3331 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3333 contentNotNull()->loadProfileInFile(fid,id);
3336 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3338 contentNotNull()->loadGlobals(fid,*this);
3341 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3343 contentNotNull()->loadAllGlobals(fid);
3346 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3348 contentNotNull()->writeGlobals(fid,opt);
3352 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3353 * or getPflsReallyUsedMulti().
3354 * \return std::vector<std::string> - a sequence of names of all profiles.
3356 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3358 return contentNotNull()->getPfls();
3362 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3363 * or getLocsReallyUsedMulti().
3364 * \return std::vector<std::string> - a sequence of names of all localizations.
3366 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3368 return contentNotNull()->getLocs();
3372 * Checks if the profile with a given name exists.
3373 * \param [in] pflName - the profile name of interest.
3374 * \return bool - \c true if the profile named \a pflName exists.
3376 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3378 return contentNotNull()->existsPfl(pflName);
3382 * Checks if the localization with a given name exists.
3383 * \param [in] locName - the localization name of interest.
3384 * \return bool - \c true if the localization named \a locName exists.
3386 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3388 return contentNotNull()->existsLoc(locName);
3391 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3393 return contentNotNull()->createNewNameOfPfl();
3396 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3398 return contentNotNull()->createNewNameOfLoc();
3402 * Sets the name of a MED file.
3403 * \param [inout] fileName - the file name.
3405 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3407 contentNotNull()->setFileName(fileName);
3411 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3412 * in the same order.
3413 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3414 * Each item of this sequence is a vector containing ids of equal profiles.
3416 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3418 return contentNotNull()->whichAreEqualProfiles();
3422 * Finds equal localizations.
3423 * \param [in] eps - a precision used to compare real values of the localizations.
3424 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3425 * Each item of this sequence is a vector containing ids of equal localizations.
3427 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3429 return contentNotNull()->whichAreEqualLocs(eps);
3433 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3434 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3435 * this sequence is a pair whose
3436 * - the first item is a vector of profile names to replace by the second item,
3437 * - the second item is a profile name to replace every profile name of the first item.
3439 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3441 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3445 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3446 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3447 * this sequence is a pair whose
3448 * - the first item is a vector of localization names to replace by the second item,
3449 * - the second item is a localization name to replace every localization name of the first item.
3451 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3453 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3457 * Replaces references to some profiles (a reference is a profile name) by references
3458 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3459 * them-selves accordingly. <br>
3460 * This method is a generalization of changePflName().
3461 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3462 * this sequence is a pair whose
3463 * - the first item is a vector of profile names to replace by the second item,
3464 * - the second item is a profile name to replace every profile of the first item.
3465 * \sa changePflsRefsNamesGen()
3466 * \sa changePflName()
3468 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3470 changePflsRefsNamesGen(mapOfModif);
3471 changePflsNamesInStruct(mapOfModif);
3475 * Replaces references to some localizations (a reference is a localization name) by references
3476 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3477 * them-selves accordingly. <br>
3478 * This method is a generalization of changeLocName().
3479 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3480 * this sequence is a pair whose
3481 * - the first item is a vector of localization names to replace by the second item,
3482 * - the second item is a localization name to replace every localization of the first item.
3483 * \sa changeLocsRefsNamesGen()
3484 * \sa changeLocName()
3486 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3488 changeLocsRefsNamesGen(mapOfModif);
3489 changeLocsNamesInStruct(mapOfModif);
3493 * Renames the profile having a given name and updates references to this profile.
3494 * \param [in] oldName - the name of the profile to rename.
3495 * \param [in] newName - a new name of the profile.
3496 * \sa changePflsNames().
3498 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3500 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3501 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3503 changePflsNames(mapOfModif);
3507 * Renames the localization having a given name and updates references to this localization.
3508 * \param [in] oldName - the name of the localization to rename.
3509 * \param [in] newName - a new name of the localization.
3510 * \sa changeLocsNames().
3512 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3514 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3515 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3517 changeLocsNames(mapOfModif);
3521 * Removes duplicated profiles. Returns a map used to update references to removed
3522 * profiles via changePflsRefsNamesGen().
3523 * Equal profiles are found using whichAreEqualProfiles().
3524 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3525 * a sequence describing the performed replacements of profiles. Each element of
3526 * this sequence is a pair whose
3527 * - the first item is a vector of profile names replaced by the second item,
3528 * - the second item is a profile name replacing every profile of the first item.
3530 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3532 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3533 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3535 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3537 std::vector< std::string > tmp((*it).size());
3539 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3540 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3541 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3543 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3544 killProfileIds(tmp2);
3546 changePflsRefsNamesGen(ret);
3551 * Removes duplicated localizations. Returns a map used to update references to removed
3552 * localizations via changeLocsRefsNamesGen().
3553 * Equal localizations are found using whichAreEqualLocs().
3554 * \param [in] eps - a precision used to compare real values of the localizations.
3555 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3556 * a sequence describing the performed replacements of localizations. Each element of
3557 * this sequence is a pair whose
3558 * - the first item is a vector of localization names replaced by the second item,
3559 * - the second item is a localization name replacing every localization of the first item.
3561 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3563 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3564 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3566 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3568 std::vector< std::string > tmp((*it).size());
3570 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3571 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3572 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3574 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3575 killLocalizationIds(tmp2);
3577 changeLocsRefsNamesGen(ret);
3582 * Returns number of Gauss points per cell in a given localization.
3583 * \param [in] locId - an id of the localization of interest.
3584 * \return int - the number of the Gauss points per cell.
3586 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3588 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3592 * Returns an id of a localization by its name.
3593 * \param [in] loc - the localization name of interest.
3594 * \return int - the id of the localization.
3595 * \throw If there is no a localization named \a loc.
3597 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3599 return contentNotNull()->getLocalizationId(loc);
3603 * Returns the name of the MED file.
3604 * \return const std::string& - the MED file name.
3606 std::string MEDFileFieldGlobsReal::getFileName() const
3608 return contentNotNull()->getFileName();
3612 * Returns a localization object by its name.
3613 * \param [in] locName - the name of the localization of interest.
3614 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3615 * \throw If there is no a localization named \a locName.
3617 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3619 return contentNotNull()->getLocalization(locName);
3623 * Returns a localization object by its id.
3624 * \param [in] locId - the id of the localization of interest.
3625 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3626 * \throw If there is no a localization with id \a locId.
3628 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3630 return contentNotNull()->getLocalizationFromId(locId);
3634 * Returns a profile array by its name.
3635 * \param [in] pflName - the name of the profile of interest.
3636 * \return const DataArrayInt * - the profile array having the name \a pflName.
3637 * \throw If there is no a profile named \a pflName.
3639 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3641 return contentNotNull()->getProfile(pflName);
3645 * Returns a profile array by its id.
3646 * \param [in] pflId - the id of the profile of interest.
3647 * \return const DataArrayInt * - the profile array having the id \a pflId.
3648 * \throw If there is no a profile with id \a pflId.
3650 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3652 return contentNotNull()->getProfileFromId(pflId);
3656 * Returns a localization object, apt for modification, by its id.
3657 * \param [in] locId - the id of the localization of interest.
3658 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3659 * having the id \a locId.
3660 * \throw If there is no a localization with id \a locId.
3662 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3664 return contentNotNull()->getLocalizationFromId(locId);
3668 * Returns a localization object, apt for modification, by its name.
3669 * \param [in] locName - the name of the localization of interest.
3670 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3671 * having the name \a locName.
3672 * \throw If there is no a localization named \a locName.
3674 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3676 return contentNotNull()->getLocalization(locName);
3680 * Returns a profile array, apt for modification, by its name.
3681 * \param [in] pflName - the name of the profile of interest.
3682 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3683 * \throw If there is no a profile named \a pflName.
3685 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3687 return contentNotNull()->getProfile(pflName);
3691 * Returns a profile array, apt for modification, by its id.
3692 * \param [in] pflId - the id of the profile of interest.
3693 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3694 * \throw If there is no a profile with id \a pflId.
3696 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3698 return contentNotNull()->getProfileFromId(pflId);
3702 * Removes profiles given by their ids. No data is updated to track this removal.
3703 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3705 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3707 contentNotNull()->killProfileIds(pflIds);
3711 * Removes localizations given by their ids. No data is updated to track this removal.
3712 * \param [in] locIds - a sequence of ids of the localizations to remove.
3714 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3716 contentNotNull()->killLocalizationIds(locIds);
3720 * Stores a profile array.
3721 * \param [in] pfl - the profile array to store.
3722 * \throw If the name of \a pfl is empty.
3723 * \throw If a profile with the same name as that of \a pfl already exists but contains
3726 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3728 contentNotNull()->appendProfile(pfl);
3732 * Adds a new localization of Gauss points.
3733 * \param [in] locName - the name of the new localization.
3734 * \param [in] geoType - a geometrical type of the reference cell.
3735 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3736 * must be \c nbOfNodesPerCell * \c dimOfType.
3737 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3738 * must be _wg_.size() * \c dimOfType.
3739 * \param [in] w - the weights of Gauss points.
3740 * \throw If \a locName is empty.
3741 * \throw If a localization with the name \a locName already exists but is
3742 * different form the new one.
3744 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)
3746 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3749 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3751 MEDFileFieldGlobs *g(_globals);
3753 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3757 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3759 const MEDFileFieldGlobs *g(_globals);
3761 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3765 //= MEDFileFieldNameScope
3767 MEDFileFieldNameScope::MEDFileFieldNameScope()
3771 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3776 * Returns the name of \a this field.
3777 * \return std::string - a string containing the field name.
3779 std::string MEDFileFieldNameScope::getName() const
3785 * Sets name of \a this field
3786 * \param [in] name - the new field name.
3788 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3793 std::string MEDFileFieldNameScope::getDtUnit() const
3798 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3803 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3806 _dt_unit=other._dt_unit;
3809 //= MEDFileAnyTypeField1TSWithoutSDA
3811 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3813 _field_per_mesh.resize(other._field_per_mesh.size());
3815 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3817 if((const MEDFileFieldPerMesh *)*it)
3818 _field_per_mesh[i]=(*it)->deepCopy(this);
3823 * Prints a string describing \a this field into a stream. This string is outputted
3824 * by \c print Python command.
3825 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3826 * \param [in,out] oss - the out stream.
3827 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3828 * info id printed, else, not.
3830 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3832 std::string startOfLine(bkOffset,' ');
3833 oss << startOfLine << "Field ";
3835 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3836 oss << "on one time Step ";
3838 oss << "(" << f1tsId << ") ";
3839 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3840 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3841 const DataArray *arr=getUndergroundDataArray();
3844 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3847 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3848 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3849 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3851 if(arr->isAllocated())
3853 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3856 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3860 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3862 oss << startOfLine << "----------------------" << std::endl;
3863 if(!_field_per_mesh.empty())
3866 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3868 const MEDFileFieldPerMesh *cur=(*it2);
3870 cur->simpleRepr(bkOffset,oss,i);
3872 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3877 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3879 oss << startOfLine << "----------------------" << std::endl;
3882 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3884 const DataArray *arr(getUndergroundDataArray());
3886 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3887 int nbOfCompo=arr->getNumberOfComponents();
3888 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3889 for(int i=0;i<nbOfCompo;i++)
3892 std::vector<int> v(1,i);
3893 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
3894 ret[i]->setArray(arr2);
3899 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)
3903 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3908 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3909 * empty. Returns -1 if this in on nodes.
3910 * \return int - the dimension of \a this.
3912 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3915 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3916 (*it)->getDimension(ret);
3921 * Returns the mesh name.
3922 * \return std::string - a string holding the mesh name.
3923 * \throw If \c _field_per_mesh.empty()
3925 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3927 if(_field_per_mesh.empty())
3928 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3929 return _field_per_mesh[0]->getMeshName();
3932 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3934 std::string oldName(getMeshName());
3935 std::vector< std::pair<std::string,std::string> > v(1);
3936 v[0].first=oldName; v[0].second=newMeshName;
3940 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3943 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3945 MEDFileFieldPerMesh *cur(*it);
3947 ret=cur->changeMeshNames(modifTab) || ret;
3953 * Returns the number of iteration of the state of underlying mesh.
3954 * \return int - the iteration number.
3955 * \throw If \c _field_per_mesh.empty()
3957 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3959 if(_field_per_mesh.empty())
3960 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3961 return _field_per_mesh[0]->getMeshIteration();
3965 * Returns the order number of iteration of the state of underlying mesh.
3966 * \return int - the order number.
3967 * \throw If \c _field_per_mesh.empty()
3969 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3971 if(_field_per_mesh.empty())
3972 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3973 return _field_per_mesh[0]->getMeshOrder();
3977 * Checks if \a this field is tagged by a given iteration number and a given
3978 * iteration order number.
3979 * \param [in] iteration - the iteration number of interest.
3980 * \param [in] order - the iteration order number of interest.
3981 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3982 * \a this->getOrder() == \a order.
3984 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3986 return iteration==_iteration && order==_order;
3990 * Returns number of iteration and order number of iteration when
3991 * \a this field has been calculated.
3992 * \return std::pair<int,int> - a pair of the iteration number and the iteration
3995 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
3997 std::pair<int,int> p;
4003 * Returns number of iteration and order number of iteration when
4004 * \a this field has been calculated.
4005 * \param [in,out] p - a pair returning the iteration number and the iteration
4008 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4015 * Returns all types of spatial discretization of \a this field.
4016 * \param [in,out] types - a sequence of types of \a this field.
4018 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4020 std::set<TypeOfField> types2;
4021 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4023 (*it)->fillTypesOfFieldAvailable(types2);
4025 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4026 std::copy(types2.begin(),types2.end(),bi);
4030 * Returns all types of spatial discretization of \a this field.
4031 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4034 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4036 std::vector<TypeOfField> ret;
4037 fillTypesOfFieldAvailable(ret);
4041 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4043 std::vector<std::string> ret;
4044 std::set<std::string> ret2;
4045 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4047 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4048 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4049 if(ret2.find(*it2)==ret2.end())
4051 ret.push_back(*it2);
4058 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4060 std::vector<std::string> ret;
4061 std::set<std::string> ret2;
4062 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4064 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4065 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4066 if(ret2.find(*it2)==ret2.end())
4068 ret.push_back(*it2);
4075 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4077 std::vector<std::string> ret;
4078 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4080 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4081 ret.insert(ret.end(),tmp.begin(),tmp.end());
4086 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4088 std::vector<std::string> ret;
4089 std::set<std::string> ret2;
4090 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4092 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4093 ret.insert(ret.end(),tmp.begin(),tmp.end());
4098 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4100 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4101 (*it)->changePflsRefsNamesGen(mapOfModif);
4104 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4106 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4107 (*it)->changeLocsRefsNamesGen(mapOfModif);
4111 * Returns all attributes of parts of \a this field lying on a given mesh.
4112 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4113 * item of every of returned sequences refers to the _i_-th part of \a this field.
4114 * Thus all sequences returned by this method are of the same length equal to number
4115 * of different types of supporting entities.<br>
4116 * A field part can include sub-parts with several different spatial discretizations,
4117 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4118 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4119 * of a nested sequence corresponds to a type of spatial discretization.<br>
4120 * This method allows for iteration over MEDFile DataStructure without any overhead.
4121 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4122 * for the case with only one underlying mesh. (Actually, the number of meshes is
4123 * not checked if \a mname == \c NULL).
4124 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4125 * a field part is returned.
4126 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4127 * This sequence is of the same length as \a types.
4128 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4129 * discretization. A profile name can be empty.
4130 * Length of this and of nested sequences is the same as that of \a typesF.
4131 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4132 * discretization. A localization name can be empty.
4133 * Length of this and of nested sequences is the same as that of \a typesF.
4134 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4135 * of ids of tuples within the data array, per each type of spatial
4136 * discretization within one mesh entity type.
4137 * Length of this and of nested sequences is the same as that of \a typesF.
4138 * \throw If no field is lying on \a mname.
4140 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
4144 meshId=getMeshIdFromMeshName(mname);
4146 if(_field_per_mesh.empty())
4147 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4148 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4152 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4153 * maximal absolute dimension and values returned via the out parameter \a levs are
4154 * dimensions relative to the maximal absolute dimension. <br>
4155 * This method is designed for MEDFileField1TS instances that have a discretization
4156 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4157 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4158 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4159 * Only these 3 discretizations will be taken into account here. If \a this is
4160 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4161 * This method is useful to make the link between the dimension of the underlying mesh
4162 * and the levels of \a this, because it is possible that the highest dimension of \a this
4163 * field is not equal to the dimension of the underlying mesh.
4165 * Let's consider the following case:
4166 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4167 * TETRA4, HEXA8, TRI3 and SEG2.
4168 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4169 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4171 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4172 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4173 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4174 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4175 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4176 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4178 * to retrieve the highest level of
4179 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4180 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4181 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4182 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4183 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4184 * for the case with only one underlying mesh. (Actually, the number of meshes is
4185 * not checked if \a mname == \c NULL).
4186 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4187 * absolute one. They are in decreasing order. This sequence is cleared before
4189 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4190 * \throw If no field is lying on \a mname.
4192 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4195 int meshId=getMeshIdFromMeshName(mname);
4196 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4197 std::vector< std::vector<TypeOfField> > typesF;
4198 std::vector< std::vector<std::string> > pfls, locs;
4199 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4201 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4202 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4203 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4205 st.erase(INTERP_KERNEL::NORM_ERROR);
4207 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4209 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4210 ret1.insert((int)cm.getDimension());
4212 int ret=*std::max_element(ret1.begin(),ret1.end());
4213 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4214 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4219 * \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.
4220 * \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.
4221 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4222 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4224 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4226 int mid=getMeshIdFromMeshName(mName);
4227 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4231 * \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.
4232 * \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.
4233 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4234 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4236 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4238 int mid=getMeshIdFromMeshName(mName);
4239 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4243 * \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.
4245 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4247 if(_field_per_mesh.empty())
4248 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4251 std::string mName2(mName);
4253 std::vector<std::string> msg;
4254 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4255 if(mName2==(*it)->getMeshName())
4258 msg.push_back((*it)->getMeshName());
4259 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4260 oss << "Possible meshes are : ";
4261 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4262 oss << "\"" << (*it2) << "\" ";
4263 throw INTERP_KERNEL::Exception(oss.str().c_str());
4266 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4269 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4270 std::string tmp(mesh->getName());
4272 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4273 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4275 for(;it!=_field_per_mesh.end();it++,i++)
4277 if((*it)->getMeshName()==tmp)
4280 int sz=_field_per_mesh.size();
4281 _field_per_mesh.resize(sz+1);
4282 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4286 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4287 MEDFileFieldGlobsReal& glob)
4290 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4292 MEDFileFieldPerMesh *fpm(*it);
4294 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4300 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4301 * splitting that leads to single spatial discretization of this.
4303 * \sa splitMultiDiscrPerGeoTypes
4305 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4307 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4308 std::vector< std::vector<TypeOfField> > typesF;
4309 std::vector< std::vector<std::string> > pfls,locs;
4310 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4311 std::set<TypeOfField> allEnt;
4312 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4313 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4314 allEnt.insert(*it2);
4315 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4316 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4317 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4319 std::vector< std::pair<int,int> > its;
4320 ret[i]=shallowCpy();
4321 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4322 ret[i]->updateData(newLgth,its);
4328 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4329 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4331 * \sa splitDiscretizations
4333 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4335 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4336 std::vector< std::vector<TypeOfField> > typesF;
4337 std::vector< std::vector<std::string> > pfls,locs;
4338 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4339 std::set<TypeOfField> allEnt;
4340 std::size_t nbOfMDPGT(0),ii(0);
4341 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4343 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4344 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4345 allEnt.insert(*it2);
4347 if(allEnt.size()!=1)
4348 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4350 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4353 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4354 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4357 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4358 for(std::size_t i=0;i<nbOfMDPGT;i++)
4360 std::vector< std::pair<int,int> > its;
4361 ret[i]=shallowCpy();
4362 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4363 ret[i]->updateData(newLgth,its);
4368 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4370 int globalCounter(0);
4371 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4372 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4373 return globalCounter;
4376 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4378 int globalCounter(0);
4379 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4380 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4381 return globalCounter;
4384 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4386 if(_nb_of_tuples_to_be_allocated>=0)
4388 _nb_of_tuples_to_be_allocated=newLgth;
4389 const DataArray *oldArr(getUndergroundDataArray());
4392 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4393 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4395 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4399 if(_nb_of_tuples_to_be_allocated==-1)
4401 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4403 const DataArray *oldArr(getUndergroundDataArray());
4404 if(!oldArr || !oldArr->isAllocated())
4405 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4406 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4407 newArr->alloc(newLgth,getNumberOfComponents());
4409 newArr->copyStringInfoFrom(*oldArr);
4411 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4413 if((*it).second<(*it).first)
4414 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4415 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4416 pos+=(*it).second-(*it).first;
4421 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4424 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4426 if(_field_per_mesh.empty())
4427 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4428 if(_field_per_mesh.size()>1)
4429 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4430 _field_per_mesh[0]->copyOptionsFrom(opts);
4431 _field_per_mesh[0]->writeLL(fid,nasc);
4435 * 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.
4436 * If false is returned the memory allocation is not required.
4438 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4440 if(_nb_of_tuples_to_be_allocated>=0)
4442 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4443 _nb_of_tuples_to_be_allocated=-2;
4446 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4448 if(_nb_of_tuples_to_be_allocated==-1)
4449 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4450 if(_nb_of_tuples_to_be_allocated<-3)
4451 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4452 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4455 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4457 med_int numdt,numit;
4461 med_int meshnumdt,meshnumit;
4462 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4463 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4464 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4465 if(_iteration!=numdt || _order!=numit)
4466 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4467 _field_per_mesh.resize(nmesh);
4472 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4473 mm=ms->getMeshWithName(meshNameCpp);
4476 for(int i=0;i<nmesh;i++)
4477 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4478 _nb_of_tuples_to_be_allocated=0;
4479 for(int i=0;i<nmesh;i++)
4480 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4483 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4485 allocIfNecessaryTheArrayToReceiveDataFromFile();
4486 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4487 (*it)->loadBigArraysRecursively(fid,nasc);
4490 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4492 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4493 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4494 (*it)->loadBigArraysRecursively(fid,nasc);
4497 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4499 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4500 loadBigArraysRecursively(fid,nasc);
4503 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4505 DataArray *thisArr(getUndergroundDataArray());
4506 if(thisArr && thisArr->isAllocated())
4508 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4509 thisArr->desallocate();
4513 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4515 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4518 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4520 std::vector<const BigMemoryObject *> ret;
4521 if(getUndergroundDataArray())
4522 ret.push_back(getUndergroundDataArray());
4523 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4524 ret.push_back((const MEDFileFieldPerMesh *)*it);
4529 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4530 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4531 * "Sort By Type"), if not, an exception is thrown.
4532 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4533 * \param [in] arr - the array of values.
4534 * \param [in,out] glob - the global data where profiles and localization present in
4535 * \a field, if any, are added.
4536 * \throw If the name of \a field is empty.
4537 * \throw If the data array of \a field is not set.
4538 * \throw If \a this->_arr is already allocated but has different number of components
4540 * \throw If the underlying mesh of \a field has no name.
4541 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4543 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4545 const MEDCouplingMesh *mesh=field->getMesh();
4547 TypeOfField type=field->getTypeOfField();
4548 std::vector<DataArrayInt *> dummy;
4549 int start=copyTinyInfoFrom(field,arr);
4550 int pos=addNewEntryIfNecessary(mesh);
4553 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4554 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4557 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4561 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4562 * of a given mesh are used as the support of the given field (a real support is not used).
4563 * Elements of the given mesh must be sorted suitable for writing to MED file.
4564 * Order of underlying mesh entities of the given field specified by \a profile parameter
4565 * is not prescribed; this method permutes field values to have them sorted by element
4566 * type as required for writing to MED file. A new profile is added only if no equal
4567 * profile is missing.
4568 * \param [in] field - the field to add to \a this. The field double values are ignored.
4569 * \param [in] arrOfVals - the values of the field \a field used.
4570 * \param [in] mesh - the supporting mesh of \a field.
4571 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4572 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4573 * \param [in,out] glob - the global data where profiles and localization present in
4574 * \a field, if any, are added.
4575 * \throw If either \a field or \a mesh or \a profile has an empty name.
4576 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4577 * \throw If the data array of \a field is not set.
4578 * \throw If \a this->_arr is already allocated but has different number of components
4580 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4581 * \sa setFieldNoProfileSBT()
4583 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4586 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4587 if(!arrOfVals || !arrOfVals->isAllocated())
4588 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4589 TypeOfField type=field->getTypeOfField();
4590 std::vector<DataArrayInt *> idsInPflPerType;
4591 std::vector<DataArrayInt *> idsPerType;
4592 std::vector<int> code,code2;
4593 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4596 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4597 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4598 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4599 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4601 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4602 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4603 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4605 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4606 throw INTERP_KERNEL::Exception(oss.str().c_str());
4609 int start=copyTinyInfoFrom(field,arrOfVals);
4610 code2=m->getDistributionOfTypes();
4612 int pos=addNewEntryIfNecessary(m);
4613 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4617 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4618 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4619 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4620 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4621 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4622 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4624 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4625 throw INTERP_KERNEL::Exception(oss.str().c_str());
4627 int start=copyTinyInfoFrom(field,arrOfVals);
4628 int pos=addNewEntryIfNecessary(m);
4629 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4634 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4636 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4638 if(_nb_of_tuples_to_be_allocated>=0)
4639 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 !");
4640 DataArray *arr(getOrCreateAndGetArray());
4641 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4642 _nb_of_tuples_to_be_allocated=-3;
4646 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4647 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4648 * larger by the size of \a field. Returns an id of the first not filled
4649 * tuple of \a this->_arr.
4650 * \param [in] field - the field to copy the info on components and the name from.
4651 * \return int - the id of first not initialized tuple of \a this->_arr.
4652 * \throw If the name of \a field is empty.
4653 * \throw If the data array of \a field is not set.
4654 * \throw If \a this->_arr is already allocated but has different number of components
4657 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4660 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4661 std::string name(field->getName());
4662 setName(name.c_str());
4663 setDtUnit(field->getTimeUnit());
4665 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4667 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4668 if(!arr->isAllocated())
4669 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4670 _dt=field->getTime(_iteration,_order);
4671 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4672 if(!getOrCreateAndGetArray()->isAllocated())
4674 allocNotFromFile(arr->getNumberOfTuples());
4679 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4680 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4681 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4682 _nb_of_tuples_to_be_allocated=-3;
4683 return oldNbOfTuples;
4688 * Returns number of components in \a this field
4689 * \return int - the number of components.
4691 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4693 return getOrCreateAndGetArray()->getNumberOfComponents();
4697 * Change info on components in \a this.
4698 * \throw If size of \a infos is not equal to the number of components already in \a this.
4700 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4702 DataArray *arr=getOrCreateAndGetArray();
4703 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4707 * Returns info on components of \a this field.
4708 * \return const std::vector<std::string>& - a sequence of strings each being an
4709 * information on _i_-th component.
4711 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4713 const DataArray *arr=getOrCreateAndGetArray();
4714 return arr->getInfoOnComponents();
4718 * Returns a mutable info on components of \a this field.
4719 * \return std::vector<std::string>& - a sequence of strings each being an
4720 * information on _i_-th component.
4722 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4724 DataArray *arr=getOrCreateAndGetArray();
4725 return arr->getInfoOnComponents();
4728 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4730 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4732 const MEDFileFieldPerMesh *fpm(*it);
4735 if(fpm->presenceOfMultiDiscPerGeoType())
4742 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4743 * \param [in] type - a spatial discretization of the new field.
4744 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4745 * \param [in] mName - a name of the supporting mesh.
4746 * \param [in] renumPol - specifies how to permute values of the result field according to
4747 * the optional numbers of cells and nodes, if any. The valid values are
4748 * - 0 - do not permute.
4749 * - 1 - permute cells.
4750 * - 2 - permute nodes.
4751 * - 3 - permute cells and nodes.
4753 * \param [in] glob - the global data storing profiles and localization.
4754 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4755 * caller is to delete this field using decrRef() as it is no more needed.
4756 * \throw If the MED file is not readable.
4757 * \throw If there is no mesh named \a mName in the MED file.
4758 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4759 * \throw If no field of \a this is lying on the mesh \a mName.
4760 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4762 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4764 MCAuto<MEDFileMesh> mm;
4766 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4768 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4769 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4773 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4774 * \param [in] type - a spatial discretization of the new field.
4775 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4776 * \param [in] renumPol - specifies how to permute values of the result field according to
4777 * the optional numbers of cells and nodes, if any. The valid values are
4778 * - 0 - do not permute.
4779 * - 1 - permute cells.
4780 * - 2 - permute nodes.
4781 * - 3 - permute cells and nodes.
4783 * \param [in] glob - the global data storing profiles and localization.
4784 * \param [in] mesh - the supporting mesh.
4785 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4786 * caller is to delete this field using decrRef() as it is no more needed.
4787 * \throw If the MED file is not readable.
4788 * \throw If no field of \a this is lying on \a mesh.
4789 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4790 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4792 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4794 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4795 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4796 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4797 if(meshDimRelToMax==1)
4798 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4799 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4803 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4805 * \param [in] type - a spatial discretization of the new field.
4806 * \param [in] mName - a name of the supporting mesh.
4807 * \param [in] renumPol - specifies how to permute values of the result field according to
4808 * the optional numbers of cells and nodes, if any. The valid values are
4809 * - 0 - do not permute.
4810 * - 1 - permute cells.
4811 * - 2 - permute nodes.
4812 * - 3 - permute cells and nodes.
4814 * \param [in] glob - the global data storing profiles and localization.
4815 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4816 * caller is to delete this field using decrRef() as it is no more needed.
4817 * \throw If the MED file is not readable.
4818 * \throw If there is no mesh named \a mName in the MED file.
4819 * \throw If there are no mesh entities in the mesh.
4820 * \throw If no field values of the given \a type are available.
4822 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4824 MCAuto<MEDFileMesh> mm;
4826 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4828 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4829 int absDim=getDimension();
4830 int meshDimRelToMax=absDim-mm->getMeshDimension();
4831 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4835 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4836 * \param [in] type - a spatial discretization of the new field.
4837 * \param [in] renumPol - specifies how to permute values of the result field according to
4838 * the optional numbers of cells and nodes, if any. The valid values are
4839 * - 0 - do not permute.
4840 * - 1 - permute cells.
4841 * - 2 - permute nodes.
4842 * - 3 - permute cells and nodes.
4844 * \param [in] glob - the global data storing profiles and localization.
4845 * \param [in] mesh - the supporting mesh.
4846 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4847 * field according to \a renumPol.
4848 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4849 * field according to \a renumPol.
4850 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4851 * caller is to delete this field using decrRef() as it is no more needed.
4852 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4853 * \throw If no field of \a this is lying on \a mesh.
4854 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4856 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
4858 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4859 int meshId=getMeshIdFromMeshName(mesh->getName());
4861 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4866 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4873 throw INTERP_KERNEL::Exception(msg1);
4874 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4877 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4879 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4880 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4881 throw INTERP_KERNEL::Exception(oss.str().c_str());
4883 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4884 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4885 std::vector<DataArray *> arrOut2(1,arrOut);
4886 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4887 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4888 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4895 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4897 throw INTERP_KERNEL::Exception(msg1);
4900 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4902 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4903 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4904 throw INTERP_KERNEL::Exception(oss.str().c_str());
4906 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4907 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4908 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4909 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4914 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4919 * Returns values and a profile of the field of a given type lying on a given support.
4920 * \param [in] type - a spatial discretization of the field.
4921 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4922 * \param [in] mesh - the supporting mesh.
4923 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4924 * field of interest lies on. If the field lies on all entities of the given
4925 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4926 * using decrRef() as it is no more needed.
4927 * \param [in] glob - the global data storing profiles and localization.
4928 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4929 * field. The caller is to delete this array using decrRef() as it is no more needed.
4930 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4931 * \throw If no field of \a this is lying on \a mesh.
4932 * \throw If no field values of the given \a type are available.
4934 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4936 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4937 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4938 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4939 ret->setName(nasc.getName().c_str());
4943 //= MEDFileField1TSWithoutSDA
4946 * Throws if a given value is not a valid (non-extended) relative dimension.
4947 * \param [in] meshDimRelToMax - the relative dimension value.
4948 * \throw If \a meshDimRelToMax > 0.
4950 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4952 if(meshDimRelToMax>0)
4953 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4957 * Checks if elements of a given mesh are in the order suitable for writing
4958 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4959 * vector describing types of elements and their number.
4960 * \param [in] mesh - the mesh to check.
4961 * \return std::vector<int> - a vector holding for each element type (1) item of
4962 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4963 * These values are in full-interlace mode.
4964 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4966 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4969 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4970 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4971 int nbOfTypes=geoTypes.size();
4972 std::vector<int> code(3*nbOfTypes);
4973 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
4974 arr1->alloc(nbOfTypes,1);
4975 int *arrPtr=arr1->getPointer();
4976 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4977 for(int i=0;i<nbOfTypes;i++,it++)
4978 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4979 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4980 const int *arrPtr2=arr2->getConstPointer();
4982 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4985 int nbCells=mesh->getNumberOfCellsWithType(*it);
4986 code[3*pos]=(int)(*it);
4987 code[3*pos+1]=nbCells;
4988 code[3*pos+2]=-1;//no profiles
4990 std::vector<const DataArrayInt *> idsPerType;//no profiles
4991 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
4995 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5000 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5002 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5006 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5007 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5008 * item of every of returned sequences refers to the _i_-th part of \a this field.
5009 * Thus all sequences returned by this method are of the same length equal to number
5010 * of different types of supporting entities.<br>
5011 * A field part can include sub-parts with several different spatial discretizations,
5012 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5013 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5014 * of a nested sequence corresponds to a type of spatial discretization.<br>
5015 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5016 * The overhead is due to selecting values into new instances of DataArrayDouble.
5017 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5018 * for the case with only one underlying mesh. (Actually, the number of meshes is
5019 * not checked if \a mname == \c NULL).
5020 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5021 * a field part is returned.
5022 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5023 * A field part can include sub-parts with several different spatial discretizations,
5024 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5025 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5026 * This sequence is of the same length as \a types.
5027 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5028 * discretization. A profile name can be empty.
5029 * Length of this and of nested sequences is the same as that of \a typesF.
5030 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5031 * discretization. A localization name can be empty.
5032 * Length of this and of nested sequences is the same as that of \a typesF.
5033 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5034 * per each type of spatial discretization within one mesh entity type.
5035 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5036 * Length of this and of nested sequences is the same as that of \a typesF.
5037 * \throw If no field is lying on \a mname.
5039 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
5043 meshId=getMeshIdFromMeshName(mname);
5045 if(_field_per_mesh.empty())
5046 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5047 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5048 int nbOfRet=ret0.size();
5049 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5050 for(int i=0;i<nbOfRet;i++)
5052 const std::vector< std::pair<int,int> >& p=ret0[i];
5053 int nbOfRet1=p.size();
5054 ret[i].resize(nbOfRet1);
5055 for(int j=0;j<nbOfRet1;j++)
5057 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5065 * Returns a pointer to the underground DataArrayDouble instance. So the
5066 * caller should not decrRef() it. This method allows for a direct access to the field
5067 * values. This method is quite unusable if there is more than a nodal field or a cell
5068 * field on single geometric cell type.
5069 * \return DataArrayDouble * - the pointer to the field values array.
5071 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
5073 const DataArrayDouble *ret=_arr;
5075 return const_cast<DataArrayDouble *>(ret);
5080 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5085 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5087 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5088 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5089 ret->deepCpyLeavesFrom(*this);
5090 const DataArrayDouble *arr(_arr);
5093 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5094 ret->setArray(arr2);
5100 * Returns a pointer to the underground DataArrayDouble instance. So the
5101 * caller should not decrRef() it. This method allows for a direct access to the field
5102 * values. This method is quite unusable if there is more than a nodal field or a cell
5103 * field on single geometric cell type.
5104 * \return DataArrayDouble * - the pointer to the field values array.
5106 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5108 return getUndergroundDataArrayDouble();
5112 * Returns a pointer to the underground DataArrayDouble instance and a
5113 * sequence describing parameters of a support of each part of \a this field. The
5114 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5115 * direct access to the field values. This method is intended for the field lying on one
5117 * \param [in,out] entries - the sequence describing parameters of a support of each
5118 * part of \a this field. Each item of this sequence consists of two parts. The
5119 * first part describes a type of mesh entity and an id of discretization of a
5120 * current field part. The second part describes a range of values [begin,end)
5121 * within the returned array relating to the current field part.
5122 * \return DataArrayDouble * - the pointer to the field values array.
5123 * \throw If the number of underlying meshes is not equal to 1.
5124 * \throw If no field values are available.
5125 * \sa getUndergroundDataArray()
5127 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5129 if(_field_per_mesh.size()!=1)
5130 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5131 if(_field_per_mesh[0]==0)
5132 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5133 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5134 return getUndergroundDataArrayDouble();
5138 * Returns a pointer to the underground DataArrayDouble instance and a
5139 * sequence describing parameters of a support of each part of \a this field. The
5140 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5141 * direct access to the field values. This method is intended for the field lying on one
5143 * \param [in,out] entries - the sequence describing parameters of a support of each
5144 * part of \a this field. Each item of this sequence consists of two parts. The
5145 * first part describes a type of mesh entity and an id of discretization of a
5146 * current field part. The second part describes a range of values [begin,end)
5147 * within the returned array relating to the current field part.
5148 * \return DataArrayDouble * - the pointer to the field values array.
5149 * \throw If the number of underlying meshes is not equal to 1.
5150 * \throw If no field values are available.
5151 * \sa getUndergroundDataArray()
5153 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5155 return getUndergroundDataArrayDoubleExt(entries);
5158 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5160 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5161 arr->setInfoAndChangeNbOfCompo(infos);
5164 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5168 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5170 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5171 ret->deepCpyLeavesFrom(*this);
5175 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5177 MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5178 if((const DataArrayDouble *)_arr)
5179 ret->_arr=_arr->deepCopy();
5183 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5187 _nb_of_tuples_to_be_allocated=-1;
5191 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5193 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5195 _nb_of_tuples_to_be_allocated=-3;
5200 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5202 return DataArrayDouble::New();
5205 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5207 DataArrayDouble *ret=_arr;
5210 _arr=DataArrayDouble::New();
5214 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5216 return getOrCreateAndGetArrayDouble();
5219 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5221 const DataArrayDouble *ret=_arr;
5224 DataArrayDouble *ret2=DataArrayDouble::New();
5225 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5229 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5231 return getOrCreateAndGetArrayDouble();
5234 //= MEDFileIntField1TSWithoutSDA
5236 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5238 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5241 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5245 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5246 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5248 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5249 arr->setInfoAndChangeNbOfCompo(infos);
5252 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5257 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5259 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5260 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5261 ret->deepCpyLeavesFrom(*this);
5262 const DataArrayInt *arr(_arr);
5265 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5266 ret->setArray(arr2);
5272 * Returns a pointer to the underground DataArrayInt instance. So the
5273 * caller should not decrRef() it. This method allows for a direct access to the field
5274 * values. This method is quite unusable if there is more than a nodal field or a cell
5275 * field on single geometric cell type.
5276 * \return DataArrayInt * - the pointer to the field values array.
5278 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5280 return getUndergroundDataArrayInt();
5284 * Returns a pointer to the underground DataArrayInt instance. So the
5285 * caller should not decrRef() it. This method allows for a direct access to the field
5286 * values. This method is quite unusable if there is more than a nodal field or a cell
5287 * field on single geometric cell type.
5288 * \return DataArrayInt * - the pointer to the field values array.
5290 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5292 const DataArrayInt *ret=_arr;
5294 return const_cast<DataArrayInt *>(ret);
5300 * Returns a pointer to the underground DataArrayInt instance and a
5301 * sequence describing parameters of a support of each part of \a this field. The
5302 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5303 * direct access to the field values. This method is intended for the field lying on one
5305 * \param [in,out] entries - the sequence describing parameters of a support of each
5306 * part of \a this field. Each item of this sequence consists of two parts. The
5307 * first part describes a type of mesh entity and an id of discretization of a
5308 * current field part. The second part describes a range of values [begin,end)
5309 * within the returned array relating to the current field part.
5310 * \return DataArrayInt * - the pointer to the field values array.
5311 * \throw If the number of underlying meshes is not equal to 1.
5312 * \throw If no field values are available.
5313 * \sa getUndergroundDataArray()
5315 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5317 return getUndergroundDataArrayIntExt(entries);
5321 * Returns a pointer to the underground DataArrayInt instance and a
5322 * sequence describing parameters of a support of each part of \a this field. The
5323 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5324 * direct access to the field values. This method is intended for the field lying on one
5326 * \param [in,out] entries - the sequence describing parameters of a support of each
5327 * part of \a this field. Each item of this sequence consists of two parts. The
5328 * first part describes a type of mesh entity and an id of discretization of a
5329 * current field part. The second part describes a range of values [begin,end)
5330 * within the returned array relating to the current field part.
5331 * \return DataArrayInt * - the pointer to the field values array.
5332 * \throw If the number of underlying meshes is not equal to 1.
5333 * \throw If no field values are available.
5334 * \sa getUndergroundDataArray()
5336 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5338 if(_field_per_mesh.size()!=1)
5339 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5340 if(_field_per_mesh[0]==0)
5341 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5342 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5343 return getUndergroundDataArrayInt();
5346 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5348 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5349 ret->deepCpyLeavesFrom(*this);
5353 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5355 MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5356 if((const DataArrayInt *)_arr)
5357 ret->_arr=_arr->deepCopy();
5361 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5365 _nb_of_tuples_to_be_allocated=-1;
5369 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5371 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5373 _nb_of_tuples_to_be_allocated=-3;
5378 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5380 return DataArrayInt::New();
5383 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5385 DataArrayInt *ret=_arr;
5388 _arr=DataArrayInt::New();
5392 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5394 return getOrCreateAndGetArrayInt();
5397 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5399 const DataArrayInt *ret=_arr;
5402 DataArrayInt *ret2=DataArrayInt::New();
5403 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5407 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5409 return getOrCreateAndGetArrayInt();
5412 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5416 //= MEDFileAnyTypeField1TS
5418 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5420 med_field_type typcha;
5422 std::vector<std::string> infos;
5423 std::string dtunit,fieldName;
5424 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5425 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5430 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5435 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5440 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] !";
5441 throw INTERP_KERNEL::Exception(oss.str().c_str());
5444 ret->setDtUnit(dtunit.c_str());
5445 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5447 med_int numdt,numit;
5449 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5450 ret->setTime(numdt,numit,dt);
5453 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5455 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5459 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5460 try:MEDFileFieldGlobsReal(fileName)
5462 MEDFileUtilities::CheckFileForRead(fileName);
5463 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5464 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5467 catch(INTERP_KERNEL::Exception& e)
5472 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5474 med_field_type typcha;
5475 std::vector<std::string> infos;
5478 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5479 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5484 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5489 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5494 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] !";
5495 throw INTERP_KERNEL::Exception(oss.str().c_str());
5498 ret->setDtUnit(dtunit.c_str());
5499 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5503 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5504 throw INTERP_KERNEL::Exception(oss.str().c_str());
5507 med_int numdt,numit;
5509 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5510 ret->setTime(numdt,numit,dt);
5513 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5515 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5519 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5520 try:MEDFileFieldGlobsReal(fileName)
5522 MEDFileUtilities::CheckFileForRead(fileName);
5523 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5524 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5527 catch(INTERP_KERNEL::Exception& e)
5532 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5535 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5536 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5538 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New();
5539 ret->setFileName(fileName);
5540 ret->_content=c; c->incrRef();
5543 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5545 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5546 ret->setFileName(fileName);
5547 ret->_content=c; c->incrRef();
5550 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5553 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5555 MEDFileUtilities::CheckFileForRead(fileName);
5556 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5557 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5558 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5559 ret->loadGlobals(fid);
5563 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5565 MEDFileUtilities::CheckFileForRead(fileName);
5566 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5567 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5568 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5569 ret->loadGlobals(fid);
5573 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5575 MEDFileUtilities::CheckFileForRead(fileName);
5576 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5577 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5578 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5579 ret->loadGlobals(fid);
5583 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5585 med_field_type typcha;
5586 std::vector<std::string> infos;
5589 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5590 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5595 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5600 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5605 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] !";
5606 throw INTERP_KERNEL::Exception(oss.str().c_str());
5609 ret->setDtUnit(dtunit.c_str());
5610 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5613 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5614 for(int i=0;i<nbOfStep2 && !found;i++)
5616 med_int numdt,numit;
5618 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5619 if(numdt==iteration && numit==order)
5625 dtits[i]=std::pair<int,int>(numdt,numit);
5629 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5630 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5631 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5632 throw INTERP_KERNEL::Exception(oss.str().c_str());
5635 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5637 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5641 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5642 try:MEDFileFieldGlobsReal(fileName)
5644 MEDFileUtilities::CheckFileForRead(fileName);
5645 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5646 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5649 catch(INTERP_KERNEL::Exception& e)
5655 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5656 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5658 * \warning this is a shallow copy constructor
5660 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5662 if(!shallowCopyOfContent)
5664 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5665 otherPtr->incrRef();
5666 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5670 _content=other.shallowCpy();
5674 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)
5678 int nbFields=MEDnField(fid);
5679 if(fieldIdCFormat>=nbFields)
5681 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5682 throw INTERP_KERNEL::Exception(oss.str().c_str());
5685 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5686 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5687 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5688 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5689 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5690 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5693 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5694 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5695 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5696 infos.clear(); infos.resize(ncomp);
5697 for(int j=0;j<ncomp;j++)
5698 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5703 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5706 * \return in case of success the number of time steps available for the field with name \a fieldName.
5708 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)
5710 int nbFields=MEDnField(fid);
5712 std::vector<std::string> fns(nbFields);
5714 for(int i=0;i<nbFields && !found;i++)
5717 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5719 found=(tmp==fieldName);
5725 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5726 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5727 oss << "\"" << *it << "\" ";
5728 throw INTERP_KERNEL::Exception(oss.str().c_str());
5734 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5735 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5736 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5737 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5738 * to keep a valid instance.
5739 * 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.
5740 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5741 * 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.
5743 * \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.
5744 * \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.
5745 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5746 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5747 * \param [in] newLocName is the new localization name.
5748 * \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.
5749 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5751 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5753 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5754 std::string oldPflName=disc->getProfile();
5755 std::vector<std::string> vv=getPflsReallyUsedMulti();
5756 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5757 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5759 disc->setProfile(newPflName);
5760 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5761 pfl->setName(newPflName);
5765 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5766 throw INTERP_KERNEL::Exception(oss.str().c_str());
5771 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5772 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5773 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5774 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5775 * to keep a valid instance.
5776 * 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.
5777 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5778 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5779 * 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.
5781 * \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.
5782 * \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.
5783 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5784 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5785 * \param [in] newLocName is the new localization name.
5786 * \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.
5787 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5789 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5791 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5792 std::string oldLocName=disc->getLocalization();
5793 std::vector<std::string> vv=getLocsReallyUsedMulti();
5794 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5795 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5797 disc->setLocalization(newLocName);
5798 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5799 loc.setName(newLocName);
5803 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5804 throw INTERP_KERNEL::Exception(oss.str().c_str());
5808 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5810 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5812 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5816 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5818 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5820 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5825 * Writes \a this field into a MED file specified by its name.
5826 * \param [in] fileName - the MED file name.
5827 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5828 * - 2 - erase; an existing file is removed.
5829 * - 1 - append; same data should not be present in an existing file.
5830 * - 0 - overwrite; same data present in an existing file is overwritten.
5831 * \throw If the field name is not set.
5832 * \throw If no field data is set.
5833 * \throw If \a mode == 1 and the same data is present in an existing file.
5835 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5837 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5838 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5843 * This method alloc the arrays and load potentially huge arrays contained in this field.
5844 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5845 * This method can be also called to refresh or reinit values from a file.
5847 * \throw If the fileName is not set or points to a non readable MED file.
5848 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5850 void MEDFileAnyTypeField1TS::loadArrays()
5852 if(getFileName().empty())
5853 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5854 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5855 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5859 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5860 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5861 * this method does not throw if \a this does not come from file read.
5863 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5865 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5867 if(!getFileName().empty())
5869 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5870 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5875 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5876 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5877 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5879 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5881 void MEDFileAnyTypeField1TS::unloadArrays()
5883 contentNotNullBase()->unloadArrays();
5887 * 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.
5888 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5889 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5891 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5893 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5895 if(!getFileName().empty())
5896 contentNotNullBase()->unloadArrays();
5899 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5901 int nbComp=getNumberOfComponents();
5902 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5903 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5904 for(int i=0;i<nbComp;i++)
5906 std::string info=getInfo()[i];
5908 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5909 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5910 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5912 if(getName().empty())
5913 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5914 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5915 writeGlobals(fid,*this);
5916 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5919 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5921 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5924 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5926 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5927 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5932 * Returns a string describing \a this field. This string is outputted
5933 * by \c print Python command.
5935 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5937 std::ostringstream oss;
5938 contentNotNullBase()->simpleRepr(0,oss,-1);
5939 simpleReprGlobs(oss);
5944 * This method returns all profiles whose name is non empty used.
5945 * \b WARNING If profile is used several times it will be reported \b only \b once.
5946 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5948 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5950 return contentNotNullBase()->getPflsReallyUsed2();
5954 * This method returns all localizations whose name is non empty used.
5955 * \b WARNING If localization is used several times it will be reported \b only \b once.
5957 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5959 return contentNotNullBase()->getLocsReallyUsed2();
5963 * This method returns all profiles whose name is non empty used.
5964 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5966 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5968 return contentNotNullBase()->getPflsReallyUsedMulti2();
5972 * This method returns all localizations whose name is non empty used.
5973 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5975 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5977 return contentNotNullBase()->getLocsReallyUsedMulti2();
5980 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5982 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5985 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5987 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5990 int MEDFileAnyTypeField1TS::getDimension() const
5992 return contentNotNullBase()->getDimension();
5995 int MEDFileAnyTypeField1TS::getIteration() const
5997 return contentNotNullBase()->getIteration();
6000 int MEDFileAnyTypeField1TS::getOrder() const
6002 return contentNotNullBase()->getOrder();
6005 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6007 return contentNotNullBase()->getTime(iteration,order);
6010 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6012 contentNotNullBase()->setTime(iteration,order,val);
6015 std::string MEDFileAnyTypeField1TS::getName() const
6017 return contentNotNullBase()->getName();
6020 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6022 contentNotNullBase()->setName(name);
6025 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6027 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6030 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6032 return contentNotNullBase()->getDtUnit();
6035 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6037 contentNotNullBase()->setDtUnit(dtUnit);
6040 std::string MEDFileAnyTypeField1TS::getMeshName() const
6042 return contentNotNullBase()->getMeshName();
6045 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6047 contentNotNullBase()->setMeshName(newMeshName);
6050 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6052 return contentNotNullBase()->changeMeshNames(modifTab);
6055 int MEDFileAnyTypeField1TS::getMeshIteration() const
6057 return contentNotNullBase()->getMeshIteration();
6060 int MEDFileAnyTypeField1TS::getMeshOrder() const
6062 return contentNotNullBase()->getMeshOrder();
6065 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6067 return contentNotNullBase()->getNumberOfComponents();
6070 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6072 return contentNotNullBase()->isDealingTS(iteration,order);
6075 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6077 return contentNotNullBase()->getDtIt();
6080 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6082 contentNotNullBase()->fillIteration(p);
6085 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6087 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6090 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6092 contentNotNullBase()->setInfo(infos);
6095 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6097 return contentNotNullBase()->getInfo();
6099 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6101 return contentNotNullBase()->getInfo();
6104 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6106 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6109 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6111 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6114 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6116 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6119 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6121 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6124 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6126 return contentNotNullBase()->getTypesOfFieldAvailable();
6129 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,
6130 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6132 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6136 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6137 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6138 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6140 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6142 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6144 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6145 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6146 std::size_t sz(contentsSplit.size());
6147 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6148 for(std::size_t i=0;i<sz;i++)
6150 ret[i]=shallowCpy();
6151 ret[i]->_content=contentsSplit[i];
6157 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6158 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6160 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6162 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6164 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6165 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6166 std::size_t sz(contentsSplit.size());
6167 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6168 for(std::size_t i=0;i<sz;i++)
6170 ret[i]=shallowCpy();
6171 ret[i]->_content=contentsSplit[i];
6177 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6178 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6180 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6182 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6184 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6185 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6186 std::size_t sz(contentsSplit.size());
6187 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6188 for(std::size_t i=0;i<sz;i++)
6190 ret[i]=shallowCpy();
6191 ret[i]->_content=contentsSplit[i];
6196 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6198 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6199 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6200 ret->_content=_content->deepCopy();
6201 ret->deepCpyGlobs(*this);
6205 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6207 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6213 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6214 * the first field that has been read from a specified MED file.
6215 * \param [in] fileName - the name of the MED file to read.
6216 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6217 * is to delete this field using decrRef() as it is no more needed.
6218 * \throw If reading the file fails.
6220 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6222 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6223 ret->contentNotNull();
6228 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6229 * a given field that has been read from a specified MED file.
6230 * \param [in] fileName - the name of the MED file to read.
6231 * \param [in] fieldName - the name of the field to read.
6232 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6233 * is to delete this field using decrRef() as it is no more needed.
6234 * \throw If reading the file fails.
6235 * \throw If there is no field named \a fieldName in the file.
6237 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6239 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6240 ret->contentNotNull();
6245 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6246 * a given field that has been read from a specified MED file.
6247 * \param [in] fileName - the name of the MED file to read.
6248 * \param [in] fieldName - the name of the field to read.
6249 * \param [in] iteration - the iteration number of a required time step.
6250 * \param [in] order - the iteration order number of required time step.
6251 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6252 * is to delete this field using decrRef() as it is no more needed.
6253 * \throw If reading the file fails.
6254 * \throw If there is no field named \a fieldName in the file.
6255 * \throw If the required time step is missing from the file.
6257 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6259 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6260 ret->contentNotNull();
6265 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6266 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6268 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6269 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6270 * \warning this is a shallow copy constructor
6271 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6272 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6273 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6274 * is to delete this field using decrRef() as it is no more needed.
6276 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6278 MCAuto<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6279 ret->contentNotNull();
6284 * Returns a new empty instance of MEDFileField1TS.
6285 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6286 * is to delete this field using decrRef() as it is no more needed.
6288 MEDFileField1TS *MEDFileField1TS::New()
6290 MCAuto<MEDFileField1TS> ret=new MEDFileField1TS;
6291 ret->contentNotNull();
6296 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6297 * following the given input policy.
6299 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6300 * By default (true) the globals are deeply copied.
6301 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6303 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6305 MCAuto<MEDFileIntField1TS> ret;
6306 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6309 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6311 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6312 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6313 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6316 ret=MEDFileIntField1TS::New();
6318 ret->deepCpyGlobs(*this);
6320 ret->shallowCpyGlobs(*this);
6324 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6326 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6328 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6329 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6331 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 !");
6335 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6337 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6339 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6340 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6342 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 !");
6346 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6349 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6350 if(!((DataArray*)arr))
6351 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6352 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6354 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6355 f->setArray(arrOutC);
6358 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6360 if(!((DataArray*)arr))
6361 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6362 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6364 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6370 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6371 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6373 * \return A new object that the caller is responsible to deallocate.
6375 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6378 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6379 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6380 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6381 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6383 if((*it0)!=ON_NODES)
6385 std::vector<int> levs;
6386 getNonEmptyLevels(mm->getName(),levs);
6387 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6389 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6390 if(it2!=extractDef.end())
6392 MCAuto<DataArrayInt> t((*it2).second);
6393 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6394 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6395 ret->setFieldNoProfileSBT(fOut);
6401 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6402 if(it2==extractDef.end())
6403 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6404 MCAuto<DataArrayInt> t((*it2).second);
6405 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6406 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6407 DataArrayDouble *arr(f->getArray());
6408 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6409 fOut->setArray(newArr);
6410 ret->setFieldNoProfileSBT(fOut);
6416 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6417 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6420 catch(INTERP_KERNEL::Exception& e)
6423 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6424 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6427 catch(INTERP_KERNEL::Exception& e)
6430 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6431 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6434 catch(INTERP_KERNEL::Exception& e)
6438 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6439 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6441 * \warning this is a shallow copy constructor
6443 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6444 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6447 catch(INTERP_KERNEL::Exception& e)
6450 MEDFileField1TS::MEDFileField1TS()
6452 _content=new MEDFileField1TSWithoutSDA;
6456 * Returns a new MEDCouplingFieldDouble of a given type lying on
6457 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6458 * has not been constructed via file reading, an exception is thrown.
6459 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6460 * \param [in] type - a spatial discretization of interest.
6461 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6462 * \param [in] renumPol - specifies how to permute values of the result field according to
6463 * the optional numbers of cells and nodes, if any. The valid values are
6464 * - 0 - do not permute.
6465 * - 1 - permute cells.
6466 * - 2 - permute nodes.
6467 * - 3 - permute cells and nodes.
6469 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6470 * caller is to delete this field using decrRef() as it is no more needed.
6471 * \throw If \a this field has not been constructed via file reading.
6472 * \throw If the MED file is not readable.
6473 * \throw If there is no mesh in the MED file.
6474 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6475 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6476 * \sa getFieldOnMeshAtLevel()
6478 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6480 if(getFileName().empty())
6481 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6482 MCAuto<DataArray> arrOut;
6483 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6484 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6489 * Returns a new MEDCouplingFieldDouble of a given type lying on
6490 * the top level cells of the first mesh in MED file. If \a this field
6491 * has not been constructed via file reading, an exception is thrown.
6492 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6493 * \param [in] type - a spatial discretization of interest.
6494 * \param [in] renumPol - specifies how to permute values of the result field according to
6495 * the optional numbers of cells and nodes, if any. The valid values are
6496 * - 0 - do not permute.
6497 * - 1 - permute cells.
6498 * - 2 - permute nodes.
6499 * - 3 - permute cells and nodes.
6501 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6502 * caller is to delete this field using decrRef() as it is no more needed.
6503 * \throw If \a this field has not been constructed via file reading.
6504 * \throw If the MED file is not readable.
6505 * \throw If there is no mesh in the MED file.
6506 * \throw If no field values of the given \a type.
6507 * \throw If no field values lying on the top level support.
6508 * \sa getFieldAtLevel()
6510 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6512 if(getFileName().empty())
6513 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6514 MCAuto<DataArray> arrOut;
6515 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6516 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6521 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6522 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6523 * \param [in] type - a spatial discretization of the new field.
6524 * \param [in] mesh - the supporting mesh.
6525 * \param [in] renumPol - specifies how to permute values of the result field according to
6526 * the optional numbers of cells and nodes, if any. The valid values are
6527 * - 0 - do not permute.
6528 * - 1 - permute cells.
6529 * - 2 - permute nodes.
6530 * - 3 - permute cells and nodes.
6532 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6533 * caller is to delete this field using decrRef() as it is no more needed.
6534 * \throw If no field of \a this is lying on \a mesh.
6535 * \throw If the mesh is empty.
6536 * \throw If no field values of the given \a type are available.
6537 * \sa getFieldAtLevel()
6538 * \sa getFieldOnMeshAtLevel()
6540 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6542 MCAuto<DataArray> arrOut;
6543 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6544 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6549 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6550 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6551 * \param [in] type - a spatial discretization of interest.
6552 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6553 * \param [in] mesh - the supporting mesh.
6554 * \param [in] renumPol - specifies how to permute values of the result field according to
6555 * the optional numbers of cells and nodes, if any. The valid values are
6556 * - 0 - do not permute.
6557 * - 1 - permute cells.
6558 * - 2 - permute nodes.
6559 * - 3 - permute cells and nodes.
6561 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6562 * caller is to delete this field using decrRef() as it is no more needed.
6563 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6564 * \throw If no field of \a this is lying on \a mesh.
6565 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6566 * \sa getFieldAtLevel()
6567 * \sa getFieldOnMeshAtLevel()
6569 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6571 MCAuto<DataArray> arrOut;
6572 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6573 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6578 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6579 * This method is called "Old" because in MED3 norm a field has only one meshName
6580 * attached, so this method is for readers of MED2 files. If \a this field
6581 * has not been constructed via file reading, an exception is thrown.
6582 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6583 * \param [in] type - a spatial discretization of interest.
6584 * \param [in] mName - a name of the supporting mesh.
6585 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6586 * \param [in] renumPol - specifies how to permute values of the result field according to
6587 * the optional numbers of cells and nodes, if any. The valid values are
6588 * - 0 - do not permute.
6589 * - 1 - permute cells.
6590 * - 2 - permute nodes.
6591 * - 3 - permute cells and nodes.
6593 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6594 * caller is to delete this field using decrRef() as it is no more needed.
6595 * \throw If the MED file is not readable.
6596 * \throw If there is no mesh named \a mName in the MED file.
6597 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6598 * \throw If \a this field has not been constructed via file reading.
6599 * \throw If no field of \a this is lying on the mesh named \a mName.
6600 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6601 * \sa getFieldAtLevel()
6603 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6605 if(getFileName().empty())
6606 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6607 MCAuto<DataArray> arrOut;
6608 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6609 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6614 * Returns values and a profile of the field of a given type lying on a given support.
6615 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6616 * \param [in] type - a spatial discretization of the field.
6617 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6618 * \param [in] mesh - the supporting mesh.
6619 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6620 * field of interest lies on. If the field lies on all entities of the given
6621 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6622 * using decrRef() as it is no more needed.
6623 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6624 * field. The caller is to delete this array using decrRef() as it is no more needed.
6625 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6626 * \throw If no field of \a this is lying on \a mesh.
6627 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6629 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6631 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6632 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6636 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6637 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6638 * "Sort By Type"), if not, an exception is thrown.
6639 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6640 * \param [in] field - the field to add to \a this.
6641 * \throw If the name of \a field is empty.
6642 * \throw If the data array of \a field is not set.
6643 * \throw If the data array is already allocated but has different number of components
6645 * \throw If the underlying mesh of \a field has no name.
6646 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6648 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6651 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6655 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6656 * can be an aggregation of several MEDCouplingFieldDouble instances.
6657 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6658 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6661 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6662 * A new profile is added only if no equal profile is missing.
6663 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6664 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6665 * \param [in] mesh - the supporting mesh of \a field.
6666 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6667 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6668 * \throw If either \a field or \a mesh or \a profile has an empty name.
6669 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6670 * \throw If the data array of \a field is not set.
6671 * \throw If the data array of \a this is already allocated but has different number of
6672 * components than \a field.
6673 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6674 * \sa setFieldNoProfileSBT()
6676 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6679 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6682 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6684 return new MEDFileField1TS(*this);
6687 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6689 return contentNotNull()->getUndergroundDataArrayDouble();
6692 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6694 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6697 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6698 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6700 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6703 //= MEDFileIntField1TS
6705 MEDFileIntField1TS *MEDFileIntField1TS::New()
6707 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6708 ret->contentNotNull();
6712 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6714 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6715 ret->contentNotNull();
6719 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6721 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6722 ret->contentNotNull();
6726 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6728 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6729 ret->contentNotNull();
6733 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6735 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6736 ret->contentNotNull();
6740 MEDFileIntField1TS::MEDFileIntField1TS()
6742 _content=new MEDFileIntField1TSWithoutSDA;
6745 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6746 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6749 catch(INTERP_KERNEL::Exception& e)
6752 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6753 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6756 catch(INTERP_KERNEL::Exception& e)
6759 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6760 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6763 catch(INTERP_KERNEL::Exception& e)
6767 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6768 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6770 * \warning this is a shallow copy constructor
6772 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6776 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6778 return new MEDFileIntField1TS(*this);
6782 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6783 * following the given input policy.
6785 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6786 * By default (true) the globals are deeply copied.
6787 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6789 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6791 MCAuto<MEDFileField1TS> ret;
6792 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6795 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6797 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6798 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6799 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6802 ret=MEDFileField1TS::New();
6804 ret->deepCpyGlobs(*this);
6806 ret->shallowCpyGlobs(*this);
6811 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6812 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6813 * "Sort By Type"), if not, an exception is thrown.
6814 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6815 * \param [in] field - the field to add to \a this. The field double values are ignored.
6816 * \param [in] arrOfVals - the values of the field \a field used.
6817 * \throw If the name of \a field is empty.
6818 * \throw If the data array of \a field is not set.
6819 * \throw If the data array is already allocated but has different number of components
6821 * \throw If the underlying mesh of \a field has no name.
6822 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6824 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6827 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6831 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6832 * can be an aggregation of several MEDCouplingFieldDouble instances.
6833 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6834 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6837 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6838 * A new profile is added only if no equal profile is missing.
6839 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6840 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6841 * \param [in] arrOfVals - the values of the field \a field used.
6842 * \param [in] mesh - the supporting mesh of \a field.
6843 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6844 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6845 * \throw If either \a field or \a mesh or \a profile has an empty name.
6846 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6847 * \throw If the data array of \a field is not set.
6848 * \throw If the data array of \a this is already allocated but has different number of
6849 * components than \a field.
6850 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6851 * \sa setFieldNoProfileSBT()
6853 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6856 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6859 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6861 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6863 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6864 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6866 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 !");
6870 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6872 if(getFileName().empty())
6873 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6874 MCAuto<DataArray> arrOut2;
6875 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6876 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6878 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6880 arrOut->incrRef(); // arrOut2 dies at the end of the func
6884 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6886 if(!((DataArray *)arr))
6887 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6888 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6890 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6895 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6897 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
6901 * Returns a new MEDCouplingFieldDouble of a given type lying on
6902 * the top level cells of the first mesh in MED file. If \a this field
6903 * has not been constructed via file reading, an exception is thrown.
6904 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6905 * \param [in] type - a spatial discretization of interest.
6906 * \param [out] arrOut - the DataArrayInt containing values of field.
6907 * \param [in] renumPol - specifies how to permute values of the result field according to
6908 * the optional numbers of cells and nodes, if any. The valid values are
6909 * - 0 - do not permute.
6910 * - 1 - permute cells.
6911 * - 2 - permute nodes.
6912 * - 3 - permute cells and nodes.
6914 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6915 * caller is to delete this field using decrRef() as it is no more needed.
6916 * \throw If \a this field has not been constructed via file reading.
6917 * \throw If the MED file is not readable.
6918 * \throw If there is no mesh in the MED file.
6919 * \throw If no field values of the given \a type.
6920 * \throw If no field values lying on the top level support.
6921 * \sa getFieldAtLevel()
6923 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6925 if(getFileName().empty())
6926 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6927 MCAuto<DataArray> arr;
6928 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6929 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6934 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6935 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6936 * \param [in] type - a spatial discretization of the new field.
6937 * \param [in] mesh - the supporting mesh.
6938 * \param [out] arrOut - the DataArrayInt containing values of field.
6939 * \param [in] renumPol - specifies how to permute values of the result field according to
6940 * the optional numbers of cells and nodes, if any. The valid values are
6941 * - 0 - do not permute.
6942 * - 1 - permute cells.
6943 * - 2 - permute nodes.
6944 * - 3 - permute cells and nodes.
6946 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6947 * caller is to delete this field using decrRef() as it is no more needed.
6948 * \throw If no field of \a this is lying on \a mesh.
6949 * \throw If the mesh is empty.
6950 * \throw If no field values of the given \a type are available.
6951 * \sa getFieldAtLevel()
6952 * \sa getFieldOnMeshAtLevel()
6954 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6956 MCAuto<DataArray> arr;
6957 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6958 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6963 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6964 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6965 * \param [in] type - a spatial discretization of interest.
6966 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6967 * \param [out] arrOut - the DataArrayInt containing values of field.
6968 * \param [in] mesh - the supporting mesh.
6969 * \param [in] renumPol - specifies how to permute values of the result field according to
6970 * the optional numbers of cells and nodes, if any. The valid values are
6971 * - 0 - do not permute.
6972 * - 1 - permute cells.
6973 * - 2 - permute nodes.
6974 * - 3 - permute cells and nodes.
6976 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6977 * caller is to delete this field using decrRef() as it is no more needed.
6978 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6979 * \throw If no field of \a this is lying on \a mesh.
6980 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6981 * \sa getFieldAtLevel()
6982 * \sa getFieldOnMeshAtLevel()
6984 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6986 MCAuto<DataArray> arr;
6987 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6988 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6993 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6994 * This method is called "Old" because in MED3 norm a field has only one meshName
6995 * attached, so this method is for readers of MED2 files. If \a this field
6996 * has not been constructed via file reading, an exception is thrown.
6997 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6998 * \param [in] type - a spatial discretization of interest.
6999 * \param [in] mName - a name of the supporting mesh.
7000 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7001 * \param [out] arrOut - the DataArrayInt containing values of field.
7002 * \param [in] renumPol - specifies how to permute values of the result field according to
7003 * the optional numbers of cells and nodes, if any. The valid values are
7004 * - 0 - do not permute.
7005 * - 1 - permute cells.
7006 * - 2 - permute nodes.
7007 * - 3 - permute cells and nodes.
7009 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
7010 * caller is to delete this field using decrRef() as it is no more needed.
7011 * \throw If the MED file is not readable.
7012 * \throw If there is no mesh named \a mName in the MED file.
7013 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7014 * \throw If \a this field has not been constructed via file reading.
7015 * \throw If no field of \a this is lying on the mesh named \a mName.
7016 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7017 * \sa getFieldAtLevel()
7019 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
7021 if(getFileName().empty())
7022 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7023 MCAuto<DataArray> arr;
7024 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
7025 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7030 * Returns values and a profile of the field of a given type lying on a given support.
7031 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7032 * \param [in] type - a spatial discretization of the field.
7033 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7034 * \param [in] mesh - the supporting mesh.
7035 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7036 * field of interest lies on. If the field lies on all entities of the given
7037 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7038 * using decrRef() as it is no more needed.
7039 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7040 * field. The caller is to delete this array using decrRef() as it is no more needed.
7041 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7042 * \throw If no field of \a this is lying on \a mesh.
7043 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7045 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7047 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7048 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7051 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7053 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7055 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7056 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7058 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 !");
7062 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7064 return contentNotNull()->getUndergroundDataArrayInt();
7067 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7069 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7073 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7078 * \param [in] fieldId field id in C mode
7080 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7082 med_field_type typcha;
7083 std::string dtunitOut;
7084 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
7085 setDtUnit(dtunitOut.c_str());
7086 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7089 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)
7090 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7092 setDtUnit(dtunit.c_str());
7093 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7095 catch(INTERP_KERNEL::Exception& e)
7100 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7102 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7103 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7104 ret+=(*it).capacity();
7108 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7110 std::vector<const BigMemoryObject *> ret;
7111 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7112 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7117 * 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
7120 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7122 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7123 ret->setInfo(_infos);
7124 int sz=(int)_time_steps.size();
7125 for(const int *id=startIds;id!=endIds;id++)
7127 if(*id>=0 && *id<sz)
7129 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7130 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7134 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7136 ret->pushBackTimeStep(tse2);
7140 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7141 oss << " ! Should be in [0," << sz << ") !";
7142 throw INTERP_KERNEL::Exception(oss.str().c_str());
7145 if(ret->getNumberOfTS()>0)
7146 ret->synchronizeNameScope();
7147 ret->copyNameScope(*this);
7152 * 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
7155 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7157 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7158 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7159 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7160 ret->setInfo(_infos);
7161 int sz=(int)_time_steps.size();
7163 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7167 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7168 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7172 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7174 ret->pushBackTimeStep(tse2);
7178 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7179 oss << " ! Should be in [0," << sz << ") !";
7180 throw INTERP_KERNEL::Exception(oss.str().c_str());
7183 if(ret->getNumberOfTS()>0)
7184 ret->synchronizeNameScope();
7185 ret->copyNameScope(*this);
7189 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7192 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7193 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7195 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7198 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7199 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7200 ids->pushBackSilent(id);
7202 return buildFromTimeStepIds(ids->begin(),ids->end());
7205 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7208 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7209 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7211 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7214 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7215 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7216 ids->pushBackSilent(id);
7218 return buildFromTimeStepIds(ids->begin(),ids->end());
7221 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7223 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7225 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7228 if(cur->presenceOfMultiDiscPerGeoType())
7234 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7239 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7244 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7247 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7249 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7250 if(pt->isDealingTS(iteration,order))
7253 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7254 std::vector< std::pair<int,int> > vp=getIterations();
7255 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7256 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7257 throw INTERP_KERNEL::Exception(oss.str().c_str());
7260 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7262 return *_time_steps[getTimeStepPos(iteration,order)];
7265 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7267 return *_time_steps[getTimeStepPos(iteration,order)];
7270 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7272 if(_time_steps.empty())
7273 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7274 return _time_steps[0]->getMeshName();
7277 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7279 std::string oldName(getMeshName());
7280 std::vector< std::pair<std::string,std::string> > v(1);
7281 v[0].first=oldName; v[0].second=newMeshName;
7285 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7288 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7290 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7292 ret=cur->changeMeshNames(modifTab) || ret;
7298 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7300 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7302 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7306 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7308 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7310 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7313 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7314 MEDFileFieldGlobsReal& glob)
7317 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7319 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7321 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7326 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7328 std::string startLine(bkOffset,' ');
7329 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7331 oss << " (" << fmtsId << ")";
7332 oss << " has the following name: \"" << _name << "\"." << std::endl;
7333 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7334 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7336 oss << startLine << " - \"" << *it << "\"" << std::endl;
7339 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7341 std::string chapter(17,'0'+i);
7342 oss << startLine << chapter << std::endl;
7343 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7345 cur->simpleRepr(bkOffset+2,oss,i);
7347 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7348 oss << startLine << chapter << std::endl;
7352 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7354 std::size_t sz=_time_steps.size();
7355 std::vector< std::pair<int,int> > ret(sz);
7357 for(std::size_t i=0;i<sz;i++)
7359 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7362 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7366 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7367 throw INTERP_KERNEL::Exception(oss.str().c_str());
7373 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7375 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7377 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7378 checkCoherencyOfType(tse2);
7379 if(_time_steps.empty())
7381 setName(tse2->getName().c_str());
7382 setInfo(tse2->getInfo());
7384 checkThatComponentsMatch(tse2->getInfo());
7385 _time_steps.push_back(tse);
7388 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7390 std::size_t nbOfCompo=_infos.size();
7391 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7393 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7396 if((cur->getInfo()).size()!=nbOfCompo)
7398 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7399 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7400 throw INTERP_KERNEL::Exception(oss.str().c_str());
7402 cur->copyNameScope(*this);
7407 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)
7409 _time_steps.resize(nbPdt);
7410 for(int i=0;i<nbPdt;i++)
7412 std::vector< std::pair<int,int> > ts;
7413 med_int numdt=0,numo=0;
7414 med_int meshIt=0,meshOrder=0;
7416 MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7421 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7426 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7430 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7433 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7435 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7439 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7441 if(_time_steps.empty())
7442 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7443 checkThatNbOfCompoOfTSMatchThis();
7444 std::vector<std::string> infos(getInfo());
7445 int nbComp=infos.size();
7446 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7447 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7448 for(int i=0;i<nbComp;i++)
7450 std::string info=infos[i];
7452 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7453 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7454 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7457 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7458 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7459 int nbOfTS=_time_steps.size();
7460 for(int i=0;i<nbOfTS;i++)
7461 _time_steps[i]->writeLL(fid,opts,*this);
7464 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7466 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7468 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7470 elt->loadBigArraysRecursively(fid,nasc);
7474 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7476 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7478 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7480 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7484 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7486 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7488 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7490 elt->unloadArrays();
7494 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7496 return _time_steps.size();
7499 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7501 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7502 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7504 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7506 newTS.push_back(*it);
7511 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7513 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7514 int maxId=(int)_time_steps.size();
7516 std::set<int> idsToDel;
7517 for(const int *id=startIds;id!=endIds;id++,ii++)
7519 if(*id>=0 && *id<maxId)
7521 idsToDel.insert(*id);
7525 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7526 throw INTERP_KERNEL::Exception(oss.str().c_str());
7529 for(int iii=0;iii<maxId;iii++)
7530 if(idsToDel.find(iii)==idsToDel.end())
7531 newTS.push_back(_time_steps[iii]);
7535 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7537 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7538 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7539 if(nbOfEntriesToKill==0)
7541 std::size_t sz=_time_steps.size();
7542 std::vector<bool> b(sz,true);
7544 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7546 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7547 for(std::size_t i=0;i<sz;i++)
7549 newTS.push_back(_time_steps[i]);
7553 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7556 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7557 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7559 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7563 tmp->getTime(it2,ord);
7564 if(it2==iteration && order==ord)
7567 oss << "(" << it2 << "," << ord << "), ";
7570 throw INTERP_KERNEL::Exception(oss.str().c_str());
7573 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7576 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7578 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7580 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7584 double ti=tmp->getTime(it2,ord);
7585 if(fabs(time-ti)<eps)
7591 throw INTERP_KERNEL::Exception(oss.str().c_str());
7594 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7596 int lgth=_time_steps.size();
7597 std::vector< std::pair<int,int> > ret(lgth);
7598 for(int i=0;i<lgth;i++)
7599 _time_steps[i]->fillIteration(ret[i]);
7604 * 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'
7605 * This method returns two things.
7606 * - The absolute dimension of 'this' in first parameter.
7607 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7608 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7610 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7611 * Only these 3 discretizations will be taken into account here.
7613 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7614 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7615 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7617 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7618 * 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'.
7620 * Let's consider the typical following case :
7621 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7622 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7623 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7625 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7627 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7629 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7630 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7631 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7632 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7634 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7636 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7639 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7641 if(pos<0 || pos>=(int)_time_steps.size())
7643 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7644 throw INTERP_KERNEL::Exception(oss.str().c_str());
7646 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7649 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7650 oss << "\nTry to use following method eraseEmptyTS !";
7651 throw INTERP_KERNEL::Exception(oss.str().c_str());
7656 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7658 if(pos<0 || pos>=(int)_time_steps.size())
7660 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7661 throw INTERP_KERNEL::Exception(oss.str().c_str());
7663 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7666 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7667 oss << "\nTry to use following method eraseEmptyTS !";
7668 throw INTERP_KERNEL::Exception(oss.str().c_str());
7673 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7675 std::vector<std::string> ret;
7676 std::set<std::string> ret2;
7677 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7679 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7680 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7681 if(ret2.find(*it2)==ret2.end())
7683 ret.push_back(*it2);
7690 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7692 std::vector<std::string> ret;
7693 std::set<std::string> ret2;
7694 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7696 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7697 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7698 if(ret2.find(*it2)==ret2.end())
7700 ret.push_back(*it2);
7707 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7709 std::vector<std::string> ret;
7710 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7712 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7713 ret.insert(ret.end(),tmp.begin(),tmp.end());
7718 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7720 std::vector<std::string> ret;
7721 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7723 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7724 ret.insert(ret.end(),tmp.begin(),tmp.end());
7729 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7731 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7732 (*it)->changePflsRefsNamesGen2(mapOfModif);
7735 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7737 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7738 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7741 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7743 int lgth=_time_steps.size();
7744 std::vector< std::vector<TypeOfField> > ret(lgth);
7745 for(int i=0;i<lgth;i++)
7746 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7751 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7753 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
7755 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7758 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7760 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7762 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7764 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7765 ret->_time_steps[i]=(*it)->deepCopy();
7770 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7772 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7773 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7774 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7775 for(std::size_t i=0;i<sz;i++)
7777 ret[i]=shallowCpy();
7778 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7780 for(std::size_t i=0;i<sz2;i++)
7782 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7785 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7786 throw INTERP_KERNEL::Exception(oss.str().c_str());
7790 for(std::size_t i=0;i<sz;i++)
7791 for(std::size_t j=0;j<sz2;j++)
7792 ret[i]->_time_steps[j]=ts[j][i];
7797 * This method splits into discretization each time steps in \a this.
7798 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7800 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7802 std::size_t sz(_time_steps.size());
7803 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7804 for(std::size_t i=0;i<sz;i++)
7806 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7809 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7810 throw INTERP_KERNEL::Exception(oss.str().c_str());
7812 items[i]=timeStep->splitDiscretizations();
7815 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7816 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7817 std::vector< TypeOfField > types;
7818 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7819 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7821 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7823 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7824 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7825 if(it2==types.end())
7826 types.push_back(ts[0]);
7828 ret.resize(types.size()); ret2.resize(types.size());
7829 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7830 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7832 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7833 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7834 ret2[pos].push_back(*it1);
7836 for(std::size_t i=0;i<types.size();i++)
7838 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7839 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7840 elt->pushBackTimeStep(*it1);//also updates infos in elt
7842 elt->MEDFileFieldNameScope::operator=(*this);
7848 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7850 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7852 std::size_t sz(_time_steps.size());
7853 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7854 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7855 for(std::size_t i=0;i<sz;i++)
7857 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7860 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7861 throw INTERP_KERNEL::Exception(oss.str().c_str());
7863 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7864 if(szOut==std::numeric_limits<std::size_t>::max())
7865 szOut=items[i].size();
7867 if(items[i].size()!=szOut)
7868 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7870 if(szOut==std::numeric_limits<std::size_t>::max())
7871 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7872 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7873 for(std::size_t i=0;i<szOut;i++)
7875 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7876 for(std::size_t j=0;j<sz;j++)
7877 elt->pushBackTimeStep(items[j][i]);
7879 elt->MEDFileFieldNameScope::operator=(*this);
7884 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7886 _name=field->getName();
7888 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7890 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7891 _infos=arr->getInfoOnComponents();
7894 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7896 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7897 if(_name!=field->getName())
7899 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7900 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7901 throw INTERP_KERNEL::Exception(oss.str().c_str());
7904 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7905 checkThatComponentsMatch(arr->getInfoOnComponents());
7908 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7910 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7911 if(getInfo().size()!=compos.size())
7913 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7914 oss << " number of components of element to append (" << compos.size() << ") !";
7915 throw INTERP_KERNEL::Exception(oss.str().c_str());
7919 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7920 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7921 oss << " But compo in input fields are : ";
7922 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7924 throw INTERP_KERNEL::Exception(oss.str().c_str());
7928 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7930 std::size_t sz=_infos.size();
7932 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7934 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7936 if(elt->getInfo().size()!=sz)
7938 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7939 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7940 throw INTERP_KERNEL::Exception(oss.str().c_str());
7945 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7948 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7949 if(!_time_steps.empty())
7950 checkCoherencyOfTinyInfo(field,arr);
7951 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7952 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7953 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7954 copyTinyInfoFrom(field,arr);
7955 _time_steps.push_back(obj);
7958 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7961 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7962 if(!_time_steps.empty())
7963 checkCoherencyOfTinyInfo(field,arr);
7964 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7965 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7966 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7967 copyTinyInfoFrom(field,arr);
7968 _time_steps.push_back(obj);
7971 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
7973 int sz=(int)_time_steps.size();
7976 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7977 throw INTERP_KERNEL::Exception(oss.str().c_str());
7979 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7982 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7984 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7985 throw INTERP_KERNEL::Exception(oss.str().c_str());
7991 //= MEDFileFieldMultiTSWithoutSDA
7993 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)
7995 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
7998 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8002 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8007 * \param [in] fieldId field id in C mode
8009 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8010 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8013 catch(INTERP_KERNEL::Exception& e)
8016 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)
8017 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8020 catch(INTERP_KERNEL::Exception& e)
8023 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8025 return new MEDFileField1TSWithoutSDA;
8028 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8031 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8032 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8034 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8037 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8039 return MEDFileField1TSWithoutSDA::TYPE_STR;
8042 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8044 return new MEDFileFieldMultiTSWithoutSDA(*this);
8047 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8049 return new MEDFileFieldMultiTSWithoutSDA;
8053 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8054 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8056 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
8058 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8059 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8061 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8062 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8065 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8067 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8068 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8070 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8072 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8075 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8077 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8078 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8079 ret->setIteration(i,elt);
8085 //= MEDFileAnyTypeFieldMultiTS
8087 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8091 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8092 try:MEDFileFieldGlobsReal(fileName)
8094 MEDFileUtilities::CheckFileForRead(fileName);
8095 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8096 _content=BuildContentFrom(fid,fileName,loadAll,ms);
8099 catch(INTERP_KERNEL::Exception& e)
8104 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)
8106 med_field_type typcha;
8107 std::vector<std::string> infos;
8110 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
8111 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8116 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8121 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8126 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] !";
8127 throw INTERP_KERNEL::Exception(oss.str().c_str());
8130 ret->setDtUnit(dtunit.c_str());
8134 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8136 med_field_type typcha;
8138 std::vector<std::string> infos;
8139 std::string dtunit,fieldName;
8140 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8141 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8146 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8151 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8156 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] !";
8157 throw INTERP_KERNEL::Exception(oss.str().c_str());
8160 ret->setDtUnit(dtunit.c_str());
8164 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8167 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8168 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8170 MCAuto<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8171 ret->setFileName(fileName);
8172 ret->_content=c; c->incrRef();
8175 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8177 MCAuto<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8178 ret->setFileName(fileName);
8179 ret->_content=c; c->incrRef();
8182 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8185 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)
8186 try:MEDFileFieldGlobsReal(fileName)
8188 MEDFileUtilities::CheckFileForRead(fileName);
8189 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8190 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
8193 catch(INTERP_KERNEL::Exception& e)
8198 //= MEDFileIntFieldMultiTSWithoutSDA
8200 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)
8202 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8205 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8209 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8213 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)
8214 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8217 catch(INTERP_KERNEL::Exception& e)
8221 * \param [in] fieldId field id in C mode
8223 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8224 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8227 catch(INTERP_KERNEL::Exception& e)
8230 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8232 return new MEDFileIntField1TSWithoutSDA;
8235 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8238 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8239 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8241 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8244 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8246 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8249 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8251 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8254 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8256 return new MEDFileIntFieldMultiTSWithoutSDA;
8259 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8261 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8262 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8264 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8266 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8269 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8271 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8272 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8273 ret->setIteration(i,elt);
8279 //= MEDFileAnyTypeFieldMultiTS
8282 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8283 * that has been read from a specified MED file.
8284 * \param [in] fileName - the name of the MED file to read.
8285 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8286 * is to delete this field using decrRef() as it is no more needed.
8287 * \throw If reading the file fails.
8289 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8291 MEDFileUtilities::CheckFileForRead(fileName);
8292 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8293 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8294 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8295 ret->loadGlobals(fid);
8300 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8301 * that has been read from a specified MED file.
8302 * \param [in] fileName - the name of the MED file to read.
8303 * \param [in] fieldName - the name of the field to read.
8304 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8305 * is to delete this field using decrRef() as it is no more needed.
8306 * \throw If reading the file fails.
8307 * \throw If there is no field named \a fieldName in the file.
8309 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8311 MEDFileUtilities::CheckFileForRead(fileName);
8312 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8313 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
8314 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8315 ret->loadGlobals(fid);
8320 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8321 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8323 * \warning this is a shallow copy constructor
8325 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8327 if(!shallowCopyOfContent)
8329 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8330 otherPtr->incrRef();
8331 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8335 _content=other.shallowCpy();
8339 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8341 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8343 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8347 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8349 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8351 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8355 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8357 return contentNotNullBase()->getPflsReallyUsed2();
8360 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8362 return contentNotNullBase()->getLocsReallyUsed2();
8365 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8367 return contentNotNullBase()->getPflsReallyUsedMulti2();
8370 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8372 return contentNotNullBase()->getLocsReallyUsedMulti2();
8375 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8377 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8380 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8382 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8385 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8387 return contentNotNullBase()->getNumberOfTS();
8390 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8392 contentNotNullBase()->eraseEmptyTS();
8395 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8397 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8400 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8402 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8405 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8407 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8408 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8413 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8415 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8416 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8421 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8423 return contentNotNullBase()->getIterations();
8426 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8428 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8429 pushBackTimeStep(*it);
8432 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8435 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8436 int nbOfTS(fmts->getNumberOfTS());
8437 for(int i=0;i<nbOfTS;i++)
8439 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8440 pushBackTimeStep(elt);
8444 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8447 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8448 checkCoherencyOfType(f1ts);
8450 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8451 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8453 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8454 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8455 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8456 _content->pushBackTimeStep(cSafe);
8457 appendGlobs(*f1ts,1e-12);
8460 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8462 contentNotNullBase()->synchronizeNameScope();
8465 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8467 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8470 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8472 return contentNotNullBase()->getPosGivenTime(time,eps);
8475 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8477 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8480 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8482 return contentNotNullBase()->getTypesOfFieldAvailable();
8485 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
8487 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8490 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8492 return contentNotNullBase()->getName();
8495 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8497 contentNotNullBase()->setName(name);
8500 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8502 return contentNotNullBase()->getDtUnit();
8505 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8507 contentNotNullBase()->setDtUnit(dtUnit);
8510 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8512 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8515 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8517 return contentNotNullBase()->getTimeSteps(ret1);
8520 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8522 return contentNotNullBase()->getMeshName();
8525 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8527 contentNotNullBase()->setMeshName(newMeshName);
8530 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8532 return contentNotNullBase()->changeMeshNames(modifTab);
8535 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8537 return contentNotNullBase()->getInfo();
8540 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8542 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8545 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8547 return contentNotNullBase()->setInfo(info);
8550 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8552 const std::vector<std::string> ret=getInfo();
8553 return (int)ret.size();
8556 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8558 writeGlobals(fid,*this);
8559 contentNotNullBase()->writeLL(fid,*this);
8563 * Writes \a this field into a MED file specified by its name.
8564 * \param [in] fileName - the MED file name.
8565 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8566 * - 2 - erase; an existing file is removed.
8567 * - 1 - append; same data should not be present in an existing file.
8568 * - 0 - overwrite; same data present in an existing file is overwritten.
8569 * \throw If the field name is not set.
8570 * \throw If no field data is set.
8571 * \throw If \a mode == 1 and the same data is present in an existing file.
8573 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8575 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8576 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8581 * This method alloc the arrays and load potentially huge arrays contained in this field.
8582 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8583 * This method can be also called to refresh or reinit values from a file.
8585 * \throw If the fileName is not set or points to a non readable MED file.
8587 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8589 if(getFileName().empty())
8590 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8591 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8592 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8596 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8597 * But once data loaded once, this method does nothing.
8599 * \throw If the fileName is not set or points to a non readable MED file.
8600 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8602 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8604 if(!getFileName().empty())
8606 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8607 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8612 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8613 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8614 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8616 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8618 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8620 contentNotNullBase()->unloadArrays();
8624 * 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.
8625 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8626 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8628 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8630 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8632 if(!getFileName().empty())
8633 contentNotNullBase()->unloadArrays();
8636 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8638 std::ostringstream oss;
8639 contentNotNullBase()->simpleRepr(0,oss,-1);
8640 simpleReprGlobs(oss);
8644 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8646 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8649 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8651 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8652 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8657 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8658 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8659 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8661 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8663 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8665 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8666 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8667 std::size_t sz(contentsSplit.size());
8668 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8669 for(std::size_t i=0;i<sz;i++)
8671 ret[i]=shallowCpy();
8672 ret[i]->_content=contentsSplit[i];
8678 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8679 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8681 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8683 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8685 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8686 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8687 std::size_t sz(contentsSplit.size());
8688 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8689 for(std::size_t i=0;i<sz;i++)
8691 ret[i]=shallowCpy();
8692 ret[i]->_content=contentsSplit[i];
8698 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8699 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8701 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8703 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8705 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8706 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8707 std::size_t sz(contentsSplit.size());
8708 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8709 for(std::size_t i=0;i<sz;i++)
8711 ret[i]=shallowCpy();
8712 ret[i]->_content=contentsSplit[i];
8717 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8719 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8720 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8721 ret->_content=_content->deepCopy();
8722 ret->deepCpyGlobs(*this);
8726 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8732 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8733 * \param [in] iteration - the iteration number of a required time step.
8734 * \param [in] order - the iteration order number of required time step.
8735 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8736 * delete this field using decrRef() as it is no more needed.
8737 * \throw If there is no required time step in \a this field.
8739 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8741 int pos=getPosOfTimeStep(iteration,order);
8742 return getTimeStepAtPos(pos);
8746 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8747 * \param [in] time - the time of the time step of interest.
8748 * \param [in] eps - a precision used to compare time values.
8749 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8750 * delete this field using decrRef() as it is no more needed.
8751 * \throw If there is no required time step in \a this field.
8753 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8755 int pos=getPosGivenTime(time,eps);
8756 return getTimeStepAtPos(pos);
8760 * 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.
8761 * The float64 value of time attached to the pair of integers are not considered here.
8762 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8764 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8765 * \throw If there is a null pointer in \a vectFMTS.
8767 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8769 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8770 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8771 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8772 while(!lstFMTS.empty())
8774 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8775 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8777 throw INTERP_KERNEL::Exception(msg);
8778 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8779 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8780 elt.push_back(curIt); it=lstFMTS.erase(it);
8781 while(it!=lstFMTS.end())
8785 throw INTERP_KERNEL::Exception(msg);
8786 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8788 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8798 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8799 * All returned instances in a subvector can be safely loaded, rendered along time
8800 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8801 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8802 * 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).
8803 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8804 * 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.
8806 * \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().
8807 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8808 * \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.
8809 * \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.
8811 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8812 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8813 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8814 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8815 * \throw If mesh is null.
8816 * \throw If an element in \a vectFMTS is null.
8817 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8819 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8821 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8823 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8824 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8825 if(vectFMTS.empty())
8827 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8828 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8830 throw INTERP_KERNEL::Exception(msg);
8832 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8833 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8834 for(;it!=vectFMTS.end();it++,i++)
8837 throw INTERP_KERNEL::Exception(msg);
8838 TypeOfField tof0,tof1;
8839 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8842 vectFMTSNotNodes.push_back(*it);
8844 vectFMTSNodes.push_back(*it);
8847 vectFMTSNotNodes.push_back(*it);
8849 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8850 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8852 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8855 bool isFetched(false);
8856 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8859 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8860 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8861 { ret[i].push_back(*it2); isFetched=true; }
8865 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8866 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8867 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8875 * 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.
8876 * \param [out] cmps - same size than the returned vector.
8878 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8880 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8881 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8882 while(!lstFMTS.empty())
8884 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8885 MEDFileAnyTypeFieldMultiTS *ref(*it);
8886 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8887 elt.push_back(ref); it=lstFMTS.erase(it);
8888 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8889 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8890 while(it!=lstFMTS.end())
8892 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8893 if(cmp->isEqual(curIt))
8894 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8898 ret.push_back(elt); cmps.push_back(cmp);
8904 * 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.
8905 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8907 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8908 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8909 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8910 * \thorw If \a f0 and \a f1 do not have the same times steps.
8911 * \throw If mesh is null.
8912 * \throw If \a f0 or \a f1 is null.
8913 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8915 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8918 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8920 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8921 if(f0->getMeshName()!=mesh->getName())
8923 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8924 throw INTERP_KERNEL::Exception(oss.str().c_str());
8926 if(f1->getMeshName()!=mesh->getName())
8928 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8929 throw INTERP_KERNEL::Exception(oss.str().c_str());
8931 int nts=f0->getNumberOfTS();
8932 if(nts!=f1->getNumberOfTS())
8933 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8936 for(int i=0;i<nts;i++)
8938 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8939 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8940 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8941 if(tofs0.size()!=1 || tofs1.size()!=1)
8942 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8945 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8946 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8949 { tof0=tofs0[0]; tof1=tofs1[0]; }
8950 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8952 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() << ") !";
8953 throw INTERP_KERNEL::Exception(oss.str().c_str());
8955 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8957 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() << ") !";
8958 throw INTERP_KERNEL::Exception(oss.str().c_str());
8960 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8962 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() << ") !";
8963 throw INTERP_KERNEL::Exception(oss.str().c_str());
8970 * Return an extraction of \a this using \a extractDef map to specify the extraction.
8971 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
8973 * \return A new object that the caller is responsible to deallocate.
8975 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
8978 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
8979 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
8980 int nbTS(getNumberOfTS());
8981 for(int i=0;i<nbTS;i++)
8983 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
8984 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
8985 fmtsOut->pushBackTimeStep(f1tsOut);
8987 return fmtsOut.retn();
8990 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8992 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8995 //= MEDFileFieldMultiTS
8998 * Returns a new empty instance of MEDFileFieldMultiTS.
8999 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9000 * is to delete this field using decrRef() as it is no more needed.
9002 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9004 return new MEDFileFieldMultiTS;
9008 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9009 * that has been read from a specified MED file.
9010 * \param [in] fileName - the name of the MED file to read.
9011 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9012 * is to delete this field using decrRef() as it is no more needed.
9013 * \throw If reading the file fails.
9015 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9017 MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
9018 ret->contentNotNull();//to check that content type matches with \a this type.
9023 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9024 * that has been read from a specified MED file.
9025 * \param [in] fileName - the name of the MED file to read.
9026 * \param [in] fieldName - the name of the field to read.
9027 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9028 * is to delete this field using decrRef() as it is no more needed.
9029 * \throw If reading the file fails.
9030 * \throw If there is no field named \a fieldName in the file.
9032 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9034 MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
9035 ret->contentNotNull();//to check that content type matches with \a this type.
9040 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9041 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9043 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9044 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9045 * \warning this is a shallow copy constructor
9046 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9047 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9048 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9049 * is to delete this field using decrRef() as it is no more needed.
9051 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9053 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9056 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9058 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities));
9059 ret->contentNotNull();//to check that content type matches with \a this type.
9063 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9065 return new MEDFileFieldMultiTS(*this);
9068 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9071 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9072 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9074 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9078 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9079 * following the given input policy.
9081 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9082 * By default (true) the globals are deeply copied.
9083 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9085 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9087 MCAuto<MEDFileIntFieldMultiTS> ret;
9088 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9091 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9093 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9094 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9095 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
9098 ret=MEDFileIntFieldMultiTS::New();
9100 ret->deepCpyGlobs(*this);
9102 ret->shallowCpyGlobs(*this);
9107 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9108 * \param [in] pos - a time step id.
9109 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9110 * delete this field using decrRef() as it is no more needed.
9111 * \throw If \a pos is not a valid time step id.
9113 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9115 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9118 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9119 throw INTERP_KERNEL::Exception(oss.str().c_str());
9121 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9124 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9125 ret->shallowCpyGlobs(*this);
9128 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9129 throw INTERP_KERNEL::Exception(oss.str().c_str());
9133 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9134 * mesh entities of a given dimension of the first mesh in MED file.
9135 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9136 * \param [in] type - a spatial discretization of interest.
9137 * \param [in] iteration - the iteration number of a required time step.
9138 * \param [in] order - the iteration order number of required time step.
9139 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9140 * \param [in] renumPol - specifies how to permute values of the result field according to
9141 * the optional numbers of cells and nodes, if any. The valid values are
9142 * - 0 - do not permute.
9143 * - 1 - permute cells.
9144 * - 2 - permute nodes.
9145 * - 3 - permute cells and nodes.
9147 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9148 * caller is to delete this field using decrRef() as it is no more needed.
9149 * \throw If the MED file is not readable.
9150 * \throw If there is no mesh in the MED file.
9151 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9152 * \throw If no field values of the required parameters are available.
9154 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9156 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9157 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9159 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9160 MCAuto<DataArray> arrOut;
9161 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9162 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9167 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9168 * the top level cells of the first mesh in MED file.
9169 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9170 * \param [in] type - a spatial discretization of interest.
9171 * \param [in] iteration - the iteration number of a required time step.
9172 * \param [in] order - the iteration order number of required time step.
9173 * \param [in] renumPol - specifies how to permute values of the result field according to
9174 * the optional numbers of cells and nodes, if any. The valid values are
9175 * - 0 - do not permute.
9176 * - 1 - permute cells.
9177 * - 2 - permute nodes.
9178 * - 3 - permute cells and nodes.
9180 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9181 * caller is to delete this field using decrRef() as it is no more needed.
9182 * \throw If the MED file is not readable.
9183 * \throw If there is no mesh in the MED file.
9184 * \throw If no field values of the required parameters are available.
9186 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9188 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9189 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9191 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9192 MCAuto<DataArray> arrOut;
9193 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9194 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9199 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9201 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9202 * \param [in] type - a spatial discretization of interest.
9203 * \param [in] iteration - the iteration number of a required time step.
9204 * \param [in] order - the iteration order number of required time step.
9205 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9206 * \param [in] mesh - the supporting mesh.
9207 * \param [in] renumPol - specifies how to permute values of the result field according to
9208 * the optional numbers of cells and nodes, if any. The valid values are
9209 * - 0 - do not permute.
9210 * - 1 - permute cells.
9211 * - 2 - permute nodes.
9212 * - 3 - permute cells and nodes.
9214 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9215 * caller is to delete this field using decrRef() as it is no more needed.
9216 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9217 * \throw If no field of \a this is lying on \a mesh.
9218 * \throw If no field values of the required parameters are available.
9220 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9222 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9223 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9225 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9226 MCAuto<DataArray> arrOut;
9227 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9228 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9233 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9235 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9236 * \param [in] type - a spatial discretization of the new field.
9237 * \param [in] iteration - the iteration number of a required time step.
9238 * \param [in] order - the iteration order number of required time step.
9239 * \param [in] mesh - the supporting mesh.
9240 * \param [in] renumPol - specifies how to permute values of the result field according to
9241 * the optional numbers of cells and nodes, if any. The valid values are
9242 * - 0 - do not permute.
9243 * - 1 - permute cells.
9244 * - 2 - permute nodes.
9245 * - 3 - permute cells and nodes.
9247 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9248 * caller is to delete this field using decrRef() as it is no more needed.
9249 * \throw If no field of \a this is lying on \a mesh.
9250 * \throw If no field values of the required parameters are available.
9252 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9254 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9255 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9257 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9258 MCAuto<DataArray> arrOut;
9259 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9260 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9265 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9266 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9267 * This method is useful for MED2 file format when field on different mesh was autorized.
9269 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9271 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9272 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9274 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9275 MCAuto<DataArray> arrOut;
9276 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9277 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9282 * Returns values and a profile of the field of a given type, of a given time step,
9283 * lying on a given support.
9284 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9285 * \param [in] type - a spatial discretization of the field.
9286 * \param [in] iteration - the iteration number of a required time step.
9287 * \param [in] order - the iteration order number of required time step.
9288 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9289 * \param [in] mesh - the supporting mesh.
9290 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9291 * field of interest lies on. If the field lies on all entities of the given
9292 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9293 * using decrRef() as it is no more needed.
9294 * \param [in] glob - the global data storing profiles and localization.
9295 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9296 * field. The caller is to delete this array using decrRef() as it is no more needed.
9297 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9298 * \throw If no field of \a this is lying on \a mesh.
9299 * \throw If no field values of the required parameters are available.
9301 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9303 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9304 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9306 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9307 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9308 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9311 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9313 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9315 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9316 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9318 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 !");
9322 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9324 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9326 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9327 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9329 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 !");
9334 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9335 * the given field is checked if its elements are sorted suitable for writing to MED file
9336 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9337 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9338 * \param [in] field - the field to add to \a this.
9339 * \throw If the name of \a field is empty.
9340 * \throw If the data array of \a field is not set.
9341 * \throw If existing time steps have different name or number of components than \a field.
9342 * \throw If the underlying mesh of \a field has no name.
9343 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9345 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9347 const DataArrayDouble *arr=0;
9349 arr=field->getArray();
9350 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9354 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9355 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9356 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9359 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9360 * A new profile is added only if no equal profile is missing.
9361 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9362 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9363 * \param [in] mesh - the supporting mesh of \a field.
9364 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9365 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9366 * \throw If either \a field or \a mesh or \a profile has an empty name.
9367 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9368 * \throw If the data array of \a field is not set.
9369 * \throw If the data array of \a this is already allocated but has different number of
9370 * components than \a field.
9371 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9372 * \sa setFieldNoProfileSBT()
9374 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9376 const DataArrayDouble *arr=0;
9378 arr=field->getArray();
9379 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9382 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9384 _content=new MEDFileFieldMultiTSWithoutSDA;
9387 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9388 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9391 catch(INTERP_KERNEL::Exception& e)
9394 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)
9395 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9398 catch(INTERP_KERNEL::Exception& e)
9401 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9405 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
9407 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9410 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9412 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9415 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9417 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9420 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9422 return MEDFileFieldMultiTS::New();
9425 //= MEDFileAnyTypeFieldMultiTSIterator
9427 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9432 _nb_iter=fmts->getNumberOfTS();
9436 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9440 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9442 if(_iter_id<_nb_iter)
9444 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9446 return fmts->getTimeStepAtPos(_iter_id++);
9454 //= MEDFileIntFieldMultiTS
9457 * Returns a new empty instance of MEDFileFieldMultiTS.
9458 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9459 * is to delete this field using decrRef() as it is no more needed.
9461 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9463 return new MEDFileIntFieldMultiTS;
9467 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9468 * that has been read from a specified MED file.
9469 * \param [in] fileName - the name of the MED file to read.
9470 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9471 * is to delete this field using decrRef() as it is no more needed.
9472 * \throw If reading the file fails.
9474 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9476 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9477 ret->contentNotNull();//to check that content type matches with \a this type.
9482 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9483 * that has been read from a specified MED file.
9484 * \param [in] fileName - the name of the MED file to read.
9485 * \param [in] fieldName - the name of the field to read.
9486 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9487 * is to delete this field using decrRef() as it is no more needed.
9488 * \throw If reading the file fails.
9489 * \throw If there is no field named \a fieldName in the file.
9491 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9493 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9494 ret->contentNotNull();//to check that content type matches with \a this type.
9499 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9500 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9502 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9503 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9504 * \warning this is a shallow copy constructor
9505 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9506 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9507 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9508 * is to delete this field using decrRef() as it is no more needed.
9510 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9512 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9515 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9517 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities);
9518 ret->contentNotNull();//to check that content type matches with \a this type.
9523 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9524 * following the given input policy.
9526 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9527 * By default (true) the globals are deeply copied.
9528 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9530 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9532 MCAuto<MEDFileFieldMultiTS> ret;
9533 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9536 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9538 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9539 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9540 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9543 ret=MEDFileFieldMultiTS::New();
9545 ret->deepCpyGlobs(*this);
9547 ret->shallowCpyGlobs(*this);
9551 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9553 return new MEDFileIntFieldMultiTS(*this);
9556 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9559 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9560 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9562 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9566 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9567 * mesh entities of a given dimension of the first mesh in MED file.
9568 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9569 * \param [in] type - a spatial discretization of interest.
9570 * \param [in] iteration - the iteration number of a required time step.
9571 * \param [in] order - the iteration order number of required time step.
9572 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9573 * \param [out] arrOut - the DataArrayInt containing values of field.
9574 * \param [in] renumPol - specifies how to permute values of the result field according to
9575 * the optional numbers of cells and nodes, if any. The valid values are
9576 * - 0 - do not permute.
9577 * - 1 - permute cells.
9578 * - 2 - permute nodes.
9579 * - 3 - permute cells and nodes.
9581 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9582 * caller is to delete this field using decrRef() as it is no more needed.
9583 * \throw If the MED file is not readable.
9584 * \throw If there is no mesh in the MED file.
9585 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9586 * \throw If no field values of the required parameters are available.
9588 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9590 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9591 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9593 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9594 MCAuto<DataArray> arr;
9595 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9596 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9601 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9602 * the top level cells of the first mesh in MED file.
9603 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9604 * \param [in] type - a spatial discretization of interest.
9605 * \param [in] iteration - the iteration number of a required time step.
9606 * \param [in] order - the iteration order number of required time step.
9607 * \param [out] arrOut - the DataArrayInt containing values of field.
9608 * \param [in] renumPol - specifies how to permute values of the result field according to
9609 * the optional numbers of cells and nodes, if any. The valid values are
9610 * - 0 - do not permute.
9611 * - 1 - permute cells.
9612 * - 2 - permute nodes.
9613 * - 3 - permute cells and nodes.
9615 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9616 * caller is to delete this field using decrRef() as it is no more needed.
9617 * \throw If the MED file is not readable.
9618 * \throw If there is no mesh in the MED file.
9619 * \throw If no field values of the required parameters are available.
9621 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9623 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9624 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9626 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9627 MCAuto<DataArray> arr;
9628 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9629 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9634 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9636 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9637 * \param [in] type - a spatial discretization of interest.
9638 * \param [in] iteration - the iteration number of a required time step.
9639 * \param [in] order - the iteration order number of required time step.
9640 * \param [out] arrOut - the DataArrayInt containing values of field.
9641 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9642 * \param [in] mesh - the supporting mesh.
9643 * \param [in] renumPol - specifies how to permute values of the result field according to
9644 * the optional numbers of cells and nodes, if any. The valid values are
9645 * - 0 - do not permute.
9646 * - 1 - permute cells.
9647 * - 2 - permute nodes.
9648 * - 3 - permute cells and nodes.
9650 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9651 * caller is to delete this field using decrRef() as it is no more needed.
9652 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9653 * \throw If no field of \a this is lying on \a mesh.
9654 * \throw If no field values of the required parameters are available.
9656 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9658 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9659 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9661 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9662 MCAuto<DataArray> arr;
9663 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9664 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9669 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9671 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9672 * \param [in] type - a spatial discretization of the new field.
9673 * \param [in] iteration - the iteration number of a required time step.
9674 * \param [in] order - the iteration order number of required time step.
9675 * \param [in] mesh - the supporting mesh.
9676 * \param [out] arrOut - the DataArrayInt containing values of field.
9677 * \param [in] renumPol - specifies how to permute values of the result field according to
9678 * the optional numbers of cells and nodes, if any. The valid values are
9679 * - 0 - do not permute.
9680 * - 1 - permute cells.
9681 * - 2 - permute nodes.
9682 * - 3 - permute cells and nodes.
9684 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9685 * caller is to delete this field using decrRef() as it is no more needed.
9686 * \throw If no field of \a this is lying on \a mesh.
9687 * \throw If no field values of the required parameters are available.
9689 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9691 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9692 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9694 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9695 MCAuto<DataArray> arr;
9696 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9697 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9702 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9703 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9704 * This method is useful for MED2 file format when field on different mesh was autorized.
9706 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9708 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9709 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9711 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9712 MCAuto<DataArray> arr;
9713 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9714 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9719 * Returns values and a profile of the field of a given type, of a given time step,
9720 * lying on a given support.
9721 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9722 * \param [in] type - a spatial discretization of the field.
9723 * \param [in] iteration - the iteration number of a required time step.
9724 * \param [in] order - the iteration order number of required time step.
9725 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9726 * \param [in] mesh - the supporting mesh.
9727 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9728 * field of interest lies on. If the field lies on all entities of the given
9729 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9730 * using decrRef() as it is no more needed.
9731 * \param [in] glob - the global data storing profiles and localization.
9732 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9733 * field. The caller is to delete this array using decrRef() as it is no more needed.
9734 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9735 * \throw If no field of \a this is lying on \a mesh.
9736 * \throw If no field values of the required parameters are available.
9738 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9740 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9741 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9743 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9744 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9745 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9749 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9750 * \param [in] pos - a time step id.
9751 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9752 * delete this field using decrRef() as it is no more needed.
9753 * \throw If \a pos is not a valid time step id.
9755 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9757 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9760 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9761 throw INTERP_KERNEL::Exception(oss.str().c_str());
9763 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9766 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9767 ret->shallowCpyGlobs(*this);
9770 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9771 throw INTERP_KERNEL::Exception(oss.str().c_str());
9775 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9776 * the given field is checked if its elements are sorted suitable for writing to MED file
9777 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9778 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9779 * \param [in] field - the field to add to \a this.
9780 * \throw If the name of \a field is empty.
9781 * \throw If the data array of \a field is not set.
9782 * \throw If existing time steps have different name or number of components than \a field.
9783 * \throw If the underlying mesh of \a field has no name.
9784 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9786 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9788 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9792 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9793 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9794 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9797 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9798 * A new profile is added only if no equal profile is missing.
9799 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9800 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9801 * \param [in] arrOfVals - the values of the field \a field used.
9802 * \param [in] mesh - the supporting mesh of \a field.
9803 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9804 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9805 * \throw If either \a field or \a mesh or \a profile has an empty name.
9806 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9807 * \throw If the data array of \a field is not set.
9808 * \throw If the data array of \a this is already allocated but has different number of
9809 * components than \a field.
9810 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9811 * \sa setFieldNoProfileSBT()
9813 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9815 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9818 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9820 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9822 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9823 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9825 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 !");
9829 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9831 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9833 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9834 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9836 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 !");
9840 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9842 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9845 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9849 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9850 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9853 catch(INTERP_KERNEL::Exception& e)
9856 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)
9857 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9860 catch(INTERP_KERNEL::Exception& e)
9863 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9865 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9868 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
9870 return MEDFileIntFieldMultiTS::New();
9875 MEDFileFields *MEDFileFields::New()
9877 return new MEDFileFields;
9880 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9882 return new MEDFileFields(fileName,loadAll,0,0);
9885 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9887 return new MEDFileFields(fileName,loadAll,ms,0);
9890 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9892 return new MEDFileFields(fileName,loadAll,0,&entities);
9895 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9897 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9898 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9902 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9904 std::vector<const BigMemoryObject *> ret;
9905 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9906 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9910 MEDFileFields *MEDFileFields::deepCopy() const
9912 MCAuto<MEDFileFields> ret=shallowCpy();
9914 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9916 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9917 ret->_fields[i]=(*it)->deepCopy();
9919 ret->deepCpyGlobs(*this);
9923 MEDFileFields *MEDFileFields::shallowCpy() const
9925 return new MEDFileFields(*this);
9929 * 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
9930 * 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.
9931 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9933 * \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.
9934 * \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.
9936 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9938 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9940 std::set< std::pair<int,int> > s;
9941 bool firstShot=true;
9942 areThereSomeForgottenTS=false;
9943 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9945 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9947 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9948 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9950 { s=s1; firstShot=false; }
9953 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9955 areThereSomeForgottenTS=true;
9959 std::vector< std::pair<int,int> > ret;
9960 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9964 int MEDFileFields::getNumberOfFields() const
9966 return _fields.size();
9969 std::vector<std::string> MEDFileFields::getFieldsNames() const
9971 std::vector<std::string> ret(_fields.size());
9973 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9975 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9978 ret[i]=f->getName();
9982 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9983 throw INTERP_KERNEL::Exception(oss.str().c_str());
9989 std::vector<std::string> MEDFileFields::getMeshesNames() const
9991 std::vector<std::string> ret;
9992 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9994 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9996 ret.push_back(cur->getMeshName());
10001 std::string MEDFileFields::simpleRepr() const
10003 std::ostringstream oss;
10004 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10009 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10011 int nbOfFields=getNumberOfFields();
10012 std::string startLine(bkOffset,' ');
10013 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10015 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10017 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10020 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10024 oss << startLine << " - not defined !" << std::endl;
10028 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10030 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10031 std::string chapter(17,'0'+i);
10032 oss << startLine << chapter << std::endl;
10035 cur->simpleRepr(bkOffset+2,oss,i);
10039 oss << startLine << " - not defined !" << std::endl;
10041 oss << startLine << chapter << std::endl;
10043 simpleReprGlobs(oss);
10046 MEDFileFields::MEDFileFields()
10050 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10051 try:MEDFileFieldGlobsReal(fileName)
10053 MEDFileUtilities::CheckFileForRead(fileName);
10054 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
10055 int nbFields(MEDnField(fid));
10056 _fields.resize(nbFields);
10057 med_field_type typcha;
10058 for(int i=0;i<nbFields;i++)
10060 std::vector<std::string> infos;
10061 std::string fieldName,dtunit;
10062 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
10067 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10072 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10077 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] !";
10078 throw INTERP_KERNEL::Exception(oss.str().c_str());
10082 loadAllGlobals(fid);
10084 catch(INTERP_KERNEL::Exception& e)
10089 void MEDFileFields::writeLL(med_idt fid) const
10092 writeGlobals(fid,*this);
10093 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10095 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10098 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10099 throw INTERP_KERNEL::Exception(oss.str().c_str());
10101 elt->writeLL(fid,*this);
10105 void MEDFileFields::write(const std::string& fileName, int mode) const
10107 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
10108 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
10113 * This method alloc the arrays and load potentially huge arrays contained in this field.
10114 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10115 * This method can be also called to refresh or reinit values from a file.
10117 * \throw If the fileName is not set or points to a non readable MED file.
10119 void MEDFileFields::loadArrays()
10121 if(getFileName().empty())
10122 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10123 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10124 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10126 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10128 elt->loadBigArraysRecursively(fid,*elt);
10133 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10134 * But once data loaded once, this method does nothing.
10136 * \throw If the fileName is not set or points to a non readable MED file.
10137 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10139 void MEDFileFields::loadArraysIfNecessary()
10141 if(!getFileName().empty())
10143 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10144 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10146 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10148 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10154 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10155 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10156 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10158 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10160 void MEDFileFields::unloadArrays()
10162 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10164 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10166 elt->unloadArrays();
10171 * 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.
10172 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10173 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10175 * \sa MEDFileFields::loadArraysIfNecessary
10177 void MEDFileFields::unloadArraysWithoutDataLoss()
10179 if(!getFileName().empty())
10183 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10185 std::vector<std::string> ret;
10186 std::set<std::string> ret2;
10187 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10189 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10190 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10191 if(ret2.find(*it2)==ret2.end())
10193 ret.push_back(*it2);
10200 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10202 std::vector<std::string> ret;
10203 std::set<std::string> ret2;
10204 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10206 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10207 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10208 if(ret2.find(*it2)==ret2.end())
10210 ret.push_back(*it2);
10217 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10219 std::vector<std::string> ret;
10220 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10222 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10223 ret.insert(ret.end(),tmp.begin(),tmp.end());
10228 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10230 std::vector<std::string> ret;
10231 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10233 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10234 ret.insert(ret.end(),tmp.begin(),tmp.end());
10239 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10241 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10242 (*it)->changePflsRefsNamesGen2(mapOfModif);
10245 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10247 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10248 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10251 void MEDFileFields::resize(int newSize)
10253 _fields.resize(newSize);
10256 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10258 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10262 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10265 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10266 _fields.push_back(field->getContent());
10267 appendGlobs(*field,1e-12);
10270 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10273 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10274 if(i>=(int)_fields.size())
10275 _fields.resize(i+1);
10276 _fields[i]=field->getContent();
10277 appendGlobs(*field,1e-12);
10280 void MEDFileFields::destroyFieldAtPos(int i)
10282 destroyFieldsAtPos(&i,&i+1);
10285 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10287 std::vector<bool> b(_fields.size(),true);
10288 for(const int *i=startIds;i!=endIds;i++)
10290 if(*i<0 || *i>=(int)_fields.size())
10292 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10293 throw INTERP_KERNEL::Exception(oss.str().c_str());
10297 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10299 for(std::size_t i=0;i<_fields.size();i++)
10301 fields[j++]=_fields[i];
10305 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10307 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10308 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10309 std::vector<bool> b(_fields.size(),true);
10311 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10313 if(k<0 || k>=(int)_fields.size())
10315 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10316 throw INTERP_KERNEL::Exception(oss.str().c_str());
10320 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10322 for(std::size_t i=0;i<_fields.size();i++)
10324 fields[j++]=_fields[i];
10328 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10331 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10333 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10335 ret=cur->changeMeshNames(modifTab) || ret;
10341 * \param [in] meshName the name of the mesh that will be renumbered.
10342 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10343 * This code corresponds to the distribution of types in the corresponding mesh.
10344 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10345 * \param [in] renumO2N the old to new renumber array.
10346 * \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
10347 * field in \a this.
10349 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10352 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10354 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10357 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10364 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10365 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10367 * \return A new object that the caller is responsible to deallocate.
10369 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10372 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10373 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10374 int nbFields(getNumberOfFields());
10375 for(int i=0;i<nbFields;i++)
10377 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10380 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10381 throw INTERP_KERNEL::Exception(oss.str().c_str());
10383 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10384 fsOut->pushField(fmtsOut);
10386 return fsOut.retn();
10389 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10391 if(i<0 || i>=(int)_fields.size())
10393 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10394 throw INTERP_KERNEL::Exception(oss.str().c_str());
10396 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10399 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10400 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10401 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10403 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10405 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10408 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10409 throw INTERP_KERNEL::Exception(oss.str().c_str());
10411 ret->shallowCpyGlobs(*this);
10416 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10417 * This method is accessible in python using __getitem__ with a list in input.
10418 * \return a new object that the caller should deal with.
10420 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10422 MCAuto<MEDFileFields> ret=shallowCpy();
10423 std::size_t sz=std::distance(startIds,endIds);
10424 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10426 for(const int *i=startIds;i!=endIds;i++,j++)
10428 if(*i<0 || *i>=(int)_fields.size())
10430 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10431 throw INTERP_KERNEL::Exception(oss.str().c_str());
10433 fields[j]=_fields[*i];
10435 ret->_fields=fields;
10439 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10441 return getFieldAtPos(getPosFromFieldName(fieldName));
10445 * This method removes, if any, fields in \a this having no time steps.
10446 * 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.
10448 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10450 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10452 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10453 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10455 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10458 if(elt->getNumberOfTS()>0)
10459 newFields.push_back(*it);
10462 if(_fields.size()==newFields.size())
10469 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10470 * This method can be seen as a filter applied on \a this, that returns an object containing
10471 * 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
10472 * shallow copied from \a this.
10474 * \param [in] meshName - the name of the mesh on w
10475 * \return a new object that the caller should deal with.
10477 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10479 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10480 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10482 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10485 if(cur->getMeshName()==meshName)
10488 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10489 ret->_fields.push_back(cur2);
10492 ret->shallowCpyOnlyUsedGlobs(*this);
10497 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10498 * Input time steps are specified using a pair of integer (iteration, order).
10499 * 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,
10500 * but for each multitimestep only the time steps in \a timeSteps are kept.
10501 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10503 * The returned object points to shallow copy of elements in \a this.
10505 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10506 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10507 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10509 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10511 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10512 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10514 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10517 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10518 ret->_fields.push_back(elt);
10520 ret->shallowCpyOnlyUsedGlobs(*this);
10525 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10527 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10529 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10530 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10532 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10535 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10536 if(elt->getNumberOfTS()!=0)
10537 ret->_fields.push_back(elt);
10539 ret->shallowCpyOnlyUsedGlobs(*this);
10543 MEDFileFieldsIterator *MEDFileFields::iterator()
10545 return new MEDFileFieldsIterator(this);
10548 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10550 std::string tmp(fieldName);
10551 std::vector<std::string> poss;
10552 for(std::size_t i=0;i<_fields.size();i++)
10554 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10557 std::string fname(f->getName());
10561 poss.push_back(fname);
10564 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10565 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10567 throw INTERP_KERNEL::Exception(oss.str().c_str());
10570 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10575 _nb_iter=fs->getNumberOfFields();
10579 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10583 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10585 if(_iter_id<_nb_iter)
10587 MEDFileFields *fs(_fs);
10589 return fs->getFieldAtPos(_iter_id++);