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 be extracted with \"field\" method ! 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.
6427 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6429 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6432 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6433 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6434 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6435 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6437 if((*it0)!=ON_NODES)
6439 std::vector<int> levs;
6440 getNonEmptyLevels(mm->getName(),levs);
6441 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6443 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6444 if(it2!=extractDef.end())
6446 MCAuto<DataArrayInt> t((*it2).second);
6448 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6449 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6450 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6451 ret->setFieldNoProfileSBT(fOut);
6457 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6458 if(it2==extractDef.end())
6459 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6460 MCAuto<DataArrayInt> t((*it2).second);
6462 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6463 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6464 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6465 DataArrayDouble *arr(f->getArray());
6466 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6467 fOut->setArray(newArr);
6468 ret->setFieldNoProfileSBT(fOut);
6474 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6475 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6478 catch(INTERP_KERNEL::Exception& e)
6481 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6482 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6485 catch(INTERP_KERNEL::Exception& e)
6488 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6489 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6492 catch(INTERP_KERNEL::Exception& e)
6496 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6497 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6499 * \warning this is a shallow copy constructor
6501 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6502 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6505 catch(INTERP_KERNEL::Exception& e)
6508 MEDFileField1TS::MEDFileField1TS()
6510 _content=new MEDFileField1TSWithoutSDA;
6514 * 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
6515 * method should be called (getFieldOnMeshAtLevel for example).
6516 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6518 * \param [in] mesh - the mesh the field is lying on
6519 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6520 * caller is to delete this field using decrRef() as it is no more needed.
6522 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6524 MCAuto<DataArray> arrOut;
6525 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6526 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6531 * Returns a new MEDCouplingFieldDouble of a given type lying on
6532 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6533 * has not been constructed via file reading, an exception is thrown.
6534 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6535 * \param [in] type - a spatial discretization of interest.
6536 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6537 * \param [in] renumPol - specifies how to permute values of the result field according to
6538 * the optional numbers of cells and nodes, if any. The valid values are
6539 * - 0 - do not permute.
6540 * - 1 - permute cells.
6541 * - 2 - permute nodes.
6542 * - 3 - permute cells and nodes.
6544 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6545 * caller is to delete this field using decrRef() as it is no more needed.
6546 * \throw If \a this field has not been constructed via file reading.
6547 * \throw If the MED file is not readable.
6548 * \throw If there is no mesh in the MED file.
6549 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6550 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6551 * \sa getFieldOnMeshAtLevel()
6553 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6555 if(getFileName().empty())
6556 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6557 MCAuto<DataArray> arrOut;
6558 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6559 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6564 * Returns a new MEDCouplingFieldDouble of a given type lying on
6565 * the top level cells of the first mesh in MED file. If \a this field
6566 * has not been constructed via file reading, an exception is thrown.
6567 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6568 * \param [in] type - a spatial discretization of interest.
6569 * \param [in] renumPol - specifies how to permute values of the result field according to
6570 * the optional numbers of cells and nodes, if any. The valid values are
6571 * - 0 - do not permute.
6572 * - 1 - permute cells.
6573 * - 2 - permute nodes.
6574 * - 3 - permute cells and nodes.
6576 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6577 * caller is to delete this field using decrRef() as it is no more needed.
6578 * \throw If \a this field has not been constructed via file reading.
6579 * \throw If the MED file is not readable.
6580 * \throw If there is no mesh in the MED file.
6581 * \throw If no field values of the given \a type.
6582 * \throw If no field values lying on the top level support.
6583 * \sa getFieldAtLevel()
6585 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6587 if(getFileName().empty())
6588 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6589 MCAuto<DataArray> arrOut;
6590 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6591 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6596 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6597 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6598 * \param [in] type - a spatial discretization of the new field.
6599 * \param [in] mesh - the supporting mesh.
6600 * \param [in] renumPol - specifies how to permute values of the result field according to
6601 * the optional numbers of cells and nodes, if any. The valid values are
6602 * - 0 - do not permute.
6603 * - 1 - permute cells.
6604 * - 2 - permute nodes.
6605 * - 3 - permute cells and nodes.
6607 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6608 * caller is to delete this field using decrRef() as it is no more needed.
6609 * \throw If no field of \a this is lying on \a mesh.
6610 * \throw If the mesh is empty.
6611 * \throw If no field values of the given \a type are available.
6612 * \sa getFieldAtLevel()
6613 * \sa getFieldOnMeshAtLevel()
6615 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6617 MCAuto<DataArray> arrOut;
6618 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6619 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6624 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6625 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6626 * \param [in] type - a spatial discretization of interest.
6627 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6628 * \param [in] mesh - the supporting mesh.
6629 * \param [in] renumPol - specifies how to permute values of the result field according to
6630 * the optional numbers of cells and nodes, if any. The valid values are
6631 * - 0 - do not permute.
6632 * - 1 - permute cells.
6633 * - 2 - permute nodes.
6634 * - 3 - permute cells and nodes.
6636 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6637 * caller is to delete this field using decrRef() as it is no more needed.
6638 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6639 * \throw If no field of \a this is lying on \a mesh.
6640 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6641 * \sa getFieldAtLevel()
6642 * \sa getFieldOnMeshAtLevel()
6644 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6646 MCAuto<DataArray> arrOut;
6647 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6648 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6653 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6654 * This method is called "Old" because in MED3 norm a field has only one meshName
6655 * attached, so this method is for readers of MED2 files. If \a this field
6656 * has not been constructed via file reading, an exception is thrown.
6657 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6658 * \param [in] type - a spatial discretization of interest.
6659 * \param [in] mName - a name of the supporting mesh.
6660 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6661 * \param [in] renumPol - specifies how to permute values of the result field according to
6662 * the optional numbers of cells and nodes, if any. The valid values are
6663 * - 0 - do not permute.
6664 * - 1 - permute cells.
6665 * - 2 - permute nodes.
6666 * - 3 - permute cells and nodes.
6668 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6669 * caller is to delete this field using decrRef() as it is no more needed.
6670 * \throw If the MED file is not readable.
6671 * \throw If there is no mesh named \a mName in the MED file.
6672 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6673 * \throw If \a this field has not been constructed via file reading.
6674 * \throw If no field of \a this is lying on the mesh named \a mName.
6675 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6676 * \sa getFieldAtLevel()
6678 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6680 if(getFileName().empty())
6681 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6682 MCAuto<DataArray> arrOut;
6683 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6684 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6689 * Returns values and a profile of the field of a given type lying on a given support.
6690 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6691 * \param [in] type - a spatial discretization of the field.
6692 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6693 * \param [in] mesh - the supporting mesh.
6694 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6695 * field of interest lies on. If the field lies on all entities of the given
6696 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6697 * using decrRef() as it is no more needed.
6698 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6699 * field. The caller is to delete this array using decrRef() as it is no more needed.
6700 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6701 * \throw If no field of \a this is lying on \a mesh.
6702 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6704 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6706 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6707 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6711 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6712 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6713 * "Sort By Type"), if not, an exception is thrown.
6714 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6715 * \param [in] field - the field to add to \a this.
6716 * \throw If the name of \a field is empty.
6717 * \throw If the data array of \a field is not set.
6718 * \throw If the data array is already allocated but has different number of components
6720 * \throw If the underlying mesh of \a field has no name.
6721 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6723 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6726 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6730 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6731 * can be an aggregation of several MEDCouplingFieldDouble instances.
6732 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6733 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6736 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6737 * A new profile is added only if no equal profile is missing.
6738 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6739 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6740 * \param [in] mesh - the supporting mesh of \a field.
6741 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6742 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6743 * \throw If either \a field or \a mesh or \a profile has an empty name.
6744 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6745 * \throw If the data array of \a field is not set.
6746 * \throw If the data array of \a this is already allocated but has different number of
6747 * components than \a field.
6748 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6749 * \sa setFieldNoProfileSBT()
6751 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6754 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6757 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6759 return new MEDFileField1TS(*this);
6762 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6764 return contentNotNull()->getUndergroundDataArrayDouble();
6767 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6769 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6772 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6773 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6775 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6778 //= MEDFileIntField1TS
6780 MEDFileIntField1TS *MEDFileIntField1TS::New()
6782 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6783 ret->contentNotNull();
6787 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6789 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6790 ret->contentNotNull();
6794 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6796 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6797 ret->contentNotNull();
6801 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6803 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6804 ret->contentNotNull();
6808 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6810 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6811 ret->contentNotNull();
6815 MEDFileIntField1TS::MEDFileIntField1TS()
6817 _content=new MEDFileIntField1TSWithoutSDA;
6820 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6821 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6824 catch(INTERP_KERNEL::Exception& e)
6827 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6828 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6831 catch(INTERP_KERNEL::Exception& e)
6834 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6835 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6838 catch(INTERP_KERNEL::Exception& e)
6842 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6843 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6845 * \warning this is a shallow copy constructor
6847 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6851 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6853 return new MEDFileIntField1TS(*this);
6857 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6858 * following the given input policy.
6860 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6861 * By default (true) the globals are deeply copied.
6862 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6864 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6866 MCAuto<MEDFileField1TS> ret;
6867 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6870 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6872 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6873 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6874 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6877 ret=MEDFileField1TS::New();
6879 ret->deepCpyGlobs(*this);
6881 ret->shallowCpyGlobs(*this);
6886 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
6887 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6888 * "Sort By Type"), if not, an exception is thrown.
6889 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6890 * \param [in] field - the field to add to \a this.
6891 * \throw If the name of \a field is empty.
6892 * \throw If the data array of \a field is not set.
6893 * \throw If the data array is already allocated but has different number of components
6895 * \throw If the underlying mesh of \a field has no name.
6896 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6898 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
6900 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6902 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
6906 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6907 * can be an aggregation of several MEDCouplingFieldDouble instances.
6908 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6909 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6912 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6913 * A new profile is added only if no equal profile is missing.
6914 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6915 * \param [in] field - the field to add to \a this.
6916 * \param [in] mesh - the supporting mesh of \a field.
6917 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6918 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6919 * \throw If either \a field or \a mesh or \a profile has an empty name.
6920 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6921 * \throw If the data array of \a field is not set.
6922 * \throw If the data array of \a this is already allocated but has different number of
6923 * components than \a field.
6924 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6925 * \sa setFieldNoProfileSBT()
6927 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6929 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
6931 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6934 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6936 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6938 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6939 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6941 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 !");
6945 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6947 if(getFileName().empty())
6948 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6949 MCAuto<DataArray> arrOut;
6950 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6951 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
6955 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
6958 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6959 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
6961 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6966 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6969 double t0(f->getTime(t1,t2));
6970 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
6971 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6972 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
6973 ret->setTime(t0,t1,t2); ret->setArray(arr2);
6977 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
6980 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
6982 double t0(f->getTime(t1,t2));
6983 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
6984 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
6985 ret->setTime(t0,t1,t2);
6989 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6991 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
6995 * 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
6996 * method should be called (getFieldOnMeshAtLevel for example).
6997 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6999 * \param [in] mesh - the mesh the field is lying on
7000 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7001 * caller is to delete this field using decrRef() as it is no more needed.
7003 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7005 MCAuto<DataArray> arrOut;
7006 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7007 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7012 * Returns a new MEDCouplingFieldInt of a given type lying on
7013 * the top level cells of the first mesh in MED file. If \a this field
7014 * has not been constructed via file reading, an exception is thrown.
7015 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7016 * \param [in] type - a spatial discretization of interest.
7017 * \param [in] renumPol - specifies how to permute values of the result field according to
7018 * the optional numbers of cells and nodes, if any. The valid values are
7019 * - 0 - do not permute.
7020 * - 1 - permute cells.
7021 * - 2 - permute nodes.
7022 * - 3 - permute cells and nodes.
7024 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7025 * caller is to delete this field using decrRef() as it is no more needed.
7026 * \throw If \a this field has not been constructed via file reading.
7027 * \throw If the MED file is not readable.
7028 * \throw If there is no mesh in the MED file.
7029 * \throw If no field values of the given \a type.
7030 * \throw If no field values lying on the top level support.
7031 * \sa getFieldAtLevel()
7033 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7035 if(getFileName().empty())
7036 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7037 MCAuto<DataArray> arrOut;
7038 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7039 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7044 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7045 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7046 * \param [in] type - a spatial discretization of the new field.
7047 * \param [in] mesh - the supporting mesh.
7048 * \param [in] renumPol - specifies how to permute values of the result field according to
7049 * the optional numbers of cells and nodes, if any. The valid values are
7050 * - 0 - do not permute.
7051 * - 1 - permute cells.
7052 * - 2 - permute nodes.
7053 * - 3 - permute cells and nodes.
7055 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7056 * caller is to delete this field using decrRef() as it is no more needed.
7057 * \throw If no field of \a this is lying on \a mesh.
7058 * \throw If the mesh is empty.
7059 * \throw If no field values of the given \a type are available.
7060 * \sa getFieldAtLevel()
7061 * \sa getFieldOnMeshAtLevel()
7063 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7065 MCAuto<DataArray> arrOut;
7066 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7067 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7072 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7073 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7074 * \param [in] type - a spatial discretization of interest.
7075 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7076 * \param [in] mesh - the supporting mesh.
7077 * \param [in] renumPol - specifies how to permute values of the result field according to
7078 * the optional numbers of cells and nodes, if any. The valid values are
7079 * - 0 - do not permute.
7080 * - 1 - permute cells.
7081 * - 2 - permute nodes.
7082 * - 3 - permute cells and nodes.
7084 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7085 * caller is to delete this field using decrRef() as it is no more needed.
7086 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7087 * \throw If no field of \a this is lying on \a mesh.
7088 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7089 * \sa getFieldAtLevel()
7090 * \sa getFieldOnMeshAtLevel()
7092 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7094 MCAuto<DataArray> arrOut;
7095 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7096 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7101 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7102 * This method is called "Old" because in MED3 norm a field has only one meshName
7103 * attached, so this method is for readers of MED2 files. If \a this field
7104 * has not been constructed via file reading, an exception is thrown.
7105 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7106 * \param [in] type - a spatial discretization of interest.
7107 * \param [in] mName - a name of the supporting mesh.
7108 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7109 * \param [in] renumPol - specifies how to permute values of the result field according to
7110 * the optional numbers of cells and nodes, if any. The valid values are
7111 * - 0 - do not permute.
7112 * - 1 - permute cells.
7113 * - 2 - permute nodes.
7114 * - 3 - permute cells and nodes.
7116 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7117 * caller is to delete this field using decrRef() as it is no more needed.
7118 * \throw If the MED file is not readable.
7119 * \throw If there is no mesh named \a mName in the MED file.
7120 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7121 * \throw If \a this field has not been constructed via file reading.
7122 * \throw If no field of \a this is lying on the mesh named \a mName.
7123 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7124 * \sa getFieldAtLevel()
7126 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7128 if(getFileName().empty())
7129 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7130 MCAuto<DataArray> arrOut;
7131 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7132 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7137 * Returns values and a profile of the field of a given type lying on a given support.
7138 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7139 * \param [in] type - a spatial discretization of the field.
7140 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7141 * \param [in] mesh - the supporting mesh.
7142 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7143 * field of interest lies on. If the field lies on all entities of the given
7144 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7145 * using decrRef() as it is no more needed.
7146 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7147 * field. The caller is to delete this array using decrRef() as it is no more needed.
7148 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7149 * \throw If no field of \a this is lying on \a mesh.
7150 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7152 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7154 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7155 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7158 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7160 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7162 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7163 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7165 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 !");
7169 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7171 return contentNotNull()->getUndergroundDataArrayInt();
7174 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7176 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7180 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7185 * \param [in] fieldId field id in C mode
7187 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7189 med_field_type typcha;
7190 std::string dtunitOut;
7191 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
7192 setDtUnit(dtunitOut.c_str());
7193 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7196 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)
7197 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7199 setDtUnit(dtunit.c_str());
7200 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7202 catch(INTERP_KERNEL::Exception& e)
7207 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7209 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7210 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7211 ret+=(*it).capacity();
7215 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7217 std::vector<const BigMemoryObject *> ret;
7218 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7219 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7224 * 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
7227 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7229 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7230 ret->setInfo(_infos);
7231 int sz=(int)_time_steps.size();
7232 for(const int *id=startIds;id!=endIds;id++)
7234 if(*id>=0 && *id<sz)
7236 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7237 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7241 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7243 ret->pushBackTimeStep(tse2);
7247 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7248 oss << " ! Should be in [0," << sz << ") !";
7249 throw INTERP_KERNEL::Exception(oss.str());
7252 if(ret->getNumberOfTS()>0)
7253 ret->synchronizeNameScope();
7254 ret->copyNameScope(*this);
7259 * 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
7262 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7264 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7265 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7266 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7267 ret->setInfo(_infos);
7268 int sz=(int)_time_steps.size();
7270 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7274 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7275 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7279 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7281 ret->pushBackTimeStep(tse2);
7285 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7286 oss << " ! Should be in [0," << sz << ") !";
7287 throw INTERP_KERNEL::Exception(oss.str());
7290 if(ret->getNumberOfTS()>0)
7291 ret->synchronizeNameScope();
7292 ret->copyNameScope(*this);
7296 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7299 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7300 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7302 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7305 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7306 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7307 ids->pushBackSilent(id);
7309 return buildFromTimeStepIds(ids->begin(),ids->end());
7312 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7315 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7316 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7318 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7321 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7322 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7323 ids->pushBackSilent(id);
7325 return buildFromTimeStepIds(ids->begin(),ids->end());
7328 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7330 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7332 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7335 if(cur->presenceOfMultiDiscPerGeoType())
7341 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7346 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7351 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7354 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7356 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7357 if(pt->isDealingTS(iteration,order))
7360 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7361 std::vector< std::pair<int,int> > vp=getIterations();
7362 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7363 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7364 throw INTERP_KERNEL::Exception(oss.str());
7367 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7369 return *_time_steps[getTimeStepPos(iteration,order)];
7372 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7374 return *_time_steps[getTimeStepPos(iteration,order)];
7377 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7379 if(_time_steps.empty())
7380 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7381 return _time_steps[0]->getMeshName();
7384 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7386 std::string oldName(getMeshName());
7387 std::vector< std::pair<std::string,std::string> > v(1);
7388 v[0].first=oldName; v[0].second=newMeshName;
7392 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7395 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7397 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7399 ret=cur->changeMeshNames(modifTab) || ret;
7405 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7407 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7409 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7413 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7415 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7417 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7420 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7421 MEDFileFieldGlobsReal& glob)
7424 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7426 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7428 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7433 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7435 std::string startLine(bkOffset,' ');
7436 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7438 oss << " (" << fmtsId << ")";
7439 oss << " has the following name: \"" << _name << "\"." << std::endl;
7440 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7441 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7443 oss << startLine << " - \"" << *it << "\"" << std::endl;
7446 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7448 std::string chapter(17,'0'+i);
7449 oss << startLine << chapter << std::endl;
7450 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7452 cur->simpleRepr(bkOffset+2,oss,i);
7454 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7455 oss << startLine << chapter << std::endl;
7459 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7461 std::size_t sz=_time_steps.size();
7462 std::vector< std::pair<int,int> > ret(sz);
7464 for(std::size_t i=0;i<sz;i++)
7466 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7469 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7473 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7474 throw INTERP_KERNEL::Exception(oss.str());
7480 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7482 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7484 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7485 checkCoherencyOfType(tse2);
7486 if(_time_steps.empty())
7488 setName(tse2->getName().c_str());
7489 setInfo(tse2->getInfo());
7491 checkThatComponentsMatch(tse2->getInfo());
7492 _time_steps.push_back(tse);
7495 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7497 std::size_t nbOfCompo=_infos.size();
7498 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7500 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7503 if((cur->getInfo()).size()!=nbOfCompo)
7505 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7506 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7507 throw INTERP_KERNEL::Exception(oss.str());
7509 cur->copyNameScope(*this);
7514 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)
7516 _time_steps.resize(nbPdt);
7517 for(int i=0;i<nbPdt;i++)
7519 std::vector< std::pair<int,int> > ts;
7520 med_int numdt=0,numo=0;
7521 med_int meshIt=0,meshOrder=0;
7523 MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7528 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7533 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7537 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7540 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7542 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7546 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7548 if(_time_steps.empty())
7549 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7550 checkThatNbOfCompoOfTSMatchThis();
7551 std::vector<std::string> infos(getInfo());
7552 int nbComp=infos.size();
7553 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7554 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7555 for(int i=0;i<nbComp;i++)
7557 std::string info=infos[i];
7559 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7560 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7561 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7564 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7565 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7566 int nbOfTS=_time_steps.size();
7567 for(int i=0;i<nbOfTS;i++)
7568 _time_steps[i]->writeLL(fid,opts,*this);
7571 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7573 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7575 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7577 elt->loadBigArraysRecursively(fid,nasc);
7581 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7583 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7585 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7587 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7591 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7593 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7595 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7597 elt->unloadArrays();
7601 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7603 return _time_steps.size();
7606 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7608 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7609 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7611 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7613 newTS.push_back(*it);
7618 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7620 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7621 int maxId=(int)_time_steps.size();
7623 std::set<int> idsToDel;
7624 for(const int *id=startIds;id!=endIds;id++,ii++)
7626 if(*id>=0 && *id<maxId)
7628 idsToDel.insert(*id);
7632 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7633 throw INTERP_KERNEL::Exception(oss.str());
7636 for(int iii=0;iii<maxId;iii++)
7637 if(idsToDel.find(iii)==idsToDel.end())
7638 newTS.push_back(_time_steps[iii]);
7642 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7644 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7645 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7646 if(nbOfEntriesToKill==0)
7648 std::size_t sz=_time_steps.size();
7649 std::vector<bool> b(sz,true);
7651 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7653 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7654 for(std::size_t i=0;i<sz;i++)
7656 newTS.push_back(_time_steps[i]);
7660 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7663 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7664 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7666 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7670 tmp->getTime(it2,ord);
7671 if(it2==iteration && order==ord)
7674 oss << "(" << it2 << "," << ord << "), ";
7677 throw INTERP_KERNEL::Exception(oss.str());
7680 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7683 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7685 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7687 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7691 double ti=tmp->getTime(it2,ord);
7692 if(fabs(time-ti)<eps)
7698 throw INTERP_KERNEL::Exception(oss.str());
7701 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7703 int lgth=_time_steps.size();
7704 std::vector< std::pair<int,int> > ret(lgth);
7705 for(int i=0;i<lgth;i++)
7706 _time_steps[i]->fillIteration(ret[i]);
7711 * 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'
7712 * This method returns two things.
7713 * - The absolute dimension of 'this' in first parameter.
7714 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7715 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7717 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7718 * Only these 3 discretizations will be taken into account here.
7720 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7721 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7722 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7724 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7725 * 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'.
7727 * Let's consider the typical following case :
7728 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7729 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7730 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7732 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7734 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7736 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7737 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7738 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7739 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7741 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7743 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7746 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7748 if(pos<0 || pos>=(int)_time_steps.size())
7750 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7751 throw INTERP_KERNEL::Exception(oss.str());
7753 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7756 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7757 oss << "\nTry to use following method eraseEmptyTS !";
7758 throw INTERP_KERNEL::Exception(oss.str());
7763 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7765 if(pos<0 || pos>=(int)_time_steps.size())
7767 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7768 throw INTERP_KERNEL::Exception(oss.str());
7770 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7773 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7774 oss << "\nTry to use following method eraseEmptyTS !";
7775 throw INTERP_KERNEL::Exception(oss.str());
7780 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7782 std::vector<std::string> ret;
7783 std::set<std::string> ret2;
7784 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7786 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7787 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7788 if(ret2.find(*it2)==ret2.end())
7790 ret.push_back(*it2);
7797 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7799 std::vector<std::string> ret;
7800 std::set<std::string> ret2;
7801 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7803 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7804 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7805 if(ret2.find(*it2)==ret2.end())
7807 ret.push_back(*it2);
7814 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7816 std::vector<std::string> ret;
7817 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7819 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7820 ret.insert(ret.end(),tmp.begin(),tmp.end());
7825 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7827 std::vector<std::string> ret;
7828 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7830 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7831 ret.insert(ret.end(),tmp.begin(),tmp.end());
7836 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7838 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7839 (*it)->changePflsRefsNamesGen2(mapOfModif);
7842 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7844 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7845 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7848 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7850 int lgth=_time_steps.size();
7851 std::vector< std::vector<TypeOfField> > ret(lgth);
7852 for(int i=0;i<lgth;i++)
7853 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7858 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7860 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
7862 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7865 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
7867 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7869 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7871 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7872 ret->_time_steps[i]=(*it)->deepCopy();
7877 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7879 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7880 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7881 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7882 for(std::size_t i=0;i<sz;i++)
7884 ret[i]=shallowCpy();
7885 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7887 for(std::size_t i=0;i<sz2;i++)
7889 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7892 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7893 throw INTERP_KERNEL::Exception(oss.str());
7897 for(std::size_t i=0;i<sz;i++)
7898 for(std::size_t j=0;j<sz2;j++)
7899 ret[i]->_time_steps[j]=ts[j][i];
7904 * This method splits into discretization each time steps in \a this.
7905 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7907 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7909 std::size_t sz(_time_steps.size());
7910 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7911 for(std::size_t i=0;i<sz;i++)
7913 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7916 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7917 throw INTERP_KERNEL::Exception(oss.str());
7919 items[i]=timeStep->splitDiscretizations();
7922 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7923 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7924 std::vector< TypeOfField > types;
7925 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7926 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7928 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7930 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7931 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7932 if(it2==types.end())
7933 types.push_back(ts[0]);
7935 ret.resize(types.size()); ret2.resize(types.size());
7936 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7937 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7939 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7940 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7941 ret2[pos].push_back(*it1);
7943 for(std::size_t i=0;i<types.size();i++)
7945 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7946 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7947 elt->pushBackTimeStep(*it1);//also updates infos in elt
7949 elt->MEDFileFieldNameScope::operator=(*this);
7955 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7957 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7959 std::size_t sz(_time_steps.size());
7960 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7961 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7962 for(std::size_t i=0;i<sz;i++)
7964 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7967 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7968 throw INTERP_KERNEL::Exception(oss.str());
7970 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7971 if(szOut==std::numeric_limits<std::size_t>::max())
7972 szOut=items[i].size();
7974 if(items[i].size()!=szOut)
7975 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7977 if(szOut==std::numeric_limits<std::size_t>::max())
7978 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7979 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7980 for(std::size_t i=0;i<szOut;i++)
7982 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7983 for(std::size_t j=0;j<sz;j++)
7984 elt->pushBackTimeStep(items[j][i]);
7986 elt->MEDFileFieldNameScope::operator=(*this);
7991 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7993 _name=field->getName();
7995 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7997 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7998 _infos=arr->getInfoOnComponents();
8001 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8003 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8004 if(_name!=field->getName())
8006 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8007 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8008 throw INTERP_KERNEL::Exception(oss.str());
8011 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8012 checkThatComponentsMatch(arr->getInfoOnComponents());
8015 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8017 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8018 if(getInfo().size()!=compos.size())
8020 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8021 oss << " number of components of element to append (" << compos.size() << ") !";
8022 throw INTERP_KERNEL::Exception(oss.str());
8026 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8027 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8028 oss << " But compo in input fields are : ";
8029 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8031 throw INTERP_KERNEL::Exception(oss.str());
8035 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8037 std::size_t sz=_infos.size();
8039 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8041 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8043 if(elt->getInfo().size()!=sz)
8045 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8046 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8047 throw INTERP_KERNEL::Exception(oss.str());
8052 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8055 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8056 if(!_time_steps.empty())
8057 checkCoherencyOfTinyInfo(field,arr);
8058 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8059 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8060 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8061 copyTinyInfoFrom(field,arr);
8062 _time_steps.push_back(obj);
8065 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8068 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8069 if(!_time_steps.empty())
8070 checkCoherencyOfTinyInfo(field,arr);
8071 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8072 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8073 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8074 copyTinyInfoFrom(field,arr);
8075 _time_steps.push_back(obj);
8078 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8080 int sz=(int)_time_steps.size();
8083 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8084 throw INTERP_KERNEL::Exception(oss.str());
8086 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8089 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8091 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8092 throw INTERP_KERNEL::Exception(oss.str());
8098 //= MEDFileFieldMultiTSWithoutSDA
8100 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)
8102 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8105 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8109 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8114 * \param [in] fieldId field id in C mode
8116 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8117 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8120 catch(INTERP_KERNEL::Exception& e)
8123 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)
8124 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8127 catch(INTERP_KERNEL::Exception& e)
8130 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8132 return new MEDFileField1TSWithoutSDA;
8135 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8138 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8139 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8141 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8144 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8146 return MEDFileField1TSWithoutSDA::TYPE_STR;
8149 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8151 return new MEDFileFieldMultiTSWithoutSDA(*this);
8154 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8156 return new MEDFileFieldMultiTSWithoutSDA;
8160 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8161 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8163 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
8165 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8166 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8168 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8169 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8172 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8174 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8175 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8177 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8179 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8182 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8184 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8185 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8186 ret->setIteration(i,elt);
8192 //= MEDFileAnyTypeFieldMultiTS
8194 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8198 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8199 try:MEDFileFieldGlobsReal(fileName)
8201 MEDFileUtilities::CheckFileForRead(fileName);
8202 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8203 _content=BuildContentFrom(fid,fileName,loadAll,ms);
8206 catch(INTERP_KERNEL::Exception& e)
8211 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)
8213 med_field_type typcha;
8214 std::vector<std::string> infos;
8217 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
8218 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8223 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8228 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8233 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] !";
8234 throw INTERP_KERNEL::Exception(oss.str());
8237 ret->setDtUnit(dtunit.c_str());
8241 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8243 med_field_type typcha;
8245 std::vector<std::string> infos;
8246 std::string dtunit,fieldName;
8247 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8248 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8253 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8258 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8263 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] !";
8264 throw INTERP_KERNEL::Exception(oss.str());
8267 ret->setDtUnit(dtunit.c_str());
8271 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8274 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8275 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8277 MCAuto<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8278 ret->setFileName(fileName);
8279 ret->_content=c; c->incrRef();
8282 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8284 MCAuto<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8285 ret->setFileName(fileName);
8286 ret->_content=c; c->incrRef();
8289 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8292 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)
8293 try:MEDFileFieldGlobsReal(fileName)
8295 MEDFileUtilities::CheckFileForRead(fileName);
8296 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8297 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
8300 catch(INTERP_KERNEL::Exception& e)
8305 //= MEDFileIntFieldMultiTSWithoutSDA
8307 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)
8309 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8312 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8316 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8320 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)
8321 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8324 catch(INTERP_KERNEL::Exception& e)
8328 * \param [in] fieldId field id in C mode
8330 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8331 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8334 catch(INTERP_KERNEL::Exception& e)
8337 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8339 return new MEDFileIntField1TSWithoutSDA;
8342 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8345 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8346 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8348 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8351 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8353 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8356 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8358 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8361 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8363 return new MEDFileIntFieldMultiTSWithoutSDA;
8366 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8368 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8369 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8371 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8373 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8376 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8378 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8379 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8380 ret->setIteration(i,elt);
8386 //= MEDFileAnyTypeFieldMultiTS
8389 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8390 * that has been read from a specified MED file.
8391 * \param [in] fileName - the name of the MED file to read.
8392 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8393 * is to delete this field using decrRef() as it is no more needed.
8394 * \throw If reading the file fails.
8396 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8398 MEDFileUtilities::CheckFileForRead(fileName);
8399 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8400 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8401 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8402 ret->loadGlobals(fid);
8407 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8408 * that has been read from a specified MED file.
8409 * \param [in] fileName - the name of the MED file to read.
8410 * \param [in] fieldName - the name of the field to read.
8411 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8412 * is to delete this field using decrRef() as it is no more needed.
8413 * \throw If reading the file fails.
8414 * \throw If there is no field named \a fieldName in the file.
8416 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8418 MEDFileUtilities::CheckFileForRead(fileName);
8419 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8420 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
8421 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8422 ret->loadGlobals(fid);
8427 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8428 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8430 * \warning this is a shallow copy constructor
8432 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8434 if(!shallowCopyOfContent)
8436 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8437 otherPtr->incrRef();
8438 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8442 _content=other.shallowCpy();
8446 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8448 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8450 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8454 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8456 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8458 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8462 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8464 return contentNotNullBase()->getPflsReallyUsed2();
8467 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8469 return contentNotNullBase()->getLocsReallyUsed2();
8472 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8474 return contentNotNullBase()->getPflsReallyUsedMulti2();
8477 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8479 return contentNotNullBase()->getLocsReallyUsedMulti2();
8482 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8484 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8487 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8489 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8492 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8494 return contentNotNullBase()->getNumberOfTS();
8497 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8499 contentNotNullBase()->eraseEmptyTS();
8502 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8504 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8507 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8509 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8512 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8514 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8515 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8520 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8522 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8523 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8528 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8530 return contentNotNullBase()->getIterations();
8533 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8535 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8536 pushBackTimeStep(*it);
8539 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8542 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8543 int nbOfTS(fmts->getNumberOfTS());
8544 for(int i=0;i<nbOfTS;i++)
8546 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8547 pushBackTimeStep(elt);
8551 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8554 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8555 checkCoherencyOfType(f1ts);
8557 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8558 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8560 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8561 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8562 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8563 _content->pushBackTimeStep(cSafe);
8564 appendGlobs(*f1ts,1e-12);
8567 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8569 contentNotNullBase()->synchronizeNameScope();
8572 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8574 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8577 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8579 return contentNotNullBase()->getPosGivenTime(time,eps);
8582 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8584 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8587 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8589 return contentNotNullBase()->getTypesOfFieldAvailable();
8592 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
8594 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8597 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8599 return contentNotNullBase()->getName();
8602 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8604 contentNotNullBase()->setName(name);
8607 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8609 return contentNotNullBase()->getDtUnit();
8612 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8614 contentNotNullBase()->setDtUnit(dtUnit);
8617 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8619 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8622 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8624 return contentNotNullBase()->getTimeSteps(ret1);
8627 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8629 return contentNotNullBase()->getMeshName();
8632 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8634 contentNotNullBase()->setMeshName(newMeshName);
8637 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8639 return contentNotNullBase()->changeMeshNames(modifTab);
8642 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8644 return contentNotNullBase()->getInfo();
8647 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8649 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8652 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8654 return contentNotNullBase()->setInfo(info);
8657 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8659 const std::vector<std::string> ret=getInfo();
8660 return (int)ret.size();
8663 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8665 writeGlobals(fid,*this);
8666 contentNotNullBase()->writeLL(fid,*this);
8670 * Writes \a this field into a MED file specified by its name.
8671 * \param [in] fileName - the MED file name.
8672 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8673 * - 2 - erase; an existing file is removed.
8674 * - 1 - append; same data should not be present in an existing file.
8675 * - 0 - overwrite; same data present in an existing file is overwritten.
8676 * \throw If the field name is not set.
8677 * \throw If no field data is set.
8678 * \throw If \a mode == 1 and the same data is present in an existing file.
8680 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8682 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8683 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8688 * This method alloc the arrays and load potentially huge arrays contained in this field.
8689 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8690 * This method can be also called to refresh or reinit values from a file.
8692 * \throw If the fileName is not set or points to a non readable MED file.
8694 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8696 if(getFileName().empty())
8697 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8698 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8699 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8703 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8704 * But once data loaded once, this method does nothing.
8706 * \throw If the fileName is not set or points to a non readable MED file.
8707 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8709 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8711 if(!getFileName().empty())
8713 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8714 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8719 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8720 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8721 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8723 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8725 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8727 contentNotNullBase()->unloadArrays();
8731 * 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.
8732 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8733 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8735 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8737 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8739 if(!getFileName().empty())
8740 contentNotNullBase()->unloadArrays();
8743 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8745 std::ostringstream oss;
8746 contentNotNullBase()->simpleRepr(0,oss,-1);
8747 simpleReprGlobs(oss);
8751 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8753 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8756 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8758 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8759 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8764 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8765 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8766 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8768 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8770 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8772 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8773 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8774 std::size_t sz(contentsSplit.size());
8775 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8776 for(std::size_t i=0;i<sz;i++)
8778 ret[i]=shallowCpy();
8779 ret[i]->_content=contentsSplit[i];
8785 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8786 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8788 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8790 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8792 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8793 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8794 std::size_t sz(contentsSplit.size());
8795 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8796 for(std::size_t i=0;i<sz;i++)
8798 ret[i]=shallowCpy();
8799 ret[i]->_content=contentsSplit[i];
8805 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8806 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8808 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8810 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8812 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8813 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8814 std::size_t sz(contentsSplit.size());
8815 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8816 for(std::size_t i=0;i<sz;i++)
8818 ret[i]=shallowCpy();
8819 ret[i]->_content=contentsSplit[i];
8824 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
8826 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8827 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8828 ret->_content=_content->deepCopy();
8829 ret->deepCpyGlobs(*this);
8833 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8839 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8840 * \param [in] iteration - the iteration number of a required time step.
8841 * \param [in] order - the iteration order number of required time step.
8842 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8843 * delete this field using decrRef() as it is no more needed.
8844 * \throw If there is no required time step in \a this field.
8846 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8848 int pos=getPosOfTimeStep(iteration,order);
8849 return getTimeStepAtPos(pos);
8853 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8854 * \param [in] time - the time of the time step of interest.
8855 * \param [in] eps - a precision used to compare time values.
8856 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8857 * delete this field using decrRef() as it is no more needed.
8858 * \throw If there is no required time step in \a this field.
8860 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8862 int pos=getPosGivenTime(time,eps);
8863 return getTimeStepAtPos(pos);
8867 * 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.
8868 * The float64 value of time attached to the pair of integers are not considered here.
8869 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8871 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8872 * \throw If there is a null pointer in \a vectFMTS.
8874 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8876 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8877 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8878 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8879 while(!lstFMTS.empty())
8881 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8882 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8884 throw INTERP_KERNEL::Exception(msg);
8885 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8886 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8887 elt.push_back(curIt); it=lstFMTS.erase(it);
8888 while(it!=lstFMTS.end())
8892 throw INTERP_KERNEL::Exception(msg);
8893 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8895 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8905 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8906 * All returned instances in a subvector can be safely loaded, rendered along time
8907 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8908 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8909 * 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).
8910 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8911 * 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.
8913 * \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().
8914 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8915 * \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.
8916 * \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.
8918 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8919 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8920 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8921 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8922 * \throw If mesh is null.
8923 * \throw If an element in \a vectFMTS is null.
8924 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8926 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
8928 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8930 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8931 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8932 if(vectFMTS.empty())
8934 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8935 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8937 throw INTERP_KERNEL::Exception(msg);
8939 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8940 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8941 for(;it!=vectFMTS.end();it++,i++)
8944 throw INTERP_KERNEL::Exception(msg);
8945 TypeOfField tof0,tof1;
8946 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8949 vectFMTSNotNodes.push_back(*it);
8951 vectFMTSNodes.push_back(*it);
8954 vectFMTSNotNodes.push_back(*it);
8956 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
8957 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8959 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8962 bool isFetched(false);
8963 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8966 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8967 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8968 { ret[i].push_back(*it2); isFetched=true; }
8972 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8973 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8974 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8982 * 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.
8983 * \param [out] cmps - same size than the returned vector.
8985 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
8987 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8988 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8989 while(!lstFMTS.empty())
8991 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8992 MEDFileAnyTypeFieldMultiTS *ref(*it);
8993 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8994 elt.push_back(ref); it=lstFMTS.erase(it);
8995 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8996 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8997 while(it!=lstFMTS.end())
8999 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9000 if(cmp->isEqual(curIt))
9001 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9005 ret.push_back(elt); cmps.push_back(cmp);
9011 * 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.
9012 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9014 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9015 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9016 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9017 * \thorw If \a f0 and \a f1 do not have the same times steps.
9018 * \throw If mesh is null.
9019 * \throw If \a f0 or \a f1 is null.
9020 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9022 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9025 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9027 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9028 if(f0->getMeshName()!=mesh->getName())
9030 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9031 throw INTERP_KERNEL::Exception(oss.str());
9033 if(f1->getMeshName()!=mesh->getName())
9035 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9036 throw INTERP_KERNEL::Exception(oss.str());
9038 int nts=f0->getNumberOfTS();
9039 if(nts!=f1->getNumberOfTS())
9040 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9043 for(int i=0;i<nts;i++)
9045 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9046 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9047 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9048 if(tofs0.size()!=1 || tofs1.size()!=1)
9049 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9052 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9053 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9056 { tof0=tofs0[0]; tof1=tofs1[0]; }
9057 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9059 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() << ") !";
9060 throw INTERP_KERNEL::Exception(oss.str());
9062 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9064 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() << ") !";
9065 throw INTERP_KERNEL::Exception(oss.str());
9067 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9069 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() << ") !";
9070 throw INTERP_KERNEL::Exception(oss.str());
9077 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9078 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9080 * \return A new object that the caller is responsible to deallocate.
9082 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9085 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9086 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9087 int nbTS(getNumberOfTS());
9088 for(int i=0;i<nbTS;i++)
9090 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9091 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9092 fmtsOut->pushBackTimeStep(f1tsOut);
9094 return fmtsOut.retn();
9097 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9099 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9102 //= MEDFileFieldMultiTS
9105 * Returns a new empty instance of MEDFileFieldMultiTS.
9106 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9107 * is to delete this field using decrRef() as it is no more needed.
9109 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9111 return new MEDFileFieldMultiTS;
9115 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9116 * that has been read from a specified MED file.
9117 * \param [in] fileName - the name of the MED file to read.
9118 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9119 * is to delete this field using decrRef() as it is no more needed.
9120 * \throw If reading the file fails.
9122 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9124 MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
9125 ret->contentNotNull();//to check that content type matches with \a this type.
9130 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9131 * that has been read from a specified MED file.
9132 * \param [in] fileName - the name of the MED file to read.
9133 * \param [in] fieldName - the name of the field to read.
9134 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9135 * is to delete this field using decrRef() as it is no more needed.
9136 * \throw If reading the file fails.
9137 * \throw If there is no field named \a fieldName in the file.
9139 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9141 MCAuto<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
9142 ret->contentNotNull();//to check that content type matches with \a this type.
9147 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9148 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9150 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9151 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9152 * \warning this is a shallow copy constructor
9153 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9154 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9155 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9156 * is to delete this field using decrRef() as it is no more needed.
9158 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9160 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9163 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9165 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities));
9166 ret->contentNotNull();//to check that content type matches with \a this type.
9170 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9172 return new MEDFileFieldMultiTS(*this);
9175 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9178 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9179 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9181 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9185 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9186 * following the given input policy.
9188 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9189 * By default (true) the globals are deeply copied.
9190 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9192 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9194 MCAuto<MEDFileIntFieldMultiTS> ret;
9195 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9198 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9200 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9201 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9202 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
9205 ret=MEDFileIntFieldMultiTS::New();
9207 ret->deepCpyGlobs(*this);
9209 ret->shallowCpyGlobs(*this);
9214 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9215 * \param [in] pos - a time step id.
9216 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9217 * delete this field using decrRef() as it is no more needed.
9218 * \throw If \a pos is not a valid time step id.
9220 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9222 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9225 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9226 throw INTERP_KERNEL::Exception(oss.str());
9228 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9231 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9232 ret->shallowCpyGlobs(*this);
9235 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9236 throw INTERP_KERNEL::Exception(oss.str());
9240 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9241 * mesh entities of a given dimension of the first mesh in MED file.
9242 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9243 * \param [in] type - a spatial discretization of interest.
9244 * \param [in] iteration - the iteration number of a required time step.
9245 * \param [in] order - the iteration order number of required time step.
9246 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9247 * \param [in] renumPol - specifies how to permute values of the result field according to
9248 * the optional numbers of cells and nodes, if any. The valid values are
9249 * - 0 - do not permute.
9250 * - 1 - permute cells.
9251 * - 2 - permute nodes.
9252 * - 3 - permute cells and nodes.
9254 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9255 * caller is to delete this field using decrRef() as it is no more needed.
9256 * \throw If the MED file is not readable.
9257 * \throw If there is no mesh in the MED file.
9258 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9259 * \throw If no field values of the required parameters are available.
9261 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9263 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9264 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9266 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9267 MCAuto<DataArray> arrOut;
9268 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9269 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9274 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9275 * the top level cells of the first mesh in MED file.
9276 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9277 * \param [in] type - a spatial discretization of interest.
9278 * \param [in] iteration - the iteration number of a required time step.
9279 * \param [in] order - the iteration order number of required time step.
9280 * \param [in] renumPol - specifies how to permute values of the result field according to
9281 * the optional numbers of cells and nodes, if any. The valid values are
9282 * - 0 - do not permute.
9283 * - 1 - permute cells.
9284 * - 2 - permute nodes.
9285 * - 3 - permute cells and nodes.
9287 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9288 * caller is to delete this field using decrRef() as it is no more needed.
9289 * \throw If the MED file is not readable.
9290 * \throw If there is no mesh in the MED file.
9291 * \throw If no field values of the required parameters are available.
9293 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9295 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9296 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9298 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9299 MCAuto<DataArray> arrOut;
9300 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9301 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9306 * 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
9307 * method should be called (getFieldOnMeshAtLevel for example).
9308 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9310 * \param [in] iteration - the iteration number of a required time step.
9311 * \param [in] order - the iteration order number of required time step.
9312 * \param [in] mesh - the mesh the field is lying on
9313 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9314 * caller is to delete this field using decrRef() as it is no more needed.
9316 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9318 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9319 MCAuto<DataArray> arrOut;
9320 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9321 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9326 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9328 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9329 * \param [in] type - a spatial discretization of interest.
9330 * \param [in] iteration - the iteration number of a required time step.
9331 * \param [in] order - the iteration order number of required time step.
9332 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9333 * \param [in] mesh - the supporting mesh.
9334 * \param [in] renumPol - specifies how to permute values of the result field according to
9335 * the optional numbers of cells and nodes, if any. The valid values are
9336 * - 0 - do not permute.
9337 * - 1 - permute cells.
9338 * - 2 - permute nodes.
9339 * - 3 - permute cells and nodes.
9341 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9342 * caller is to delete this field using decrRef() as it is no more needed.
9343 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9344 * \throw If no field of \a this is lying on \a mesh.
9345 * \throw If no field values of the required parameters are available.
9347 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9349 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9350 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9352 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9353 MCAuto<DataArray> arrOut;
9354 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9355 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9360 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9362 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9363 * \param [in] type - a spatial discretization of the new field.
9364 * \param [in] iteration - the iteration number of a required time step.
9365 * \param [in] order - the iteration order number of required time step.
9366 * \param [in] mesh - the supporting mesh.
9367 * \param [in] renumPol - specifies how to permute values of the result field according to
9368 * the optional numbers of cells and nodes, if any. The valid values are
9369 * - 0 - do not permute.
9370 * - 1 - permute cells.
9371 * - 2 - permute nodes.
9372 * - 3 - permute cells and nodes.
9374 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9375 * caller is to delete this field using decrRef() as it is no more needed.
9376 * \throw If no field of \a this is lying on \a mesh.
9377 * \throw If no field values of the required parameters are available.
9379 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9381 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9382 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9384 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9385 MCAuto<DataArray> arrOut;
9386 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9387 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9392 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9393 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9394 * This method is useful for MED2 file format when field on different mesh was autorized.
9396 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9398 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9399 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9401 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9402 MCAuto<DataArray> arrOut;
9403 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9404 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9409 * Returns values and a profile of the field of a given type, of a given time step,
9410 * lying on a given support.
9411 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9412 * \param [in] type - a spatial discretization of the field.
9413 * \param [in] iteration - the iteration number of a required time step.
9414 * \param [in] order - the iteration order number of required time step.
9415 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9416 * \param [in] mesh - the supporting mesh.
9417 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9418 * field of interest lies on. If the field lies on all entities of the given
9419 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9420 * using decrRef() as it is no more needed.
9421 * \param [in] glob - the global data storing profiles and localization.
9422 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9423 * field. The caller is to delete this array using decrRef() as it is no more needed.
9424 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9425 * \throw If no field of \a this is lying on \a mesh.
9426 * \throw If no field values of the required parameters are available.
9428 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9430 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9431 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9433 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9434 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9435 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9438 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9440 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9442 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9443 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9445 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 !");
9449 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9451 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9453 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9454 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9456 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 !");
9461 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9462 * the given field is checked if its elements are sorted suitable for writing to MED file
9463 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9464 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9465 * \param [in] field - the field to add to \a this.
9466 * \throw If the name of \a field is empty.
9467 * \throw If the data array of \a field is not set.
9468 * \throw If existing time steps have different name or number of components than \a field.
9469 * \throw If the underlying mesh of \a field has no name.
9470 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9472 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9474 const DataArrayDouble *arr=0;
9476 arr=field->getArray();
9477 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9481 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9482 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9483 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9486 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9487 * A new profile is added only if no equal profile is missing.
9488 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9489 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9490 * \param [in] mesh - the supporting mesh of \a field.
9491 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9492 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9493 * \throw If either \a field or \a mesh or \a profile has an empty name.
9494 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9495 * \throw If the data array of \a field is not set.
9496 * \throw If the data array of \a this is already allocated but has different number of
9497 * components than \a field.
9498 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9499 * \sa setFieldNoProfileSBT()
9501 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9503 const DataArrayDouble *arr=0;
9505 arr=field->getArray();
9506 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9509 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9511 _content=new MEDFileFieldMultiTSWithoutSDA;
9514 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9515 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9518 catch(INTERP_KERNEL::Exception& e)
9521 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)
9522 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9525 catch(INTERP_KERNEL::Exception& e)
9528 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9532 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
9534 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9537 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9539 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9542 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9544 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9547 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
9549 return MEDFileFieldMultiTS::New();
9552 //= MEDFileAnyTypeFieldMultiTSIterator
9554 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9559 _nb_iter=fmts->getNumberOfTS();
9563 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9567 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9569 if(_iter_id<_nb_iter)
9571 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9573 return fmts->getTimeStepAtPos(_iter_id++);
9581 //= MEDFileIntFieldMultiTS
9584 * Returns a new empty instance of MEDFileFieldMultiTS.
9585 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9586 * is to delete this field using decrRef() as it is no more needed.
9588 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9590 return new MEDFileIntFieldMultiTS;
9594 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9595 * that has been read from a specified MED file.
9596 * \param [in] fileName - the name of the MED file to read.
9597 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9598 * is to delete this field using decrRef() as it is no more needed.
9599 * \throw If reading the file fails.
9601 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9603 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9604 ret->contentNotNull();//to check that content type matches with \a this type.
9609 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9610 * that has been read from a specified MED file.
9611 * \param [in] fileName - the name of the MED file to read.
9612 * \param [in] fieldName - the name of the field to read.
9613 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9614 * is to delete this field using decrRef() as it is no more needed.
9615 * \throw If reading the file fails.
9616 * \throw If there is no field named \a fieldName in the file.
9618 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9620 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9621 ret->contentNotNull();//to check that content type matches with \a this type.
9626 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9627 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9629 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9630 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9631 * \warning this is a shallow copy constructor
9632 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9633 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9634 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9635 * is to delete this field using decrRef() as it is no more needed.
9637 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9639 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9642 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9644 MCAuto<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities);
9645 ret->contentNotNull();//to check that content type matches with \a this type.
9650 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9651 * following the given input policy.
9653 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9654 * By default (true) the globals are deeply copied.
9655 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9657 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9659 MCAuto<MEDFileFieldMultiTS> ret;
9660 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9663 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9665 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9666 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9667 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9670 ret=MEDFileFieldMultiTS::New();
9672 ret->deepCpyGlobs(*this);
9674 ret->shallowCpyGlobs(*this);
9678 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9680 return new MEDFileIntFieldMultiTS(*this);
9683 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9686 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9687 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9689 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9693 * 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
9694 * method should be called (getFieldOnMeshAtLevel for example).
9695 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9697 * \param [in] iteration - the iteration number of a required time step.
9698 * \param [in] order - the iteration order number of required time step.
9699 * \param [in] mesh - the mesh the field is lying on
9700 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
9701 * caller is to delete this field using decrRef() as it is no more needed.
9703 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9705 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9706 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9708 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
9709 MCAuto<DataArray> arrOut;
9710 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9711 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
9716 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9717 * mesh entities of a given dimension of the first mesh in MED file.
9718 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9719 * \param [in] type - a spatial discretization of interest.
9720 * \param [in] iteration - the iteration number of a required time step.
9721 * \param [in] order - the iteration order number of required time step.
9722 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9723 * \param [in] renumPol - specifies how to permute values of the result field according to
9724 * the optional numbers of cells and nodes, if any. The valid values are
9725 * - 0 - do not permute.
9726 * - 1 - permute cells.
9727 * - 2 - permute nodes.
9728 * - 3 - permute cells and nodes.
9730 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9731 * caller is to delete this field using decrRef() as it is no more needed.
9732 * \throw If the MED file is not readable.
9733 * \throw If there is no mesh in the MED file.
9734 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9735 * \throw If no field values of the required parameters are available.
9737 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9739 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9740 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9742 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9743 MCAuto<DataArray> arr;
9744 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
9745 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9750 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9751 * the top level cells of the first mesh in MED file.
9752 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9753 * \param [in] type - a spatial discretization of interest.
9754 * \param [in] iteration - the iteration number of a required time step.
9755 * \param [in] order - the iteration order number of required time step.
9756 * \param [in] renumPol - specifies how to permute values of the result field according to
9757 * the optional numbers of cells and nodes, if any. The valid values are
9758 * - 0 - do not permute.
9759 * - 1 - permute cells.
9760 * - 2 - permute nodes.
9761 * - 3 - permute cells and nodes.
9763 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9764 * caller is to delete this field using decrRef() as it is no more needed.
9765 * \throw If the MED file is not readable.
9766 * \throw If there is no mesh in the MED file.
9767 * \throw If no field values of the required parameters are available.
9769 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9771 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9772 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9774 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9775 MCAuto<DataArray> arr;
9776 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
9777 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9782 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
9784 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9785 * \param [in] type - a spatial discretization of interest.
9786 * \param [in] iteration - the iteration number of a required time step.
9787 * \param [in] order - the iteration order number of required time step.
9788 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9789 * \param [in] mesh - the supporting mesh.
9790 * \param [in] renumPol - specifies how to permute values of the result field according to
9791 * the optional numbers of cells and nodes, if any. The valid values are
9792 * - 0 - do not permute.
9793 * - 1 - permute cells.
9794 * - 2 - permute nodes.
9795 * - 3 - permute cells and nodes.
9797 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9798 * caller is to delete this field using decrRef() as it is no more needed.
9799 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9800 * \throw If no field of \a this is lying on \a mesh.
9801 * \throw If no field values of the required parameters are available.
9803 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9805 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9806 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9808 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9809 MCAuto<DataArray> arr;
9810 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
9811 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9816 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
9818 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9819 * \param [in] type - a spatial discretization of the new field.
9820 * \param [in] iteration - the iteration number of a required time step.
9821 * \param [in] order - the iteration order number of required time step.
9822 * \param [in] mesh - the supporting mesh.
9823 * \param [out] arrOut - the DataArrayInt containing values of field.
9824 * \param [in] renumPol - specifies how to permute values of the result field according to
9825 * the optional numbers of cells and nodes, if any. The valid values are
9826 * - 0 - do not permute.
9827 * - 1 - permute cells.
9828 * - 2 - permute nodes.
9829 * - 3 - permute cells and nodes.
9831 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
9832 * caller is to delete this field using decrRef() as it is no more needed.
9833 * \throw If no field of \a this is lying on \a mesh.
9834 * \throw If no field values of the required parameters are available.
9836 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9838 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9839 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9841 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9842 MCAuto<DataArray> arr;
9843 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
9844 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9849 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9850 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9851 * This method is useful for MED2 file format when field on different mesh was autorized.
9853 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
9855 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9856 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
9858 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9859 MCAuto<DataArray> arr;
9860 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
9861 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
9866 * Returns values and a profile of the field of a given type, of a given time step,
9867 * lying on a given support.
9868 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9869 * \param [in] type - a spatial discretization of the field.
9870 * \param [in] iteration - the iteration number of a required time step.
9871 * \param [in] order - the iteration order number of required time step.
9872 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9873 * \param [in] mesh - the supporting mesh.
9874 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9875 * field of interest lies on. If the field lies on all entities of the given
9876 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9877 * using decrRef() as it is no more needed.
9878 * \param [in] glob - the global data storing profiles and localization.
9879 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9880 * field. The caller is to delete this array using decrRef() as it is no more needed.
9881 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9882 * \throw If no field of \a this is lying on \a mesh.
9883 * \throw If no field values of the required parameters are available.
9885 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9887 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9888 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9890 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9891 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9892 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9896 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9897 * \param [in] pos - a time step id.
9898 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9899 * delete this field using decrRef() as it is no more needed.
9900 * \throw If \a pos is not a valid time step id.
9902 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9904 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9907 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9908 throw INTERP_KERNEL::Exception(oss.str());
9910 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9913 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9914 ret->shallowCpyGlobs(*this);
9917 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9918 throw INTERP_KERNEL::Exception(oss.str());
9922 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
9923 * the given field is checked if its elements are sorted suitable for writing to MED file
9924 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9925 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9926 * \param [in] field - the field to add to \a this.
9927 * \throw If the name of \a field is empty.
9928 * \throw If the data array of \a field is not set.
9929 * \throw If existing time steps have different name or number of components than \a field.
9930 * \throw If the underlying mesh of \a field has no name.
9931 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9933 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
9935 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
9936 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
9940 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9941 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9942 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9945 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9946 * A new profile is added only if no equal profile is missing.
9947 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9948 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9949 * \param [in] arrOfVals - the values of the field \a field used.
9950 * \param [in] mesh - the supporting mesh of \a field.
9951 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9952 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9953 * \throw If either \a field or \a mesh or \a profile has an empty name.
9954 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9955 * \throw If the data array of \a field is not set.
9956 * \throw If the data array of \a this is already allocated but has different number of
9957 * components than \a field.
9958 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9959 * \sa setFieldNoProfileSBT()
9961 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9963 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
9964 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
9967 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9969 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9971 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9972 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9974 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 !");
9978 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9980 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9982 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9983 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9985 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 !");
9989 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9991 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9994 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9998 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9999 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
10002 catch(INTERP_KERNEL::Exception& e)
10005 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)
10006 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
10009 catch(INTERP_KERNEL::Exception& e)
10012 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10014 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10017 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10019 return MEDFileIntFieldMultiTS::New();
10024 MEDFileFields *MEDFileFields::New()
10026 return new MEDFileFields;
10029 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10031 return new MEDFileFields(fileName,loadAll,0,0);
10034 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10036 return new MEDFileFields(fileName,loadAll,ms,0);
10039 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10041 return new MEDFileFields(fileName,loadAll,0,&entities);
10044 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10046 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10047 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10051 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10053 std::vector<const BigMemoryObject *> ret;
10054 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10055 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10059 MEDFileFields *MEDFileFields::deepCopy() const
10061 MCAuto<MEDFileFields> ret=shallowCpy();
10063 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10065 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10066 ret->_fields[i]=(*it)->deepCopy();
10068 ret->deepCpyGlobs(*this);
10072 MEDFileFields *MEDFileFields::shallowCpy() const
10074 return new MEDFileFields(*this);
10078 * 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
10079 * 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.
10080 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10082 * \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.
10083 * \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.
10085 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10087 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10089 std::set< std::pair<int,int> > s;
10090 bool firstShot=true;
10091 areThereSomeForgottenTS=false;
10092 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10094 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10096 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10097 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10099 { s=s1; firstShot=false; }
10102 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10104 areThereSomeForgottenTS=true;
10108 std::vector< std::pair<int,int> > ret;
10109 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10113 int MEDFileFields::getNumberOfFields() const
10115 return _fields.size();
10118 std::vector<std::string> MEDFileFields::getFieldsNames() const
10120 std::vector<std::string> ret(_fields.size());
10122 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10124 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10127 ret[i]=f->getName();
10131 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10132 throw INTERP_KERNEL::Exception(oss.str());
10138 std::vector<std::string> MEDFileFields::getMeshesNames() const
10140 std::vector<std::string> ret;
10141 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10143 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10145 ret.push_back(cur->getMeshName());
10150 std::string MEDFileFields::simpleRepr() const
10152 std::ostringstream oss;
10153 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10158 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10160 int nbOfFields=getNumberOfFields();
10161 std::string startLine(bkOffset,' ');
10162 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10164 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10166 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10169 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10173 oss << startLine << " - not defined !" << std::endl;
10177 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10179 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10180 std::string chapter(17,'0'+i);
10181 oss << startLine << chapter << std::endl;
10184 cur->simpleRepr(bkOffset+2,oss,i);
10188 oss << startLine << " - not defined !" << std::endl;
10190 oss << startLine << chapter << std::endl;
10192 simpleReprGlobs(oss);
10195 MEDFileFields::MEDFileFields()
10199 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
10200 try:MEDFileFieldGlobsReal(fileName)
10202 MEDFileUtilities::CheckFileForRead(fileName);
10203 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
10204 int nbFields(MEDnField(fid));
10205 _fields.resize(nbFields);
10206 med_field_type typcha;
10207 for(int i=0;i<nbFields;i++)
10209 std::vector<std::string> infos;
10210 std::string fieldName,dtunit;
10211 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
10216 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10221 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10226 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] !";
10227 throw INTERP_KERNEL::Exception(oss.str());
10231 loadAllGlobals(fid);
10233 catch(INTERP_KERNEL::Exception& e)
10238 void MEDFileFields::writeLL(med_idt fid) const
10241 writeGlobals(fid,*this);
10242 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10244 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10247 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10248 throw INTERP_KERNEL::Exception(oss.str());
10250 elt->writeLL(fid,*this);
10254 void MEDFileFields::write(const std::string& fileName, int mode) const
10256 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
10257 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
10262 * This method alloc the arrays and load potentially huge arrays contained in this field.
10263 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10264 * This method can be also called to refresh or reinit values from a file.
10266 * \throw If the fileName is not set or points to a non readable MED file.
10268 void MEDFileFields::loadArrays()
10270 if(getFileName().empty())
10271 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10272 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10273 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10275 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10277 elt->loadBigArraysRecursively(fid,*elt);
10282 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10283 * But once data loaded once, this method does nothing.
10285 * \throw If the fileName is not set or points to a non readable MED file.
10286 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10288 void MEDFileFields::loadArraysIfNecessary()
10290 if(!getFileName().empty())
10292 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10293 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10295 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10297 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10303 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10304 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10305 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10307 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10309 void MEDFileFields::unloadArrays()
10311 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10313 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10315 elt->unloadArrays();
10320 * 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.
10321 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10322 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10324 * \sa MEDFileFields::loadArraysIfNecessary
10326 void MEDFileFields::unloadArraysWithoutDataLoss()
10328 if(!getFileName().empty())
10332 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10334 std::vector<std::string> ret;
10335 std::set<std::string> ret2;
10336 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10338 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10339 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10340 if(ret2.find(*it2)==ret2.end())
10342 ret.push_back(*it2);
10349 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10351 std::vector<std::string> ret;
10352 std::set<std::string> ret2;
10353 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10355 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10356 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10357 if(ret2.find(*it2)==ret2.end())
10359 ret.push_back(*it2);
10366 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10368 std::vector<std::string> ret;
10369 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10371 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10372 ret.insert(ret.end(),tmp.begin(),tmp.end());
10377 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10379 std::vector<std::string> ret;
10380 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10382 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10383 ret.insert(ret.end(),tmp.begin(),tmp.end());
10388 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10390 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10391 (*it)->changePflsRefsNamesGen2(mapOfModif);
10394 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10396 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10397 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10400 void MEDFileFields::resize(int newSize)
10402 _fields.resize(newSize);
10405 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10407 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10411 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10414 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10415 _fields.push_back(field->getContent());
10416 appendGlobs(*field,1e-12);
10419 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10422 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10423 if(i>=(int)_fields.size())
10424 _fields.resize(i+1);
10425 _fields[i]=field->getContent();
10426 appendGlobs(*field,1e-12);
10429 void MEDFileFields::destroyFieldAtPos(int i)
10431 destroyFieldsAtPos(&i,&i+1);
10434 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10436 std::vector<bool> b(_fields.size(),true);
10437 for(const int *i=startIds;i!=endIds;i++)
10439 if(*i<0 || *i>=(int)_fields.size())
10441 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10442 throw INTERP_KERNEL::Exception(oss.str());
10446 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10448 for(std::size_t i=0;i<_fields.size();i++)
10450 fields[j++]=_fields[i];
10454 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10456 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10457 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10458 std::vector<bool> b(_fields.size(),true);
10460 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10462 if(k<0 || k>=(int)_fields.size())
10464 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10465 throw INTERP_KERNEL::Exception(oss.str());
10469 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10471 for(std::size_t i=0;i<_fields.size();i++)
10473 fields[j++]=_fields[i];
10477 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10480 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10482 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10484 ret=cur->changeMeshNames(modifTab) || ret;
10490 * \param [in] meshName the name of the mesh that will be renumbered.
10491 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10492 * This code corresponds to the distribution of types in the corresponding mesh.
10493 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10494 * \param [in] renumO2N the old to new renumber array.
10495 * \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
10496 * field in \a this.
10498 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10501 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10503 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10506 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10513 * Return an extraction of \a this using \a extractDef map to specify the extraction.
10514 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
10516 * \return A new object that the caller is responsible to deallocate.
10518 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
10521 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
10522 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
10523 int nbFields(getNumberOfFields());
10524 for(int i=0;i<nbFields;i++)
10526 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
10529 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
10530 throw INTERP_KERNEL::Exception(oss.str());
10532 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
10533 fsOut->pushField(fmtsOut);
10535 return fsOut.retn();
10538 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10540 if(i<0 || i>=(int)_fields.size())
10542 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10543 throw INTERP_KERNEL::Exception(oss.str());
10545 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10548 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
10549 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10550 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10552 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10554 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10557 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10558 throw INTERP_KERNEL::Exception(oss.str());
10560 ret->shallowCpyGlobs(*this);
10565 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10566 * This method is accessible in python using __getitem__ with a list in input.
10567 * \return a new object that the caller should deal with.
10569 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10571 MCAuto<MEDFileFields> ret=shallowCpy();
10572 std::size_t sz=std::distance(startIds,endIds);
10573 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10575 for(const int *i=startIds;i!=endIds;i++,j++)
10577 if(*i<0 || *i>=(int)_fields.size())
10579 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10580 throw INTERP_KERNEL::Exception(oss.str());
10582 fields[j]=_fields[*i];
10584 ret->_fields=fields;
10588 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10590 return getFieldAtPos(getPosFromFieldName(fieldName));
10594 * This method removes, if any, fields in \a this having no time steps.
10595 * 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.
10597 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10599 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10601 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10602 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10604 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10607 if(elt->getNumberOfTS()>0)
10608 newFields.push_back(*it);
10611 if(_fields.size()==newFields.size())
10618 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10619 * This method can be seen as a filter applied on \a this, that returns an object containing
10620 * 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
10621 * shallow copied from \a this.
10623 * \param [in] meshName - the name of the mesh on w
10624 * \return a new object that the caller should deal with.
10626 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10628 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10629 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10631 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10634 if(cur->getMeshName()==meshName)
10637 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10638 ret->_fields.push_back(cur2);
10641 ret->shallowCpyOnlyUsedGlobs(*this);
10646 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10647 * Input time steps are specified using a pair of integer (iteration, order).
10648 * 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,
10649 * but for each multitimestep only the time steps in \a timeSteps are kept.
10650 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10652 * The returned object points to shallow copy of elements in \a this.
10654 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10655 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10656 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10658 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10660 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10661 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10663 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10666 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10667 ret->_fields.push_back(elt);
10669 ret->shallowCpyOnlyUsedGlobs(*this);
10674 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10676 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10678 MCAuto<MEDFileFields> ret=MEDFileFields::New();
10679 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10681 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10684 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10685 if(elt->getNumberOfTS()!=0)
10686 ret->_fields.push_back(elt);
10688 ret->shallowCpyOnlyUsedGlobs(*this);
10692 MEDFileFieldsIterator *MEDFileFields::iterator()
10694 return new MEDFileFieldsIterator(this);
10697 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10699 std::string tmp(fieldName);
10700 std::vector<std::string> poss;
10701 for(std::size_t i=0;i<_fields.size();i++)
10703 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10706 std::string fname(f->getName());
10710 poss.push_back(fname);
10713 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10714 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10716 throw INTERP_KERNEL::Exception(oss.str());
10719 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10724 _nb_iter=fs->getNumberOfFields();
10728 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10732 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10734 if(_iter_id<_nb_iter)
10736 MEDFileFields *fs(_fs);
10738 return fs->getFieldAtPos(_iter_id++);