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 "MEDCouplingFieldTemplate.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
32 #include "InterpKernelAutoPtr.hxx"
33 #include "CellModel.hxx"
38 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
39 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
40 extern med_geometry_type typmainoeud[1];
41 extern med_geometry_type typmai3[34];
43 using namespace MEDCoupling;
45 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
46 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
48 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
50 return new MEDFileFieldLoc(fid,locName);
53 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
55 return new MEDFileFieldLoc(fid,id);
58 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)
60 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
63 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
65 med_geometry_type geotype;
66 med_geometry_type sectiongeotype;
68 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
69 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
70 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
71 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
72 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
73 _nb_node_per_cell=cm.getNumberOfNodes();
74 _ref_coo.resize(_dim*_nb_node_per_cell);
75 _gs_coo.resize(_dim*_nb_gauss_pt);
76 _w.resize(_nb_gauss_pt);
77 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
80 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
82 med_geometry_type geotype;
83 med_geometry_type sectiongeotype;
85 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
87 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
88 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
90 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
91 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
92 _nb_node_per_cell=cm.getNumberOfNodes();
93 _ref_coo.resize(_dim*_nb_node_per_cell);
94 _gs_coo.resize(_dim*_nb_gauss_pt);
95 _w.resize(_nb_gauss_pt);
96 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
99 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
100 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),
103 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
104 _dim=cm.getDimension();
105 _nb_node_per_cell=cm.getNumberOfNodes();
106 _nb_gauss_pt=_w.size();
109 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
111 return new MEDFileFieldLoc(*this);
114 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
116 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
119 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
121 return std::vector<const BigMemoryObject *>();
124 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
126 static const char OFF7[]="\n ";
127 oss << "\"" << _name << "\"" << OFF7;
128 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
129 oss << "Dimension=" << _dim << OFF7;
130 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
131 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
132 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
133 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
134 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
137 void MEDFileFieldLoc::setName(const std::string& name)
142 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
144 if(_name!=other._name)
148 if(_nb_gauss_pt!=other._nb_gauss_pt)
150 if(_nb_node_per_cell!=other._nb_node_per_cell)
152 if(_geo_type!=other._geo_type)
154 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
156 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
158 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
164 void MEDFileFieldLoc::writeLL(med_idt fid) const
166 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);
169 std::string MEDFileFieldLoc::repr() const
171 std::ostringstream oss; oss.precision(15);
172 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
173 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
174 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
175 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
176 oss << "\n - Ref coords are : ";
177 int sz=_ref_coo.size();
180 int nbOfTuples=sz/_dim;
181 for(int i=0;i<nbOfTuples;i++)
184 for(int j=0;j<_dim;j++)
185 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
190 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
191 oss << "\n - Gauss coords in reference element : ";
195 int nbOfTuples=sz/_dim;
196 for(int i=0;i<nbOfTuples;i++)
199 for(int j=0;j<_dim;j++)
200 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
205 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
206 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
210 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
212 _type=field->getTypeOfField();
218 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
219 _end=_start+nbOfCells;
225 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
226 const int *arrPtr=arr->getConstPointer();
227 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
228 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
234 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
235 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
236 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
238 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
239 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
240 MCAuto<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
241 const int *dai2Ptr=dai2->getConstPointer();
242 int nbi=gsLoc.getWeights().size();
243 MCAuto<DataArrayInt> da2=dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
244 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
245 const int *da3Ptr=da3->getConstPointer();
246 if(da3->getNumberOfTuples()!=nbOfCells)
247 {//profile : for gauss even in NoProfile !!!
248 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
250 da3->setName(_profile.c_str());
251 glob.appendProfile(da3);
253 MCAuto<DataArrayInt> da4=DataArrayInt::New();
254 _nval=da3->getNbOfElems();
255 da4->alloc(_nval*nbi,1);
256 int *da4Ptr=da4->getPointer();
257 for(int i=0;i<_nval;i++)
259 int ref=dai2Ptr[offset+da3Ptr[i]];
260 for(int j=0;j<nbi;j++)
263 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
264 _localization=oss2.str();
265 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
266 _end=_start+_nval*nbi;
267 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
271 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
277 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
278 * \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).
279 * \param [in] multiTypePfl is the end user profile specified in high level API
280 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
281 * \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.
282 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
283 * \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.
285 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)
288 _type=field->getTypeOfField();
289 std::string pflName(multiTypePfl->getName());
290 std::ostringstream oss; oss << pflName;
294 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
301 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
302 if(_type!=ON_GAUSS_PT)
304 locIds->setName(oss.str());
305 glob.appendProfile(locIds);
314 _nval=idsInPfl->getNumberOfTuples();
315 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
321 _nval=idsInPfl->getNumberOfTuples();
322 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
328 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
329 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
330 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
331 arr3->computeOffsetsFull();
332 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
333 int trueNval=tmp->getNumberOfTuples();
334 _nval=idsInPfl->getNumberOfTuples();
335 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
336 _end=_start+trueNval;
341 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
343 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
344 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
345 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
346 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
347 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
348 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
350 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
351 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
353 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
355 for(const int *pt=da4->begin();pt!=da4->end();pt++)
356 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
357 tmp->alloc(trueNval,1);
358 int *tmpPtr=tmp->getPointer();
359 for(const int *pt=da4->begin();pt!=da4->end();pt++)
360 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
363 _nval=da4->getNumberOfTuples();
364 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
365 _end=_start+trueNval;
366 oss << "_loc_" << _loc_id;
369 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
370 da5->setName(oss.str());
371 glob.appendProfile(da5);
376 if(!da3->isIota(nbOfEltsInWholeMesh))
378 da3->setName(oss.str());
379 glob.appendProfile(da3);
383 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
384 _localization=oss2.str();
385 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
389 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
394 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
397 _nval=arrr->getNumberOfTuples();
398 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
403 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
405 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
408 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
410 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
413 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
415 return new MEDFileFieldPerMeshPerTypePerDisc(other);
418 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
420 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
423 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
425 std::vector<const BigMemoryObject *> ret(1);
426 ret[0]=(const PartDefinition*)_pd;
430 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerType *father) const
432 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
437 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
438 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
443 catch(INTERP_KERNEL::Exception& e)
448 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
452 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)
456 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
457 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
461 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)
463 const PartDefinition *pd(_pd);
466 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
468 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
469 if(_end-_start!=nbValsInFile*nbi)
471 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 !";
472 throw INTERP_KERNEL::Exception(oss.str());
474 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
478 if(!_profile.empty())
479 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
480 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
482 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
483 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
487 spd->getSlice(start,stop,step);
488 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
489 med_filter filter=MED_FILTER_INIT;
490 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
491 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
492 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
493 /*lastblocksize=useless because count=1*/0,&filter);
494 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
495 MEDfilterClose(&filter);
498 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
501 dpd->checkConsistencyLight();
502 MCAuto<DataArrayInt> myIds(dpd->toDAI());
503 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
504 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
505 myIds->applyLin(1,-a);
506 int nbOfEltsToLoad(b-a+1);
507 med_filter filter=MED_FILTER_INIT;
508 {//TODO : manage int32 !
509 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
510 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
511 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
512 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
513 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
514 /*lastblocksize=useless because count=1*/0,&filter);
515 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
516 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
517 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
518 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
520 MEDfilterClose(&filter);
523 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
527 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
532 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
534 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
535 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
536 std::string fieldName(nasc.getName()),meshName(getMeshName());
537 int iteration(getIteration()),order(getOrder());
538 TypeOfField type(getType());
539 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
541 med_geometry_type mgeoti;
542 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
543 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
544 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
545 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
546 const PartDefinition *pd(_pd);
553 if(!_profile.empty())
554 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
555 _nval=pd->getNumberOfElems();
558 _end=start+_nval*nbi;
560 if(type==ON_CELLS && !_localization.empty())
562 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
563 setType(ON_GAUSS_PT);
566 setType(ON_GAUSS_NE);
567 _localization.clear();
572 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
574 std::string fieldName(nasc.getName()),meshName(getMeshName());
575 int iteration(getIteration()),order(getOrder());
576 TypeOfField type(getType());
577 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
578 med_geometry_type mgeoti;
579 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
581 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
584 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
585 if(_start<0 || _start>=arr->getNumberOfTuples())
587 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
588 throw INTERP_KERNEL::Exception(oss.str());
590 if(_end<0 || _end>arr->getNumberOfTuples())
592 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
593 throw INTERP_KERNEL::Exception(oss.str());
595 int nbOfCompo(arr->getNumberOfComponents());
596 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
599 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
600 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
603 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
606 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
607 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
610 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
614 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
616 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
618 int delta=_end-_start;
619 _start=newValueOfStart;
623 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
625 return _father->getIteration();
628 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
630 return _father->getOrder();
633 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
635 return _father->getTime();
638 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
640 return _father->getMeshName();
643 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
645 const char startLine[]=" ## ";
646 std::string startLine2(bkOffset,' ');
647 startLine2+=startLine;
648 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
649 oss << startLine2 << "Localization #" << id << "." << std::endl;
650 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
652 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
653 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
654 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
657 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
662 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
667 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
672 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
674 return _father->getGeoType();
677 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
679 return _father->getNumberOfComponents();
682 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
687 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
689 return _father->getOrCreateAndGetArray();
692 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
694 const MEDFileFieldPerMeshPerType *fath=_father;
695 return fath->getOrCreateAndGetArray();
698 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
700 return _father->getInfo();
703 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
708 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
713 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
715 return _localization;
718 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
720 _localization=newLocName;
723 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
725 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
727 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
729 _profile=(*it2).second;
735 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
737 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
739 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
741 _localization=(*it2).second;
747 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
751 dads.push_back(std::pair<int,int>(_start,_end));
752 geoTypes.push_back(getGeoType());
757 pfls.push_back(glob->getProfile(_profile.c_str()));
759 if(_localization.empty())
763 locs.push_back(glob->getLocalizationId(_localization.c_str()));
767 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
769 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));
773 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
775 TypeOfField type=getType();
776 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
777 med_geometry_type mgeoti;
778 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
779 const DataArray *arr=getOrCreateAndGetArray();
781 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
782 if(!arr->isAllocated())
783 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
784 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
785 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
786 const unsigned char *locToWrite=0;
788 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
790 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
792 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
793 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
794 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
798 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
803 dad.first=_start; dad.second=_end;
807 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
808 * This code corresponds to the distribution of types in the corresponding mesh.
809 * \param [out] ptToFill memory zone where the output will be stored.
810 * \return the size of data pushed into output param \a ptToFill
812 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
815 std::ostringstream oss;
816 std::size_t nbOfType=codeOfMesh.size()/3;
818 for(std::size_t i=0;i<nbOfType && found==-1;i++)
819 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
823 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
824 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
825 throw INTERP_KERNEL::Exception(oss.str());
830 if(_nval!=codeOfMesh[3*found+1])
832 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
833 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
834 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
835 throw INTERP_KERNEL::Exception(oss.str());
837 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
842 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
843 if(pfl->getNumberOfTuples()!=_nval)
845 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
846 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
848 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
849 throw INTERP_KERNEL::Exception(oss.str());
851 int offset2=codeOfMesh[3*found+2];
852 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
854 if(*pflId<codeOfMesh[3*found+1])
855 *work++=offset2+*pflId;
861 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
863 for(int i=_start;i<_end;i++)
868 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
879 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
883 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
886 std::map<std::pair<std::string,TypeOfField>,int> m;
887 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
888 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
889 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
890 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
892 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
893 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
898 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
900 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
901 * \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.
902 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
903 * \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)
904 * \param [in,out] glob if necessary by the method, new profiles can be added to it
905 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
906 * \param [out] result All new entries will be appended on it.
907 * \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 !)
909 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
910 const DataArrayInt *explicitIdsInMesh,
911 const std::vector<int>& newCode,
912 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
913 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
915 if(entriesOnSameDisc.empty())
917 TypeOfField type=entriesOnSameDisc[0]->getType();
918 int szEntities=0,szTuples=0;
919 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
920 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
921 int nbi=szTuples/szEntities;
922 if(szTuples%szEntities!=0)
923 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
924 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
925 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
926 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
927 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
928 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
929 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
930 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
932 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
934 int startOfEltIdOfChunk=(*it)->_start;
935 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
936 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
937 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
939 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
940 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
942 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
943 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
945 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
946 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
947 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
948 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
950 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
952 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
953 arrPart->renumberInPlace(renumTupleIds->begin());
954 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
956 const int *idIt=diffVals->begin();
957 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
959 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
961 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
962 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
963 int nbEntityElts=subIds->getNumberOfTuples();
965 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
966 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
970 result.push_back(eltToAdd);
971 offset2+=nbEntityElts*nbi;
973 ret=ret || li.empty();
978 * \param [in] typeF type of field of new chunk
979 * \param [in] geoType the geometric type of the chunk
980 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
981 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
982 * \param [in] nbi number of integration points
983 * \param [in] offset The offset in the **global array of data**.
984 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
985 * to the new chunk to create.
986 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
987 * \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
988 * and corresponding entry erased from \a entriesOnSameDisc.
989 * \return a newly allocated chunk
991 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
992 bool isPfl, int nbi, int offset,
993 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
994 MEDFileFieldGlobsReal& glob,
997 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
998 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
999 for(;it!=entriesOnSameDisc.end();it++)
1001 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1005 if((*it)->_profile.empty())
1008 if(!(*it)->_profile.empty())
1010 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1011 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1017 if(it==entriesOnSameDisc.end())
1020 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1022 ret->_loc_id=(int)geoType;
1023 ret->_nval=nbMeshEntities;
1025 ret->_end=ret->_start+ret->_nval*nbi;
1028 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1029 glob.appendProfile(idsOfMeshElt);
1030 ret->_profile=idsOfMeshElt->getName();
1032 //tony treatment of localization
1037 notInExisting=false;
1038 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1039 ret->_loc_id=(int)geoType;
1040 ret->setNewStart(offset);
1041 entriesOnSameDisc.erase(it);
1047 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1049 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1052 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1054 return new MEDFileFieldPerMeshPerType(fath,geoType);
1057 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1059 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1062 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1064 std::vector<const BigMemoryObject *> ret;
1065 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1066 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1070 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1072 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1073 ret->_father=father;
1075 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1077 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1078 ret->_field_pm_pt_pd[i]=(*it)->deepCopy((MEDFileFieldPerMeshPerType *)ret);
1083 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1085 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1086 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1087 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1091 * This method is the most general one. No optimization is done here.
1092 * \param [in] multiTypePfl is the end user profile specified in high level API
1093 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1094 * \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.
1095 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1096 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1097 * \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.
1099 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)
1101 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1102 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1103 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1106 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1108 _field_pm_pt_pd.resize(1);
1109 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1110 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1113 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1115 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1116 if(!arr || !arr->isAllocated())
1117 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1118 _field_pm_pt_pd.resize(1);
1119 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1120 _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.
1123 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1125 TypeOfField type=field->getTypeOfField();
1126 if(type!=ON_GAUSS_PT)
1128 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1129 int sz=_field_pm_pt_pd.size();
1131 for(int j=0;j<sz && !found;j++)
1133 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1135 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1141 _field_pm_pt_pd.resize(sz+1);
1142 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1144 std::vector<int> ret(1,(int)sz);
1149 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1150 int sz2=ret2.size();
1151 std::vector<int> ret3(sz2);
1153 for(int i=0;i<sz2;i++)
1155 int sz=_field_pm_pt_pd.size();
1156 int locIdToFind=ret2[i];
1158 for(int j=0;j<sz && !found;j++)
1160 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1162 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1169 _field_pm_pt_pd.resize(sz+1);
1170 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1178 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1180 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1181 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1183 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1184 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1186 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1187 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1188 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1189 if(retTmp->presenceOfValue(-1))
1190 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1191 std::vector<int> ret(retTmp->begin(),retTmp->end());
1195 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1197 TypeOfField type=field->getTypeOfField();
1198 if(type!=ON_GAUSS_PT)
1200 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1201 int sz=_field_pm_pt_pd.size();
1203 for(int j=0;j<sz && !found;j++)
1205 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1207 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1213 _field_pm_pt_pd.resize(sz+1);
1214 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1216 std::vector<int> ret(1,0);
1221 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1222 int sz2=ret2.size();
1223 std::vector<int> ret3(sz2);
1225 for(int i=0;i<sz2;i++)
1227 int sz=_field_pm_pt_pd.size();
1228 int locIdToFind=ret2[i];
1230 for(int j=0;j<sz && !found;j++)
1232 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1234 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1241 _field_pm_pt_pd.resize(sz+1);
1242 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1250 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1252 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1253 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1255 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1256 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1258 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1259 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1260 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1261 if(retTmp->presenceOfValue(-1))
1262 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1263 std::vector<int> ret(retTmp->begin(),retTmp->end());
1267 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1272 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1274 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1275 int curDim((int)cm.getDimension());
1276 dim=std::max(dim,curDim);
1279 bool MEDFileFieldPerMeshPerType::isUniqueLevel(int& dim) const
1281 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1282 int curDim((int)cm.getDimension());
1283 if(dim!=std::numeric_limits<int>::max())
1293 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1295 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1297 (*it)->fillTypesOfFieldAvailable(types);
1301 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
1303 int sz=_field_pm_pt_pd.size();
1304 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1305 for(int i=0;i<sz;i++)
1307 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1311 int MEDFileFieldPerMeshPerType::getIteration() const
1313 return _father->getIteration();
1316 int MEDFileFieldPerMeshPerType::getOrder() const
1318 return _father->getOrder();
1321 double MEDFileFieldPerMeshPerType::getTime() const
1323 return _father->getTime();
1326 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1328 return _father->getMeshName();
1331 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1333 const char startLine[]=" ## ";
1334 std::string startLine2(bkOffset,' ');
1335 std::string startLine3(startLine2);
1336 startLine3+=startLine;
1337 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1339 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1340 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1343 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1344 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1346 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1348 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1350 cur->simpleRepr(bkOffset,oss,i);
1353 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1358 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1360 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1362 globalSz+=(*it)->getNumberOfTuples();
1364 nbOfEntries+=(int)_field_pm_pt_pd.size();
1367 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1373 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1375 return _father->getNumberOfComponents();
1378 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1381 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1383 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1390 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1392 return _father->getOrCreateAndGetArray();
1395 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1397 const MEDFileFieldPerMesh *fath=_father;
1398 return fath->getOrCreateAndGetArray();
1401 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1403 return _father->getInfo();
1406 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1408 std::vector<std::string> ret;
1409 std::set<std::string> ret2;
1410 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1412 std::string tmp=(*it1)->getProfile();
1414 if(ret2.find(tmp)==ret2.end())
1423 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1425 std::vector<std::string> ret;
1426 std::set<std::string> ret2;
1427 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1429 std::string tmp=(*it1)->getLocalization();
1430 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1431 if(ret2.find(tmp)==ret2.end())
1440 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1442 std::vector<std::string> ret;
1443 std::set<std::string> ret2;
1444 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1446 std::string tmp=(*it1)->getProfile();
1453 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1455 std::vector<std::string> ret;
1456 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1458 std::string tmp=(*it1)->getLocalization();
1459 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1465 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1467 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1468 (*it1)->changePflsRefsNamesGen(mapOfModif);
1471 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1473 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1474 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1477 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1479 if(_field_pm_pt_pd.empty())
1481 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1482 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1483 throw INTERP_KERNEL::Exception(oss.str());
1485 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1486 return _field_pm_pt_pd[locId];
1487 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1488 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1489 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1490 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1491 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1494 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1496 if(_field_pm_pt_pd.empty())
1498 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1499 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1500 throw INTERP_KERNEL::Exception(oss.str());
1502 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1503 return _field_pm_pt_pd[locId];
1504 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1505 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1506 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1507 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1508 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1511 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
1513 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1515 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1516 if(meshDim!=(int)cm.getDimension())
1519 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1520 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1523 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1526 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1528 (*it)->fillValues(i,startEntryId,entries);
1532 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1534 _field_pm_pt_pd=leaves;
1535 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1536 (*it)->setFather(this);
1540 * \param [in,out] globalNum a global numbering counter for the renumbering.
1541 * \param [out] its - list of pair (start,stop) kept
1542 * \return bool - false if the type of field \a tof is not contained in \a this.
1544 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1547 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1548 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1549 if((*it)->getType()==tof)
1551 newPmPtPd.push_back(*it);
1552 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1553 (*it)->setNewStart(globalNum);
1554 globalNum=(*it)->getEnd();
1555 its.push_back(bgEnd);
1559 _field_pm_pt_pd=newPmPtPd;
1564 * \param [in,out] globalNum a global numbering counter for the renumbering.
1565 * \param [out] its - list of pair (start,stop) kept
1566 * \return bool - false if the type of field \a tof is not contained in \a this.
1568 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1570 if(_field_pm_pt_pd.size()<=idOfDisc)
1572 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1573 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1574 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1575 elt->setNewStart(globalNum);
1576 globalNum=elt->getEnd();
1577 its.push_back(bgEnd);
1578 _field_pm_pt_pd=newPmPtPd;
1582 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1586 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1588 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1589 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1590 med_geometry_type mgeoti;
1591 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1592 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1593 _field_pm_pt_pd.resize(nbProfiles);
1594 for(int i=0;i<nbProfiles;i++)
1596 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1600 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1601 for(int i=0;i<nbProfiles2;i++)
1602 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1606 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1608 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1609 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1612 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1614 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1615 (*it)->loadBigArray(fid,nasc);
1618 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1620 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1622 (*it)->copyOptionsFrom(*this);
1623 (*it)->writeLL(fid,nasc);
1627 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1632 medfGeoType=typmai3[(int)ikGeoType];
1635 medfGeoType=MED_NONE;
1638 medfGeoType=typmai3[(int)ikGeoType];
1639 return MED_NODE_ELEMENT;
1641 medfGeoType=typmai3[(int)ikGeoType];
1644 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1646 return MED_UNDEF_ENTITY_TYPE;
1649 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)
1651 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1654 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1656 return new MEDFileFieldPerMesh(fath,mesh);
1659 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1661 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1664 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1666 std::vector<const BigMemoryObject *> ret;
1667 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1668 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1672 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1674 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1675 ret->_father=father;
1677 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1679 if((const MEDFileFieldPerMeshPerType *)*it)
1680 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1685 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1687 std::string startLine(bkOffset,' ');
1688 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1689 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1691 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1693 const MEDFileFieldPerMeshPerType *cur=*it;
1695 cur->simpleRepr(bkOffset,oss,i);
1698 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1703 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1705 _mesh_name=mesh->getName();
1706 mesh->getTime(_mesh_iteration,_mesh_order);
1709 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1711 int nbOfTypes=code.size()/3;
1713 for(int i=0;i<nbOfTypes;i++)
1715 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1716 int nbOfCells=code[3*i+1];
1717 int pos=addNewEntryIfNecessary(type);
1718 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1724 * This method is the most general one. No optimization is done here.
1725 * \param [in] multiTypePfl is the end user profile specified in high level API
1726 * \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].
1727 * \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.
1728 * \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.
1729 * \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.
1730 * \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.
1732 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)
1734 int nbOfTypes(code.size()/3);
1735 for(int i=0;i<nbOfTypes;i++)
1737 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1738 int pos=addNewEntryIfNecessary(type);
1739 DataArrayInt *pfl=0;
1741 pfl=idsPerType[code[3*i+2]];
1742 int nbOfTupes2=code2.size()/3;
1744 for(;found<nbOfTupes2;found++)
1745 if(code[3*i]==code2[3*found])
1747 if(found==nbOfTupes2)
1748 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1749 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1753 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1755 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1756 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1759 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1761 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1762 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1765 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1767 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1768 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1771 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1773 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1774 (*it)->loadBigArraysRecursively(fid,nasc);
1777 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1779 int nbOfTypes=_field_pm_pt.size();
1780 for(int i=0;i<nbOfTypes;i++)
1782 _field_pm_pt[i]->copyOptionsFrom(*this);
1783 _field_pm_pt[i]->writeLL(fid,nasc);
1787 void MEDFileFieldPerMesh::getDimension(int& dim) const
1789 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1790 (*it)->getDimension(dim);
1793 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1795 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1796 if(!(*it)->isUniqueLevel(dim))
1801 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1803 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1804 (*it)->fillTypesOfFieldAvailable(types);
1807 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
1809 int sz=_field_pm_pt.size();
1810 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1811 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1812 for(int i=0;i<sz;i++)
1814 types[i]=_field_pm_pt[i]->getGeoType();
1815 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1820 double MEDFileFieldPerMesh::getTime() const
1823 return _father->getTime(tmp1,tmp2);
1826 int MEDFileFieldPerMesh::getIteration() const
1828 return _father->getIteration();
1831 int MEDFileFieldPerMesh::getOrder() const
1833 return _father->getOrder();
1836 int MEDFileFieldPerMesh::getNumberOfComponents() const
1838 return _father->getNumberOfComponents();
1841 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1843 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1845 const MEDFileFieldPerMeshPerType *fpmt(*it);
1848 if(fpmt->presenceOfMultiDiscPerGeoType())
1854 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1857 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1858 return _father->getOrCreateAndGetArray();
1861 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1864 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1865 return _father->getOrCreateAndGetArray();
1868 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1870 return _father->getInfo();
1874 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1875 * 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.
1876 * It returns 2 output vectors :
1877 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1878 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1879 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1881 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)
1883 int notNullPflsSz=0;
1884 int nbOfArrs=geoTypes.size();
1885 for(int i=0;i<nbOfArrs;i++)
1888 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1889 int nbOfDiffGeoTypes=geoTypes3.size();
1890 code.resize(3*nbOfDiffGeoTypes);
1891 notNullPfls.resize(notNullPflsSz);
1894 for(int i=0;i<nbOfDiffGeoTypes;i++)
1897 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1898 std::vector<const DataArrayInt *> notNullTmp;
1900 notNullTmp.push_back(pfls[j]);
1902 for(;j<nbOfArrs;j++)
1903 if(geoTypes[j]==refType)
1906 notNullTmp.push_back(pfls[j]);
1910 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1911 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1912 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1913 code[3*i]=(int)refType;
1914 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1915 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1916 if(notNullTmp.empty())
1920 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1921 code[3*i+2]=notNullPflsSz++;
1927 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1929 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)
1933 for(int i=0;i<sz;i++)
1937 if(type!=ON_GAUSS_NE)
1938 ret+=dads[i].second-dads[i].first;
1941 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1942 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1947 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1948 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1954 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1956 std::vector<std::string> ret;
1957 std::set<std::string> ret2;
1958 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1960 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1961 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1962 if(ret2.find(*it2)==ret2.end())
1964 ret.push_back(*it2);
1971 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1973 std::vector<std::string> ret;
1974 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1976 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1977 ret.insert(ret.end(),tmp.begin(),tmp.end());
1982 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1984 std::vector<std::string> ret;
1985 std::set<std::string> ret2;
1986 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1988 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1989 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1990 if(ret2.find(*it2)==ret2.end())
1992 ret.push_back(*it2);
1999 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2001 std::vector<std::string> ret;
2002 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2004 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2005 ret.insert(ret.end(),tmp.begin(),tmp.end());
2010 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2012 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2014 if((*it).first==_mesh_name)
2016 _mesh_name=(*it).second;
2023 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2024 MEDFileFieldGlobsReal& glob)
2026 if(_mesh_name!=meshName)
2028 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2029 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2030 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2031 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2032 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2033 getUndergroundDataArrayExt(entries);
2034 DataArray *arr0=getOrCreateAndGetArray();//tony
2036 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2037 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
2039 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2042 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2043 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2045 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2047 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2048 sz+=(*it).second.second-(*it).second.first;
2051 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2053 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2054 ////////////////////
2055 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2056 int *workI2=explicitIdsOldInMesh->getPointer();
2057 int sz1=0,sz2=0,sid=1;
2058 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2059 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2060 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2062 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2063 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2064 int *workI=explicitIdsOldInArr->getPointer();
2065 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2067 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2068 (*itL2)->setLocId(sz2);
2069 (*itL2)->_tmp_work1=(*itL2)->getStart();
2070 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2072 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2074 explicitIdsOldInMesh->reAlloc(sz2);
2075 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2076 ////////////////////
2077 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2078 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2079 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2080 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2082 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2083 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2084 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2086 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2087 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2088 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2090 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2091 int newStart=elt->getLocId();
2092 elt->setLocId((*it)->getGeoType());
2093 elt->setNewStart(newStart);
2094 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2095 entriesKeptNew.push_back(elt);
2096 entriesKeptNew2.push_back(elt);
2098 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2099 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2100 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2101 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2103 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2106 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2108 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2109 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2111 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2112 glob,arr2,otherEntriesNew) || ret;
2116 // Assign new dispatching
2117 assignNewLeaves(otherEntriesNew);
2118 arr->deepCopyFrom(*arr2);
2123 * \param [in,out] globalNum a global numbering counter for the renumbering.
2124 * \param [out] its - list of pair (start,stop) kept
2126 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2128 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2129 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2131 std::vector< std::pair<int,int> > its2;
2132 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2135 its.insert(its.end(),its2.begin(),its2.end());
2142 * \param [in,out] globalNum a global numbering counter for the renumbering.
2143 * \param [out] its - list of pair (start,stop) kept
2145 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2147 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > ret;
2148 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2150 std::vector< std::pair<int,int> > its2;
2151 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2154 its.insert(its.end(),its2.begin(),its2.end());
2160 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2162 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2163 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2164 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2166 std::vector< MCAuto< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2167 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2168 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2169 for(;it1!=types.end();it1++,it2++)
2171 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2172 elt->setLeaves((*it1).second);
2175 _field_pm_pt=fieldPmPt;
2178 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2180 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2181 (*it)->changePflsRefsNamesGen(mapOfModif);
2184 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2186 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2187 (*it)->changeLocsRefsNamesGen(mapOfModif);
2191 * \param [in] mesh is the whole mesh
2193 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2195 if(_field_pm_pt.empty())
2196 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2198 std::vector< std::pair<int,int> > dads;
2199 std::vector<const DataArrayInt *> pfls;
2200 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2201 std::vector<int> locs,code;
2202 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2203 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2204 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2206 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2209 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2210 throw INTERP_KERNEL::Exception(oss.str());
2213 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2214 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2217 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2219 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2222 MCAuto<DataArrayInt> arr2(arr);
2223 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2229 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2233 if(nb!=mesh->getNumberOfNodes())
2235 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2236 oss << " nodes in mesh !";
2237 throw INTERP_KERNEL::Exception(oss.str());
2239 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2242 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2246 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2248 if(_field_pm_pt.empty())
2249 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2251 std::vector<std::pair<int,int> > dads;
2252 std::vector<const DataArrayInt *> pfls;
2253 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2254 std::vector<int> locs,code;
2255 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2256 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2257 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2259 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2262 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2263 throw INTERP_KERNEL::Exception(oss.str());
2265 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2266 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2269 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2270 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2275 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2279 if(nb!=mesh->getNumberOfNodes())
2281 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2282 oss << " nodes in mesh !";
2283 throw INTERP_KERNEL::Exception(oss.str());
2286 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2292 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2296 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2298 (*it)->getSizes(globalSz,nbOfEntries);
2300 entries.resize(nbOfEntries);
2302 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2304 (*it)->fillValues(nbOfEntries,entries);
2308 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2310 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2312 if((*it)->getGeoType()==typ)
2313 return (*it)->getLeafGivenLocId(locId);
2315 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2316 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2317 oss << "Possiblities are : ";
2318 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2320 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2321 oss << "\"" << cm2.getRepr() << "\", ";
2323 throw INTERP_KERNEL::Exception(oss.str());
2326 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2328 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2330 if((*it)->getGeoType()==typ)
2331 return (*it)->getLeafGivenLocId(locId);
2333 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2334 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2335 oss << "Possiblities are : ";
2336 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2338 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2339 oss << "\"" << cm2.getRepr() << "\", ";
2341 throw INTERP_KERNEL::Exception(oss.str());
2344 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2347 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2348 std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2349 for(std::vector< MCAuto< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2351 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2356 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2361 int ret=std::distance(_field_pm_pt.begin(),it2);
2362 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2367 * 'dads' and 'locs' input parameters have the same number of elements
2368 * \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
2370 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2371 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2372 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2375 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2376 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2377 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2378 const std::vector<std::string>& infos=getInfo();
2379 da->setInfoOnComponents(infos);
2381 if(type==ON_GAUSS_PT)
2384 int nbOfArrs=dads.size();
2385 for(int i=0;i<nbOfArrs;i++)
2387 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2388 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2389 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2390 MCAuto<DataArrayInt> di=DataArrayInt::New();
2391 di->alloc(nbOfElems,1);
2393 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2394 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2403 * 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.
2404 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2405 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2406 * The order of cells in the returned field is those imposed by the profile.
2407 * \param [in] mesh is the global mesh.
2409 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2410 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2411 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2412 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2414 if(da->isIota(mesh->getNumberOfCells()))
2415 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2416 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2417 m2->setName(mesh->getName().c_str());
2418 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2424 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2426 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2427 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2428 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2430 if(da->isIota(mesh->getNumberOfNodes()))
2431 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2432 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2433 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2436 if(meshu->getNodalConnectivity()==0)
2438 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2439 int nb=da->getNbOfElems();
2440 const int *ptr=da->getConstPointer();
2441 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2442 meshuc->allocateCells(nb);
2443 for(int i=0;i<nb;i++)
2444 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2445 meshuc->finishInsertingCells();
2446 ret->setMesh(meshuc);
2447 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2448 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2449 disc->checkCoherencyBetween(meshuc,arrOut);
2454 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2456 DataArrayInt *arr2=0;
2457 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2458 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2459 MCAuto<DataArrayInt> arr3(arr2);
2460 int nnodes=mesh2->getNumberOfNodes();
2461 if(nnodes==(int)da->getNbOfElems())
2463 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2464 arrOut->renumberInPlace(da3->getConstPointer());
2465 mesh2->setName(mesh->getName().c_str());
2466 ret->setMesh(mesh2);
2471 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 !!!";
2472 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2473 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2474 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2475 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2476 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2477 throw INTERP_KERNEL::Exception(oss.str());
2483 * This method is the most light method of field retrieving.
2485 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2489 pflOut=DataArrayInt::New();
2490 pflOut->alloc(nbOfElems,1);
2495 pflOut=const_cast<DataArrayInt*>(pflIn);
2498 MCAuto<DataArrayInt> safePfl(pflOut);
2499 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2500 const std::vector<std::string>& infos=getInfo();
2501 int nbOfComp=infos.size();
2502 for(int i=0;i<nbOfComp;i++)
2503 da->setInfoOnComponent(i,infos[i].c_str());
2514 static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2515 static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2516 virtual ~MFFPMIter() { }
2517 virtual void begin() = 0;
2518 virtual bool finished() const = 0;
2519 virtual void next() = 0;
2520 virtual int current() const = 0;
2523 class MFFPMIterSimple : public MFFPMIter
2526 MFFPMIterSimple():_pos(0) { }
2527 void begin() { _pos=0; }
2528 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2529 void next() { _pos++; }
2530 int current() const { return _pos; }
2535 class MFFPMIter2 : public MFFPMIter
2538 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2539 void begin() { _it=_ids.begin(); }
2540 bool finished() const { return _it==_ids.end(); }
2541 void next() { _it++; }
2542 int current() const { return *_it; }
2544 std::vector<int> _ids;
2545 std::vector<int>::const_iterator _it;
2548 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2551 return new MFFPMIterSimple;
2554 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2555 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2557 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2558 tmp.push_back((*it).second);
2560 return new MFFPMIter2(tmp);
2564 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2570 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2571 if((*it).first==ON_NODES)
2577 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2579 std::size_t sz(cts.size());
2581 for(std::size_t i=0;i<sz;i++)
2583 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2584 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2585 _ids[i]=(int)std::distance(typmai2,loc);
2587 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2593 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),
2596 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2597 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2598 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2599 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2600 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2601 for(iter0->begin();!iter0->finished();iter0->next())
2603 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2604 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2605 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2606 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2607 if(nbProfile>0 || nbProfile2>0)
2609 const PartDefinition *pd(0);
2611 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2612 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2619 if(MFFPMIter::IsPresenceOfNode(entities))
2621 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2624 const PartDefinition *pd(0);
2626 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2627 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2628 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2633 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2635 copyTinyInfoFrom(mesh);
2638 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2640 if(id>=(int)_pfls.size())
2642 _pfls[id]=DataArrayInt::New();
2643 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2644 _pfls[id]->setName(pflName);
2645 _pfls[id]->alloc(lgth,1);
2646 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2647 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2650 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2652 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2654 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2655 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2656 if(i>=(int)_pfls.size())
2658 _pfls[i]=DataArrayInt::New();
2659 _pfls[i]->alloc(sz,1);
2660 _pfls[i]->setName(pflCpp.c_str());
2661 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2662 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2665 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2667 int nbOfPfls=_pfls.size();
2668 for(int i=0;i<nbOfPfls;i++)
2670 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
2671 cpy->applyLin(1,1,0);
2672 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2673 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2674 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2677 int nbOfLocs=_locs.size();
2678 for(int i=0;i<nbOfLocs;i++)
2679 _locs[i]->writeLL(fid);
2682 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2684 std::vector<std::string> pfls=getPfls();
2685 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2687 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2690 _pfls.push_back(*it);
2694 int id=std::distance(pfls.begin(),it2);
2695 if(!(*it)->isEqual(*_pfls[id]))
2697 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2698 throw INTERP_KERNEL::Exception(oss.str());
2702 std::vector<std::string> locs=getLocs();
2703 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2705 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2708 _locs.push_back(*it);
2712 int id=std::distance(locs.begin(),it2);
2713 if(!(*it)->isEqual(*_locs[id],eps))
2715 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2716 throw INTERP_KERNEL::Exception(oss.str());
2722 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2724 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2725 getProfile((*it).c_str());
2728 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2730 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2731 getLocalization((*it).c_str());
2734 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2736 std::vector<std::string> profiles=real.getPflsReallyUsed();
2737 int sz=profiles.size();
2739 for(int i=0;i<sz;i++)
2740 loadProfileInFile(fid,i,profiles[i].c_str());
2742 std::vector<std::string> locs=real.getLocsReallyUsed();
2745 for(int i=0;i<sz;i++)
2746 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2749 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2751 int nProfil=MEDnProfile(fid);
2752 for(int i=0;i<nProfil;i++)
2753 loadProfileInFile(fid,i);
2754 int sz=MEDnLocalization(fid);
2756 for(int i=0;i<sz;i++)
2758 _locs[i]=MEDFileFieldLoc::New(fid,i);
2762 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2764 return new MEDFileFieldGlobs(fname);
2767 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2769 return new MEDFileFieldGlobs;
2772 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2774 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
2777 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2779 std::vector<const BigMemoryObject *> ret;
2780 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2781 ret.push_back((const DataArrayInt *)*it);
2782 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2783 ret.push_back((const MEDFileFieldLoc *)*it);
2787 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
2789 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2791 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2793 if((const DataArrayInt *)*it)
2794 ret->_pfls[i]=(*it)->deepCopy();
2797 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2799 if((const MEDFileFieldLoc*)*it)
2800 ret->_locs[i]=(*it)->deepCopy();
2806 * \throw if a profile in \a pfls in not in \a this.
2807 * \throw if a localization in \a locs in not in \a this.
2808 * \sa MEDFileFieldGlobs::deepCpyPart
2810 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2812 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2813 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2815 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2817 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2819 MCAuto<DataArrayInt> pfl2(pfl);
2820 ret->_pfls.push_back(pfl2);
2822 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2824 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2826 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2828 MCAuto<MEDFileFieldLoc> loc2(loc);
2829 ret->_locs.push_back(loc2);
2831 ret->setFileName(getFileName());
2836 * \throw if a profile in \a pfls in not in \a this.
2837 * \throw if a localization in \a locs in not in \a this.
2838 * \sa MEDFileFieldGlobs::shallowCpyPart
2840 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2842 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2843 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2845 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2847 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2848 ret->_pfls.push_back(pfl->deepCopy());
2850 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2852 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2854 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2855 ret->_locs.push_back(loc->deepCopy());
2857 ret->setFileName(getFileName());
2861 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2865 MEDFileFieldGlobs::MEDFileFieldGlobs()
2869 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2873 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2875 oss << "Profiles :\n";
2876 std::size_t n=_pfls.size();
2877 for(std::size_t i=0;i<n;i++)
2879 oss << " - #" << i << " ";
2880 const DataArrayInt *pfl=_pfls[i];
2882 oss << "\"" << pfl->getName() << "\"\n";
2887 oss << "Localizations :\n";
2888 for(std::size_t i=0;i<n;i++)
2890 oss << " - #" << i << " ";
2891 const MEDFileFieldLoc *loc=_locs[i];
2893 loc->simpleRepr(oss);
2899 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2901 _file_name=fileName;
2904 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2906 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2908 DataArrayInt *elt(*it);
2911 std::string name(elt->getName());
2912 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2914 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2916 elt->setName((*it2).second.c_str());
2924 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2926 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2928 MEDFileFieldLoc *elt(*it);
2931 std::string name(elt->getName());
2932 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2934 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2936 elt->setName((*it2).second.c_str());
2944 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2946 if(locId<0 || locId>=(int)_locs.size())
2947 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2948 return _locs[locId]->getNbOfGaussPtPerCell();
2951 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2953 return getLocalizationFromId(getLocalizationId(locName));
2956 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2958 if(locId<0 || locId>=(int)_locs.size())
2959 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2960 return *_locs[locId];
2964 namespace MEDCouplingImpl
2969 LocFinder(const std::string& loc):_loc(loc) { }
2970 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2972 const std::string &_loc;
2978 PflFinder(const std::string& pfl):_pfl(pfl) { }
2979 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2981 const std::string& _pfl;
2986 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2988 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
2991 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2992 for(it=_locs.begin();it!=_locs.end();it++)
2993 oss << "\"" << (*it)->getName() << "\", ";
2994 throw INTERP_KERNEL::Exception(oss.str());
2996 return std::distance(_locs.begin(),it);
3000 * The returned value is never null.
3002 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3004 std::string pflNameCpp(pflName);
3005 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3008 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3009 for(it=_pfls.begin();it!=_pfls.end();it++)
3010 oss << "\"" << (*it)->getName() << "\", ";
3011 throw INTERP_KERNEL::Exception(oss.str());
3016 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3018 if(pflId<0 || pflId>=(int)_pfls.size())
3019 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3020 return _pfls[pflId];
3023 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3025 if(locId<0 || locId>=(int)_locs.size())
3026 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3027 return *_locs[locId];
3030 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3032 return getLocalizationFromId(getLocalizationId(locName));
3036 * The returned value is never null.
3038 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3040 std::string pflNameCpp(pflName);
3041 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3044 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3045 for(it=_pfls.begin();it!=_pfls.end();it++)
3046 oss << "\"" << (*it)->getName() << "\", ";
3047 throw INTERP_KERNEL::Exception(oss.str());
3052 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3054 if(pflId<0 || pflId>=(int)_pfls.size())
3055 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3056 return _pfls[pflId];
3059 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3061 std::vector< MCAuto<DataArrayInt> > newPfls;
3063 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3065 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3066 newPfls.push_back(*it);
3071 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3073 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3075 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3077 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3078 newLocs.push_back(*it);
3083 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3085 int sz=_pfls.size();
3086 std::vector<std::string> ret(sz);
3087 for(int i=0;i<sz;i++)
3088 ret[i]=_pfls[i]->getName();
3092 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3094 int sz=_locs.size();
3095 std::vector<std::string> ret(sz);
3096 for(int i=0;i<sz;i++)
3097 ret[i]=_locs[i]->getName();
3101 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3103 std::vector<std::string> v=getPfls();
3104 std::string s(pflName);
3105 return std::find(v.begin(),v.end(),s)!=v.end();
3108 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3110 std::vector<std::string> v=getLocs();
3111 std::string s(locName);
3112 return std::find(v.begin(),v.end(),s)!=v.end();
3115 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3117 std::map<int,std::vector<int> > m;
3119 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3121 const DataArrayInt *tmp=(*it);
3124 m[tmp->getHashCode()].push_back(i);
3127 std::vector< std::vector<int> > ret;
3128 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3130 if((*it2).second.size()>1)
3132 std::vector<int> ret0;
3133 bool equalityOrNot=false;
3134 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3136 std::vector<int>::const_iterator it4=it3; it4++;
3137 for(;it4!=(*it2).second.end();it4++)
3139 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3142 ret0.push_back(*it3);
3143 ret0.push_back(*it4);
3149 ret.push_back(ret0);
3155 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3157 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3160 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3162 std::string name(pfl->getName());
3164 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3165 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3166 if(name==(*it)->getName())
3168 if(!pfl->isEqual(*(*it)))
3170 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3171 throw INTERP_KERNEL::Exception(oss.str());
3175 _pfls.push_back(pfl);
3178 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)
3180 std::string name(locName);
3182 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3183 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3184 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3185 if((*it)->isName(locName))
3187 if(!(*it)->isEqual(*obj,1e-12))
3189 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3190 throw INTERP_KERNEL::Exception(oss.str());
3193 _locs.push_back(obj);
3196 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3198 std::vector<std::string> names=getPfls();
3199 return CreateNewNameNotIn("NewPfl_",names);
3202 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3204 std::vector<std::string> names=getLocs();
3205 return CreateNewNameNotIn("NewLoc_",names);
3208 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3210 for(std::size_t sz=0;sz<100000;sz++)
3212 std::ostringstream tryName;
3213 tryName << prefix << sz;
3214 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3215 return tryName.str();
3217 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3221 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3222 * \param [in] fname - the file name.
3224 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3229 * Creates an empty MEDFileFieldGlobsReal.
3231 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3235 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3240 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3242 std::vector<const BigMemoryObject *> ret;
3243 ret.push_back((const MEDFileFieldGlobs *)_globals);
3248 * Returns a string describing profiles and Gauss points held in \a this.
3249 * \return std::string - the description string.
3251 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3253 const MEDFileFieldGlobs *glob=_globals;
3254 std::ostringstream oss2; oss2 << glob;
3255 std::string stars(oss2.str().length(),'*');
3256 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3258 glob->simpleRepr(oss);
3260 oss << "NO GLOBAL INFORMATION !\n";
3263 void MEDFileFieldGlobsReal::resetContent()
3265 _globals=MEDFileFieldGlobs::New();
3268 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3273 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3274 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3276 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3278 _globals=other._globals;
3282 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3283 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3285 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3287 const MEDFileFieldGlobs *otherg(other._globals);
3290 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3294 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3295 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3297 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3299 const MEDFileFieldGlobs *otherg(other._globals);
3302 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3305 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3307 _globals=other._globals;
3308 if((const MEDFileFieldGlobs *)_globals)
3309 _globals=other._globals->deepCopy();
3313 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3314 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3315 * \param [in] eps - a precision used to compare Gauss points with same name held by
3316 * \a this and \a other MEDFileFieldGlobsReal.
3317 * \throw If \a this and \a other hold profiles with equal names but different ids.
3318 * \throw If \a this and \a other hold different Gauss points with equal names.
3320 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3322 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3323 if(thisGlobals==otherGlobals)
3327 _globals=other._globals;
3330 _globals->appendGlobs(*other._globals,eps);
3333 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3335 checkGlobsPflsPartCoherency();
3336 checkGlobsLocsPartCoherency();
3339 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3341 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3344 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3346 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3349 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3351 contentNotNull()->loadProfileInFile(fid,id,pflName);
3354 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3356 contentNotNull()->loadProfileInFile(fid,id);
3359 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3361 contentNotNull()->loadGlobals(fid,*this);
3364 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3366 contentNotNull()->loadAllGlobals(fid);
3369 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3371 contentNotNull()->writeGlobals(fid,opt);
3375 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3376 * or getPflsReallyUsedMulti().
3377 * \return std::vector<std::string> - a sequence of names of all profiles.
3379 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3381 return contentNotNull()->getPfls();
3385 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3386 * or getLocsReallyUsedMulti().
3387 * \return std::vector<std::string> - a sequence of names of all localizations.
3389 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3391 return contentNotNull()->getLocs();
3395 * Checks if the profile with a given name exists.
3396 * \param [in] pflName - the profile name of interest.
3397 * \return bool - \c true if the profile named \a pflName exists.
3399 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3401 return contentNotNull()->existsPfl(pflName);
3405 * Checks if the localization with a given name exists.
3406 * \param [in] locName - the localization name of interest.
3407 * \return bool - \c true if the localization named \a locName exists.
3409 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3411 return contentNotNull()->existsLoc(locName);
3414 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3416 return contentNotNull()->createNewNameOfPfl();
3419 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3421 return contentNotNull()->createNewNameOfLoc();
3425 * Sets the name of a MED file.
3426 * \param [inout] fileName - the file name.
3428 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3430 contentNotNull()->setFileName(fileName);
3434 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3435 * in the same order.
3436 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3437 * Each item of this sequence is a vector containing ids of equal profiles.
3439 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3441 return contentNotNull()->whichAreEqualProfiles();
3445 * Finds equal localizations.
3446 * \param [in] eps - a precision used to compare real values of the localizations.
3447 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3448 * Each item of this sequence is a vector containing ids of equal localizations.
3450 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3452 return contentNotNull()->whichAreEqualLocs(eps);
3456 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3457 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3458 * this sequence is a pair whose
3459 * - the first item is a vector of profile names to replace by the second item,
3460 * - the second item is a profile name to replace every profile name of the first item.
3462 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3464 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3468 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3469 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3470 * this sequence is a pair whose
3471 * - the first item is a vector of localization names to replace by the second item,
3472 * - the second item is a localization name to replace every localization name of the first item.
3474 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3476 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3480 * Replaces references to some profiles (a reference is a profile name) by references
3481 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3482 * them-selves accordingly. <br>
3483 * This method is a generalization of changePflName().
3484 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3485 * this sequence is a pair whose
3486 * - the first item is a vector of profile names to replace by the second item,
3487 * - the second item is a profile name to replace every profile of the first item.
3488 * \sa changePflsRefsNamesGen()
3489 * \sa changePflName()
3491 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3493 changePflsRefsNamesGen(mapOfModif);
3494 changePflsNamesInStruct(mapOfModif);
3498 * Replaces references to some localizations (a reference is a localization name) by references
3499 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3500 * them-selves accordingly. <br>
3501 * This method is a generalization of changeLocName().
3502 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3503 * this sequence is a pair whose
3504 * - the first item is a vector of localization names to replace by the second item,
3505 * - the second item is a localization name to replace every localization of the first item.
3506 * \sa changeLocsRefsNamesGen()
3507 * \sa changeLocName()
3509 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3511 changeLocsRefsNamesGen(mapOfModif);
3512 changeLocsNamesInStruct(mapOfModif);
3516 * Renames the profile having a given name and updates references to this profile.
3517 * \param [in] oldName - the name of the profile to rename.
3518 * \param [in] newName - a new name of the profile.
3519 * \sa changePflsNames().
3521 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3523 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3524 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3526 changePflsNames(mapOfModif);
3530 * Renames the localization having a given name and updates references to this localization.
3531 * \param [in] oldName - the name of the localization to rename.
3532 * \param [in] newName - a new name of the localization.
3533 * \sa changeLocsNames().
3535 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3537 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3538 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3540 changeLocsNames(mapOfModif);
3544 * Removes duplicated profiles. Returns a map used to update references to removed
3545 * profiles via changePflsRefsNamesGen().
3546 * Equal profiles are found using whichAreEqualProfiles().
3547 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3548 * a sequence describing the performed replacements of profiles. Each element of
3549 * this sequence is a pair whose
3550 * - the first item is a vector of profile names replaced by the second item,
3551 * - the second item is a profile name replacing every profile of the first item.
3553 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3555 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3556 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3558 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3560 std::vector< std::string > tmp((*it).size());
3562 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3563 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3564 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3566 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3567 killProfileIds(tmp2);
3569 changePflsRefsNamesGen(ret);
3574 * Removes duplicated localizations. Returns a map used to update references to removed
3575 * localizations via changeLocsRefsNamesGen().
3576 * Equal localizations are found using whichAreEqualLocs().
3577 * \param [in] eps - a precision used to compare real values of the localizations.
3578 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3579 * a sequence describing the performed replacements of localizations. Each element of
3580 * this sequence is a pair whose
3581 * - the first item is a vector of localization names replaced by the second item,
3582 * - the second item is a localization name replacing every localization of the first item.
3584 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3586 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3587 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3589 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3591 std::vector< std::string > tmp((*it).size());
3593 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3594 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3595 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3597 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3598 killLocalizationIds(tmp2);
3600 changeLocsRefsNamesGen(ret);
3605 * Returns number of Gauss points per cell in a given localization.
3606 * \param [in] locId - an id of the localization of interest.
3607 * \return int - the number of the Gauss points per cell.
3609 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3611 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3615 * Returns an id of a localization by its name.
3616 * \param [in] loc - the localization name of interest.
3617 * \return int - the id of the localization.
3618 * \throw If there is no a localization named \a loc.
3620 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3622 return contentNotNull()->getLocalizationId(loc);
3626 * Returns the name of the MED file.
3627 * \return const std::string& - the MED file name.
3629 std::string MEDFileFieldGlobsReal::getFileName() const
3631 return contentNotNull()->getFileName();
3635 * Returns a localization object by its name.
3636 * \param [in] locName - the name of the localization of interest.
3637 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3638 * \throw If there is no a localization named \a locName.
3640 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3642 return contentNotNull()->getLocalization(locName);
3646 * Returns a localization object by its id.
3647 * \param [in] locId - the id of the localization of interest.
3648 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3649 * \throw If there is no a localization with id \a locId.
3651 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3653 return contentNotNull()->getLocalizationFromId(locId);
3657 * Returns a profile array by its name.
3658 * \param [in] pflName - the name of the profile of interest.
3659 * \return const DataArrayInt * - the profile array having the name \a pflName.
3660 * \throw If there is no a profile named \a pflName.
3662 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3664 return contentNotNull()->getProfile(pflName);
3668 * Returns a profile array by its id.
3669 * \param [in] pflId - the id of the profile of interest.
3670 * \return const DataArrayInt * - the profile array having the id \a pflId.
3671 * \throw If there is no a profile with id \a pflId.
3673 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3675 return contentNotNull()->getProfileFromId(pflId);
3679 * Returns a localization object, apt for modification, by its id.
3680 * \param [in] locId - the id of the localization of interest.
3681 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3682 * having the id \a locId.
3683 * \throw If there is no a localization with id \a locId.
3685 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3687 return contentNotNull()->getLocalizationFromId(locId);
3691 * Returns a localization object, apt for modification, by its name.
3692 * \param [in] locName - the name of the localization of interest.
3693 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3694 * having the name \a locName.
3695 * \throw If there is no a localization named \a locName.
3697 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3699 return contentNotNull()->getLocalization(locName);
3703 * Returns a profile array, apt for modification, by its name.
3704 * \param [in] pflName - the name of the profile of interest.
3705 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3706 * \throw If there is no a profile named \a pflName.
3708 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3710 return contentNotNull()->getProfile(pflName);
3714 * Returns a profile array, apt for modification, by its id.
3715 * \param [in] pflId - the id of the profile of interest.
3716 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3717 * \throw If there is no a profile with id \a pflId.
3719 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3721 return contentNotNull()->getProfileFromId(pflId);
3725 * Removes profiles given by their ids. No data is updated to track this removal.
3726 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3728 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3730 contentNotNull()->killProfileIds(pflIds);
3734 * Removes localizations given by their ids. No data is updated to track this removal.
3735 * \param [in] locIds - a sequence of ids of the localizations to remove.
3737 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3739 contentNotNull()->killLocalizationIds(locIds);
3743 * Stores a profile array.
3744 * \param [in] pfl - the profile array to store.
3745 * \throw If the name of \a pfl is empty.
3746 * \throw If a profile with the same name as that of \a pfl already exists but contains
3749 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3751 contentNotNull()->appendProfile(pfl);
3755 * Adds a new localization of Gauss points.
3756 * \param [in] locName - the name of the new localization.
3757 * \param [in] geoType - a geometrical type of the reference cell.
3758 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3759 * must be \c nbOfNodesPerCell * \c dimOfType.
3760 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3761 * must be _wg_.size() * \c dimOfType.
3762 * \param [in] w - the weights of Gauss points.
3763 * \throw If \a locName is empty.
3764 * \throw If a localization with the name \a locName already exists but is
3765 * different form the new one.
3767 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)
3769 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3772 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3774 MEDFileFieldGlobs *g(_globals);
3776 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3780 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3782 const MEDFileFieldGlobs *g(_globals);
3784 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3788 //= MEDFileFieldNameScope
3790 MEDFileFieldNameScope::MEDFileFieldNameScope()
3794 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3799 * Returns the name of \a this field.
3800 * \return std::string - a string containing the field name.
3802 std::string MEDFileFieldNameScope::getName() const
3808 * Sets name of \a this field
3809 * \param [in] name - the new field name.
3811 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3816 std::string MEDFileFieldNameScope::getDtUnit() const
3821 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3826 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3829 _dt_unit=other._dt_unit;
3832 //= MEDFileAnyTypeField1TSWithoutSDA
3834 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3836 _field_per_mesh.resize(other._field_per_mesh.size());
3838 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3840 if((const MEDFileFieldPerMesh *)*it)
3841 _field_per_mesh[i]=(*it)->deepCopy(this);
3846 * Prints a string describing \a this field into a stream. This string is outputted
3847 * by \c print Python command.
3848 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3849 * \param [in,out] oss - the out stream.
3850 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3851 * info id printed, else, not.
3853 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3855 std::string startOfLine(bkOffset,' ');
3856 oss << startOfLine << "Field ";
3858 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3859 oss << "on one time Step ";
3861 oss << "(" << f1tsId << ") ";
3862 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3863 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3864 const DataArray *arr=getUndergroundDataArray();
3867 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3870 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3871 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3872 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3874 if(arr->isAllocated())
3876 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3879 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3883 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3885 oss << startOfLine << "----------------------" << std::endl;
3886 if(!_field_per_mesh.empty())
3889 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3891 const MEDFileFieldPerMesh *cur=(*it2);
3893 cur->simpleRepr(bkOffset,oss,i);
3895 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3900 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3902 oss << startOfLine << "----------------------" << std::endl;
3905 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3907 const DataArray *arr(getUndergroundDataArray());
3909 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3910 int nbOfCompo=arr->getNumberOfComponents();
3911 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3912 for(int i=0;i<nbOfCompo;i++)
3915 std::vector<int> v(1,i);
3916 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
3917 ret[i]->setArray(arr2);
3922 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)
3926 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3931 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3932 * empty. Returns -1 if this in on nodes.
3933 * \return int - the dimension of \a this.
3935 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3938 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3939 (*it)->getDimension(ret);
3944 * Returns the mesh name.
3945 * \return std::string - a string holding the mesh name.
3946 * \throw If \c _field_per_mesh.empty()
3948 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3950 if(_field_per_mesh.empty())
3951 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3952 return _field_per_mesh[0]->getMeshName();
3955 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3957 std::string oldName(getMeshName());
3958 std::vector< std::pair<std::string,std::string> > v(1);
3959 v[0].first=oldName; v[0].second=newMeshName;
3963 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3966 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3968 MEDFileFieldPerMesh *cur(*it);
3970 ret=cur->changeMeshNames(modifTab) || ret;
3976 * Returns the number of iteration of the state of underlying mesh.
3977 * \return int - the iteration number.
3978 * \throw If \c _field_per_mesh.empty()
3980 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3982 if(_field_per_mesh.empty())
3983 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3984 return _field_per_mesh[0]->getMeshIteration();
3988 * Returns the order number of iteration of the state of underlying mesh.
3989 * \return int - the order number.
3990 * \throw If \c _field_per_mesh.empty()
3992 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3994 if(_field_per_mesh.empty())
3995 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3996 return _field_per_mesh[0]->getMeshOrder();
4000 * Checks if \a this field is tagged by a given iteration number and a given
4001 * iteration order number.
4002 * \param [in] iteration - the iteration number of interest.
4003 * \param [in] order - the iteration order number of interest.
4004 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4005 * \a this->getOrder() == \a order.
4007 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4009 return iteration==_iteration && order==_order;
4013 * Returns number of iteration and order number of iteration when
4014 * \a this field has been calculated.
4015 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4018 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4020 std::pair<int,int> p;
4026 * Returns number of iteration and order number of iteration when
4027 * \a this field has been calculated.
4028 * \param [in,out] p - a pair returning the iteration number and the iteration
4031 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4038 * Returns all types of spatial discretization of \a this field.
4039 * \param [in,out] types - a sequence of types of \a this field.
4041 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4043 std::set<TypeOfField> types2;
4044 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4046 (*it)->fillTypesOfFieldAvailable(types2);
4048 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4049 std::copy(types2.begin(),types2.end(),bi);
4053 * Returns all types of spatial discretization of \a this field.
4054 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4057 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4059 std::vector<TypeOfField> ret;
4060 fillTypesOfFieldAvailable(ret);
4064 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4066 std::vector<std::string> ret;
4067 std::set<std::string> ret2;
4068 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4070 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4071 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4072 if(ret2.find(*it2)==ret2.end())
4074 ret.push_back(*it2);
4081 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4083 std::vector<std::string> ret;
4084 std::set<std::string> ret2;
4085 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4087 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4088 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4089 if(ret2.find(*it2)==ret2.end())
4091 ret.push_back(*it2);
4098 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4100 std::vector<std::string> ret;
4101 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4103 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4104 ret.insert(ret.end(),tmp.begin(),tmp.end());
4109 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4111 std::vector<std::string> ret;
4112 std::set<std::string> ret2;
4113 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4115 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4116 ret.insert(ret.end(),tmp.begin(),tmp.end());
4121 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4123 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4124 (*it)->changePflsRefsNamesGen(mapOfModif);
4127 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4129 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4130 (*it)->changeLocsRefsNamesGen(mapOfModif);
4134 * Returns all attributes of parts of \a this field lying on a given mesh.
4135 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4136 * item of every of returned sequences refers to the _i_-th part of \a this field.
4137 * Thus all sequences returned by this method are of the same length equal to number
4138 * of different types of supporting entities.<br>
4139 * A field part can include sub-parts with several different spatial discretizations,
4140 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4141 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4142 * of a nested sequence corresponds to a type of spatial discretization.<br>
4143 * This method allows for iteration over MEDFile DataStructure without any overhead.
4144 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4145 * for the case with only one underlying mesh. (Actually, the number of meshes is
4146 * not checked if \a mname == \c NULL).
4147 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4148 * a field part is returned.
4149 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4150 * This sequence is of the same length as \a types.
4151 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4152 * discretization. A profile name can be empty.
4153 * Length of this and of nested sequences is the same as that of \a typesF.
4154 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4155 * discretization. A localization name can be empty.
4156 * Length of this and of nested sequences is the same as that of \a typesF.
4157 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4158 * of ids of tuples within the data array, per each type of spatial
4159 * discretization within one mesh entity type.
4160 * Length of this and of nested sequences is the same as that of \a typesF.
4161 * \throw If no field is lying on \a mname.
4163 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
4167 meshId=getMeshIdFromMeshName(mname);
4169 if(_field_per_mesh.empty())
4170 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4171 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4175 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4176 * maximal absolute dimension and values returned via the out parameter \a levs are
4177 * dimensions relative to the maximal absolute dimension. <br>
4178 * This method is designed for MEDFileField1TS instances that have a discretization
4179 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4180 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4181 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4182 * Only these 3 discretizations will be taken into account here. If \a this is
4183 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4184 * This method is useful to make the link between the dimension of the underlying mesh
4185 * and the levels of \a this, because it is possible that the highest dimension of \a this
4186 * field is not equal to the dimension of the underlying mesh.
4188 * Let's consider the following case:
4189 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4190 * TETRA4, HEXA8, TRI3 and SEG2.
4191 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4192 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4194 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4195 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4196 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4197 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4198 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4199 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4201 * to retrieve the highest level of
4202 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4203 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4204 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4205 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4206 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4207 * for the case with only one underlying mesh. (Actually, the number of meshes is
4208 * not checked if \a mname == \c NULL).
4209 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4210 * absolute one. They are in decreasing order. This sequence is cleared before
4212 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4213 * \throw If no field is lying on \a mname.
4215 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4218 int meshId=getMeshIdFromMeshName(mname);
4219 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4220 std::vector< std::vector<TypeOfField> > typesF;
4221 std::vector< std::vector<std::string> > pfls, locs;
4222 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4224 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4225 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4226 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4228 st.erase(INTERP_KERNEL::NORM_ERROR);
4230 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4232 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4233 ret1.insert((int)cm.getDimension());
4235 int ret=*std::max_element(ret1.begin(),ret1.end());
4236 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4237 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4242 * \param [in] mName specifies the underlying mesh name. This value can be pointer 0 for users that do not deal with fields on multi mesh.
4243 * \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.
4244 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4245 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4247 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4249 int mid=getMeshIdFromMeshName(mName);
4250 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4254 * \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.
4255 * \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.
4256 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4257 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4259 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4261 int mid=getMeshIdFromMeshName(mName);
4262 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4266 * \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.
4268 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4270 if(_field_per_mesh.empty())
4271 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4274 std::string mName2(mName);
4276 std::vector<std::string> msg;
4277 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4278 if(mName2==(*it)->getMeshName())
4281 msg.push_back((*it)->getMeshName());
4282 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4283 oss << "Possible meshes are : ";
4284 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4285 oss << "\"" << (*it2) << "\" ";
4286 throw INTERP_KERNEL::Exception(oss.str());
4289 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4292 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4293 std::string tmp(mesh->getName());
4295 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4296 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4298 for(;it!=_field_per_mesh.end();it++,i++)
4300 if((*it)->getMeshName()==tmp)
4303 int sz=_field_per_mesh.size();
4304 _field_per_mesh.resize(sz+1);
4305 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4309 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4310 MEDFileFieldGlobsReal& glob)
4313 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4315 MEDFileFieldPerMesh *fpm(*it);
4317 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4323 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4324 * splitting that leads to single spatial discretization of this.
4326 * \sa splitMultiDiscrPerGeoTypes
4328 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4330 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4331 std::vector< std::vector<TypeOfField> > typesF;
4332 std::vector< std::vector<std::string> > pfls,locs;
4333 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4334 std::set<TypeOfField> allEnt;
4335 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4336 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4337 allEnt.insert(*it2);
4338 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4339 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4340 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4342 std::vector< std::pair<int,int> > its;
4343 ret[i]=shallowCpy();
4344 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4345 ret[i]->updateData(newLgth,its);
4351 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4352 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4354 * \sa splitDiscretizations
4356 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4358 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4359 std::vector< std::vector<TypeOfField> > typesF;
4360 std::vector< std::vector<std::string> > pfls,locs;
4361 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4362 std::set<TypeOfField> allEnt;
4363 std::size_t nbOfMDPGT(0),ii(0);
4364 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4366 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4367 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4368 allEnt.insert(*it2);
4370 if(allEnt.size()!=1)
4371 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4373 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4376 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4377 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4380 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4381 for(std::size_t i=0;i<nbOfMDPGT;i++)
4383 std::vector< std::pair<int,int> > its;
4384 ret[i]=shallowCpy();
4385 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4386 ret[i]->updateData(newLgth,its);
4391 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4393 int globalCounter(0);
4394 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4395 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4396 return globalCounter;
4399 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4401 int globalCounter(0);
4402 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4403 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4404 return globalCounter;
4407 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4409 if(_nb_of_tuples_to_be_allocated>=0)
4411 _nb_of_tuples_to_be_allocated=newLgth;
4412 const DataArray *oldArr(getUndergroundDataArray());
4415 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4416 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4418 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4422 if(_nb_of_tuples_to_be_allocated==-1)
4424 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4426 const DataArray *oldArr(getUndergroundDataArray());
4427 if(!oldArr || !oldArr->isAllocated())
4428 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4429 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4430 newArr->alloc(newLgth,getNumberOfComponents());
4432 newArr->copyStringInfoFrom(*oldArr);
4434 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4436 if((*it).second<(*it).first)
4437 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4438 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4439 pos+=(*it).second-(*it).first;
4444 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4447 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4449 if(_field_per_mesh.empty())
4450 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4451 if(_field_per_mesh.size()>1)
4452 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4453 _field_per_mesh[0]->copyOptionsFrom(opts);
4454 _field_per_mesh[0]->writeLL(fid,nasc);
4458 * 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.
4459 * If false is returned the memory allocation is not required.
4461 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4463 if(_nb_of_tuples_to_be_allocated>=0)
4465 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4466 _nb_of_tuples_to_be_allocated=-2;
4469 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4471 if(_nb_of_tuples_to_be_allocated==-1)
4472 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4473 if(_nb_of_tuples_to_be_allocated<-3)
4474 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4475 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4478 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4480 med_int numdt,numit;
4484 med_int meshnumdt,meshnumit;
4485 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4486 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4487 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4488 if(_iteration!=numdt || _order!=numit)
4489 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4490 _field_per_mesh.resize(nmesh);
4495 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4496 mm=ms->getMeshWithName(meshNameCpp);
4499 for(int i=0;i<nmesh;i++)
4500 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4501 _nb_of_tuples_to_be_allocated=0;
4502 for(int i=0;i<nmesh;i++)
4503 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4506 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4508 allocIfNecessaryTheArrayToReceiveDataFromFile();
4509 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4510 (*it)->loadBigArraysRecursively(fid,nasc);
4513 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4515 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4516 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4517 (*it)->loadBigArraysRecursively(fid,nasc);
4520 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4522 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4523 loadBigArraysRecursively(fid,nasc);
4526 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4528 DataArray *thisArr(getUndergroundDataArray());
4529 if(thisArr && thisArr->isAllocated())
4531 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4532 thisArr->desallocate();
4536 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4538 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4541 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4543 std::vector<const BigMemoryObject *> ret;
4544 if(getUndergroundDataArray())
4545 ret.push_back(getUndergroundDataArray());
4546 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4547 ret.push_back((const MEDFileFieldPerMesh *)*it);
4552 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4553 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4554 * "Sort By Type"), if not, an exception is thrown.
4555 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4556 * \param [in] arr - the array of values.
4557 * \param [in,out] glob - the global data where profiles and localization present in
4558 * \a field, if any, are added.
4559 * \throw If the name of \a field is empty.
4560 * \throw If the data array of \a field is not set.
4561 * \throw If \a this->_arr is already allocated but has different number of components
4563 * \throw If the underlying mesh of \a field has no name.
4564 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4566 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4568 const MEDCouplingMesh *mesh=field->getMesh();
4570 TypeOfField type=field->getTypeOfField();
4571 std::vector<DataArrayInt *> dummy;
4572 int start=copyTinyInfoFrom(field,arr);
4573 int pos=addNewEntryIfNecessary(mesh);
4576 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4577 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4580 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4584 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4585 * of a given mesh are used as the support of the given field (a real support is not used).
4586 * Elements of the given mesh must be sorted suitable for writing to MED file.
4587 * Order of underlying mesh entities of the given field specified by \a profile parameter
4588 * is not prescribed; this method permutes field values to have them sorted by element
4589 * type as required for writing to MED file. A new profile is added only if no equal
4590 * profile is missing.
4591 * \param [in] field - the field to add to \a this. The field double values are ignored.
4592 * \param [in] arrOfVals - the values of the field \a field used.
4593 * \param [in] mesh - the supporting mesh of \a field.
4594 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4595 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4596 * \param [in,out] glob - the global data where profiles and localization present in
4597 * \a field, if any, are added.
4598 * \throw If either \a field or \a mesh or \a profile has an empty name.
4599 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4600 * \throw If the data array of \a field is not set.
4601 * \throw If \a this->_arr is already allocated but has different number of components
4603 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4604 * \sa setFieldNoProfileSBT()
4606 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4609 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4610 if(!arrOfVals || !arrOfVals->isAllocated())
4611 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4612 TypeOfField type=field->getTypeOfField();
4613 std::vector<DataArrayInt *> idsInPflPerType;
4614 std::vector<DataArrayInt *> idsPerType;
4615 std::vector<int> code,code2;
4616 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4619 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4620 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4621 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4622 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4624 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4625 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4626 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4628 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4629 throw INTERP_KERNEL::Exception(oss.str());
4632 int start=copyTinyInfoFrom(field,arrOfVals);
4633 code2=m->getDistributionOfTypes();
4635 int pos=addNewEntryIfNecessary(m);
4636 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4640 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4641 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4642 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4643 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4644 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4645 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4647 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4648 throw INTERP_KERNEL::Exception(oss.str());
4650 int start=copyTinyInfoFrom(field,arrOfVals);
4651 int pos=addNewEntryIfNecessary(m);
4652 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4657 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4659 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4661 if(_nb_of_tuples_to_be_allocated>=0)
4662 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 !");
4663 DataArray *arr(getOrCreateAndGetArray());
4664 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4665 _nb_of_tuples_to_be_allocated=-3;
4669 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4670 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4671 * larger by the size of \a field. Returns an id of the first not filled
4672 * tuple of \a this->_arr.
4673 * \param [in] field - the field to copy the info on components and the name from.
4674 * \return int - the id of first not initialized tuple of \a this->_arr.
4675 * \throw If the name of \a field is empty.
4676 * \throw If the data array of \a field is not set.
4677 * \throw If \a this->_arr is already allocated but has different number of components
4680 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4683 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4684 std::string name(field->getName());
4685 setName(name.c_str());
4686 setDtUnit(field->getTimeUnit());
4688 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4690 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4691 if(!arr->isAllocated())
4692 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4693 _dt=field->getTime(_iteration,_order);
4694 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4695 if(!getOrCreateAndGetArray()->isAllocated())
4697 allocNotFromFile(arr->getNumberOfTuples());
4702 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4703 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4704 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4705 _nb_of_tuples_to_be_allocated=-3;
4706 return oldNbOfTuples;
4711 * Returns number of components in \a this field
4712 * \return int - the number of components.
4714 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4716 return getOrCreateAndGetArray()->getNumberOfComponents();
4720 * Change info on components in \a this.
4721 * \throw If size of \a infos is not equal to the number of components already in \a this.
4723 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4725 DataArray *arr=getOrCreateAndGetArray();
4726 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4730 * Returns info on components of \a this field.
4731 * \return const std::vector<std::string>& - a sequence of strings each being an
4732 * information on _i_-th component.
4734 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4736 const DataArray *arr=getOrCreateAndGetArray();
4737 return arr->getInfoOnComponents();
4741 * Returns a mutable info on components of \a this field.
4742 * \return std::vector<std::string>& - a sequence of strings each being an
4743 * information on _i_-th component.
4745 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4747 DataArray *arr=getOrCreateAndGetArray();
4748 return arr->getInfoOnComponents();
4751 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4753 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4755 const MEDFileFieldPerMesh *fpm(*it);
4758 if(fpm->presenceOfMultiDiscPerGeoType())
4764 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4766 static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to extract a field ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
4767 if(_field_per_mesh.empty())
4768 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
4769 if(_field_per_mesh.size()>1)
4770 throw INTERP_KERNEL::Exception(MSG0);
4771 if(_field_per_mesh[0].isNull())
4772 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
4773 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
4774 std::set<TypeOfField> types;
4775 pm->fillTypesOfFieldAvailable(types);
4777 throw INTERP_KERNEL::Exception(MSG0);
4778 TypeOfField type(*types.begin());
4779 int meshDimRelToMax(0);
4784 int myDim(std::numeric_limits<int>::max());
4785 bool isUnique(pm->isUniqueLevel(myDim));
4787 throw INTERP_KERNEL::Exception(MSG0);
4788 meshDimRelToMax=myDim-mesh->getMeshDimension();
4789 if(meshDimRelToMax>0)
4790 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
4792 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
4796 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4797 * \param [in] type - a spatial discretization of the new field.
4798 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4799 * \param [in] mName - a name of the supporting mesh.
4800 * \param [in] renumPol - specifies how to permute values of the result field according to
4801 * the optional numbers of cells and nodes, if any. The valid values are
4802 * - 0 - do not permute.
4803 * - 1 - permute cells.
4804 * - 2 - permute nodes.
4805 * - 3 - permute cells and nodes.
4807 * \param [in] glob - the global data storing profiles and localization.
4808 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4809 * caller is to delete this field using decrRef() as it is no more needed.
4810 * \throw If the MED file is not readable.
4811 * \throw If there is no mesh named \a mName in the MED file.
4812 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4813 * \throw If no field of \a this is lying on the mesh \a mName.
4814 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4816 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4818 MCAuto<MEDFileMesh> mm;
4820 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4822 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4823 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4827 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4828 * \param [in] type - a spatial discretization of the new field.
4829 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4830 * \param [in] renumPol - specifies how to permute values of the result field according to
4831 * the optional numbers of cells and nodes, if any. The valid values are
4832 * - 0 - do not permute.
4833 * - 1 - permute cells.
4834 * - 2 - permute nodes.
4835 * - 3 - permute cells and nodes.
4837 * \param [in] glob - the global data storing profiles and localization.
4838 * \param [in] mesh - the supporting mesh.
4839 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4840 * caller is to delete this field using decrRef() as it is no more needed.
4841 * \throw If the MED file is not readable.
4842 * \throw If no field of \a this is lying on \a mesh.
4843 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4844 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4846 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4848 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
4849 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
4850 if(meshDimRelToMax==1)
4851 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4852 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4856 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4858 * \param [in] type - a spatial discretization of the new field.
4859 * \param [in] mName - a name of the supporting mesh.
4860 * \param [in] renumPol - specifies how to permute values of the result field according to
4861 * the optional numbers of cells and nodes, if any. The valid values are
4862 * - 0 - do not permute.
4863 * - 1 - permute cells.
4864 * - 2 - permute nodes.
4865 * - 3 - permute cells and nodes.
4867 * \param [in] glob - the global data storing profiles and localization.
4868 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4869 * caller is to delete this field using decrRef() as it is no more needed.
4870 * \throw If the MED file is not readable.
4871 * \throw If there is no mesh named \a mName in the MED file.
4872 * \throw If there are no mesh entities in the mesh.
4873 * \throw If no field values of the given \a type are available.
4875 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4877 MCAuto<MEDFileMesh> mm;
4879 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4881 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4882 int absDim=getDimension();
4883 int meshDimRelToMax=absDim-mm->getMeshDimension();
4884 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4888 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4889 * \param [in] type - a spatial discretization of the new field.
4890 * \param [in] renumPol - specifies how to permute values of the result field according to
4891 * the optional numbers of cells and nodes, if any. The valid values are
4892 * - 0 - do not permute.
4893 * - 1 - permute cells.
4894 * - 2 - permute nodes.
4895 * - 3 - permute cells and nodes.
4897 * \param [in] glob - the global data storing profiles and localization.
4898 * \param [in] mesh - the supporting mesh.
4899 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4900 * field according to \a renumPol.
4901 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4902 * field according to \a renumPol.
4903 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4904 * caller is to delete this field using decrRef() as it is no more needed.
4905 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4906 * \throw If no field of \a this is lying on \a mesh.
4907 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4909 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
4911 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4912 int meshId=getMeshIdFromMeshName(mesh->getName());
4914 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4919 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4926 throw INTERP_KERNEL::Exception(msg1);
4927 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4930 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4932 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4933 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4934 throw INTERP_KERNEL::Exception(oss.str());
4936 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4937 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4938 std::vector<DataArray *> arrOut2(1,arrOut);
4939 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4940 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4941 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4948 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4950 throw INTERP_KERNEL::Exception(msg1);
4953 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4955 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4956 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4957 throw INTERP_KERNEL::Exception(oss.str());
4959 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4960 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4961 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4962 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4967 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4972 * Returns values and a profile of the field of a given type lying on a given support.
4973 * \param [in] type - a spatial discretization of the field.
4974 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4975 * \param [in] mesh - the supporting mesh.
4976 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4977 * field of interest lies on. If the field lies on all entities of the given
4978 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4979 * using decrRef() as it is no more needed.
4980 * \param [in] glob - the global data storing profiles and localization.
4981 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4982 * field. The caller is to delete this array using decrRef() as it is no more needed.
4983 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4984 * \throw If no field of \a this is lying on \a mesh.
4985 * \throw If no field values of the given \a type are available.
4987 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4989 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4990 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4991 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4992 ret->setName(nasc.getName().c_str());
4996 //= MEDFileField1TSWithoutSDA
4999 * Throws if a given value is not a valid (non-extended) relative dimension.
5000 * \param [in] meshDimRelToMax - the relative dimension value.
5001 * \throw If \a meshDimRelToMax > 0.
5003 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5005 if(meshDimRelToMax>0)
5006 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5010 * Checks if elements of a given mesh are in the order suitable for writing
5011 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5012 * vector describing types of elements and their number.
5013 * \param [in] mesh - the mesh to check.
5014 * \return std::vector<int> - a vector holding for each element type (1) item of
5015 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5016 * These values are in full-interlace mode.
5017 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5019 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5022 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5023 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5024 int nbOfTypes=geoTypes.size();
5025 std::vector<int> code(3*nbOfTypes);
5026 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5027 arr1->alloc(nbOfTypes,1);
5028 int *arrPtr=arr1->getPointer();
5029 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5030 for(int i=0;i<nbOfTypes;i++,it++)
5031 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5032 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5033 const int *arrPtr2=arr2->getConstPointer();
5035 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5038 int nbCells=mesh->getNumberOfCellsWithType(*it);
5039 code[3*pos]=(int)(*it);
5040 code[3*pos+1]=nbCells;
5041 code[3*pos+2]=-1;//no profiles
5043 std::vector<const DataArrayInt *> idsPerType;//no profiles
5044 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5048 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5053 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5055 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5059 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5060 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5061 * item of every of returned sequences refers to the _i_-th part of \a this field.
5062 * Thus all sequences returned by this method are of the same length equal to number
5063 * of different types of supporting entities.<br>
5064 * A field part can include sub-parts with several different spatial discretizations,
5065 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5066 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5067 * of a nested sequence corresponds to a type of spatial discretization.<br>
5068 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5069 * The overhead is due to selecting values into new instances of DataArrayDouble.
5070 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5071 * for the case with only one underlying mesh. (Actually, the number of meshes is
5072 * not checked if \a mname == \c NULL).
5073 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5074 * a field part is returned.
5075 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5076 * A field part can include sub-parts with several different spatial discretizations,
5077 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5078 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5079 * This sequence is of the same length as \a types.
5080 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5081 * discretization. A profile name can be empty.
5082 * Length of this and of nested sequences is the same as that of \a typesF.
5083 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5084 * discretization. A localization name can be empty.
5085 * Length of this and of nested sequences is the same as that of \a typesF.
5086 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5087 * per each type of spatial discretization within one mesh entity type.
5088 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5089 * Length of this and of nested sequences is the same as that of \a typesF.
5090 * \throw If no field is lying on \a mname.
5092 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
5096 meshId=getMeshIdFromMeshName(mname);
5098 if(_field_per_mesh.empty())
5099 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5100 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5101 int nbOfRet=ret0.size();
5102 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5103 for(int i=0;i<nbOfRet;i++)
5105 const std::vector< std::pair<int,int> >& p=ret0[i];
5106 int nbOfRet1=p.size();
5107 ret[i].resize(nbOfRet1);
5108 for(int j=0;j<nbOfRet1;j++)
5110 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5118 * Returns a pointer to the underground DataArrayDouble instance. So the
5119 * caller should not decrRef() it. This method allows for a direct access to the field
5120 * values. This method is quite unusable if there is more than a nodal field or a cell
5121 * field on single geometric cell type.
5122 * \return DataArrayDouble * - the pointer to the field values array.
5124 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
5126 const DataArrayDouble *ret=_arr;
5128 return const_cast<DataArrayDouble *>(ret);
5133 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5138 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5140 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5141 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5142 ret->deepCpyLeavesFrom(*this);
5143 const DataArrayDouble *arr(_arr);
5146 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5147 ret->setArray(arr2);
5153 * Returns a pointer to the underground DataArrayDouble instance. So the
5154 * caller should not decrRef() it. This method allows for a direct access to the field
5155 * values. This method is quite unusable if there is more than a nodal field or a cell
5156 * field on single geometric cell type.
5157 * \return DataArrayDouble * - the pointer to the field values array.
5159 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5161 return getUndergroundDataArrayDouble();
5165 * Returns a pointer to the underground DataArrayDouble instance and a
5166 * sequence describing parameters of a support of each part of \a this field. The
5167 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5168 * direct access to the field values. This method is intended for the field lying on one
5170 * \param [in,out] entries - the sequence describing parameters of a support of each
5171 * part of \a this field. Each item of this sequence consists of two parts. The
5172 * first part describes a type of mesh entity and an id of discretization of a
5173 * current field part. The second part describes a range of values [begin,end)
5174 * within the returned array relating to the current field part.
5175 * \return DataArrayDouble * - the pointer to the field values array.
5176 * \throw If the number of underlying meshes is not equal to 1.
5177 * \throw If no field values are available.
5178 * \sa getUndergroundDataArray()
5180 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5182 if(_field_per_mesh.size()!=1)
5183 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5184 if(_field_per_mesh[0]==0)
5185 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5186 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5187 return getUndergroundDataArrayDouble();
5191 * Returns a pointer to the underground DataArrayDouble instance and a
5192 * sequence describing parameters of a support of each part of \a this field. The
5193 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5194 * direct access to the field values. This method is intended for the field lying on one
5196 * \param [in,out] entries - the sequence describing parameters of a support of each
5197 * part of \a this field. Each item of this sequence consists of two parts. The
5198 * first part describes a type of mesh entity and an id of discretization of a
5199 * current field part. The second part describes a range of values [begin,end)
5200 * within the returned array relating to the current field part.
5201 * \return DataArrayDouble * - the pointer to the field values array.
5202 * \throw If the number of underlying meshes is not equal to 1.
5203 * \throw If no field values are available.
5204 * \sa getUndergroundDataArray()
5206 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5208 return getUndergroundDataArrayDoubleExt(entries);
5211 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5213 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5214 arr->setInfoAndChangeNbOfCompo(infos);
5217 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5221 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5223 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5224 ret->deepCpyLeavesFrom(*this);
5228 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5230 MCAuto<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5231 if((const DataArrayDouble *)_arr)
5232 ret->_arr=_arr->deepCopy();
5236 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5240 _nb_of_tuples_to_be_allocated=-1;
5244 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5246 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5248 _nb_of_tuples_to_be_allocated=-3;
5253 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5255 return DataArrayDouble::New();
5258 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5260 DataArrayDouble *ret=_arr;
5263 _arr=DataArrayDouble::New();
5267 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5269 return getOrCreateAndGetArrayDouble();
5272 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5274 const DataArrayDouble *ret=_arr;
5277 DataArrayDouble *ret2=DataArrayDouble::New();
5278 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5282 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5284 return getOrCreateAndGetArrayDouble();
5287 //= MEDFileIntField1TSWithoutSDA
5289 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5291 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5294 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5298 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5299 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5301 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5302 arr->setInfoAndChangeNbOfCompo(infos);
5305 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5310 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5312 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5313 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5314 ret->deepCpyLeavesFrom(*this);
5315 const DataArrayInt *arr(_arr);
5318 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5319 ret->setArray(arr2);
5325 * Returns a pointer to the underground DataArrayInt instance. So the
5326 * caller should not decrRef() it. This method allows for a direct access to the field
5327 * values. This method is quite unusable if there is more than a nodal field or a cell
5328 * field on single geometric cell type.
5329 * \return DataArrayInt * - the pointer to the field values array.
5331 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5333 return getUndergroundDataArrayInt();
5337 * Returns a pointer to the underground DataArrayInt instance. So the
5338 * caller should not decrRef() it. This method allows for a direct access to the field
5339 * values. This method is quite unusable if there is more than a nodal field or a cell
5340 * field on single geometric cell type.
5341 * \return DataArrayInt * - the pointer to the field values array.
5343 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5345 const DataArrayInt *ret=_arr;
5347 return const_cast<DataArrayInt *>(ret);
5353 * Returns a pointer to the underground DataArrayInt instance and a
5354 * sequence describing parameters of a support of each part of \a this field. The
5355 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5356 * direct access to the field values. This method is intended for the field lying on one
5358 * \param [in,out] entries - the sequence describing parameters of a support of each
5359 * part of \a this field. Each item of this sequence consists of two parts. The
5360 * first part describes a type of mesh entity and an id of discretization of a
5361 * current field part. The second part describes a range of values [begin,end)
5362 * within the returned array relating to the current field part.
5363 * \return DataArrayInt * - the pointer to the field values array.
5364 * \throw If the number of underlying meshes is not equal to 1.
5365 * \throw If no field values are available.
5366 * \sa getUndergroundDataArray()
5368 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5370 return getUndergroundDataArrayIntExt(entries);
5374 * Returns a pointer to the underground DataArrayInt instance and a
5375 * sequence describing parameters of a support of each part of \a this field. The
5376 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5377 * direct access to the field values. This method is intended for the field lying on one
5379 * \param [in,out] entries - the sequence describing parameters of a support of each
5380 * part of \a this field. Each item of this sequence consists of two parts. The
5381 * first part describes a type of mesh entity and an id of discretization of a
5382 * current field part. The second part describes a range of values [begin,end)
5383 * within the returned array relating to the current field part.
5384 * \return DataArrayInt * - the pointer to the field values array.
5385 * \throw If the number of underlying meshes is not equal to 1.
5386 * \throw If no field values are available.
5387 * \sa getUndergroundDataArray()
5389 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5391 if(_field_per_mesh.size()!=1)
5392 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5393 if(_field_per_mesh[0]==0)
5394 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5395 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5396 return getUndergroundDataArrayInt();
5399 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5401 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5402 ret->deepCpyLeavesFrom(*this);
5406 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5408 MCAuto<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5409 if((const DataArrayInt *)_arr)
5410 ret->_arr=_arr->deepCopy();
5414 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5418 _nb_of_tuples_to_be_allocated=-1;
5422 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5424 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5426 _nb_of_tuples_to_be_allocated=-3;
5431 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5433 return DataArrayInt::New();
5436 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5438 DataArrayInt *ret=_arr;
5441 _arr=DataArrayInt::New();
5445 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5447 return getOrCreateAndGetArrayInt();
5450 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5452 const DataArrayInt *ret=_arr;
5455 DataArrayInt *ret2=DataArrayInt::New();
5456 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5460 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5462 return getOrCreateAndGetArrayInt();
5465 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5469 //= MEDFileAnyTypeField1TS
5471 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5473 med_field_type typcha;
5475 std::vector<std::string> infos;
5476 std::string dtunit,fieldName;
5477 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5478 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5483 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5488 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5493 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] !";
5494 throw INTERP_KERNEL::Exception(oss.str());
5497 ret->setDtUnit(dtunit.c_str());
5498 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5500 med_int numdt,numit;
5502 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5503 ret->setTime(numdt,numit,dt);
5506 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5508 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5512 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5513 try:MEDFileFieldGlobsReal(fileName)
5515 MEDFileUtilities::CheckFileForRead(fileName);
5516 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5517 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5520 catch(INTERP_KERNEL::Exception& e)
5525 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5527 med_field_type typcha;
5528 std::vector<std::string> infos;
5531 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5532 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5537 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5542 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5547 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] !";
5548 throw INTERP_KERNEL::Exception(oss.str());
5551 ret->setDtUnit(dtunit.c_str());
5552 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5556 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5557 throw INTERP_KERNEL::Exception(oss.str());
5560 med_int numdt,numit;
5562 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5563 ret->setTime(numdt,numit,dt);
5566 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5568 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5572 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5573 try:MEDFileFieldGlobsReal(fileName)
5575 MEDFileUtilities::CheckFileForRead(fileName);
5576 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5577 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5580 catch(INTERP_KERNEL::Exception& e)
5585 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5588 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5589 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5591 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New();
5592 ret->setFileName(fileName);
5593 ret->_content=c; c->incrRef();
5596 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5598 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5599 ret->setFileName(fileName);
5600 ret->_content=c; c->incrRef();
5603 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5606 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5608 MEDFileUtilities::CheckFileForRead(fileName);
5609 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5610 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5611 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5612 ret->loadGlobals(fid);
5616 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5618 MEDFileUtilities::CheckFileForRead(fileName);
5619 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5620 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5621 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5622 ret->loadGlobals(fid);
5626 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5628 MEDFileUtilities::CheckFileForRead(fileName);
5629 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5630 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5631 MCAuto<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5632 ret->loadGlobals(fid);
5636 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5638 med_field_type typcha;
5639 std::vector<std::string> infos;
5642 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5643 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5648 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5653 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5658 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] !";
5659 throw INTERP_KERNEL::Exception(oss.str());
5662 ret->setDtUnit(dtunit.c_str());
5663 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5666 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5667 for(int i=0;i<nbOfStep2 && !found;i++)
5669 med_int numdt,numit;
5671 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5672 if(numdt==iteration && numit==order)
5678 dtits[i]=std::pair<int,int>(numdt,numit);
5682 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5683 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5684 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5685 throw INTERP_KERNEL::Exception(oss.str());
5688 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5690 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5694 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5695 try:MEDFileFieldGlobsReal(fileName)
5697 MEDFileUtilities::CheckFileForRead(fileName);
5698 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5699 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5702 catch(INTERP_KERNEL::Exception& e)
5708 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5709 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5711 * \warning this is a shallow copy constructor
5713 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5715 if(!shallowCopyOfContent)
5717 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5718 otherPtr->incrRef();
5719 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5723 _content=other.shallowCpy();
5727 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)
5731 int nbFields=MEDnField(fid);
5732 if(fieldIdCFormat>=nbFields)
5734 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5735 throw INTERP_KERNEL::Exception(oss.str());
5738 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5739 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5740 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5741 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5742 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5743 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5746 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5747 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5748 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5749 infos.clear(); infos.resize(ncomp);
5750 for(int j=0;j<ncomp;j++)
5751 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5756 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5759 * \return in case of success the number of time steps available for the field with name \a fieldName.
5761 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)
5763 int nbFields=MEDnField(fid);
5765 std::vector<std::string> fns(nbFields);
5767 for(int i=0;i<nbFields && !found;i++)
5770 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5772 found=(tmp==fieldName);
5778 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5779 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5780 oss << "\"" << *it << "\" ";
5781 throw INTERP_KERNEL::Exception(oss.str());
5787 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5788 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5789 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5790 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5791 * to keep a valid instance.
5792 * 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.
5793 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5794 * 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.
5796 * \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.
5797 * \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.
5798 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5799 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5800 * \param [in] newLocName is the new localization name.
5801 * \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.
5802 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5804 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5806 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5807 std::string oldPflName=disc->getProfile();
5808 std::vector<std::string> vv=getPflsReallyUsedMulti();
5809 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5810 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5812 disc->setProfile(newPflName);
5813 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5814 pfl->setName(newPflName);
5818 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5819 throw INTERP_KERNEL::Exception(oss.str());
5824 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5825 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5826 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5827 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5828 * to keep a valid instance.
5829 * 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.
5830 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5831 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5832 * 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.
5834 * \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.
5835 * \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.
5836 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5837 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5838 * \param [in] newLocName is the new localization name.
5839 * \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.
5840 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5842 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5844 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5845 std::string oldLocName=disc->getLocalization();
5846 std::vector<std::string> vv=getLocsReallyUsedMulti();
5847 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5848 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5850 disc->setLocalization(newLocName);
5851 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5852 loc.setName(newLocName);
5856 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5857 throw INTERP_KERNEL::Exception(oss.str());
5861 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5863 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5865 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5869 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5871 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5873 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5878 * Writes \a this field into a MED file specified by its name.
5879 * \param [in] fileName - the MED file name.
5880 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5881 * - 2 - erase; an existing file is removed.
5882 * - 1 - append; same data should not be present in an existing file.
5883 * - 0 - overwrite; same data present in an existing file is overwritten.
5884 * \throw If the field name is not set.
5885 * \throw If no field data is set.
5886 * \throw If \a mode == 1 and the same data is present in an existing file.
5888 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5890 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5891 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5896 * This method alloc the arrays and load potentially huge arrays contained in this field.
5897 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5898 * This method can be also called to refresh or reinit values from a file.
5900 * \throw If the fileName is not set or points to a non readable MED file.
5901 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5903 void MEDFileAnyTypeField1TS::loadArrays()
5905 if(getFileName().empty())
5906 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5907 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5908 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5912 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5913 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5914 * this method does not throw if \a this does not come from file read.
5916 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5918 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5920 if(!getFileName().empty())
5922 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5923 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5928 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5929 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5930 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5932 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5934 void MEDFileAnyTypeField1TS::unloadArrays()
5936 contentNotNullBase()->unloadArrays();
5940 * 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.
5941 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5942 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5944 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5946 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5948 if(!getFileName().empty())
5949 contentNotNullBase()->unloadArrays();
5952 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5954 int nbComp=getNumberOfComponents();
5955 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5956 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5957 for(int i=0;i<nbComp;i++)
5959 std::string info=getInfo()[i];
5961 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5962 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5963 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5965 if(getName().empty())
5966 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5967 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5968 writeGlobals(fid,*this);
5969 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5972 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5974 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5977 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5979 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5980 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5985 * Returns a string describing \a this field. This string is outputted
5986 * by \c print Python command.
5988 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5990 std::ostringstream oss;
5991 contentNotNullBase()->simpleRepr(0,oss,-1);
5992 simpleReprGlobs(oss);
5997 * This method returns all profiles whose name is non empty used.
5998 * \b WARNING If profile is used several times it will be reported \b only \b once.
5999 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6001 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6003 return contentNotNullBase()->getPflsReallyUsed2();
6007 * This method returns all localizations whose name is non empty used.
6008 * \b WARNING If localization is used several times it will be reported \b only \b once.
6010 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6012 return contentNotNullBase()->getLocsReallyUsed2();
6016 * This method returns all profiles whose name is non empty used.
6017 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6019 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6021 return contentNotNullBase()->getPflsReallyUsedMulti2();
6025 * This method returns all localizations whose name is non empty used.
6026 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6028 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6030 return contentNotNullBase()->getLocsReallyUsedMulti2();
6033 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6035 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6038 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6040 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6043 int MEDFileAnyTypeField1TS::getDimension() const
6045 return contentNotNullBase()->getDimension();
6048 int MEDFileAnyTypeField1TS::getIteration() const
6050 return contentNotNullBase()->getIteration();
6053 int MEDFileAnyTypeField1TS::getOrder() const
6055 return contentNotNullBase()->getOrder();
6058 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6060 return contentNotNullBase()->getTime(iteration,order);
6063 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6065 contentNotNullBase()->setTime(iteration,order,val);
6068 std::string MEDFileAnyTypeField1TS::getName() const
6070 return contentNotNullBase()->getName();
6073 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6075 contentNotNullBase()->setName(name);
6078 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6080 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6083 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6085 return contentNotNullBase()->getDtUnit();
6088 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6090 contentNotNullBase()->setDtUnit(dtUnit);
6093 std::string MEDFileAnyTypeField1TS::getMeshName() const
6095 return contentNotNullBase()->getMeshName();
6098 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6100 contentNotNullBase()->setMeshName(newMeshName);
6103 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6105 return contentNotNullBase()->changeMeshNames(modifTab);
6108 int MEDFileAnyTypeField1TS::getMeshIteration() const
6110 return contentNotNullBase()->getMeshIteration();
6113 int MEDFileAnyTypeField1TS::getMeshOrder() const
6115 return contentNotNullBase()->getMeshOrder();
6118 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6120 return contentNotNullBase()->getNumberOfComponents();
6123 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6125 return contentNotNullBase()->isDealingTS(iteration,order);
6128 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6130 return contentNotNullBase()->getDtIt();
6133 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6135 contentNotNullBase()->fillIteration(p);
6138 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6140 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6143 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6145 contentNotNullBase()->setInfo(infos);
6148 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6150 return contentNotNullBase()->getInfo();
6152 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6154 return contentNotNullBase()->getInfo();
6157 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6159 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6162 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6164 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6167 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6169 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6172 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6174 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6177 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6179 return contentNotNullBase()->getTypesOfFieldAvailable();
6182 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,
6183 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6185 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6189 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6190 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6191 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6193 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6195 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6197 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6198 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6199 std::size_t sz(contentsSplit.size());
6200 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6201 for(std::size_t i=0;i<sz;i++)
6203 ret[i]=shallowCpy();
6204 ret[i]->_content=contentsSplit[i];
6210 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6211 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6213 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6215 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6217 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6218 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6219 std::size_t sz(contentsSplit.size());
6220 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6221 for(std::size_t i=0;i<sz;i++)
6223 ret[i]=shallowCpy();
6224 ret[i]->_content=contentsSplit[i];
6230 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6231 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6233 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6235 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6237 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6238 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6239 std::size_t sz(contentsSplit.size());
6240 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6241 for(std::size_t i=0;i<sz;i++)
6243 ret[i]=shallowCpy();
6244 ret[i]->_content=contentsSplit[i];
6249 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6251 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6252 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6253 ret->_content=_content->deepCopy();
6254 ret->deepCpyGlobs(*this);
6258 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6260 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6266 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6267 * the first field that has been read from a specified MED file.
6268 * \param [in] fileName - the name of the MED file to read.
6269 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6270 * is to delete this field using decrRef() as it is no more needed.
6271 * \throw If reading the file fails.
6273 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6275 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6276 ret->contentNotNull();
6281 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6282 * a given field that has been read from a specified MED file.
6283 * \param [in] fileName - the name of the MED file to read.
6284 * \param [in] fieldName - the name of the field to read.
6285 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6286 * is to delete this field using decrRef() as it is no more needed.
6287 * \throw If reading the file fails.
6288 * \throw If there is no field named \a fieldName in the file.
6290 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6292 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6293 ret->contentNotNull();
6298 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6299 * a given field that has been read from a specified MED file.
6300 * \param [in] fileName - the name of the MED file to read.
6301 * \param [in] fieldName - the name of the field to read.
6302 * \param [in] iteration - the iteration number of a required time step.
6303 * \param [in] order - the iteration order number of required time step.
6304 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6305 * is to delete this field using decrRef() as it is no more needed.
6306 * \throw If reading the file fails.
6307 * \throw If there is no field named \a fieldName in the file.
6308 * \throw If the required time step is missing from the file.
6310 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6312 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6313 ret->contentNotNull();
6318 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6319 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6321 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6322 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6323 * \warning this is a shallow copy constructor
6324 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6325 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6326 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6327 * is to delete this field using decrRef() as it is no more needed.
6329 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6331 MCAuto<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6332 ret->contentNotNull();
6337 * Returns a new empty instance of MEDFileField1TS.
6338 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6339 * is to delete this field using decrRef() as it is no more needed.
6341 MEDFileField1TS *MEDFileField1TS::New()
6343 MCAuto<MEDFileField1TS> ret=new MEDFileField1TS;
6344 ret->contentNotNull();
6349 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6350 * following the given input policy.
6352 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6353 * By default (true) the globals are deeply copied.
6354 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6356 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6358 MCAuto<MEDFileIntField1TS> ret;
6359 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6362 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6364 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6365 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6366 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6369 ret=MEDFileIntField1TS::New();
6371 ret->deepCpyGlobs(*this);
6373 ret->shallowCpyGlobs(*this);
6377 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6379 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6381 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6382 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6384 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 !");
6388 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6390 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6392 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6393 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6395 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 !");
6399 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6402 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6404 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6405 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6407 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6408 f->setArray(arrOutC);
6411 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6414 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6415 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6417 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6423 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6424 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6426 * \return A new object that the caller is responsible to deallocate.
6428 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6431 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6432 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6433 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6434 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6436 if((*it0)!=ON_NODES)
6438 std::vector<int> levs;
6439 getNonEmptyLevels(mm->getName(),levs);
6440 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6442 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6443 if(it2!=extractDef.end())
6445 MCAuto<DataArrayInt> t((*it2).second);
6446 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6447 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6448 ret->setFieldNoProfileSBT(fOut);
6454 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6455 if(it2==extractDef.end())
6456 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6457 MCAuto<DataArrayInt> t((*it2).second);
6458 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6459 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6460 DataArrayDouble *arr(f->getArray());
6461 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6462 fOut->setArray(newArr);
6463 ret->setFieldNoProfileSBT(fOut);
6469 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6470 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6473 catch(INTERP_KERNEL::Exception& e)
6476 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6477 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6480 catch(INTERP_KERNEL::Exception& e)
6483 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6484 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6487 catch(INTERP_KERNEL::Exception& e)
6491 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6492 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6494 * \warning this is a shallow copy constructor
6496 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6497 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6500 catch(INTERP_KERNEL::Exception& e)
6503 MEDFileField1TS::MEDFileField1TS()
6505 _content=new MEDFileField1TSWithoutSDA;
6509 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
6510 * method should be called (getFieldOnMeshAtLevel for example).
6511 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6513 * \param [in] mesh - the mesh the field is lying on
6514 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6515 * caller is to delete this field using decrRef() as it is no more needed.
6517 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6519 MCAuto<DataArray> arrOut;
6520 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6521 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6526 * Returns a new MEDCouplingFieldDouble of a given type lying on
6527 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6528 * has not been constructed via file reading, an exception is thrown.
6529 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6530 * \param [in] type - a spatial discretization of interest.
6531 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6532 * \param [in] renumPol - specifies how to permute values of the result field according to
6533 * the optional numbers of cells and nodes, if any. The valid values are
6534 * - 0 - do not permute.
6535 * - 1 - permute cells.
6536 * - 2 - permute nodes.
6537 * - 3 - permute cells and nodes.
6539 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6540 * caller is to delete this field using decrRef() as it is no more needed.
6541 * \throw If \a this field has not been constructed via file reading.
6542 * \throw If the MED file is not readable.
6543 * \throw If there is no mesh in the MED file.
6544 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6545 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6546 * \sa getFieldOnMeshAtLevel()
6548 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6550 if(getFileName().empty())
6551 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6552 MCAuto<DataArray> arrOut;
6553 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6554 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6559 * Returns a new MEDCouplingFieldDouble of a given type lying on
6560 * the top level cells of the first mesh in MED file. If \a this field
6561 * has not been constructed via file reading, an exception is thrown.
6562 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6563 * \param [in] type - a spatial discretization of interest.
6564 * \param [in] renumPol - specifies how to permute values of the result field according to
6565 * the optional numbers of cells and nodes, if any. The valid values are
6566 * - 0 - do not permute.
6567 * - 1 - permute cells.
6568 * - 2 - permute nodes.
6569 * - 3 - permute cells and nodes.
6571 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6572 * caller is to delete this field using decrRef() as it is no more needed.
6573 * \throw If \a this field has not been constructed via file reading.
6574 * \throw If the MED file is not readable.
6575 * \throw If there is no mesh in the MED file.
6576 * \throw If no field values of the given \a type.
6577 * \throw If no field values lying on the top level support.
6578 * \sa getFieldAtLevel()
6580 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6582 if(getFileName().empty())
6583 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6584 MCAuto<DataArray> arrOut;
6585 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6586 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6591 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6592 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6593 * \param [in] type - a spatial discretization of the new field.
6594 * \param [in] mesh - the supporting mesh.
6595 * \param [in] renumPol - specifies how to permute values of the result field according to
6596 * the optional numbers of cells and nodes, if any. The valid values are
6597 * - 0 - do not permute.
6598 * - 1 - permute cells.
6599 * - 2 - permute nodes.
6600 * - 3 - permute cells and nodes.
6602 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6603 * caller is to delete this field using decrRef() as it is no more needed.
6604 * \throw If no field of \a this is lying on \a mesh.
6605 * \throw If the mesh is empty.
6606 * \throw If no field values of the given \a type are available.
6607 * \sa getFieldAtLevel()
6608 * \sa getFieldOnMeshAtLevel()
6610 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6612 MCAuto<DataArray> arrOut;
6613 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6614 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6619 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6620 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6621 * \param [in] type - a spatial discretization of interest.
6622 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6623 * \param [in] mesh - the supporting mesh.
6624 * \param [in] renumPol - specifies how to permute values of the result field according to
6625 * the optional numbers of cells and nodes, if any. The valid values are
6626 * - 0 - do not permute.
6627 * - 1 - permute cells.
6628 * - 2 - permute nodes.
6629 * - 3 - permute cells and nodes.
6631 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6632 * caller is to delete this field using decrRef() as it is no more needed.
6633 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6634 * \throw If no field of \a this is lying on \a mesh.
6635 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6636 * \sa getFieldAtLevel()
6637 * \sa getFieldOnMeshAtLevel()
6639 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6641 MCAuto<DataArray> arrOut;
6642 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6643 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6648 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6649 * This method is called "Old" because in MED3 norm a field has only one meshName
6650 * attached, so this method is for readers of MED2 files. If \a this field
6651 * has not been constructed via file reading, an exception is thrown.
6652 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6653 * \param [in] type - a spatial discretization of interest.
6654 * \param [in] mName - a name of the supporting mesh.
6655 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6656 * \param [in] renumPol - specifies how to permute values of the result field according to
6657 * the optional numbers of cells and nodes, if any. The valid values are
6658 * - 0 - do not permute.
6659 * - 1 - permute cells.
6660 * - 2 - permute nodes.
6661 * - 3 - permute cells and nodes.
6663 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6664 * caller is to delete this field using decrRef() as it is no more needed.
6665 * \throw If the MED file is not readable.
6666 * \throw If there is no mesh named \a mName in the MED file.
6667 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6668 * \throw If \a this field has not been constructed via file reading.
6669 * \throw If no field of \a this is lying on the mesh named \a mName.
6670 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6671 * \sa getFieldAtLevel()
6673 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6675 if(getFileName().empty())
6676 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6677 MCAuto<DataArray> arrOut;
6678 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6679 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6684 * Returns values and a profile of the field of a given type lying on a given support.
6685 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6686 * \param [in] type - a spatial discretization of the field.
6687 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6688 * \param [in] mesh - the supporting mesh.
6689 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6690 * field of interest lies on. If the field lies on all entities of the given
6691 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6692 * using decrRef() as it is no more needed.
6693 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6694 * field. The caller is to delete this array using decrRef() as it is no more needed.
6695 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6696 * \throw If no field of \a this is lying on \a mesh.
6697 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6699 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6701 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6702 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6706 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6707 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6708 * "Sort By Type"), if not, an exception is thrown.
6709 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6710 * \param [in] field - the field to add to \a this.
6711 * \throw If the name of \a field is empty.
6712 * \throw If the data array of \a field is not set.
6713 * \throw If the data array is already allocated but has different number of components
6715 * \throw If the underlying mesh of \a field has no name.
6716 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6718 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6721 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6725 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6726 * can be an aggregation of several MEDCouplingFieldDouble instances.
6727 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6728 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6731 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6732 * A new profile is added only if no equal profile is missing.
6733 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6734 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6735 * \param [in] mesh - the supporting mesh of \a field.
6736 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6737 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6738 * \throw If either \a field or \a mesh or \a profile has an empty name.
6739 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6740 * \throw If the data array of \a field is not set.
6741 * \throw If the data array of \a this is already allocated but has different number of
6742 * components than \a field.
6743 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6744 * \sa setFieldNoProfileSBT()
6746 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6749 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6752 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6754 return new MEDFileField1TS(*this);
6757 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6759 return contentNotNull()->getUndergroundDataArrayDouble();
6762 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6764 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6767 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6768 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6770 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6773 //= MEDFileIntField1TS
6775 MEDFileIntField1TS *MEDFileIntField1TS::New()
6777 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6778 ret->contentNotNull();
6782 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6784 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6785 ret->contentNotNull();
6789 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6791 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6792 ret->contentNotNull();
6796 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6798 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6799 ret->contentNotNull();
6803 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6805 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6806 ret->contentNotNull();
6810 MEDFileIntField1TS::MEDFileIntField1TS()
6812 _content=new MEDFileIntField1TSWithoutSDA;
6815 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6816 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6819 catch(INTERP_KERNEL::Exception& e)
6822 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6823 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6826 catch(INTERP_KERNEL::Exception& e)
6829 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6830 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6833 catch(INTERP_KERNEL::Exception& e)
6837 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6838 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6840 * \warning this is a shallow copy constructor
6842 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6846 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6848 return new MEDFileIntField1TS(*this);
6852 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6853 * following the given input policy.
6855 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6856 * By default (true) the globals are deeply copied.
6857 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6859 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6861 MCAuto<MEDFileField1TS> ret;
6862 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6865 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6867 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6868 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6869 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6872 ret=MEDFileField1TS::New();
6874 ret->deepCpyGlobs(*this);
6876 ret->shallowCpyGlobs(*this);
6881 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6882 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6883 * "Sort By Type"), if not, an exception is thrown.
6884 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6885 * \param [in] field - the field to add to \a this.
6886 * \throw If the name of \a field is empty.
6887 * \throw If the data array of \a field is not set.
6888 * \throw If the data array is already allocated but has different number of components
6890 * \throw If the underlying mesh of \a field has no name.
6891 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6893 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6895 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6897 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6901 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6902 * can be an aggregation of several MEDCouplingFieldDouble instances.
6903 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6904 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6907 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6908 * A new profile is added only if no equal profile is missing.
6909 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6910 * \param [in] field - the field to add to \a this.
6911 * \param [in] mesh - the supporting mesh of \a field.
6912 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6913 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6914 * \throw If either \a field or \a mesh or \a profile has an empty name.
6915 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6916 * \throw If the data array of \a field is not set.
6917 * \throw If the data array of \a this is already allocated but has different number of
6918 * components than \a field.
6919 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6920 * \sa setFieldNoProfileSBT()
6922 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6924 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6926 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6929 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6931 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6933 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6934 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6936 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 !");
6940 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6942 if(getFileName().empty())
6943 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6944 MCAuto<DataArray> arrOut;
6945 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6946 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6950 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6953 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6954 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
6956 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6961 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6964 double t0(f->getTime(t1,t2));
6965 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
6966 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6967 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
6968 ret->setTime(t0,t1,t2); ret->setArray(arr2);
6972 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6975 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6977 double t0(f->getTime(t1,t2));
6978 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6979 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6980 ret->setTime(t0,t1,t2);
6984 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6986 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
6990 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
6991 * method should be called (getFieldOnMeshAtLevel for example).
6992 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6994 * \param [in] mesh - the mesh the field is lying on
6995 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
6996 * caller is to delete this field using decrRef() as it is no more needed.
6998 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7000 MCAuto<DataArray> arrOut;
7001 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7002 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7007 * Returns a new MEDCouplingFieldInt of a given type lying on
7008 * the top level cells of the first mesh in MED file. If \a this field
7009 * has not been constructed via file reading, an exception is thrown.
7010 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7011 * \param [in] type - a spatial discretization of interest.
7012 * \param [in] renumPol - specifies how to permute values of the result field according to
7013 * the optional numbers of cells and nodes, if any. The valid values are
7014 * - 0 - do not permute.
7015 * - 1 - permute cells.
7016 * - 2 - permute nodes.
7017 * - 3 - permute cells and nodes.
7019 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7020 * caller is to delete this field using decrRef() as it is no more needed.
7021 * \throw If \a this field has not been constructed via file reading.
7022 * \throw If the MED file is not readable.
7023 * \throw If there is no mesh in the MED file.
7024 * \throw If no field values of the given \a type.
7025 * \throw If no field values lying on the top level support.
7026 * \sa getFieldAtLevel()
7028 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7030 if(getFileName().empty())
7031 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7032 MCAuto<DataArray> arrOut;
7033 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7034 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7039 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7040 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7041 * \param [in] type - a spatial discretization of the new field.
7042 * \param [in] mesh - the supporting mesh.
7043 * \param [in] renumPol - specifies how to permute values of the result field according to
7044 * the optional numbers of cells and nodes, if any. The valid values are
7045 * - 0 - do not permute.
7046 * - 1 - permute cells.
7047 * - 2 - permute nodes.
7048 * - 3 - permute cells and nodes.
7050 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7051 * caller is to delete this field using decrRef() as it is no more needed.
7052 * \throw If no field of \a this is lying on \a mesh.
7053 * \throw If the mesh is empty.
7054 * \throw If no field values of the given \a type are available.
7055 * \sa getFieldAtLevel()
7056 * \sa getFieldOnMeshAtLevel()
7058 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7060 MCAuto<DataArray> arrOut;
7061 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7062 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7067 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7068 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7069 * \param [in] type - a spatial discretization of interest.
7070 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7071 * \param [in] mesh - the supporting mesh.
7072 * \param [in] renumPol - specifies how to permute values of the result field according to
7073 * the optional numbers of cells and nodes, if any. The valid values are
7074 * - 0 - do not permute.
7075 * - 1 - permute cells.
7076 * - 2 - permute nodes.
7077 * - 3 - permute cells and nodes.
7079 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7080 * caller is to delete this field using decrRef() as it is no more needed.
7081 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7082 * \throw If no field of \a this is lying on \a mesh.
7083 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7084 * \sa getFieldAtLevel()
7085 * \sa getFieldOnMeshAtLevel()
7087 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7089 MCAuto<DataArray> arrOut;
7090 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7091 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7096 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7097 * This method is called "Old" because in MED3 norm a field has only one meshName
7098 * attached, so this method is for readers of MED2 files. If \a this field
7099 * has not been constructed via file reading, an exception is thrown.
7100 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7101 * \param [in] type - a spatial discretization of interest.
7102 * \param [in] mName - a name of the supporting mesh.
7103 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7104 * \param [in] renumPol - specifies how to permute values of the result field according to
7105 * the optional numbers of cells and nodes, if any. The valid values are
7106 * - 0 - do not permute.
7107 * - 1 - permute cells.
7108 * - 2 - permute nodes.
7109 * - 3 - permute cells and nodes.
7111 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7112 * caller is to delete this field using decrRef() as it is no more needed.
7113 * \throw If the MED file is not readable.
7114 * \throw If there is no mesh named \a mName in the MED file.
7115 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7116 * \throw If \a this field has not been constructed via file reading.
7117 * \throw If no field of \a this is lying on the mesh named \a mName.
7118 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7119 * \sa getFieldAtLevel()
7121 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7123 if(getFileName().empty())
7124 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7125 MCAuto<DataArray> arrOut;
7126 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7127 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7132 * Returns values and a profile of the field of a given type lying on a given support.
7133 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7134 * \param [in] type - a spatial discretization of the field.
7135 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7136 * \param [in] mesh - the supporting mesh.
7137 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7138 * field of interest lies on. If the field lies on all entities of the given
7139 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7140 * using decrRef() as it is no more needed.
7141 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7142 * field. The caller is to delete this array using decrRef() as it is no more needed.
7143 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7144 * \throw If no field of \a this is lying on \a mesh.
7145 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7147 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7149 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7150 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7153 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7155 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7157 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7158 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7160 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 !");
7164 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7166 return contentNotNull()->getUndergroundDataArrayInt();
7169 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7171 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7175 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7180 * \param [in] fieldId field id in C mode
7182 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7184 med_field_type typcha;
7185 std::string dtunitOut;
7186 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
7187 setDtUnit(dtunitOut.c_str());
7188 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7191 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)
7192 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7194 setDtUnit(dtunit.c_str());
7195 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7197 catch(INTERP_KERNEL::Exception& e)
7202 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7204 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7205 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7206 ret+=(*it).capacity();
7210 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7212 std::vector<const BigMemoryObject *> ret;
7213 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7214 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7219 * 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
7222 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7224 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7225 ret->setInfo(_infos);
7226 int sz=(int)_time_steps.size();
7227 for(const int *id=startIds;id!=endIds;id++)
7229 if(*id>=0 && *id<sz)
7231 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7232 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7236 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7238 ret->pushBackTimeStep(tse2);
7242 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7243 oss << " ! Should be in [0," << sz << ") !";
7244 throw INTERP_KERNEL::Exception(oss.str());
7247 if(ret->getNumberOfTS()>0)
7248 ret->synchronizeNameScope();
7249 ret->copyNameScope(*this);
7254 * 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
7257 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7259 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7260 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7261 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7262 ret->setInfo(_infos);
7263 int sz=(int)_time_steps.size();
7265 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7269 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7270 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7274 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7276 ret->pushBackTimeStep(tse2);
7280 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7281 oss << " ! Should be in [0," << sz << ") !";
7282 throw INTERP_KERNEL::Exception(oss.str());
7285 if(ret->getNumberOfTS()>0)
7286 ret->synchronizeNameScope();
7287 ret->copyNameScope(*this);
7291 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7294 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7295 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7297 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7300 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7301 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7302 ids->pushBackSilent(id);
7304 return buildFromTimeStepIds(ids->begin(),ids->end());
7307 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7310 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7311 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7313 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7316 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7317 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7318 ids->pushBackSilent(id);
7320 return buildFromTimeStepIds(ids->begin(),ids->end());
7323 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7325 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7327 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7330 if(cur->presenceOfMultiDiscPerGeoType())
7336 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7341 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7346 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7349 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7351 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7352 if(pt->isDealingTS(iteration,order))
7355 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7356 std::vector< std::pair<int,int> > vp=getIterations();
7357 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7358 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7359 throw INTERP_KERNEL::Exception(oss.str());
7362 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7364 return *_time_steps[getTimeStepPos(iteration,order)];
7367 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7369 return *_time_steps[getTimeStepPos(iteration,order)];
7372 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7374 if(_time_steps.empty())
7375 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7376 return _time_steps[0]->getMeshName();
7379 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7381 std::string oldName(getMeshName());
7382 std::vector< std::pair<std::string,std::string> > v(1);
7383 v[0].first=oldName; v[0].second=newMeshName;
7387 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7390 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7392 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7394 ret=cur->changeMeshNames(modifTab) || ret;
7400 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7402 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7404 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7408 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7410 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7412 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7415 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7416 MEDFileFieldGlobsReal& glob)
7419 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7421 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7423 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7428 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7430 std::string startLine(bkOffset,' ');
7431 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7433 oss << " (" << fmtsId << ")";
7434 oss << " has the following name: \"" << _name << "\"." << std::endl;
7435 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7436 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7438 oss << startLine << " - \"" << *it << "\"" << std::endl;
7441 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7443 std::string chapter(17,'0'+i);
7444 oss << startLine << chapter << std::endl;
7445 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7447 cur->simpleRepr(bkOffset+2,oss,i);
7449 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7450 oss << startLine << chapter << std::endl;
7454 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7456 std::size_t sz=_time_steps.size();
7457 std::vector< std::pair<int,int> > ret(sz);
7459 for(std::size_t i=0;i<sz;i++)
7461 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7464 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7468 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7469 throw INTERP_KERNEL::Exception(oss.str());
7475 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7477 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7479 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7480 checkCoherencyOfType(tse2);
7481 if(_time_steps.empty())
7483 setName(tse2->getName().c_str());
7484 setInfo(tse2->getInfo());
7486 checkThatComponentsMatch(tse2->getInfo());
7487 _time_steps.push_back(tse);
7490 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7492 std::size_t nbOfCompo=_infos.size();
7493 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7495 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7498 if((cur->getInfo()).size()!=nbOfCompo)
7500 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7501 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7502 throw INTERP_KERNEL::Exception(oss.str());
7504 cur->copyNameScope(*this);
7509 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)
7511 _time_steps.resize(nbPdt);
7512 for(int i=0;i<nbPdt;i++)
7514 std::vector< std::pair<int,int> > ts;
7515 med_int numdt=0,numo=0;
7516 med_int meshIt=0,meshOrder=0;
7518 MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7523 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7528 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7532 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7535 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7537 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7541 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7543 if(_time_steps.empty())
7544 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7545 checkThatNbOfCompoOfTSMatchThis();
7546 std::vector<std::string> infos(getInfo());
7547 int nbComp=infos.size();
7548 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7549 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7550 for(int i=0;i<nbComp;i++)
7552 std::string info=infos[i];
7554 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7555 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7556 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7559 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7560 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7561 int nbOfTS=_time_steps.size();
7562 for(int i=0;i<nbOfTS;i++)
7563 _time_steps[i]->writeLL(fid,opts,*this);
7566 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7568 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7570 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7572 elt->loadBigArraysRecursively(fid,nasc);
7576 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7578 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7580 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7582 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7586 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7588 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7590 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7592 elt->unloadArrays();
7596 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7598 return _time_steps.size();
7601 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7603 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7604 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7606 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7608 newTS.push_back(*it);
7613 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7615 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7616 int maxId=(int)_time_steps.size();
7618 std::set<int> idsToDel;
7619 for(const int *id=startIds;id!=endIds;id++,ii++)
7621 if(*id>=0 && *id<maxId)
7623 idsToDel.insert(*id);
7627 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7628 throw INTERP_KERNEL::Exception(oss.str());
7631 for(int iii=0;iii<maxId;iii++)
7632 if(idsToDel.find(iii)==idsToDel.end())
7633 newTS.push_back(_time_steps[iii]);
7637 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7639 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7640 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7641 if(nbOfEntriesToKill==0)
7643 std::size_t sz=_time_steps.size();
7644 std::vector<bool> b(sz,true);
7646 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7648 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7649 for(std::size_t i=0;i<sz;i++)
7651 newTS.push_back(_time_steps[i]);
7655 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7658 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7659 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7661 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7665 tmp->getTime(it2,ord);
7666 if(it2==iteration && order==ord)
7669 oss << "(" << it2 << "," << ord << "), ";
7672 throw INTERP_KERNEL::Exception(oss.str());
7675 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7678 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7680 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7682 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7686 double ti=tmp->getTime(it2,ord);
7687 if(fabs(time-ti)<eps)
7693 throw INTERP_KERNEL::Exception(oss.str());
7696 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7698 int lgth=_time_steps.size();
7699 std::vector< std::pair<int,int> > ret(lgth);
7700 for(int i=0;i<lgth;i++)
7701 _time_steps[i]->fillIteration(ret[i]);
7706 * 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'
7707 * This method returns two things.
7708 * - The absolute dimension of 'this' in first parameter.
7709 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7710 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7712 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7713 * Only these 3 discretizations will be taken into account here.
7715 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7716 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7717 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7719 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7720 * 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'.
7722 * Let's consider the typical following case :
7723 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7724 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7725 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7727 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7729 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7731 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7732 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7733 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7734 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7736 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7738 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7741 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7743 if(pos<0 || pos>=(int)_time_steps.size())
7745 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7746 throw INTERP_KERNEL::Exception(oss.str());
7748 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7751 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7752 oss << "\nTry to use following method eraseEmptyTS !";
7753 throw INTERP_KERNEL::Exception(oss.str());
7758 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7760 if(pos<0 || pos>=(int)_time_steps.size())
7762 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7763 throw INTERP_KERNEL::Exception(oss.str());
7765 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7768 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7769 oss << "\nTry to use following method eraseEmptyTS !";
7770 throw INTERP_KERNEL::Exception(oss.str());
7775 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7777 std::vector<std::string> ret;
7778 std::set<std::string> ret2;
7779 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7781 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7782 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7783 if(ret2.find(*it2)==ret2.end())
7785 ret.push_back(*it2);
7792 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7794 std::vector<std::string> ret;
7795 std::set<std::string> ret2;
7796 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7798 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7799 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7800 if(ret2.find(*it2)==ret2.end())
7802 ret.push_back(*it2);
7809 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7811 std::vector<std::string> ret;
7812 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7814 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7815 ret.insert(ret.end(),tmp.begin(),tmp.end());
7820 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7822 std::vector<std::string> ret;
7823 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7825 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7826 ret.insert(ret.end(),tmp.begin(),tmp.end());
7831 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7833 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7834 (*it)->changePflsRefsNamesGen2(mapOfModif);
7837 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7839 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7840 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7843 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7845 int lgth=_time_steps.size();
7846 std::vector< std::vector<TypeOfField> > ret(lgth);
7847 for(int i=0;i<lgth;i++)
7848 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7853 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7855 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
7857 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7860 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7862 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7864 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7866 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7867 ret->_time_steps[i]=(*it)->deepCopy();
7872 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7874 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7875 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7876 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7877 for(std::size_t i=0;i<sz;i++)
7879 ret[i]=shallowCpy();
7880 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7882 for(std::size_t i=0;i<sz2;i++)
7884 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7887 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7888 throw INTERP_KERNEL::Exception(oss.str());
7892 for(std::size_t i=0;i<sz;i++)
7893 for(std::size_t j=0;j<sz2;j++)
7894 ret[i]->_time_steps[j]=ts[j][i];
7899 * This method splits into discretization each time steps in \a this.
7900 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7902 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7904 std::size_t sz(_time_steps.size());
7905 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7906 for(std::size_t i=0;i<sz;i++)
7908 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7911 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7912 throw INTERP_KERNEL::Exception(oss.str());
7914 items[i]=timeStep->splitDiscretizations();
7917 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7918 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7919 std::vector< TypeOfField > types;
7920 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7921 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7923 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7925 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7926 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7927 if(it2==types.end())
7928 types.push_back(ts[0]);
7930 ret.resize(types.size()); ret2.resize(types.size());
7931 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7932 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7934 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7935 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7936 ret2[pos].push_back(*it1);
7938 for(std::size_t i=0;i<types.size();i++)
7940 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7941 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7942 elt->pushBackTimeStep(*it1);//also updates infos in elt
7944 elt->MEDFileFieldNameScope::operator=(*this);
7950 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7952 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7954 std::size_t sz(_time_steps.size());
7955 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7956 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7957 for(std::size_t i=0;i<sz;i++)
7959 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7962 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7963 throw INTERP_KERNEL::Exception(oss.str());
7965 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7966 if(szOut==std::numeric_limits<std::size_t>::max())
7967 szOut=items[i].size();
7969 if(items[i].size()!=szOut)
7970 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7972 if(szOut==std::numeric_limits<std::size_t>::max())
7973 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7974 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7975 for(std::size_t i=0;i<szOut;i++)
7977 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7978 for(std::size_t j=0;j<sz;j++)
7979 elt->pushBackTimeStep(items[j][i]);
7981 elt->MEDFileFieldNameScope::operator=(*this);
7986 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7988 _name=field->getName();
7990 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7992 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7993 _infos=arr->getInfoOnComponents();
7996 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7998 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7999 if(_name!=field->getName())
8001 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8002 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8003 throw INTERP_KERNEL::Exception(oss.str());
8006 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8007 checkThatComponentsMatch(arr->getInfoOnComponents());
8010 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8012 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8013 if(getInfo().size()!=compos.size())
8015 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8016 oss << " number of components of element to append (" << compos.size() << ") !";
8017 throw INTERP_KERNEL::Exception(oss.str());
8021 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8022 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8023 oss << " But compo in input fields are : ";
8024 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8026 throw INTERP_KERNEL::Exception(oss.str());
8030 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8032 std::size_t sz=_infos.size();
8034 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8036 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8038 if(elt->getInfo().size()!=sz)
8040 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8041 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8042 throw INTERP_KERNEL::Exception(oss.str());
8047 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8050 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8051 if(!_time_steps.empty())
8052 checkCoherencyOfTinyInfo(field,arr);
8053 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8054 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8055 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8056 copyTinyInfoFrom(field,arr);
8057 _time_steps.push_back(obj);
8060 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8063 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8064 if(!_time_steps.empty())
8065 checkCoherencyOfTinyInfo(field,arr);
8066 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8067 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8068 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8069 copyTinyInfoFrom(field,arr);
8070 _time_steps.push_back(obj);
8073 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8075 int sz=(int)_time_steps.size();
8078 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8079 throw INTERP_KERNEL::Exception(oss.str());
8081 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8084 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8086 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8087 throw INTERP_KERNEL::Exception(oss.str());
8093 //= MEDFileFieldMultiTSWithoutSDA
8095 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)
8097 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8100 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8104 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8109 * \param [in] fieldId field id in C mode
8111 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8112 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8115 catch(INTERP_KERNEL::Exception& e)
8118 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)
8119 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8122 catch(INTERP_KERNEL::Exception& e)
8125 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8127 return new MEDFileField1TSWithoutSDA;
8130 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8133 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8134 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8136 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8139 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8141 return MEDFileField1TSWithoutSDA::TYPE_STR;
8144 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8146 return new MEDFileFieldMultiTSWithoutSDA(*this);
8149 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8151 return new MEDFileFieldMultiTSWithoutSDA;
8155 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8156 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8158 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
8160 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8161 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8163 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8164 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8167 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8169 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8170 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8172 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8174 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8177 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8179 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8180 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8181 ret->setIteration(i,elt);
8187 //= MEDFileAnyTypeFieldMultiTS
8189 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8193 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8194 try:MEDFileFieldGlobsReal(fileName)
8196 MEDFileUtilities::CheckFileForRead(fileName);
8197 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8198 _content=BuildContentFrom(fid,fileName,loadAll,ms);
8201 catch(INTERP_KERNEL::Exception& e)
8206 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)
8208 med_field_type typcha;
8209 std::vector<std::string> infos;
8212 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
8213 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8218 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8223 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8228 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] !";
8229 throw INTERP_KERNEL::Exception(oss.str());
8232 ret->setDtUnit(dtunit.c_str());
8236 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8238 med_field_type typcha;
8240 std::vector<std::string> infos;
8241 std::string dtunit,fieldName;
8242 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8243 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8248 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8253 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8258 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] !";
8259 throw INTERP_KERNEL::Exception(oss.str());
8262 ret->setDtUnit(dtunit.c_str());
8266 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8269 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8270 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8272 MCAuto<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8273 ret->setFileName(fileName);
8274 ret->_content=c; c->incrRef();
8277 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8279 MCAuto<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8280 ret->setFileName(fileName);
8281 ret->_content=c; c->incrRef();
8284 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8287 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)
8288 try:MEDFileFieldGlobsReal(fileName)
8290 MEDFileUtilities::CheckFileForRead(fileName);
8291 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8292 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
8295 catch(INTERP_KERNEL::Exception& e)
8300 //= MEDFileIntFieldMultiTSWithoutSDA
8302 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)
8304 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8307 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8311 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8315 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)
8316 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8319 catch(INTERP_KERNEL::Exception& e)
8323 * \param [in] fieldId field id in C mode
8325 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8326 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8329 catch(INTERP_KERNEL::Exception& e)
8332 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8334 return new MEDFileIntField1TSWithoutSDA;
8337 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8340 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8341 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8343 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8346 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8348 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8351 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8353 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8356 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8358 return new MEDFileIntFieldMultiTSWithoutSDA;
8361 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8363 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8364 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8366 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8368 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8371 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8373 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8374 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8375 ret->setIteration(i,elt);
8381 //= MEDFileAnyTypeFieldMultiTS
8384 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8385 * that has been read from a specified MED file.
8386 * \param [in] fileName - the name of the MED file to read.
8387 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8388 * is to delete this field using decrRef() as it is no more needed.
8389 * \throw If reading the file fails.
8391 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8393 MEDFileUtilities::CheckFileForRead(fileName);
8394 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8395 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8396 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8397 ret->loadGlobals(fid);
8402 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8403 * that has been read from a specified MED file.
8404 * \param [in] fileName - the name of the MED file to read.
8405 * \param [in] fieldName - the name of the field to read.
8406 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8407 * is to delete this field using decrRef() as it is no more needed.
8408 * \throw If reading the file fails.
8409 * \throw If there is no field named \a fieldName in the file.
8411 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8413 MEDFileUtilities::CheckFileForRead(fileName);
8414 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8415 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
8416 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8417 ret->loadGlobals(fid);
8422 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8423 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8425 * \warning this is a shallow copy constructor
8427 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8429 if(!shallowCopyOfContent)
8431 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8432 otherPtr->incrRef();
8433 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8437 _content=other.shallowCpy();
8441 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8443 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8445 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8449 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8451 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8453 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8457 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8459 return contentNotNullBase()->getPflsReallyUsed2();
8462 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8464 return contentNotNullBase()->getLocsReallyUsed2();
8467 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8469 return contentNotNullBase()->getPflsReallyUsedMulti2();
8472 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8474 return contentNotNullBase()->getLocsReallyUsedMulti2();
8477 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8479 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8482 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8484 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8487 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8489 return contentNotNullBase()->getNumberOfTS();
8492 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8494 contentNotNullBase()->eraseEmptyTS();
8497 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8499 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8502 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8504 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8507 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8509 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8510 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8515 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8517 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8518 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8523 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8525 return contentNotNullBase()->getIterations();
8528 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8530 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8531 pushBackTimeStep(*it);
8534 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8537 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8538 int nbOfTS(fmts->getNumberOfTS());
8539 for(int i=0;i<nbOfTS;i++)
8541 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8542 pushBackTimeStep(elt);
8546 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8549 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8550 checkCoherencyOfType(f1ts);
8552 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8553 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8555 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8556 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8557 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8558 _content->pushBackTimeStep(cSafe);
8559 appendGlobs(*f1ts,1e-12);
8562 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8564 contentNotNullBase()->synchronizeNameScope();
8567 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8569 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8572 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8574 return contentNotNullBase()->getPosGivenTime(time,eps);
8577 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8579 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8582 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8584 return contentNotNullBase()->getTypesOfFieldAvailable();
8587 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
8589 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8592 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8594 return contentNotNullBase()->getName();
8597 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8599 contentNotNullBase()->setName(name);
8602 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8604 return contentNotNullBase()->getDtUnit();
8607 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8609 contentNotNullBase()->setDtUnit(dtUnit);
8612 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8614 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8617 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8619 return contentNotNullBase()->getTimeSteps(ret1);
8622 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8624 return contentNotNullBase()->getMeshName();
8627 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8629 contentNotNullBase()->setMeshName(newMeshName);
8632 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8634 return contentNotNullBase()->changeMeshNames(modifTab);
8637 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8639 return contentNotNullBase()->getInfo();
8642 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8644 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8647 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8649 return contentNotNullBase()->setInfo(info);
8652 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8654 const std::vector<std::string> ret=getInfo();
8655 return (int)ret.size();
8658 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8660 writeGlobals(fid,*this);
8661 contentNotNullBase()->writeLL(fid,*this);
8665 * Writes \a this field into a MED file specified by its name.
8666 * \param [in] fileName - the MED file name.
8667 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8668 * - 2 - erase; an existing file is removed.
8669 * - 1 - append; same data should not be present in an existing file.
8670 * - 0 - overwrite; same data present in an existing file is overwritten.
8671 * \throw If the field name is not set.
8672 * \throw If no field data is set.
8673 * \throw If \a mode == 1 and the same data is present in an existing file.
8675 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8677 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8678 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8683 * This method alloc the arrays and load potentially huge arrays contained in this field.
8684 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8685 * This method can be also called to refresh or reinit values from a file.
8687 * \throw If the fileName is not set or points to a non readable MED file.
8689 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8691 if(getFileName().empty())
8692 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8693 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8694 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8698 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8699 * But once data loaded once, this method does nothing.
8701 * \throw If the fileName is not set or points to a non readable MED file.
8702 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8704 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8706 if(!getFileName().empty())
8708 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8709 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8714 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8715 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8716 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8718 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8720 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8722 contentNotNullBase()->unloadArrays();
8726 * 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.
8727 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8728 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8730 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8732 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8734 if(!getFileName().empty())
8735 contentNotNullBase()->unloadArrays();
8738 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8740 std::ostringstream oss;
8741 contentNotNullBase()->simpleRepr(0,oss,-1);
8742 simpleReprGlobs(oss);
8746 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8748 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8751 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8753 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8754 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8759 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8760 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8761 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8763 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8765 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8767 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8768 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8769 std::size_t sz(contentsSplit.size());
8770 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8771 for(std::size_t i=0;i<sz;i++)
8773 ret[i]=shallowCpy();
8774 ret[i]->_content=contentsSplit[i];
8780 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8781 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8783 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8785 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8787 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8788 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8789 std::size_t sz(contentsSplit.size());
8790 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8791 for(std::size_t i=0;i<sz;i++)
8793 ret[i]=shallowCpy();
8794 ret[i]->_content=contentsSplit[i];
8800 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8801 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8803 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8805 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8807 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8808 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8809 std::size_t sz(contentsSplit.size());
8810 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8811 for(std::size_t i=0;i<sz;i++)
8813 ret[i]=shallowCpy();
8814 ret[i]->_content=contentsSplit[i];
8819 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8821 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8822 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8823 ret->_content=_content->deepCopy();
8824 ret->deepCpyGlobs(*this);
8828 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8834 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8835 * \param [in] iteration - the iteration number of a required time step.
8836 * \param [in] order - the iteration order number of required time step.
8837 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8838 * delete this field using decrRef() as it is no more needed.
8839 * \throw If there is no required time step in \a this field.
8841 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8843 int pos=getPosOfTimeStep(iteration,order);
8844 return getTimeStepAtPos(pos);
8848 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8849 * \param [in] time - the time of the time step of interest.
8850 * \param [in] eps - a precision used to compare time values.
8851 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8852 * delete this field using decrRef() as it is no more needed.
8853 * \throw If there is no required time step in \a this field.
8855 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8857 int pos=getPosGivenTime(time,eps);
8858 return getTimeStepAtPos(pos);
8862 * 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.
8863 * The float64 value of time attached to the pair of integers are not considered here.
8864 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8866 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8867 * \throw If there is a null pointer in \a vectFMTS.
8869 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8871 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8872 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8873 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8874 while(!lstFMTS.empty())
8876 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8877 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8879 throw INTERP_KERNEL::Exception(msg);
8880 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8881 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8882 elt.push_back(curIt); it=lstFMTS.erase(it);
8883 while(it!=lstFMTS.end())
8887 throw INTERP_KERNEL::Exception(msg);
8888 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8890 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8900 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8901 * All returned instances in a subvector can be safely loaded, rendered along time
8902 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8903 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8904 * 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).
8905 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8906 * 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.
8908 * \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().
8909 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8910 * \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.
8911 * \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.
8913 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8914 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8915 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8916 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8917 * \throw If mesh is null.
8918 * \throw If an element in \a vectFMTS is null.
8919 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8921 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8923 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8925 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8926 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8927 if(vectFMTS.empty())
8929 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8930 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8932 throw INTERP_KERNEL::Exception(msg);
8934 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8935 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8936 for(;it!=vectFMTS.end();it++,i++)
8939 throw INTERP_KERNEL::Exception(msg);
8940 TypeOfField tof0,tof1;
8941 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8944 vectFMTSNotNodes.push_back(*it);
8946 vectFMTSNodes.push_back(*it);
8949 vectFMTSNotNodes.push_back(*it);
8951 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8952 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8954 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8957 bool isFetched(false);
8958 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8961 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8962 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8963 { ret[i].push_back(*it2); isFetched=true; }
8967 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8968 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8969 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8977 * 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.
8978 * \param [out] cmps - same size than the returned vector.
8980 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8982 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8983 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8984 while(!lstFMTS.empty())
8986 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8987 MEDFileAnyTypeFieldMultiTS *ref(*it);
8988 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8989 elt.push_back(ref); it=lstFMTS.erase(it);
8990 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8991 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8992 while(it!=lstFMTS.end())
8994 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8995 if(cmp->isEqual(curIt))
8996 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9000 ret.push_back(elt); cmps.push_back(cmp);
9006 * 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.
9007 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9009 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9010 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9011 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9012 * \thorw If \a f0 and \a f1 do not have the same times steps.
9013 * \throw If mesh is null.
9014 * \throw If \a f0 or \a f1 is null.
9015 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9017 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9020 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9022 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9023 if(f0->getMeshName()!=mesh->getName())
9025 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9026 throw INTERP_KERNEL::Exception(oss.str());
9028 if(f1->getMeshName()!=mesh->getName())
9030 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9031 throw INTERP_KERNEL::Exception(oss.str());
9033 int nts=f0->getNumberOfTS();
9034 if(nts!=f1->getNumberOfTS())
9035 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9038 for(int i=0;i<nts;i++)
9040 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9041 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9042 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9043 if(tofs0.size()!=1 || tofs1.size()!=1)
9044 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9047 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9048 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9051 { tof0=tofs0[0]; tof1=tofs1[0]; }
9052 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9054 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() << ") !";
9055 throw INTERP_KERNEL::Exception(oss.str());
9057 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9059 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() << ") !";
9060 throw INTERP_KERNEL::Exception(oss.str());
9062 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9064 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() << ") !";
9065 throw INTERP_KERNEL::Exception(oss.str());
9072 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9073 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9075 * \return A new object that the caller is responsible to deallocate.
9077 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9080 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9081 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9082 int nbTS(getNumberOfTS());
9083 for(int i=0;i<nbTS;i++)
9085 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9086 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9087 fmtsOut->pushBackTimeStep(f1tsOut);
9089 return fmtsOut.retn();
9092 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9094 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9097 //= MEDFileFieldMultiTS
9100 * Returns a new empty instance of MEDFileFieldMultiTS.
9101 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9102 * is to delete this field using decrRef() as it is no more needed.
9104 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9106 return new MEDFileFieldMultiTS;
9110 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9111 * that has been read from a specified MED file.
9112 * \param [in] fileName - the name of the MED file to read.
9113 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9114 * is to delete this field using decrRef() as it is no more needed.
9115 * \throw If reading the file fails.
9117 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9119 MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
9120 ret->contentNotNull();//to check that content type matches with \a this type.
9125 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9126 * that has been read from a specified MED file.
9127 * \param [in] fileName - the name of the MED file to read.
9128 * \param [in] fieldName - the name of the field to read.
9129 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9130 * is to delete this field using decrRef() as it is no more needed.
9131 * \throw If reading the file fails.
9132 * \throw If there is no field named \a fieldName in the file.
9134 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9136 MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
9137 ret->contentNotNull();//to check that content type matches with \a this type.
9142 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9143 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9145 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9146 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9147 * \warning this is a shallow copy constructor
9148 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9149 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9150 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9151 * is to delete this field using decrRef() as it is no more needed.
9153 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9155 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9158 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9160 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities));
9161 ret->contentNotNull();//to check that content type matches with \a this type.
9165 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9167 return new MEDFileFieldMultiTS(*this);
9170 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9173 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9174 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9176 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9180 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9181 * following the given input policy.
9183 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9184 * By default (true) the globals are deeply copied.
9185 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9187 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9189 MCAuto<MEDFileIntFieldMultiTS> ret;
9190 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9193 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9195 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9196 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9197 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
9200 ret=MEDFileIntFieldMultiTS::New();
9202 ret->deepCpyGlobs(*this);
9204 ret->shallowCpyGlobs(*this);
9209 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9210 * \param [in] pos - a time step id.
9211 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9212 * delete this field using decrRef() as it is no more needed.
9213 * \throw If \a pos is not a valid time step id.
9215 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9217 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9220 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9221 throw INTERP_KERNEL::Exception(oss.str());
9223 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9226 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9227 ret->shallowCpyGlobs(*this);
9230 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9231 throw INTERP_KERNEL::Exception(oss.str());
9235 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9236 * mesh entities of a given dimension of the first mesh in MED file.
9237 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9238 * \param [in] type - a spatial discretization of interest.
9239 * \param [in] iteration - the iteration number of a required time step.
9240 * \param [in] order - the iteration order number of required time step.
9241 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9242 * \param [in] renumPol - specifies how to permute values of the result field according to
9243 * the optional numbers of cells and nodes, if any. The valid values are
9244 * - 0 - do not permute.
9245 * - 1 - permute cells.
9246 * - 2 - permute nodes.
9247 * - 3 - permute cells and nodes.
9249 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9250 * caller is to delete this field using decrRef() as it is no more needed.
9251 * \throw If the MED file is not readable.
9252 * \throw If there is no mesh in the MED file.
9253 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9254 * \throw If no field values of the required parameters are available.
9256 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9258 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9259 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9261 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9262 MCAuto<DataArray> arrOut;
9263 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9264 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9269 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9270 * the top level cells of the first mesh in MED file.
9271 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9272 * \param [in] type - a spatial discretization of interest.
9273 * \param [in] iteration - the iteration number of a required time step.
9274 * \param [in] order - the iteration order number of required time step.
9275 * \param [in] renumPol - specifies how to permute values of the result field according to
9276 * the optional numbers of cells and nodes, if any. The valid values are
9277 * - 0 - do not permute.
9278 * - 1 - permute cells.
9279 * - 2 - permute nodes.
9280 * - 3 - permute cells and nodes.
9282 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9283 * caller is to delete this field using decrRef() as it is no more needed.
9284 * \throw If the MED file is not readable.
9285 * \throw If there is no mesh in the MED file.
9286 * \throw If no field values of the required parameters are available.
9288 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9290 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9291 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9293 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9294 MCAuto<DataArray> arrOut;
9295 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9296 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9301 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
9302 * method should be called (getFieldOnMeshAtLevel for example).
9303 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9305 * \param [in] iteration - the iteration number of a required time step.
9306 * \param [in] order - the iteration order number of required time step.
9307 * \param [in] mesh - the mesh the field is lying on
9308 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9309 * caller is to delete this field using decrRef() as it is no more needed.
9311 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9313 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9314 MCAuto<DataArray> arrOut;
9315 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9316 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9321 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9323 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9324 * \param [in] type - a spatial discretization of interest.
9325 * \param [in] iteration - the iteration number of a required time step.
9326 * \param [in] order - the iteration order number of required time step.
9327 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9328 * \param [in] mesh - the supporting mesh.
9329 * \param [in] renumPol - specifies how to permute values of the result field according to
9330 * the optional numbers of cells and nodes, if any. The valid values are
9331 * - 0 - do not permute.
9332 * - 1 - permute cells.
9333 * - 2 - permute nodes.
9334 * - 3 - permute cells and nodes.
9336 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9337 * caller is to delete this field using decrRef() as it is no more needed.
9338 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9339 * \throw If no field of \a this is lying on \a mesh.
9340 * \throw If no field values of the required parameters are available.
9342 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9344 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9345 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9347 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9348 MCAuto<DataArray> arrOut;
9349 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9350 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9355 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9357 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9358 * \param [in] type - a spatial discretization of the new field.
9359 * \param [in] iteration - the iteration number of a required time step.
9360 * \param [in] order - the iteration order number of required time step.
9361 * \param [in] mesh - the supporting mesh.
9362 * \param [in] renumPol - specifies how to permute values of the result field according to
9363 * the optional numbers of cells and nodes, if any. The valid values are
9364 * - 0 - do not permute.
9365 * - 1 - permute cells.
9366 * - 2 - permute nodes.
9367 * - 3 - permute cells and nodes.
9369 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9370 * caller is to delete this field using decrRef() as it is no more needed.
9371 * \throw If no field of \a this is lying on \a mesh.
9372 * \throw If no field values of the required parameters are available.
9374 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9376 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9377 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9379 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9380 MCAuto<DataArray> arrOut;
9381 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9382 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9387 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9388 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9389 * This method is useful for MED2 file format when field on different mesh was autorized.
9391 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9393 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9394 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9396 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9397 MCAuto<DataArray> arrOut;
9398 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9399 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9404 * Returns values and a profile of the field of a given type, of a given time step,
9405 * lying on a given support.
9406 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9407 * \param [in] type - a spatial discretization of the field.
9408 * \param [in] iteration - the iteration number of a required time step.
9409 * \param [in] order - the iteration order number of required time step.
9410 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9411 * \param [in] mesh - the supporting mesh.
9412 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9413 * field of interest lies on. If the field lies on all entities of the given
9414 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9415 * using decrRef() as it is no more needed.
9416 * \param [in] glob - the global data storing profiles and localization.
9417 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9418 * field. The caller is to delete this array using decrRef() as it is no more needed.
9419 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9420 * \throw If no field of \a this is lying on \a mesh.
9421 * \throw If no field values of the required parameters are available.
9423 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9425 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9426 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9428 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9429 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9430 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9433 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9435 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9437 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9438 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9440 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 !");
9444 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9446 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9448 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9449 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9451 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 !");
9456 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9457 * the given field is checked if its elements are sorted suitable for writing to MED file
9458 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9459 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9460 * \param [in] field - the field to add to \a this.
9461 * \throw If the name of \a field is empty.
9462 * \throw If the data array of \a field is not set.
9463 * \throw If existing time steps have different name or number of components than \a field.
9464 * \throw If the underlying mesh of \a field has no name.
9465 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9467 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9469 const DataArrayDouble *arr=0;
9471 arr=field->getArray();
9472 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9476 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9477 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9478 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9481 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9482 * A new profile is added only if no equal profile is missing.
9483 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9484 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9485 * \param [in] mesh - the supporting mesh of \a field.
9486 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9487 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9488 * \throw If either \a field or \a mesh or \a profile has an empty name.
9489 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9490 * \throw If the data array of \a field is not set.
9491 * \throw If the data array of \a this is already allocated but has different number of
9492 * components than \a field.
9493 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9494 * \sa setFieldNoProfileSBT()
9496 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9498 const DataArrayDouble *arr=0;
9500 arr=field->getArray();
9501 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9504 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9506 _content=new MEDFileFieldMultiTSWithoutSDA;
9509 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9510 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9513 catch(INTERP_KERNEL::Exception& e)
9516 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)
9517 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9520 catch(INTERP_KERNEL::Exception& e)
9523 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9527 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
9529 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9532 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9534 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9537 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9539 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9542 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9544 return MEDFileFieldMultiTS::New();
9547 //= MEDFileAnyTypeFieldMultiTSIterator
9549 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9554 _nb_iter=fmts->getNumberOfTS();
9558 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9562 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9564 if(_iter_id<_nb_iter)
9566 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9568 return fmts->getTimeStepAtPos(_iter_id++);
9576 //= MEDFileIntFieldMultiTS
9579 * Returns a new empty instance of MEDFileFieldMultiTS.
9580 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9581 * is to delete this field using decrRef() as it is no more needed.
9583 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9585 return new MEDFileIntFieldMultiTS;
9589 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9590 * that has been read from a specified MED file.
9591 * \param [in] fileName - the name of the MED file to read.
9592 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9593 * is to delete this field using decrRef() as it is no more needed.
9594 * \throw If reading the file fails.
9596 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9598 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9599 ret->contentNotNull();//to check that content type matches with \a this type.
9604 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9605 * that has been read from a specified MED file.
9606 * \param [in] fileName - the name of the MED file to read.
9607 * \param [in] fieldName - the name of the field to read.
9608 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9609 * is to delete this field using decrRef() as it is no more needed.
9610 * \throw If reading the file fails.
9611 * \throw If there is no field named \a fieldName in the file.
9613 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9615 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9616 ret->contentNotNull();//to check that content type matches with \a this type.
9621 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9622 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9624 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9625 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9626 * \warning this is a shallow copy constructor
9627 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9628 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9629 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9630 * is to delete this field using decrRef() as it is no more needed.
9632 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9634 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9637 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9639 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities);
9640 ret->contentNotNull();//to check that content type matches with \a this type.
9645 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9646 * following the given input policy.
9648 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9649 * By default (true) the globals are deeply copied.
9650 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9652 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9654 MCAuto<MEDFileFieldMultiTS> ret;
9655 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9658 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9660 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9661 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9662 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9665 ret=MEDFileFieldMultiTS::New();
9667 ret->deepCpyGlobs(*this);
9669 ret->shallowCpyGlobs(*this);
9673 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9675 return new MEDFileIntFieldMultiTS(*this);
9678 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9681 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9682 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9684 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9688 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
9689 * method should be called (getFieldOnMeshAtLevel for example).
9690 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9692 * \param [in] iteration - the iteration number of a required time step.
9693 * \param [in] order - the iteration order number of required time step.
9694 * \param [in] mesh - the mesh the field is lying on
9695 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9696 * caller is to delete this field using decrRef() as it is no more needed.
9698 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9700 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9701 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9703 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9704 MCAuto<DataArray> arrOut;
9705 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9706 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9711 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9712 * mesh entities of a given dimension of the first mesh in MED file.
9713 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9714 * \param [in] type - a spatial discretization of interest.
9715 * \param [in] iteration - the iteration number of a required time step.
9716 * \param [in] order - the iteration order number of required time step.
9717 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9718 * \param [in] renumPol - specifies how to permute values of the result field according to
9719 * the optional numbers of cells and nodes, if any. The valid values are
9720 * - 0 - do not permute.
9721 * - 1 - permute cells.
9722 * - 2 - permute nodes.
9723 * - 3 - permute cells and nodes.
9725 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9726 * caller is to delete this field using decrRef() as it is no more needed.
9727 * \throw If the MED file is not readable.
9728 * \throw If there is no mesh in the MED file.
9729 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9730 * \throw If no field values of the required parameters are available.
9732 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9734 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9735 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9737 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9738 MCAuto<DataArray> arr;
9739 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9740 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9745 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9746 * the top level cells of the first mesh in MED file.
9747 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9748 * \param [in] type - a spatial discretization of interest.
9749 * \param [in] iteration - the iteration number of a required time step.
9750 * \param [in] order - the iteration order number of required time step.
9751 * \param [in] renumPol - specifies how to permute values of the result field according to
9752 * the optional numbers of cells and nodes, if any. The valid values are
9753 * - 0 - do not permute.
9754 * - 1 - permute cells.
9755 * - 2 - permute nodes.
9756 * - 3 - permute cells and nodes.
9758 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9759 * caller is to delete this field using decrRef() as it is no more needed.
9760 * \throw If the MED file is not readable.
9761 * \throw If there is no mesh in the MED file.
9762 * \throw If no field values of the required parameters are available.
9764 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9766 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9767 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9769 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9770 MCAuto<DataArray> arr;
9771 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9772 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9777 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9779 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9780 * \param [in] type - a spatial discretization of interest.
9781 * \param [in] iteration - the iteration number of a required time step.
9782 * \param [in] order - the iteration order number of required time step.
9783 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9784 * \param [in] mesh - the supporting mesh.
9785 * \param [in] renumPol - specifies how to permute values of the result field according to
9786 * the optional numbers of cells and nodes, if any. The valid values are
9787 * - 0 - do not permute.
9788 * - 1 - permute cells.
9789 * - 2 - permute nodes.
9790 * - 3 - permute cells and nodes.
9792 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9793 * caller is to delete this field using decrRef() as it is no more needed.
9794 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9795 * \throw If no field of \a this is lying on \a mesh.
9796 * \throw If no field values of the required parameters are available.
9798 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9800 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9801 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9803 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9804 MCAuto<DataArray> arr;
9805 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
9806 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9811 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
9813 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9814 * \param [in] type - a spatial discretization of the new field.
9815 * \param [in] iteration - the iteration number of a required time step.
9816 * \param [in] order - the iteration order number of required time step.
9817 * \param [in] mesh - the supporting mesh.
9818 * \param [out] arrOut - the DataArrayInt containing values of field.
9819 * \param [in] renumPol - specifies how to permute values of the result field according to
9820 * the optional numbers of cells and nodes, if any. The valid values are
9821 * - 0 - do not permute.
9822 * - 1 - permute cells.
9823 * - 2 - permute nodes.
9824 * - 3 - permute cells and nodes.
9826 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9827 * caller is to delete this field using decrRef() as it is no more needed.
9828 * \throw If no field of \a this is lying on \a mesh.
9829 * \throw If no field values of the required parameters are available.
9831 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9833 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9834 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9836 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9837 MCAuto<DataArray> arr;
9838 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
9839 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9844 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9845 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9846 * This method is useful for MED2 file format when field on different mesh was autorized.
9848 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
9850 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9851 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9853 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9854 MCAuto<DataArray> arr;
9855 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
9856 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9861 * Returns values and a profile of the field of a given type, of a given time step,
9862 * lying on a given support.
9863 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9864 * \param [in] type - a spatial discretization of the field.
9865 * \param [in] iteration - the iteration number of a required time step.
9866 * \param [in] order - the iteration order number of required time step.
9867 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9868 * \param [in] mesh - the supporting mesh.
9869 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9870 * field of interest lies on. If the field lies on all entities of the given
9871 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9872 * using decrRef() as it is no more needed.
9873 * \param [in] glob - the global data storing profiles and localization.
9874 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9875 * field. The caller is to delete this array using decrRef() as it is no more needed.
9876 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9877 * \throw If no field of \a this is lying on \a mesh.
9878 * \throw If no field values of the required parameters are available.
9880 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9882 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9883 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9885 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9886 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9887 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9891 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9892 * \param [in] pos - a time step id.
9893 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9894 * delete this field using decrRef() as it is no more needed.
9895 * \throw If \a pos is not a valid time step id.
9897 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9899 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9902 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9903 throw INTERP_KERNEL::Exception(oss.str());
9905 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9908 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9909 ret->shallowCpyGlobs(*this);
9912 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9913 throw INTERP_KERNEL::Exception(oss.str());
9917 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
9918 * the given field is checked if its elements are sorted suitable for writing to MED file
9919 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9920 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9921 * \param [in] field - the field to add to \a this.
9922 * \throw If the name of \a field is empty.
9923 * \throw If the data array of \a field is not set.
9924 * \throw If existing time steps have different name or number of components than \a field.
9925 * \throw If the underlying mesh of \a field has no name.
9926 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9928 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
9930 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
9931 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
9935 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9936 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9937 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9940 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9941 * A new profile is added only if no equal profile is missing.
9942 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9943 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9944 * \param [in] arrOfVals - the values of the field \a field used.
9945 * \param [in] mesh - the supporting mesh of \a field.
9946 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9947 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9948 * \throw If either \a field or \a mesh or \a profile has an empty name.
9949 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9950 * \throw If the data array of \a field is not set.
9951 * \throw If the data array of \a this is already allocated but has different number of
9952 * components than \a field.
9953 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9954 * \sa setFieldNoProfileSBT()
9956 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9958 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
9959 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
9962 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9964 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9966 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9967 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9969 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 !");
9973 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9975 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9977 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9978 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9980 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 !");
9984 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9986 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9989 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9993 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9994 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9997 catch(INTERP_KERNEL::Exception& e)
10000 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)
10001 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
10004 catch(INTERP_KERNEL::Exception& e)
10007 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10009 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10012 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10014 return MEDFileIntFieldMultiTS::New();
10019 MEDFileFields *MEDFileFields::New()
10021 return new MEDFileFields;
10024 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10026 return new MEDFileFields(fileName,loadAll,0,0);
10029 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10031 return new MEDFileFields(fileName,loadAll,ms,0);
10034 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10036 return new MEDFileFields(fileName,loadAll,0,&entities);
10039 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10041 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10042 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10046 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10048 std::vector<const BigMemoryObject *> ret;
10049 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10050 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10054 MEDFileFields *MEDFileFields::deepCopy() const
10056 MCAuto<MEDFileFields> ret=shallowCpy();
10058 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10060 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10061 ret->_fields[i]=(*it)->deepCopy();
10063 ret->deepCpyGlobs(*this);
10067 MEDFileFields *MEDFileFields::shallowCpy() const
10069 return new MEDFileFields(*this);
10073 * 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
10074 * 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.
10075 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10077 * \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.
10078 * \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.
10080 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10082 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10084 std::set< std::pair<int,int> > s;
10085 bool firstShot=true;
10086 areThereSomeForgottenTS=false;
10087 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10089 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10091 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10092 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10094 { s=s1; firstShot=false; }
10097 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10099 areThereSomeForgottenTS=true;
10103 std::vector< std::pair<int,int> > ret;
10104 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10108 int MEDFileFields::getNumberOfFields() const
10110 return _fields.size();
10113 std::vector<std::string> MEDFileFields::getFieldsNames() const
10115 std::vector<std::string> ret(_fields.size());
10117 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10119 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10122 ret[i]=f->getName();
10126 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10127 throw INTERP_KERNEL::Exception(oss.str());
10133 std::vector<std::string> MEDFileFields::getMeshesNames() const
10135 std::vector<std::string> ret;
10136 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10138 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10140 ret.push_back(cur->getMeshName());
10145 std::string MEDFileFields::simpleRepr() const
10147 std::ostringstream oss;
10148 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10153 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10155 int nbOfFields=getNumberOfFields();
10156 std::string startLine(bkOffset,' ');
10157 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10159 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10161 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10164 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10168 oss << startLine << " - not defined !" << std::endl;
10172 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10174 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10175 std::string chapter(17,'0'+i);
10176 oss << startLine << chapter << std::endl;
10179 cur->simpleRepr(bkOffset+2,oss,i);
10183 oss << startLine << " - not defined !" << std::endl;
10185 oss << startLine << chapter << std::endl;
10187 simpleReprGlobs(oss);
10190 MEDFileFields::MEDFileFields()
10194 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10195 try:MEDFileFieldGlobsReal(fileName)
10197 MEDFileUtilities::CheckFileForRead(fileName);
10198 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
10199 int nbFields(MEDnField(fid));
10200 _fields.resize(nbFields);
10201 med_field_type typcha;
10202 for(int i=0;i<nbFields;i++)
10204 std::vector<std::string> infos;
10205 std::string fieldName,dtunit;
10206 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
10211 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10216 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10221 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] !";
10222 throw INTERP_KERNEL::Exception(oss.str());
10226 loadAllGlobals(fid);
10228 catch(INTERP_KERNEL::Exception& e)
10233 void MEDFileFields::writeLL(med_idt fid) const
10236 writeGlobals(fid,*this);
10237 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10239 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10242 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10243 throw INTERP_KERNEL::Exception(oss.str());
10245 elt->writeLL(fid,*this);
10249 void MEDFileFields::write(const std::string& fileName, int mode) const
10251 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
10252 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
10257 * This method alloc the arrays and load potentially huge arrays contained in this field.
10258 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10259 * This method can be also called to refresh or reinit values from a file.
10261 * \throw If the fileName is not set or points to a non readable MED file.
10263 void MEDFileFields::loadArrays()
10265 if(getFileName().empty())
10266 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10267 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10268 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10270 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10272 elt->loadBigArraysRecursively(fid,*elt);
10277 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10278 * But once data loaded once, this method does nothing.
10280 * \throw If the fileName is not set or points to a non readable MED file.
10281 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10283 void MEDFileFields::loadArraysIfNecessary()
10285 if(!getFileName().empty())
10287 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10288 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10290 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10292 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10298 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10299 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10300 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10302 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10304 void MEDFileFields::unloadArrays()
10306 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10308 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10310 elt->unloadArrays();
10315 * 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.
10316 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10317 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10319 * \sa MEDFileFields::loadArraysIfNecessary
10321 void MEDFileFields::unloadArraysWithoutDataLoss()
10323 if(!getFileName().empty())
10327 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10329 std::vector<std::string> ret;
10330 std::set<std::string> ret2;
10331 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10333 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10334 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10335 if(ret2.find(*it2)==ret2.end())
10337 ret.push_back(*it2);
10344 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10346 std::vector<std::string> ret;
10347 std::set<std::string> ret2;
10348 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10350 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10351 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10352 if(ret2.find(*it2)==ret2.end())
10354 ret.push_back(*it2);
10361 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10363 std::vector<std::string> ret;
10364 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10366 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10367 ret.insert(ret.end(),tmp.begin(),tmp.end());
10372 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10374 std::vector<std::string> ret;
10375 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10377 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10378 ret.insert(ret.end(),tmp.begin(),tmp.end());
10383 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10385 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10386 (*it)->changePflsRefsNamesGen2(mapOfModif);
10389 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10391 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10392 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10395 void MEDFileFields::resize(int newSize)
10397 _fields.resize(newSize);
10400 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10402 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10406 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10409 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10410 _fields.push_back(field->getContent());
10411 appendGlobs(*field,1e-12);
10414 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10417 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10418 if(i>=(int)_fields.size())
10419 _fields.resize(i+1);
10420 _fields[i]=field->getContent();
10421 appendGlobs(*field,1e-12);
10424 void MEDFileFields::destroyFieldAtPos(int i)
10426 destroyFieldsAtPos(&i,&i+1);
10429 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10431 std::vector<bool> b(_fields.size(),true);
10432 for(const int *i=startIds;i!=endIds;i++)
10434 if(*i<0 || *i>=(int)_fields.size())
10436 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10437 throw INTERP_KERNEL::Exception(oss.str());
10441 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10443 for(std::size_t i=0;i<_fields.size();i++)
10445 fields[j++]=_fields[i];
10449 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10451 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10452 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10453 std::vector<bool> b(_fields.size(),true);
10455 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10457 if(k<0 || k>=(int)_fields.size())
10459 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10460 throw INTERP_KERNEL::Exception(oss.str());
10464 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10466 for(std::size_t i=0;i<_fields.size();i++)
10468 fields[j++]=_fields[i];
10472 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10475 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10477 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10479 ret=cur->changeMeshNames(modifTab) || ret;
10485 * \param [in] meshName the name of the mesh that will be renumbered.
10486 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10487 * This code corresponds to the distribution of types in the corresponding mesh.
10488 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10489 * \param [in] renumO2N the old to new renumber array.
10490 * \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
10491 * field in \a this.
10493 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10496 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10498 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10501 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10508 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10509 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10511 * \return A new object that the caller is responsible to deallocate.
10513 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10516 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10517 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10518 int nbFields(getNumberOfFields());
10519 for(int i=0;i<nbFields;i++)
10521 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10524 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10525 throw INTERP_KERNEL::Exception(oss.str());
10527 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10528 fsOut->pushField(fmtsOut);
10530 return fsOut.retn();
10533 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10535 if(i<0 || i>=(int)_fields.size())
10537 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10538 throw INTERP_KERNEL::Exception(oss.str());
10540 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10543 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10544 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10545 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10547 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10549 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10552 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10553 throw INTERP_KERNEL::Exception(oss.str());
10555 ret->shallowCpyGlobs(*this);
10560 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10561 * This method is accessible in python using __getitem__ with a list in input.
10562 * \return a new object that the caller should deal with.
10564 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10566 MCAuto<MEDFileFields> ret=shallowCpy();
10567 std::size_t sz=std::distance(startIds,endIds);
10568 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10570 for(const int *i=startIds;i!=endIds;i++,j++)
10572 if(*i<0 || *i>=(int)_fields.size())
10574 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10575 throw INTERP_KERNEL::Exception(oss.str());
10577 fields[j]=_fields[*i];
10579 ret->_fields=fields;
10583 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10585 return getFieldAtPos(getPosFromFieldName(fieldName));
10589 * This method removes, if any, fields in \a this having no time steps.
10590 * 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.
10592 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10594 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10596 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10597 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10599 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10602 if(elt->getNumberOfTS()>0)
10603 newFields.push_back(*it);
10606 if(_fields.size()==newFields.size())
10613 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10614 * This method can be seen as a filter applied on \a this, that returns an object containing
10615 * 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
10616 * shallow copied from \a this.
10618 * \param [in] meshName - the name of the mesh on w
10619 * \return a new object that the caller should deal with.
10621 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10623 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10624 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10626 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10629 if(cur->getMeshName()==meshName)
10632 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10633 ret->_fields.push_back(cur2);
10636 ret->shallowCpyOnlyUsedGlobs(*this);
10641 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10642 * Input time steps are specified using a pair of integer (iteration, order).
10643 * 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,
10644 * but for each multitimestep only the time steps in \a timeSteps are kept.
10645 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10647 * The returned object points to shallow copy of elements in \a this.
10649 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10650 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10651 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10653 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10655 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10656 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10658 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10661 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10662 ret->_fields.push_back(elt);
10664 ret->shallowCpyOnlyUsedGlobs(*this);
10669 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10671 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10673 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10674 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10676 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10679 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10680 if(elt->getNumberOfTS()!=0)
10681 ret->_fields.push_back(elt);
10683 ret->shallowCpyOnlyUsedGlobs(*this);
10687 MEDFileFieldsIterator *MEDFileFields::iterator()
10689 return new MEDFileFieldsIterator(this);
10692 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10694 std::string tmp(fieldName);
10695 std::vector<std::string> poss;
10696 for(std::size_t i=0;i<_fields.size();i++)
10698 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10701 std::string fname(f->getName());
10705 poss.push_back(fname);
10708 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10709 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10711 throw INTERP_KERNEL::Exception(oss.str());
10714 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10719 _nb_iter=fs->getNumberOfFields();
10723 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10727 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10729 if(_iter_id<_nb_iter)
10731 MEDFileFields *fs(_fs);
10733 return fs->getFieldAtPos(_iter_id++);