1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.hxx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDFileUtilities.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldDiscretization.hxx"
31 #include "InterpKernelAutoPtr.hxx"
32 #include "CellModel.hxx"
37 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
38 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
39 extern med_geometry_type typmainoeud[1];
40 extern med_geometry_type typmai3[34];
42 using namespace ParaMEDMEM;
44 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
45 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
47 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
49 return new MEDFileFieldLoc(fid,locName);
52 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
54 return new MEDFileFieldLoc(fid,id);
57 MEDFileFieldLoc *MEDFileFieldLoc::New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w)
59 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
62 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
64 med_geometry_type geotype;
65 med_geometry_type sectiongeotype;
67 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
68 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
69 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
70 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
71 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
72 _nb_node_per_cell=cm.getNumberOfNodes();
73 _ref_coo.resize(_dim*_nb_node_per_cell);
74 _gs_coo.resize(_dim*_nb_gauss_pt);
75 _w.resize(_nb_gauss_pt);
76 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
79 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
81 med_geometry_type geotype;
82 med_geometry_type sectiongeotype;
84 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
85 INTERP_KERNEL::AutoPtr<char> geointerpname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
86 INTERP_KERNEL::AutoPtr<char> sectionmeshname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
87 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
89 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
90 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
91 _nb_node_per_cell=cm.getNumberOfNodes();
92 _ref_coo.resize(_dim*_nb_node_per_cell);
93 _gs_coo.resize(_dim*_nb_gauss_pt);
94 _w.resize(_nb_gauss_pt);
95 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
98 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
99 const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w):_name(locName),_geo_type(geoType),_ref_coo(refCoo),_gs_coo(gsCoo),
102 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
103 _dim=cm.getDimension();
104 _nb_node_per_cell=cm.getNumberOfNodes();
105 _nb_gauss_pt=_w.size();
108 MEDFileFieldLoc *MEDFileFieldLoc::deepCpy() const
110 return new MEDFileFieldLoc(*this);
113 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
115 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
118 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
120 return std::vector<const BigMemoryObject *>();
123 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
125 static const char OFF7[]="\n ";
126 oss << "\"" << _name << "\"" << OFF7;
127 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
128 oss << "Dimension=" << _dim << OFF7;
129 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
130 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
131 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
132 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
133 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
136 void MEDFileFieldLoc::setName(const std::string& name)
141 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
143 if(_name!=other._name)
147 if(_nb_gauss_pt!=other._nb_gauss_pt)
149 if(_nb_node_per_cell!=other._nb_node_per_cell)
151 if(_geo_type!=other._geo_type)
153 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
155 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
157 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
163 void MEDFileFieldLoc::writeLL(med_idt fid) const
165 MEDlocalizationWr(fid,_name.c_str(),typmai3[(int)_geo_type],_dim,&_ref_coo[0],MED_FULL_INTERLACE,_nb_gauss_pt,&_gs_coo[0],&_w[0],MED_NO_INTERPOLATION,MED_NO_MESH_SUPPORT);
168 std::string MEDFileFieldLoc::repr() const
170 std::ostringstream oss; oss.precision(15);
171 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
172 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
173 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
174 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
175 oss << "\n - Ref coords are : ";
176 int sz=_ref_coo.size();
179 int nbOfTuples=sz/_dim;
180 for(int i=0;i<nbOfTuples;i++)
183 for(int j=0;j<_dim;j++)
184 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
189 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
190 oss << "\n - Gauss coords in reference element : ";
194 int nbOfTuples=sz/_dim;
195 for(int i=0;i<nbOfTuples;i++)
198 for(int j=0;j<_dim;j++)
199 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
204 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
205 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
209 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
211 _type=field->getTypeOfField();
217 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,offset,offset+nbOfCells,1);
218 _end=_start+nbOfCells;
224 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
225 const int *arrPtr=arr->getConstPointer();
226 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
227 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
233 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
234 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
235 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
237 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
238 const DataArrayInt *dai=disc2->getArrayOfDiscIds();
239 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> dai2=disc2->getOffsetArr(field->getMesh());
240 const int *dai2Ptr=dai2->getConstPointer();
241 int nbi=gsLoc.getWeights().size();
242 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=dai->selectByTupleId2(offset,offset+nbOfCells,1);
243 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
244 const int *da3Ptr=da3->getConstPointer();
245 if(da3->getNumberOfTuples()!=nbOfCells)
246 {//profile : for gauss even in NoProfile !!!
247 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
249 da3->setName(_profile.c_str());
250 glob.appendProfile(da3);
252 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=DataArrayInt::New();
253 _nval=da3->getNbOfElems();
254 da4->alloc(_nval*nbi,1);
255 int *da4Ptr=da4->getPointer();
256 for(int i=0;i<_nval;i++)
258 int ref=dai2Ptr[offset+da3Ptr[i]];
259 for(int j=0;j<nbi;j++)
262 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
263 _localization=oss2.str();
264 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
265 _end=_start+_nval*nbi;
266 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
270 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
276 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
277 * \param [in] pflName input containing name of profile if any. 0 if no profile (except for GAUSS_PT where a no profile can hide a profile when splitted by loc_id).
278 * \param [in] multiTypePfl is the end user profile specified in high level API
279 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
280 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
281 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
282 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
284 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
287 _type=field->getTypeOfField();
288 std::string pflName(multiTypePfl->getName());
289 std::ostringstream oss; oss << pflName;
293 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
300 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
301 if(_type!=ON_GAUSS_PT)
303 locIds->setName(oss.str().c_str());
304 glob.appendProfile(locIds);
313 _nval=idsInPfl->getNumberOfTuples();
314 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,arrr->getNumberOfTuples(),1);
320 _nval=idsInPfl->getNumberOfTuples();
321 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
327 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
328 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr->deltaShiftIndex();
329 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
330 arr3->computeOffsets2();
331 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
332 int trueNval=tmp->getNumberOfTuples();
333 _nval=idsInPfl->getNumberOfTuples();
334 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
335 _end=_start+trueNval;
340 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
342 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
343 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
344 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
345 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
346 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da2->getIdsEqual(_loc_id);
347 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
349 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
350 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
352 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=DataArrayInt::New();
354 for(const int *pt=da4->begin();pt!=da4->end();pt++)
355 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
356 tmp->alloc(trueNval,1);
357 int *tmpPtr=tmp->getPointer();
358 for(const int *pt=da4->begin();pt!=da4->end();pt++)
359 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
362 _nval=da4->getNumberOfTuples();
363 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
364 _end=_start+trueNval;
365 oss << "_loc_" << _loc_id;
368 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
369 da5->setName(oss.str().c_str());
370 glob.appendProfile(da5);
375 if(da3->getNumberOfTuples()!=nbOfEltsInWholeMesh || !da3->isIdentity())
377 da3->setName(oss.str().c_str());
378 glob.appendProfile(da3);
382 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
383 _localization=oss2.str();
384 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
388 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
393 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
396 _nval=arrr->getNumberOfTuples();
397 getOrCreateAndGetArray()->setContigPartOfSelectedValues2(_start,arrr,0,_nval,1);
402 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
404 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
407 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
409 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
412 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
414 return new MEDFileFieldPerMeshPerTypePerDisc(other);
417 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
419 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
422 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
424 std::vector<const BigMemoryObject *> ret(1);
425 ret[0]=(const PartDefinition*)_pd;
429 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCpy(MEDFileFieldPerMeshPerType *father) const
431 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> ret=new MEDFileFieldPerMeshPerTypePerDisc(*this);
436 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
437 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
442 catch(INTERP_KERNEL::Exception& e)
447 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
451 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other):RefCountObject(other),_type(other._type),_father(0),_start(other._start),_end(other._end),_nval(other._nval),_profile(other._profile),_localization(other._localization),_loc_id(other._loc_id),_profile_it(other._profile_it),_pd(other._pd),_tmp_work1(other._tmp_work1)
455 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
456 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
460 void MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr)
462 const PartDefinition *pd(_pd);
465 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
467 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
468 if(_end-_start!=nbValsInFile*nbi)
470 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !";
471 throw INTERP_KERNEL::Exception(oss.str().c_str());
473 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
477 if(!_profile.empty())
478 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
479 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
481 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
482 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
486 spd->getSlice(start,stop,step);
487 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
488 med_filter filter=MED_FILTER_INIT;
489 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
490 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
491 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
492 /*lastblocksize=useless because count=1*/0,&filter);
493 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
494 MEDfilterClose(&filter);
497 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
500 dpd->checkCoherency();
501 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> myIds(dpd->toDAI());
502 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
503 myIds->applyLin(1,-a);
504 int nbOfEltsToLoad(b-a+1);
505 med_filter filter=MED_FILTER_INIT;
506 {//TODO : manage int32 !
507 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp(DataArrayDouble::New());
508 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
509 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
510 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
511 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
512 /*lastblocksize=useless because count=1*/0,&filter);
513 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
514 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> feeder(DataArrayDouble::New());
515 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
516 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
518 MEDfilterClose(&filter);
521 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
525 const MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
530 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
532 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
533 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
534 std::string fieldName(nasc.getName()),meshName(getMeshName());
535 int iteration(getIteration()),order(getOrder());
536 TypeOfField type(getType());
537 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
539 med_geometry_type mgeoti;
540 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
541 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
542 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
543 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
544 const PartDefinition *pd(_pd);
551 if(!_profile.empty())
552 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
553 _nval=pd->getNumberOfElems();
556 _end=start+_nval*nbi;
558 if(type==ON_CELLS && !_localization.empty())
560 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
561 setType(ON_GAUSS_PT);
564 setType(ON_GAUSS_NE);
565 _localization.clear();
570 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
572 std::string fieldName(nasc.getName()),meshName(getMeshName());
573 int iteration(getIteration()),order(getOrder());
574 TypeOfField type(getType());
575 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
576 med_geometry_type mgeoti;
577 med_entity_type menti(MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti));
579 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
582 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
583 if(_start<0 || _start>=arr->getNumberOfTuples())
585 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
586 throw INTERP_KERNEL::Exception(oss.str().c_str());
588 if(_end<0 || _end>arr->getNumberOfTuples())
590 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
591 throw INTERP_KERNEL::Exception(oss.str().c_str());
593 int nbOfCompo(arr->getNumberOfComponents());
594 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
597 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
598 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
601 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
604 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
605 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
608 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
612 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
614 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
616 int delta=_end-_start;
617 _start=newValueOfStart;
621 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
623 return _father->getIteration();
626 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
628 return _father->getOrder();
631 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
633 return _father->getTime();
636 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
638 return _father->getMeshName();
641 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
643 const char startLine[]=" ## ";
644 std::string startLine2(bkOffset,' ');
645 startLine2+=startLine;
646 MEDCouplingFieldDiscretization *tmp=MEDCouplingFieldDiscretization::New(_type);
647 oss << startLine2 << "Localization #" << id << "." << std::endl;
648 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
650 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
651 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
652 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
655 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
660 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
665 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
670 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
672 return _father->getGeoType();
675 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
677 return _father->getNumberOfComponents();
680 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
685 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
687 return _father->getOrCreateAndGetArray();
690 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
692 const MEDFileFieldPerMeshPerType *fath=_father;
693 return fath->getOrCreateAndGetArray();
696 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
698 return _father->getInfo();
701 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
706 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
711 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
713 return _localization;
716 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
718 _localization=newLocName;
721 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
723 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
725 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
727 _profile=(*it2).second;
733 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
735 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
737 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
739 _localization=(*it2).second;
745 void MEDFileFieldPerMeshPerTypePerDisc::getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
749 dads.push_back(std::pair<int,int>(_start,_end));
750 geoTypes.push_back(getGeoType());
755 pfls.push_back(glob->getProfile(_profile.c_str()));
757 if(_localization.empty())
761 locs.push_back(glob->getLocalizationId(_localization.c_str()));
765 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
767 entries[startEntryId]=std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int> ,std::pair<int,int> >(std::pair<INTERP_KERNEL::NormalizedCellType,int>(getGeoType(),discId),std::pair<int,int>(_start,_end));
771 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
773 TypeOfField type=getType();
774 INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
775 med_geometry_type mgeoti;
776 med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti);
777 const DataArray *arr=getOrCreateAndGetArray();
779 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
780 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
781 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
782 const unsigned char *locToWrite=0;
784 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
786 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
788 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
789 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
790 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
794 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
799 dad.first=_start; dad.second=_end;
803 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
804 * This code corresponds to the distribution of types in the corresponding mesh.
805 * \param [out] ptToFill memory zone where the output will be stored.
806 * \return the size of data pushed into output param \a ptToFill
808 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
811 std::ostringstream oss;
812 std::size_t nbOfType=codeOfMesh.size()/3;
814 for(std::size_t i=0;i<nbOfType && found==-1;i++)
815 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
819 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
820 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
821 throw INTERP_KERNEL::Exception(oss.str().c_str());
826 if(_nval!=codeOfMesh[3*found+1])
828 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
829 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
830 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
831 throw INTERP_KERNEL::Exception(oss.str().c_str());
833 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
838 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
839 if(pfl->getNumberOfTuples()!=_nval)
841 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
842 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
844 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
845 throw INTERP_KERNEL::Exception(oss.str().c_str());
847 int offset2=codeOfMesh[3*found+2];
848 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
850 if(*pflId<codeOfMesh[3*found+1])
851 *work++=offset2+*pflId;
857 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
859 for(int i=_start;i<_end;i++)
864 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
875 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
879 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
882 std::map<std::pair<std::string,TypeOfField>,int> m;
883 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
884 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
885 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
886 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
888 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
889 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
894 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
896 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
897 * \param [in] entriesOnSameDisc some entries **on same localization** if not the result can be invalid. The _start and _end on them are relative to \a arr parameter.
898 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
899 * \param [in] newCode one of the input parameter to explicit the new geo type dispatch (in classical format same than those asked by MEDFileFields::renumberEntitiesLyingOnMesh)
900 * \param [in,out] glob if necessary by the method, new profiles can be added to it
901 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
902 * \param [out] result All new entries will be appended on it.
903 * \return false if the configuration of renumbering leads to an unnecessary resplit of input \a entriesOnSameDisc. If not true is returned (the most general case !)
905 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
906 const DataArrayInt *explicitIdsInMesh,
907 const std::vector<int>& newCode,
908 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
909 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result)
911 if(entriesOnSameDisc.empty())
913 TypeOfField type=entriesOnSameDisc[0]->getType();
914 int szEntities=0,szTuples=0;
915 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
916 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
917 int nbi=szTuples/szEntities;
918 if(szTuples%szEntities!=0)
919 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
920 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
921 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
922 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
923 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
924 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
925 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
926 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
928 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
930 int startOfEltIdOfChunk=(*it)->_start;
931 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newEltIds=explicitIdsInMesh->substr(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
932 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
933 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
935 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
936 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
938 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
939 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
941 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
942 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
943 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
944 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
946 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
948 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arrPart=arr->substr(offset,offset+szTuples);
949 arrPart->renumberInPlace(renumTupleIds->begin());
950 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
952 const int *idIt=diffVals->begin();
953 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
955 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
957 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=newGeoTypesEltIdsAllGather->getIdsEqual(*idIt);
958 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
959 int nbEntityElts=subIds->getNumberOfTuples();
961 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
962 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIdentity() || nbEntityElts!=newCode[3*(*idIt)+1],nbi,
966 result.push_back(eltToAdd);
967 offset2+=nbEntityElts*nbi;
969 ret=ret || li.empty();
974 * \param [in] typeF type of field of new chunk
975 * \param [in] geoType the geometric type of the chunk
976 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
977 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
978 * \param [in] nbi number of integration points
979 * \param [in] offset The offset in the **global array of data**.
980 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
981 * to the new chunk to create.
982 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
983 * \param [out] notInExisting If false the return newly allocated entry is not coming from \a entriesOnSameDisc. If true the output comes from copy of \a entriesOnSameDisc
984 * and corresponding entry erased from \a entriesOnSameDisc.
985 * \return a newly allocated chunk
987 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
988 bool isPfl, int nbi, int offset,
989 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
990 MEDFileFieldGlobsReal& glob,
993 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
994 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
995 for(;it!=entriesOnSameDisc.end();it++)
997 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1001 if((*it)->_profile.empty())
1004 if(!(*it)->_profile.empty())
1006 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1007 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1013 if(it==entriesOnSameDisc.end())
1016 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1018 ret->_loc_id=(int)geoType;
1019 ret->_nval=nbMeshEntities;
1021 ret->_end=ret->_start+ret->_nval*nbi;
1024 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1025 glob.appendProfile(idsOfMeshElt);
1026 ret->_profile=idsOfMeshElt->getName();
1028 //tony treatment of localization
1033 notInExisting=false;
1034 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1035 ret->_loc_id=(int)geoType;
1036 ret->setNewStart(offset);
1037 entriesOnSameDisc.erase(it);
1043 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1045 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1048 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1050 return new MEDFileFieldPerMeshPerType(fath,geoType);
1053 std::size_t MEDFileFieldPerMeshPerType::getHeapMemorySizeWithoutChildren() const
1055 return _field_pm_pt_pd.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc>);
1058 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerType::getDirectChildrenWithNull() const
1060 std::vector<const BigMemoryObject *> ret;
1061 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1062 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1066 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCpy(MEDFileFieldPerMesh *father) const
1068 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1069 ret->_father=father;
1071 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1073 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1074 ret->_field_pm_pt_pd[i]=(*it)->deepCpy((MEDFileFieldPerMeshPerType *)ret);
1079 void MEDFileFieldPerMeshPerType::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1081 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1082 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1083 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1087 * This method is the most general one. No optimization is done here.
1088 * \param [in] multiTypePfl is the end user profile specified in high level API
1089 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1090 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1091 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1092 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1093 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1095 void MEDFileFieldPerMeshPerType::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1097 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1098 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1099 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1102 void MEDFileFieldPerMeshPerType::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1104 _field_pm_pt_pd.resize(1);
1105 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1106 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1109 void MEDFileFieldPerMeshPerType::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1111 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2=pfl->deepCpy();
1112 if(!arr || !arr->isAllocated())
1113 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::assignNodeFieldProfile : input array is null, or not allocated !");
1114 _field_pm_pt_pd.resize(1);
1115 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1116 _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1119 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1121 TypeOfField type=field->getTypeOfField();
1122 if(type!=ON_GAUSS_PT)
1124 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1125 int sz=_field_pm_pt_pd.size();
1127 for(int j=0;j<sz && !found;j++)
1129 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1131 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1137 _field_pm_pt_pd.resize(sz+1);
1138 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1140 std::vector<int> ret(1,(int)sz);
1145 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1146 int sz2=ret2.size();
1147 std::vector<int> ret3(sz2);
1149 for(int i=0;i<sz2;i++)
1151 int sz=_field_pm_pt_pd.size();
1152 int locIdToFind=ret2[i];
1154 for(int j=0;j<sz && !found;j++)
1156 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1158 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1165 _field_pm_pt_pd.resize(sz+1);
1166 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1174 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1176 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1177 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1179 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1180 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1182 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1183 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleId2(offset,offset+nbOfCells,1);
1184 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1185 if(retTmp->presenceOfValue(-1))
1186 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1187 std::vector<int> ret(retTmp->begin(),retTmp->end());
1191 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1193 TypeOfField type=field->getTypeOfField();
1194 if(type!=ON_GAUSS_PT)
1196 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1197 int sz=_field_pm_pt_pd.size();
1199 for(int j=0;j<sz && !found;j++)
1201 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1203 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1209 _field_pm_pt_pd.resize(sz+1);
1210 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1212 std::vector<int> ret(1,0);
1217 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1218 int sz2=ret2.size();
1219 std::vector<int> ret3(sz2);
1221 for(int i=0;i<sz2;i++)
1223 int sz=_field_pm_pt_pd.size();
1224 int locIdToFind=ret2[i];
1226 for(int j=0;j<sz && !found;j++)
1228 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1230 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1237 _field_pm_pt_pd.resize(sz+1);
1238 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1246 std::vector<int> MEDFileFieldPerMeshPerType::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1248 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1249 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1251 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1252 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1254 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1255 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1256 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> retTmp=da2->getDifferentValues();
1257 if(retTmp->presenceOfValue(-1))
1258 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1259 std::vector<int> ret(retTmp->begin(),retTmp->end());
1263 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerType::getFather() const
1268 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1270 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1271 int curDim=(int)cm.getDimension();
1272 dim=std::max(dim,curDim);
1275 void MEDFileFieldPerMeshPerType::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1277 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1279 (*it)->fillTypesOfFieldAvailable(types);
1283 void MEDFileFieldPerMeshPerType::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1285 int sz=_field_pm_pt_pd.size();
1286 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1287 for(int i=0;i<sz;i++)
1289 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1293 int MEDFileFieldPerMeshPerType::getIteration() const
1295 return _father->getIteration();
1298 int MEDFileFieldPerMeshPerType::getOrder() const
1300 return _father->getOrder();
1303 double MEDFileFieldPerMeshPerType::getTime() const
1305 return _father->getTime();
1308 std::string MEDFileFieldPerMeshPerType::getMeshName() const
1310 return _father->getMeshName();
1313 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1315 const char startLine[]=" ## ";
1316 std::string startLine2(bkOffset,' ');
1317 std::string startLine3(startLine2);
1318 startLine3+=startLine;
1319 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1321 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1322 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1325 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1326 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1328 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1330 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1332 cur->simpleRepr(bkOffset,oss,i);
1335 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1340 void MEDFileFieldPerMeshPerType::getSizes(int& globalSz, int& nbOfEntries) const
1342 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1344 globalSz+=(*it)->getNumberOfTuples();
1346 nbOfEntries+=(int)_field_pm_pt_pd.size();
1349 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1355 int MEDFileFieldPerMeshPerType::getNumberOfComponents() const
1357 return _father->getNumberOfComponents();
1360 bool MEDFileFieldPerMeshPerType::presenceOfMultiDiscPerGeoType() const
1363 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1365 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1372 DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray()
1374 return _father->getOrCreateAndGetArray();
1377 const DataArray *MEDFileFieldPerMeshPerType::getOrCreateAndGetArray() const
1379 const MEDFileFieldPerMesh *fath=_father;
1380 return fath->getOrCreateAndGetArray();
1383 const std::vector<std::string>& MEDFileFieldPerMeshPerType::getInfo() const
1385 return _father->getInfo();
1388 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsed() const
1390 std::vector<std::string> ret;
1391 std::set<std::string> ret2;
1392 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1394 std::string tmp=(*it1)->getProfile();
1396 if(ret2.find(tmp)==ret2.end())
1405 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsed() const
1407 std::vector<std::string> ret;
1408 std::set<std::string> ret2;
1409 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1411 std::string tmp=(*it1)->getLocalization();
1412 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1413 if(ret2.find(tmp)==ret2.end())
1422 std::vector<std::string> MEDFileFieldPerMeshPerType::getPflsReallyUsedMulti() const
1424 std::vector<std::string> ret;
1425 std::set<std::string> ret2;
1426 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1428 std::string tmp=(*it1)->getProfile();
1435 std::vector<std::string> MEDFileFieldPerMeshPerType::getLocsReallyUsedMulti() const
1437 std::vector<std::string> ret;
1438 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1440 std::string tmp=(*it1)->getLocalization();
1441 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1447 void MEDFileFieldPerMeshPerType::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1449 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1450 (*it1)->changePflsRefsNamesGen(mapOfModif);
1453 void MEDFileFieldPerMeshPerType::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1455 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1456 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1459 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId)
1461 if(_field_pm_pt_pd.empty())
1463 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1464 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1465 throw INTERP_KERNEL::Exception(oss.str().c_str());
1467 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1468 return _field_pm_pt_pd[locId];
1469 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1470 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1471 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1472 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1473 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1476 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerType::getLeafGivenLocId(int locId) const
1478 if(_field_pm_pt_pd.empty())
1480 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1481 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no localizations for geotype \"" << cm.getRepr() << "\" !";
1482 throw INTERP_KERNEL::Exception(oss.str().c_str());
1484 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1485 return _field_pm_pt_pd[locId];
1486 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1487 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerType::getLeafGivenLocId : no such locId available (" << locId;
1488 oss2 << ") for geometric type \"" << cm.getRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1489 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1490 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1493 void MEDFileFieldPerMeshPerType::getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const
1495 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1497 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1498 if(meshDim!=(int)cm.getDimension())
1501 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1502 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1505 void MEDFileFieldPerMeshPerType::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1508 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1510 (*it)->fillValues(i,startEntryId,entries);
1514 void MEDFileFieldPerMeshPerType::setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1516 _field_pm_pt_pd=leaves;
1517 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1518 (*it)->setFather(this);
1522 * \param [in,out] globalNum a global numbering counter for the renumbering.
1523 * \param [out] its - list of pair (start,stop) kept
1524 * \return bool - false if the type of field \a tof is not contained in \a this.
1526 bool MEDFileFieldPerMeshPerType::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1529 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1530 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1531 if((*it)->getType()==tof)
1533 newPmPtPd.push_back(*it);
1534 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1535 (*it)->setNewStart(globalNum);
1536 globalNum=(*it)->getEnd();
1537 its.push_back(bgEnd);
1541 _field_pm_pt_pd=newPmPtPd;
1546 * \param [in,out] globalNum a global numbering counter for the renumbering.
1547 * \param [out] its - list of pair (start,stop) kept
1548 * \return bool - false if the type of field \a tof is not contained in \a this.
1550 bool MEDFileFieldPerMeshPerType::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1552 if(_field_pm_pt_pd.size()<=idOfDisc)
1554 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1555 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1556 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1557 elt->setNewStart(globalNum);
1558 globalNum=elt->getEnd();
1559 its.push_back(bgEnd);
1560 _field_pm_pt_pd=newPmPtPd;
1564 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType):_father(fath),_geo_type(geoType)
1568 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):_father(fath),_geo_type(geoType)
1570 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1571 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1572 med_geometry_type mgeoti;
1573 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1574 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1575 _field_pm_pt_pd.resize(nbProfiles);
1576 for(int i=0;i<nbProfiles;i++)
1578 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1582 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1583 for(int i=0;i<nbProfiles2;i++)
1584 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1588 void MEDFileFieldPerMeshPerType::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1590 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1591 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1594 void MEDFileFieldPerMeshPerType::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1596 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1597 (*it)->loadBigArray(fid,nasc);
1600 void MEDFileFieldPerMeshPerType::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1602 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1604 (*it)->copyOptionsFrom(*this);
1605 (*it)->writeLL(fid,nasc);
1609 med_entity_type MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1614 medfGeoType=typmai3[(int)ikGeoType];
1617 medfGeoType=MED_NONE;
1620 medfGeoType=typmai3[(int)ikGeoType];
1621 return MED_NODE_ELEMENT;
1623 medfGeoType=typmai3[(int)ikGeoType];
1626 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1628 return MED_UNDEF_ENTITY_TYPE;
1631 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
1633 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1636 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1638 return new MEDFileFieldPerMesh(fath,mesh);
1641 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1643 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType >);
1646 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1648 std::vector<const BigMemoryObject *> ret;
1649 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1650 ret.push_back((const MEDFileFieldPerMeshPerType *)*it);
1654 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1656 MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1657 ret->_father=father;
1659 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1661 if((const MEDFileFieldPerMeshPerType *)*it)
1662 ret->_field_pm_pt[i]=(*it)->deepCpy((MEDFileFieldPerMesh *)(ret));
1667 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1669 std::string startLine(bkOffset,' ');
1670 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1671 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1673 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1675 const MEDFileFieldPerMeshPerType *cur=*it;
1677 cur->simpleRepr(bkOffset,oss,i);
1680 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1685 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1687 _mesh_name=mesh->getName();
1688 mesh->getTime(_mesh_iteration,_mesh_order);
1691 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1693 int nbOfTypes=code.size()/3;
1695 for(int i=0;i<nbOfTypes;i++)
1697 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1698 int nbOfCells=code[3*i+1];
1699 int pos=addNewEntryIfNecessary(type);
1700 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1706 * This method is the most general one. No optimization is done here.
1707 * \param [in] multiTypePfl is the end user profile specified in high level API
1708 * \param [in] code is the code of \a mesh[multiTypePfl] mesh. It is of size of number of different geometric types into \a mesh[multiTypePfl].
1709 * \param [in] code2 is the code of the \b WHOLE mesh on the same level. So all types in \a code are in \a code2.
1710 * \param [in] idsInPflPerType is the selection into the \a multiTypePfl whole profile that corresponds to the given geometric type. This vector is always 3 times smaller than \a code.
1711 * \param [in] idsPerType is a vector containing the profiles needed to be created for MED file format. \b WARNING these processed MED file profiles can be subdivided again in case of Gauss points.
1712 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1714 void MEDFileFieldPerMesh::assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1716 int nbOfTypes(code.size()/3);
1717 for(int i=0;i<nbOfTypes;i++)
1719 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1720 int pos=addNewEntryIfNecessary(type);
1721 DataArrayInt *pfl=0;
1723 pfl=idsPerType[code[3*i+2]];
1724 int nbOfTupes2=code2.size()/3;
1726 for(;found<nbOfTupes2;found++)
1727 if(code[3*i]==code2[3*found])
1729 if(found==nbOfTupes2)
1730 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1731 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1735 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1737 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1738 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1741 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1743 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1744 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1747 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1749 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1750 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1753 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1755 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1756 (*it)->loadBigArraysRecursively(fid,nasc);
1759 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1761 int nbOfTypes=_field_pm_pt.size();
1762 for(int i=0;i<nbOfTypes;i++)
1764 _field_pm_pt[i]->copyOptionsFrom(*this);
1765 _field_pm_pt[i]->writeLL(fid,nasc);
1769 void MEDFileFieldPerMesh::getDimension(int& dim) const
1771 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1772 (*it)->getDimension(dim);
1775 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1777 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1778 (*it)->fillTypesOfFieldAvailable(types);
1781 std::vector< std::vector< std::pair<int,int> > > MEDFileFieldPerMesh::getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> > & locs) const
1783 int sz=_field_pm_pt.size();
1784 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1785 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1786 for(int i=0;i<sz;i++)
1788 types[i]=_field_pm_pt[i]->getGeoType();
1789 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1794 double MEDFileFieldPerMesh::getTime() const
1797 return _father->getTime(tmp1,tmp2);
1800 int MEDFileFieldPerMesh::getIteration() const
1802 return _father->getIteration();
1805 int MEDFileFieldPerMesh::getOrder() const
1807 return _father->getOrder();
1810 int MEDFileFieldPerMesh::getNumberOfComponents() const
1812 return _father->getNumberOfComponents();
1815 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1817 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1819 const MEDFileFieldPerMeshPerType *fpmt(*it);
1822 if(fpmt->presenceOfMultiDiscPerGeoType())
1828 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
1831 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1832 return _father->getOrCreateAndGetArray();
1835 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
1838 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
1839 return _father->getOrCreateAndGetArray();
1842 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
1844 return _father->getInfo();
1848 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
1849 * Before the call of this method 'geoTypes','dads','pfls','locs' must be reorganized so that types in geoTypes are contiguous and ordered following typmai2 array.
1850 * It returns 2 output vectors :
1851 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
1852 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
1853 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
1855 void MEDFileFieldPerMesh::SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs, std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls)
1857 int notNullPflsSz=0;
1858 int nbOfArrs=geoTypes.size();
1859 for(int i=0;i<nbOfArrs;i++)
1862 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
1863 int nbOfDiffGeoTypes=geoTypes3.size();
1864 code.resize(3*nbOfDiffGeoTypes);
1865 notNullPfls.resize(notNullPflsSz);
1868 for(int i=0;i<nbOfDiffGeoTypes;i++)
1871 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
1872 std::vector<const DataArrayInt *> notNullTmp;
1874 notNullTmp.push_back(pfls[j]);
1876 for(;j<nbOfArrs;j++)
1877 if(geoTypes[j]==refType)
1880 notNullTmp.push_back(pfls[j]);
1884 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
1885 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
1886 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
1887 code[3*i]=(int)refType;
1888 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
1889 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
1890 if(notNullTmp.empty())
1894 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
1895 code[3*i+2]=notNullPflsSz++;
1901 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
1903 int MEDFileFieldPerMesh::ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs)
1907 for(int i=0;i<sz;i++)
1911 if(type!=ON_GAUSS_NE)
1912 ret+=dads[i].second-dads[i].first;
1915 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
1916 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
1921 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
1922 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
1928 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
1930 std::vector<std::string> ret;
1931 std::set<std::string> ret2;
1932 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1934 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
1935 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1936 if(ret2.find(*it2)==ret2.end())
1938 ret.push_back(*it2);
1945 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
1947 std::vector<std::string> ret;
1948 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1950 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
1951 ret.insert(ret.end(),tmp.begin(),tmp.end());
1956 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
1958 std::vector<std::string> ret;
1959 std::set<std::string> ret2;
1960 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1962 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
1963 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
1964 if(ret2.find(*it2)==ret2.end())
1966 ret.push_back(*it2);
1973 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
1975 std::vector<std::string> ret;
1976 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1978 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
1979 ret.insert(ret.end(),tmp.begin(),tmp.end());
1984 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
1986 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
1988 if((*it).first==_mesh_name)
1990 _mesh_name=(*it).second;
1997 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
1998 MEDFileFieldGlobsReal& glob)
2000 if(_mesh_name!=meshName)
2002 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2003 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2004 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2005 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2006 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2007 getUndergroundDataArrayExt(entries);
2008 DataArray *arr0=getOrCreateAndGetArray();//tony
2010 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2011 DataArrayDouble *arr=dynamic_cast<DataArrayDouble *>(arr0);//tony
2013 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2016 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2017 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2019 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2021 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2022 sz+=(*it).second.second-(*it).second.first;
2025 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2027 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2028 ////////////////////
2029 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2030 int *workI2=explicitIdsOldInMesh->getPointer();
2031 int sz1=0,sz2=0,sid=1;
2032 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2033 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2034 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2036 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2037 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2038 int *workI=explicitIdsOldInArr->getPointer();
2039 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2041 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2042 (*itL2)->setLocId(sz2);
2043 (*itL2)->_tmp_work1=(*itL2)->getStart();
2044 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2046 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2048 explicitIdsOldInMesh->reAlloc(sz2);
2049 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2050 ////////////////////
2051 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2052 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2053 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2054 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2056 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2057 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2058 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2060 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2061 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2062 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2064 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2065 int newStart=elt->getLocId();
2066 elt->setLocId((*it)->getGeoType());
2067 elt->setNewStart(newStart);
2068 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2069 entriesKeptNew.push_back(elt);
2070 entriesKeptNew2.push_back(elt);
2072 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2073 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2074 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2075 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2077 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2080 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2082 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2083 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2085 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2086 glob,arr2,otherEntriesNew) || ret;
2090 // Assign new dispatching
2091 assignNewLeaves(otherEntriesNew);
2092 arr->cpyFrom(*arr2);
2097 * \param [in,out] globalNum a global numbering counter for the renumbering.
2098 * \param [out] its - list of pair (start,stop) kept
2100 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2102 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2103 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2105 std::vector< std::pair<int,int> > its2;
2106 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2109 its.insert(its.end(),its2.begin(),its2.end());
2116 * \param [in,out] globalNum a global numbering counter for the renumbering.
2117 * \param [out] its - list of pair (start,stop) kept
2119 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2121 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > ret;
2122 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2124 std::vector< std::pair<int,int> > its2;
2125 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2128 its.insert(its.end(),its2.begin(),its2.end());
2134 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2136 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2137 for( std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2138 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2140 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > fieldPmPt(types.size());
2141 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2142 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=fieldPmPt.begin();
2143 for(;it1!=types.end();it1++,it2++)
2145 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2146 elt->setLeaves((*it1).second);
2149 _field_pm_pt=fieldPmPt;
2152 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2154 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2155 (*it)->changePflsRefsNamesGen(mapOfModif);
2158 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2160 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2161 (*it)->changeLocsRefsNamesGen(mapOfModif);
2165 * \param [in] mesh is the whole mesh
2167 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2169 if(_field_pm_pt.empty())
2170 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2172 std::vector< std::pair<int,int> > dads;
2173 std::vector<const DataArrayInt *> pfls;
2174 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2175 std::vector<int> locs,code;
2176 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2177 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2178 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2180 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2183 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2184 throw INTERP_KERNEL::Exception(oss.str().c_str());
2187 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2188 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2191 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2193 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2196 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr);
2197 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2203 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2207 if(nb!=mesh->getNumberOfNodes())
2209 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2210 oss << " nodes in mesh !";
2211 throw INTERP_KERNEL::Exception(oss.str().c_str());
2213 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2216 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2220 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2222 if(_field_pm_pt.empty())
2223 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2225 std::vector<std::pair<int,int> > dads;
2226 std::vector<const DataArrayInt *> pfls;
2227 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2228 std::vector<int> locs,code;
2229 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2230 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2231 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2233 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2236 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2237 throw INTERP_KERNEL::Exception(oss.str().c_str());
2239 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2240 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2243 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2244 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2249 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2253 if(nb!=mesh->getNumberOfNodes())
2255 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2256 oss << " nodes in mesh !";
2257 throw INTERP_KERNEL::Exception(oss.str().c_str());
2260 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2266 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2270 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2272 (*it)->getSizes(globalSz,nbOfEntries);
2274 entries.resize(nbOfEntries);
2276 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2278 (*it)->fillValues(nbOfEntries,entries);
2282 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2284 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2286 if((*it)->getGeoType()==typ)
2287 return (*it)->getLeafGivenLocId(locId);
2289 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2290 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2291 oss << "Possiblities are : ";
2292 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2294 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2295 oss << "\"" << cm2.getRepr() << "\", ";
2297 throw INTERP_KERNEL::Exception(oss.str().c_str());
2300 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2302 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2304 if((*it)->getGeoType()==typ)
2305 return (*it)->getLeafGivenLocId(locId);
2307 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2308 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2309 oss << "Possiblities are : ";
2310 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2312 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2313 oss << "\"" << cm2.getRepr() << "\", ";
2315 throw INTERP_KERNEL::Exception(oss.str().c_str());
2318 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2321 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2322 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it2=_field_pm_pt.begin();
2323 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2325 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2330 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2335 int ret=std::distance(_field_pm_pt.begin(),it2);
2336 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2341 * 'dads' and 'locs' input parameters have the same number of elements
2342 * \param [in] mesh is \b NOT the global mesh, but the possibly reduced mesh. \a mesh parameter will be directly aggregated in the returned field
2344 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2345 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2346 const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2349 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2350 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2351 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2352 const std::vector<std::string>& infos=getInfo();
2353 da->setInfoOnComponents(infos);
2355 if(type==ON_GAUSS_PT)
2358 int nbOfArrs=dads.size();
2359 for(int i=0;i<nbOfArrs;i++)
2361 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2362 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2363 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2364 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> di=DataArrayInt::New();
2365 di->alloc(nbOfElems,1);
2367 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2368 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2377 * This method is an extension of MEDFileFieldPerMesh::finishField method. It deals with profiles. This method should be called when type is different from ON_NODES.
2378 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2379 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2380 * The order of cells in the returned field is those imposed by the profile.
2381 * \param [in] mesh is the global mesh.
2383 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2384 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2385 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2386 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2388 if(da->isIdentity())
2390 int nbOfTuples=da->getNumberOfTuples();
2391 if(nbOfTuples==mesh->getNumberOfCells())
2392 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2394 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2395 m2->setName(mesh->getName().c_str());
2396 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2402 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2404 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2405 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2406 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2408 if(da->isIdentity())
2410 int nbOfTuples=da->getNumberOfTuples();
2411 if(nbOfTuples==mesh->getNumberOfNodes())//No problem for NORM_ERROR because it is in context of node
2412 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2414 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2415 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2418 if(meshu->getNodalConnectivity()==0)
2420 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2421 int nb=da->getNbOfElems();
2422 const int *ptr=da->getConstPointer();
2423 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2424 meshuc->allocateCells(nb);
2425 for(int i=0;i<nb;i++)
2426 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2427 meshuc->finishInsertingCells();
2428 ret->setMesh(meshuc);
2429 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2430 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2431 disc->checkCoherencyBetween(meshuc,arrOut);
2436 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2438 DataArrayInt *arr2=0;
2439 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2440 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2441 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2);
2442 int nnodes=mesh2->getNumberOfNodes();
2443 if(nnodes==(int)da->getNbOfElems())
2445 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2446 arrOut->renumberInPlace(da3->getConstPointer());
2447 mesh2->setName(mesh->getName().c_str());
2448 ret->setMesh(mesh2);
2453 std::ostringstream oss; oss << "MEDFileFieldPerMesh::finishFieldNode2 : The field on nodes lies on a node profile so that it is impossible to find a submesh having exactly the same nodes of that profile !!!";
2454 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2455 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2456 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2457 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2458 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2459 throw INTERP_KERNEL::Exception(oss.str().c_str());
2465 * This method is the most light method of field retrieving.
2467 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2471 pflOut=DataArrayInt::New();
2472 pflOut->alloc(nbOfElems,1);
2477 pflOut=const_cast<DataArrayInt*>(pflIn);
2480 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> safePfl(pflOut);
2481 MEDCouplingAutoRefCountObjectPtr<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2482 const std::vector<std::string>& infos=getInfo();
2483 int nbOfComp=infos.size();
2484 for(int i=0;i<nbOfComp;i++)
2485 da->setInfoOnComponent(i,infos[i].c_str());
2496 static MFFPMIter *NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2497 static bool IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities);
2498 virtual ~MFFPMIter() { }
2499 virtual void begin() = 0;
2500 virtual bool finished() const = 0;
2501 virtual void next() = 0;
2502 virtual int current() const = 0;
2505 class MFFPMIterSimple : public MFFPMIter
2508 MFFPMIterSimple():_pos(0) { }
2509 void begin() { _pos=0; }
2510 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2511 void next() { _pos++; }
2512 int current() const { return _pos; }
2517 class MFFPMIter2 : public MFFPMIter
2520 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2521 void begin() { _it=_ids.begin(); }
2522 bool finished() const { return _it==_ids.end(); }
2523 void next() { _it++; }
2524 int current() const { return *_it; }
2526 std::vector<int> _ids;
2527 std::vector<int>::const_iterator _it;
2530 MFFPMIter *MFFPMIter::NewCell(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2533 return new MFFPMIterSimple;
2536 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2537 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2539 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2540 tmp.push_back((*it).second);
2542 return new MFFPMIter2(tmp);
2546 bool MFFPMIter::IsPresenceOfNode(const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
2552 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=(*entities).begin();it!=(*entities).end();it++)
2553 if((*it).first==ON_NODES)
2559 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2561 std::size_t sz(cts.size());
2563 for(std::size_t i=0;i<sz;i++)
2565 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2566 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2567 _ids[i]=(int)std::distance(typmai2,loc);
2569 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2575 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2578 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2579 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2580 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2581 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2582 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2583 for(iter0->begin();!iter0->finished();iter0->next())
2585 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2586 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2587 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2588 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2589 if(nbProfile>0 || nbProfile2>0)
2591 const PartDefinition *pd(0);
2593 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2594 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2601 if(MFFPMIter::IsPresenceOfNode(entities))
2603 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2606 const PartDefinition *pd(0);
2608 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2609 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2610 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2615 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2617 copyTinyInfoFrom(mesh);
2620 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2622 if(id>=(int)_pfls.size())
2624 _pfls[id]=DataArrayInt::New();
2625 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2626 _pfls[id]->setName(pflName);
2627 _pfls[id]->alloc(lgth,1);
2628 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2629 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2632 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2634 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2636 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
2637 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
2638 if(i>=(int)_pfls.size())
2640 _pfls[i]=DataArrayInt::New();
2641 _pfls[i]->alloc(sz,1);
2642 _pfls[i]->setName(pflCpp.c_str());
2643 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
2644 _pfls[i]->applyLin(1,-1,0);//Converting into C format
2647 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
2649 int nbOfPfls=_pfls.size();
2650 for(int i=0;i<nbOfPfls;i++)
2652 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cpy=_pfls[i]->deepCpy();
2653 cpy->applyLin(1,1,0);
2654 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
2655 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
2656 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
2659 int nbOfLocs=_locs.size();
2660 for(int i=0;i<nbOfLocs;i++)
2661 _locs[i]->writeLL(fid);
2664 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
2666 std::vector<std::string> pfls=getPfls();
2667 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
2669 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
2672 _pfls.push_back(*it);
2676 int id=std::distance(pfls.begin(),it2);
2677 if(!(*it)->isEqual(*_pfls[id]))
2679 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2680 throw INTERP_KERNEL::Exception(oss.str().c_str());
2684 std::vector<std::string> locs=getLocs();
2685 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
2687 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
2690 _locs.push_back(*it);
2694 int id=std::distance(locs.begin(),it2);
2695 if(!(*it)->isEqual(*_locs[id],eps))
2697 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
2698 throw INTERP_KERNEL::Exception(oss.str().c_str());
2704 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
2706 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
2707 getProfile((*it).c_str());
2710 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
2712 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
2713 getLocalization((*it).c_str());
2716 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
2718 std::vector<std::string> profiles=real.getPflsReallyUsed();
2719 int sz=profiles.size();
2721 for(int i=0;i<sz;i++)
2722 loadProfileInFile(fid,i,profiles[i].c_str());
2724 std::vector<std::string> locs=real.getLocsReallyUsed();
2727 for(int i=0;i<sz;i++)
2728 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
2731 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
2733 int nProfil=MEDnProfile(fid);
2734 for(int i=0;i<nProfil;i++)
2735 loadProfileInFile(fid,i);
2736 int sz=MEDnLocalization(fid);
2738 for(int i=0;i<sz;i++)
2740 _locs[i]=MEDFileFieldLoc::New(fid,i);
2744 MEDFileFieldGlobs *MEDFileFieldGlobs::New(const std::string& fname)
2746 return new MEDFileFieldGlobs(fname);
2749 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
2751 return new MEDFileFieldGlobs;
2754 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
2756 return _file_name.capacity()+_pfls.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayInt>)+_locs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>);
2759 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
2761 std::vector<const BigMemoryObject *> ret;
2762 for(std::vector< MEDCouplingAutoRefCountObjectPtr< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
2763 ret.push_back((const DataArrayInt *)*it);
2764 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
2765 ret.push_back((const MEDFileFieldLoc *)*it);
2769 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpy() const
2771 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
2773 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
2775 if((const DataArrayInt *)*it)
2776 ret->_pfls[i]=(*it)->deepCpy();
2779 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
2781 if((const MEDFileFieldLoc*)*it)
2782 ret->_locs[i]=(*it)->deepCpy();
2788 * \throw if a profile in \a pfls in not in \a this.
2789 * \throw if a localization in \a locs in not in \a this.
2790 * \sa MEDFileFieldGlobs::deepCpyPart
2792 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2794 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2795 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2797 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2799 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
2801 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pfl2(pfl);
2802 ret->_pfls.push_back(pfl2);
2804 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2806 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2808 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
2810 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> loc2(loc);
2811 ret->_locs.push_back(loc2);
2813 ret->setFileName(getFileName());
2818 * \throw if a profile in \a pfls in not in \a this.
2819 * \throw if a localization in \a locs in not in \a this.
2820 * \sa MEDFileFieldGlobs::shallowCpyPart
2822 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
2824 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
2825 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
2827 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
2829 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
2830 ret->_pfls.push_back(pfl->deepCpy());
2832 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
2834 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
2836 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
2837 ret->_locs.push_back(loc->deepCpy());
2839 ret->setFileName(getFileName());
2843 MEDFileFieldGlobs::MEDFileFieldGlobs(const std::string& fname):_file_name(fname)
2847 MEDFileFieldGlobs::MEDFileFieldGlobs()
2851 MEDFileFieldGlobs::~MEDFileFieldGlobs()
2855 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
2857 oss << "Profiles :\n";
2858 std::size_t n=_pfls.size();
2859 for(std::size_t i=0;i<n;i++)
2861 oss << " - #" << i << " ";
2862 const DataArrayInt *pfl=_pfls[i];
2864 oss << "\"" << pfl->getName() << "\"\n";
2869 oss << "Localizations :\n";
2870 for(std::size_t i=0;i<n;i++)
2872 oss << " - #" << i << " ";
2873 const MEDFileFieldLoc *loc=_locs[i];
2875 loc->simpleRepr(oss);
2881 void MEDFileFieldGlobs::setFileName(const std::string& fileName)
2883 _file_name=fileName;
2886 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2888 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
2890 DataArrayInt *elt(*it);
2893 std::string name(elt->getName());
2894 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2896 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2898 elt->setName((*it2).second.c_str());
2906 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2908 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
2910 MEDFileFieldLoc *elt(*it);
2913 std::string name(elt->getName());
2914 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
2916 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
2918 elt->setName((*it2).second.c_str());
2926 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
2928 if(locId<0 || locId>=(int)_locs.size())
2929 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
2930 return _locs[locId]->getNbOfGaussPtPerCell();
2933 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
2935 return getLocalizationFromId(getLocalizationId(locName));
2938 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
2940 if(locId<0 || locId>=(int)_locs.size())
2941 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
2942 return *_locs[locId];
2946 namespace ParaMEDMEMImpl
2951 LocFinder(const std::string& loc):_loc(loc) { }
2952 bool operator() (const MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
2954 const std::string &_loc;
2960 PflFinder(const std::string& pfl):_pfl(pfl) { }
2961 bool operator() (const MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
2963 const std::string& _pfl;
2968 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
2970 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),ParaMEDMEMImpl::LocFinder(loc));
2973 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
2974 for(it=_locs.begin();it!=_locs.end();it++)
2975 oss << "\"" << (*it)->getName() << "\", ";
2976 throw INTERP_KERNEL::Exception(oss.str().c_str());
2978 return std::distance(_locs.begin(),it);
2982 * The returned value is never null.
2984 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
2986 std::string pflNameCpp(pflName);
2987 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
2990 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
2991 for(it=_pfls.begin();it!=_pfls.end();it++)
2992 oss << "\"" << (*it)->getName() << "\", ";
2993 throw INTERP_KERNEL::Exception(oss.str().c_str());
2998 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3000 if(pflId<0 || pflId>=(int)_pfls.size())
3001 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3002 return _pfls[pflId];
3005 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3007 if(locId<0 || locId>=(int)_locs.size())
3008 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3009 return *_locs[locId];
3012 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3014 return getLocalizationFromId(getLocalizationId(locName));
3018 * The returned value is never null.
3020 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3022 std::string pflNameCpp(pflName);
3023 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),ParaMEDMEMImpl::PflFinder(pflNameCpp));
3026 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3027 for(it=_pfls.begin();it!=_pfls.end();it++)
3028 oss << "\"" << (*it)->getName() << "\", ";
3029 throw INTERP_KERNEL::Exception(oss.str().c_str());
3034 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3036 if(pflId<0 || pflId>=(int)_pfls.size())
3037 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3038 return _pfls[pflId];
3041 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3043 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > newPfls;
3045 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3047 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3048 newPfls.push_back(*it);
3053 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3055 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > newLocs;
3057 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3059 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3060 newLocs.push_back(*it);
3065 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3067 int sz=_pfls.size();
3068 std::vector<std::string> ret(sz);
3069 for(int i=0;i<sz;i++)
3070 ret[i]=_pfls[i]->getName();
3074 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3076 int sz=_locs.size();
3077 std::vector<std::string> ret(sz);
3078 for(int i=0;i<sz;i++)
3079 ret[i]=_locs[i]->getName();
3083 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3085 std::vector<std::string> v=getPfls();
3086 std::string s(pflName);
3087 return std::find(v.begin(),v.end(),s)!=v.end();
3090 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3092 std::vector<std::string> v=getLocs();
3093 std::string s(locName);
3094 return std::find(v.begin(),v.end(),s)!=v.end();
3097 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3099 std::map<int,std::vector<int> > m;
3101 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3103 const DataArrayInt *tmp=(*it);
3106 m[tmp->getHashCode()].push_back(i);
3109 std::vector< std::vector<int> > ret;
3110 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3112 if((*it2).second.size()>1)
3114 std::vector<int> ret0;
3115 bool equalityOrNot=false;
3116 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3118 std::vector<int>::const_iterator it4=it3; it4++;
3119 for(;it4!=(*it2).second.end();it4++)
3121 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3124 ret0.push_back(*it3);
3125 ret0.push_back(*it4);
3131 ret.push_back(ret0);
3137 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3139 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3142 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3144 std::string name(pfl->getName());
3146 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3147 for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3148 if(name==(*it)->getName())
3150 if(!pfl->isEqual(*(*it)))
3152 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3153 throw INTERP_KERNEL::Exception(oss.str().c_str());
3157 _pfls.push_back(pfl);
3160 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)
3162 std::string name(locName);
3164 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3165 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3166 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3167 if((*it)->isName(locName))
3169 if(!(*it)->isEqual(*obj,1e-12))
3171 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3172 throw INTERP_KERNEL::Exception(oss.str().c_str());
3175 _locs.push_back(obj);
3178 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3180 std::vector<std::string> names=getPfls();
3181 return CreateNewNameNotIn("NewPfl_",names);
3184 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3186 std::vector<std::string> names=getLocs();
3187 return CreateNewNameNotIn("NewLoc_",names);
3190 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3192 for(std::size_t sz=0;sz<100000;sz++)
3194 std::ostringstream tryName;
3195 tryName << prefix << sz;
3196 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3197 return tryName.str();
3199 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3203 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3204 * \param [in] fname - the file name.
3206 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(const std::string& fname):_globals(MEDFileFieldGlobs::New(fname))
3211 * Creates an empty MEDFileFieldGlobsReal.
3213 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3217 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3222 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3224 std::vector<const BigMemoryObject *> ret;
3225 ret.push_back((const MEDFileFieldGlobs *)_globals);
3230 * Returns a string describing profiles and Gauss points held in \a this.
3231 * \return std::string - the description string.
3233 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3235 const MEDFileFieldGlobs *glob=_globals;
3236 std::ostringstream oss2; oss2 << glob;
3237 std::string stars(oss2.str().length(),'*');
3238 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3240 glob->simpleRepr(oss);
3242 oss << "NO GLOBAL INFORMATION !\n";
3245 void MEDFileFieldGlobsReal::resetContent()
3247 _globals=MEDFileFieldGlobs::New();
3250 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3255 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3256 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3258 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3260 _globals=other._globals;
3264 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3265 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3267 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3269 const MEDFileFieldGlobs *otherg(other._globals);
3272 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3276 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3277 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3279 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3281 const MEDFileFieldGlobs *otherg(other._globals);
3284 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3287 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3289 _globals=other._globals;
3290 if((const MEDFileFieldGlobs *)_globals)
3291 _globals=other._globals->deepCpy();
3295 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3296 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3297 * \param [in] eps - a precision used to compare Gauss points with same name held by
3298 * \a this and \a other MEDFileFieldGlobsReal.
3299 * \throw If \a this and \a other hold profiles with equal names but different ids.
3300 * \throw If \a this and \a other hold different Gauss points with equal names.
3302 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3304 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3305 if(thisGlobals==otherGlobals)
3309 _globals=other._globals;
3312 _globals->appendGlobs(*other._globals,eps);
3315 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3317 checkGlobsPflsPartCoherency();
3318 checkGlobsLocsPartCoherency();
3321 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3323 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3326 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3328 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3331 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3333 contentNotNull()->loadProfileInFile(fid,id,pflName);
3336 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3338 contentNotNull()->loadProfileInFile(fid,id);
3341 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3343 contentNotNull()->loadGlobals(fid,*this);
3346 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3348 contentNotNull()->loadAllGlobals(fid);
3351 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3353 contentNotNull()->writeGlobals(fid,opt);
3357 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3358 * or getPflsReallyUsedMulti().
3359 * \return std::vector<std::string> - a sequence of names of all profiles.
3361 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3363 return contentNotNull()->getPfls();
3367 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3368 * or getLocsReallyUsedMulti().
3369 * \return std::vector<std::string> - a sequence of names of all localizations.
3371 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3373 return contentNotNull()->getLocs();
3377 * Checks if the profile with a given name exists.
3378 * \param [in] pflName - the profile name of interest.
3379 * \return bool - \c true if the profile named \a pflName exists.
3381 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3383 return contentNotNull()->existsPfl(pflName);
3387 * Checks if the localization with a given name exists.
3388 * \param [in] locName - the localization name of interest.
3389 * \return bool - \c true if the localization named \a locName exists.
3391 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3393 return contentNotNull()->existsLoc(locName);
3396 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3398 return contentNotNull()->createNewNameOfPfl();
3401 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3403 return contentNotNull()->createNewNameOfLoc();
3407 * Sets the name of a MED file.
3408 * \param [inout] fileName - the file name.
3410 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3412 contentNotNull()->setFileName(fileName);
3416 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3417 * in the same order.
3418 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3419 * Each item of this sequence is a vector containing ids of equal profiles.
3421 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3423 return contentNotNull()->whichAreEqualProfiles();
3427 * Finds equal localizations.
3428 * \param [in] eps - a precision used to compare real values of the localizations.
3429 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3430 * Each item of this sequence is a vector containing ids of equal localizations.
3432 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3434 return contentNotNull()->whichAreEqualLocs(eps);
3438 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3439 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3440 * this sequence is a pair whose
3441 * - the first item is a vector of profile names to replace by the second item,
3442 * - the second item is a profile name to replace every profile name of the first item.
3444 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3446 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3450 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3451 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3452 * this sequence is a pair whose
3453 * - the first item is a vector of localization names to replace by the second item,
3454 * - the second item is a localization name to replace every localization name of the first item.
3456 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3458 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3462 * Replaces references to some profiles (a reference is a profile name) by references
3463 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3464 * them-selves accordingly. <br>
3465 * This method is a generalization of changePflName().
3466 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3467 * this sequence is a pair whose
3468 * - the first item is a vector of profile names to replace by the second item,
3469 * - the second item is a profile name to replace every profile of the first item.
3470 * \sa changePflsRefsNamesGen()
3471 * \sa changePflName()
3473 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3475 changePflsRefsNamesGen(mapOfModif);
3476 changePflsNamesInStruct(mapOfModif);
3480 * Replaces references to some localizations (a reference is a localization name) by references
3481 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3482 * them-selves accordingly. <br>
3483 * This method is a generalization of changeLocName().
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 localization names to replace by the second item,
3487 * - the second item is a localization name to replace every localization of the first item.
3488 * \sa changeLocsRefsNamesGen()
3489 * \sa changeLocName()
3491 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3493 changeLocsRefsNamesGen(mapOfModif);
3494 changeLocsNamesInStruct(mapOfModif);
3498 * Renames the profile having a given name and updates references to this profile.
3499 * \param [in] oldName - the name of the profile to rename.
3500 * \param [in] newName - a new name of the profile.
3501 * \sa changePflsNames().
3503 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3505 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3506 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3508 changePflsNames(mapOfModif);
3512 * Renames the localization having a given name and updates references to this localization.
3513 * \param [in] oldName - the name of the localization to rename.
3514 * \param [in] newName - a new name of the localization.
3515 * \sa changeLocsNames().
3517 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3519 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3520 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3522 changeLocsNames(mapOfModif);
3526 * Removes duplicated profiles. Returns a map used to update references to removed
3527 * profiles via changePflsRefsNamesGen().
3528 * Equal profiles are found using whichAreEqualProfiles().
3529 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3530 * a sequence describing the performed replacements of profiles. Each element of
3531 * this sequence is a pair whose
3532 * - the first item is a vector of profile names replaced by the second item,
3533 * - the second item is a profile name replacing every profile of the first item.
3535 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3537 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3538 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3540 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3542 std::vector< std::string > tmp((*it).size());
3544 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3545 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3546 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3548 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3549 killProfileIds(tmp2);
3551 changePflsRefsNamesGen(ret);
3556 * Removes duplicated localizations. Returns a map used to update references to removed
3557 * localizations via changeLocsRefsNamesGen().
3558 * Equal localizations are found using whichAreEqualLocs().
3559 * \param [in] eps - a precision used to compare real values of the localizations.
3560 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3561 * a sequence describing the performed replacements of localizations. Each element of
3562 * this sequence is a pair whose
3563 * - the first item is a vector of localization names replaced by the second item,
3564 * - the second item is a localization name replacing every localization of the first item.
3566 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3568 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3569 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3571 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3573 std::vector< std::string > tmp((*it).size());
3575 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3576 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3577 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3579 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3580 killLocalizationIds(tmp2);
3582 changeLocsRefsNamesGen(ret);
3587 * Returns number of Gauss points per cell in a given localization.
3588 * \param [in] locId - an id of the localization of interest.
3589 * \return int - the number of the Gauss points per cell.
3591 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3593 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3597 * Returns an id of a localization by its name.
3598 * \param [in] loc - the localization name of interest.
3599 * \return int - the id of the localization.
3600 * \throw If there is no a localization named \a loc.
3602 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3604 return contentNotNull()->getLocalizationId(loc);
3608 * Returns the name of the MED file.
3609 * \return const std::string& - the MED file name.
3611 std::string MEDFileFieldGlobsReal::getFileName() const
3613 return contentNotNull()->getFileName();
3617 * Returns a localization object by its name.
3618 * \param [in] locName - the name of the localization of interest.
3619 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3620 * \throw If there is no a localization named \a locName.
3622 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3624 return contentNotNull()->getLocalization(locName);
3628 * Returns a localization object by its id.
3629 * \param [in] locId - the id of the localization of interest.
3630 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3631 * \throw If there is no a localization with id \a locId.
3633 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3635 return contentNotNull()->getLocalizationFromId(locId);
3639 * Returns a profile array by its name.
3640 * \param [in] pflName - the name of the profile of interest.
3641 * \return const DataArrayInt * - the profile array having the name \a pflName.
3642 * \throw If there is no a profile named \a pflName.
3644 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
3646 return contentNotNull()->getProfile(pflName);
3650 * Returns a profile array by its id.
3651 * \param [in] pflId - the id of the profile of interest.
3652 * \return const DataArrayInt * - the profile array having the id \a pflId.
3653 * \throw If there is no a profile with id \a pflId.
3655 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
3657 return contentNotNull()->getProfileFromId(pflId);
3661 * Returns a localization object, apt for modification, by its id.
3662 * \param [in] locId - the id of the localization of interest.
3663 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3664 * having the id \a locId.
3665 * \throw If there is no a localization with id \a locId.
3667 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
3669 return contentNotNull()->getLocalizationFromId(locId);
3673 * Returns a localization object, apt for modification, by its name.
3674 * \param [in] locName - the name of the localization of interest.
3675 * \return MEDFileFieldLoc& - a non-const reference to the localization object
3676 * having the name \a locName.
3677 * \throw If there is no a localization named \a locName.
3679 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
3681 return contentNotNull()->getLocalization(locName);
3685 * Returns a profile array, apt for modification, by its name.
3686 * \param [in] pflName - the name of the profile of interest.
3687 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
3688 * \throw If there is no a profile named \a pflName.
3690 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
3692 return contentNotNull()->getProfile(pflName);
3696 * Returns a profile array, apt for modification, by its id.
3697 * \param [in] pflId - the id of the profile of interest.
3698 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
3699 * \throw If there is no a profile with id \a pflId.
3701 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
3703 return contentNotNull()->getProfileFromId(pflId);
3707 * Removes profiles given by their ids. No data is updated to track this removal.
3708 * \param [in] pflIds - a sequence of ids of the profiles to remove.
3710 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
3712 contentNotNull()->killProfileIds(pflIds);
3716 * Removes localizations given by their ids. No data is updated to track this removal.
3717 * \param [in] locIds - a sequence of ids of the localizations to remove.
3719 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
3721 contentNotNull()->killLocalizationIds(locIds);
3725 * Stores a profile array.
3726 * \param [in] pfl - the profile array to store.
3727 * \throw If the name of \a pfl is empty.
3728 * \throw If a profile with the same name as that of \a pfl already exists but contains
3731 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
3733 contentNotNull()->appendProfile(pfl);
3737 * Adds a new localization of Gauss points.
3738 * \param [in] locName - the name of the new localization.
3739 * \param [in] geoType - a geometrical type of the reference cell.
3740 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
3741 * must be \c nbOfNodesPerCell * \c dimOfType.
3742 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
3743 * must be _wg_.size() * \c dimOfType.
3744 * \param [in] w - the weights of Gauss points.
3745 * \throw If \a locName is empty.
3746 * \throw If a localization with the name \a locName already exists but is
3747 * different form the new one.
3749 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)
3751 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
3754 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
3756 MEDFileFieldGlobs *g(_globals);
3758 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
3762 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
3764 const MEDFileFieldGlobs *g(_globals);
3766 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
3770 //= MEDFileFieldNameScope
3772 MEDFileFieldNameScope::MEDFileFieldNameScope()
3776 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
3781 * Returns the name of \a this field.
3782 * \return std::string - a string containing the field name.
3784 std::string MEDFileFieldNameScope::getName() const
3790 * Sets name of \a this field
3791 * \param [in] name - the new field name.
3793 void MEDFileFieldNameScope::setName(const std::string& fieldName)
3798 std::string MEDFileFieldNameScope::getDtUnit() const
3803 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
3808 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
3811 _dt_unit=other._dt_unit;
3814 //= MEDFileAnyTypeField1TSWithoutSDA
3816 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
3818 _field_per_mesh.resize(other._field_per_mesh.size());
3820 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
3822 if((const MEDFileFieldPerMesh *)*it)
3823 _field_per_mesh[i]=(*it)->deepCpy(this);
3828 * Prints a string describing \a this field into a stream. This string is outputted
3829 * by \c print Python command.
3830 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
3831 * \param [in,out] oss - the out stream.
3832 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
3833 * info id printed, else, not.
3835 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
3837 std::string startOfLine(bkOffset,' ');
3838 oss << startOfLine << "Field ";
3840 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
3841 oss << "on one time Step ";
3843 oss << "(" << f1tsId << ") ";
3844 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
3845 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
3846 const DataArray *arr=getUndergroundDataArray();
3849 const std::vector<std::string> &comps=arr->getInfoOnComponents();
3852 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
3853 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
3854 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
3856 if(arr->isAllocated())
3858 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
3861 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
3865 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
3867 oss << startOfLine << "----------------------" << std::endl;
3868 if(!_field_per_mesh.empty())
3871 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
3873 const MEDFileFieldPerMesh *cur=(*it2);
3875 cur->simpleRepr(bkOffset,oss,i);
3877 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
3882 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
3884 oss << startOfLine << "----------------------" << std::endl;
3887 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
3889 const DataArray *arr(getUndergroundDataArray());
3891 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
3892 int nbOfCompo=arr->getNumberOfComponents();
3893 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
3894 for(int i=0;i<nbOfCompo;i++)
3897 std::vector<int> v(1,i);
3898 MEDCouplingAutoRefCountObjectPtr<DataArray> arr2=arr->keepSelectedComponents(v);
3899 ret[i]->setArray(arr2);
3904 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)
3908 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
3913 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
3914 * empty. Returns -1 if this in on nodes.
3915 * \return int - the dimension of \a this.
3917 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
3920 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3921 (*it)->getDimension(ret);
3926 * Returns the mesh name.
3927 * \return std::string - a string holding the mesh name.
3928 * \throw If \c _field_per_mesh.empty()
3930 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
3932 if(_field_per_mesh.empty())
3933 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
3934 return _field_per_mesh[0]->getMeshName();
3937 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
3939 std::string oldName(getMeshName());
3940 std::vector< std::pair<std::string,std::string> > v(1);
3941 v[0].first=oldName; v[0].second=newMeshName;
3945 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
3948 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
3950 MEDFileFieldPerMesh *cur(*it);
3952 ret=cur->changeMeshNames(modifTab) || ret;
3958 * Returns the number of iteration of the state of underlying mesh.
3959 * \return int - the iteration number.
3960 * \throw If \c _field_per_mesh.empty()
3962 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
3964 if(_field_per_mesh.empty())
3965 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
3966 return _field_per_mesh[0]->getMeshIteration();
3970 * Returns the order number of iteration of the state of underlying mesh.
3971 * \return int - the order number.
3972 * \throw If \c _field_per_mesh.empty()
3974 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
3976 if(_field_per_mesh.empty())
3977 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
3978 return _field_per_mesh[0]->getMeshOrder();
3982 * Checks if \a this field is tagged by a given iteration number and a given
3983 * iteration order number.
3984 * \param [in] iteration - the iteration number of interest.
3985 * \param [in] order - the iteration order number of interest.
3986 * \return bool - \c true if \a this->getIteration() == \a iteration &&
3987 * \a this->getOrder() == \a order.
3989 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
3991 return iteration==_iteration && order==_order;
3995 * Returns number of iteration and order number of iteration when
3996 * \a this field has been calculated.
3997 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4000 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4002 std::pair<int,int> p;
4008 * Returns number of iteration and order number of iteration when
4009 * \a this field has been calculated.
4010 * \param [in,out] p - a pair returning the iteration number and the iteration
4013 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4020 * Returns all types of spatial discretization of \a this field.
4021 * \param [in,out] types - a sequence of types of \a this field.
4023 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4025 std::set<TypeOfField> types2;
4026 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4028 (*it)->fillTypesOfFieldAvailable(types2);
4030 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4031 std::copy(types2.begin(),types2.end(),bi);
4035 * Returns all types of spatial discretization of \a this field.
4036 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4039 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4041 std::vector<TypeOfField> ret;
4042 fillTypesOfFieldAvailable(ret);
4046 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4048 std::vector<std::string> ret;
4049 std::set<std::string> ret2;
4050 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4052 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4053 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4054 if(ret2.find(*it2)==ret2.end())
4056 ret.push_back(*it2);
4063 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4065 std::vector<std::string> ret;
4066 std::set<std::string> ret2;
4067 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4069 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4070 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4071 if(ret2.find(*it2)==ret2.end())
4073 ret.push_back(*it2);
4080 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4082 std::vector<std::string> ret;
4083 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4085 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4086 ret.insert(ret.end(),tmp.begin(),tmp.end());
4091 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4093 std::vector<std::string> ret;
4094 std::set<std::string> ret2;
4095 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4097 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4098 ret.insert(ret.end(),tmp.begin(),tmp.end());
4103 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4105 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4106 (*it)->changePflsRefsNamesGen(mapOfModif);
4109 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4111 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4112 (*it)->changeLocsRefsNamesGen(mapOfModif);
4116 * Returns all attributes of parts of \a this field lying on a given mesh.
4117 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4118 * item of every of returned sequences refers to the _i_-th part of \a this field.
4119 * Thus all sequences returned by this method are of the same length equal to number
4120 * of different types of supporting entities.<br>
4121 * A field part can include sub-parts with several different spatial discretizations,
4122 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
4123 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4124 * of a nested sequence corresponds to a type of spatial discretization.<br>
4125 * This method allows for iteration over MEDFile DataStructure without any overhead.
4126 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4127 * for the case with only one underlying mesh. (Actually, the number of meshes is
4128 * not checked if \a mname == \c NULL).
4129 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4130 * a field part is returned.
4131 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4132 * This sequence is of the same length as \a types.
4133 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4134 * discretization. A profile name can be empty.
4135 * Length of this and of nested sequences is the same as that of \a typesF.
4136 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4137 * discretization. A localization name can be empty.
4138 * Length of this and of nested sequences is the same as that of \a typesF.
4139 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4140 * of ids of tuples within the data array, per each type of spatial
4141 * discretization within one mesh entity type.
4142 * Length of this and of nested sequences is the same as that of \a typesF.
4143 * \throw If no field is lying on \a mname.
4145 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
4149 meshId=getMeshIdFromMeshName(mname);
4151 if(_field_per_mesh.empty())
4152 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4153 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4157 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4158 * maximal absolute dimension and values returned via the out parameter \a levs are
4159 * dimensions relative to the maximal absolute dimension. <br>
4160 * This method is designed for MEDFileField1TS instances that have a discretization
4161 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS",
4162 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT",
4163 * \ref ParaMEDMEM::ON_GAUSS_NE "ON_GAUSS_NE".
4164 * Only these 3 discretizations will be taken into account here. If \a this is
4165 * \ref ParaMEDMEM::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4166 * This method is useful to make the link between the dimension of the underlying mesh
4167 * and the levels of \a this, because it is possible that the highest dimension of \a this
4168 * field is not equal to the dimension of the underlying mesh.
4170 * Let's consider the following case:
4171 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4172 * TETRA4, HEXA8, TRI3 and SEG2.
4173 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4174 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4176 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4177 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4178 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4179 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4180 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4181 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4183 * to retrieve the highest level of
4184 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4185 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4186 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4187 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4188 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4189 * for the case with only one underlying mesh. (Actually, the number of meshes is
4190 * not checked if \a mname == \c NULL).
4191 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4192 * absolute one. They are in decreasing order. This sequence is cleared before
4194 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4195 * \throw If no field is lying on \a mname.
4197 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4200 int meshId=getMeshIdFromMeshName(mname);
4201 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4202 std::vector< std::vector<TypeOfField> > typesF;
4203 std::vector< std::vector<std::string> > pfls, locs;
4204 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4206 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4207 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4208 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4210 st.erase(INTERP_KERNEL::NORM_ERROR);
4212 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4214 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4215 ret1.insert((int)cm.getDimension());
4217 int ret=*std::max_element(ret1.begin(),ret1.end());
4218 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4219 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4224 * \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.
4225 * \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.
4226 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4227 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4229 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4231 int mid=getMeshIdFromMeshName(mName);
4232 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4236 * \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.
4237 * \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.
4238 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4239 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4241 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4243 int mid=getMeshIdFromMeshName(mName);
4244 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4248 * \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.
4250 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4252 if(_field_per_mesh.empty())
4253 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4256 std::string mName2(mName);
4258 std::vector<std::string> msg;
4259 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4260 if(mName2==(*it)->getMeshName())
4263 msg.push_back((*it)->getMeshName());
4264 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4265 oss << "Possible meshes are : ";
4266 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4267 oss << "\"" << (*it2) << "\" ";
4268 throw INTERP_KERNEL::Exception(oss.str().c_str());
4271 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4274 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4275 std::string tmp(mesh->getName());
4277 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4278 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4280 for(;it!=_field_per_mesh.end();it++,i++)
4282 if((*it)->getMeshName()==tmp)
4285 int sz=_field_per_mesh.size();
4286 _field_per_mesh.resize(sz+1);
4287 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4291 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4292 MEDFileFieldGlobsReal& glob)
4295 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4297 MEDFileFieldPerMesh *fpm(*it);
4299 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4305 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4306 * splitting that leads to single spatial discretization of this.
4308 * \sa splitMultiDiscrPerGeoTypes
4310 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4312 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4313 std::vector< std::vector<TypeOfField> > typesF;
4314 std::vector< std::vector<std::string> > pfls,locs;
4315 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4316 std::set<TypeOfField> allEnt;
4317 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4318 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4319 allEnt.insert(*it2);
4320 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4321 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4322 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4324 std::vector< std::pair<int,int> > its;
4325 ret[i]=shallowCpy();
4326 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4327 ret[i]->updateData(newLgth,its);
4333 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4334 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4336 * \sa splitDiscretizations
4338 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4340 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4341 std::vector< std::vector<TypeOfField> > typesF;
4342 std::vector< std::vector<std::string> > pfls,locs;
4343 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4344 std::set<TypeOfField> allEnt;
4345 std::size_t nbOfMDPGT(0),ii(0);
4346 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4348 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4349 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4350 allEnt.insert(*it2);
4352 if(allEnt.size()!=1)
4353 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4355 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4358 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4359 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4362 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4363 for(std::size_t i=0;i<nbOfMDPGT;i++)
4365 std::vector< std::pair<int,int> > its;
4366 ret[i]=shallowCpy();
4367 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4368 ret[i]->updateData(newLgth,its);
4373 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4375 int globalCounter(0);
4376 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4377 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4378 return globalCounter;
4381 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4383 int globalCounter(0);
4384 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4385 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4386 return globalCounter;
4389 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4391 if(_nb_of_tuples_to_be_allocated>=0)
4393 _nb_of_tuples_to_be_allocated=newLgth;
4394 const DataArray *oldArr(getUndergroundDataArray());
4397 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4398 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4400 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4404 if(_nb_of_tuples_to_be_allocated==-1)
4406 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4408 const DataArray *oldArr(getUndergroundDataArray());
4409 if(!oldArr || !oldArr->isAllocated())
4410 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4411 MEDCouplingAutoRefCountObjectPtr<DataArray> newArr(createNewEmptyDataArrayInstance());
4412 newArr->alloc(newLgth,getNumberOfComponents());
4414 newArr->copyStringInfoFrom(*oldArr);
4416 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4418 if((*it).second<(*it).first)
4419 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4420 newArr->setContigPartOfSelectedValues2(pos,oldArr,(*it).first,(*it).second,1);
4421 pos+=(*it).second-(*it).first;
4426 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4429 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4431 if(_field_per_mesh.empty())
4432 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4433 if(_field_per_mesh.size()>1)
4434 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4435 _field_per_mesh[0]->copyOptionsFrom(opts);
4436 _field_per_mesh[0]->writeLL(fid,nasc);
4440 * 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.
4441 * If false is returned the memory allocation is not required.
4443 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4445 if(_nb_of_tuples_to_be_allocated>=0)
4447 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4448 _nb_of_tuples_to_be_allocated=-2;
4451 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4453 if(_nb_of_tuples_to_be_allocated==-1)
4454 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4455 if(_nb_of_tuples_to_be_allocated<-3)
4456 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4457 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4460 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4462 med_int numdt,numit;
4466 med_int meshnumdt,meshnumit;
4467 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4468 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4469 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4470 if(_iteration!=numdt || _order!=numit)
4471 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4472 _field_per_mesh.resize(nmesh);
4477 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4478 mm=ms->getMeshWithName(meshNameCpp);
4481 for(int i=0;i<nmesh;i++)
4482 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4483 _nb_of_tuples_to_be_allocated=0;
4484 for(int i=0;i<nmesh;i++)
4485 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4488 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4490 allocIfNecessaryTheArrayToReceiveDataFromFile();
4491 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4492 (*it)->loadBigArraysRecursively(fid,nasc);
4495 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4497 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4498 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4499 (*it)->loadBigArraysRecursively(fid,nasc);
4502 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
4504 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4505 loadBigArraysRecursively(fid,nasc);
4508 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4510 DataArray *thisArr(getUndergroundDataArray());
4511 if(thisArr && thisArr->isAllocated())
4513 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4514 thisArr->desallocate();
4518 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4520 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >);
4523 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4525 std::vector<const BigMemoryObject *> ret;
4526 if(getUndergroundDataArray())
4527 ret.push_back(getUndergroundDataArray());
4528 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4529 ret.push_back((const MEDFileFieldPerMesh *)*it);
4534 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4535 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4536 * "Sort By Type"), if not, an exception is thrown.
4537 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4538 * \param [in] arr - the array of values.
4539 * \param [in,out] glob - the global data where profiles and localization present in
4540 * \a field, if any, are added.
4541 * \throw If the name of \a field is empty.
4542 * \throw If the data array of \a field is not set.
4543 * \throw If \a this->_arr is already allocated but has different number of components
4545 * \throw If the underlying mesh of \a field has no name.
4546 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4548 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4550 const MEDCouplingMesh *mesh=field->getMesh();
4552 TypeOfField type=field->getTypeOfField();
4553 std::vector<DataArrayInt *> dummy;
4554 int start=copyTinyInfoFrom(field,arr);
4555 int pos=addNewEntryIfNecessary(mesh);
4558 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4559 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4562 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4566 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4567 * of a given mesh are used as the support of the given field (a real support is not used).
4568 * Elements of the given mesh must be sorted suitable for writing to MED file.
4569 * Order of underlying mesh entities of the given field specified by \a profile parameter
4570 * is not prescribed; this method permutes field values to have them sorted by element
4571 * type as required for writing to MED file. A new profile is added only if no equal
4572 * profile is missing.
4573 * \param [in] field - the field to add to \a this. The field double values are ignored.
4574 * \param [in] arrOfVals - the values of the field \a field used.
4575 * \param [in] mesh - the supporting mesh of \a field.
4576 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4577 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4578 * \param [in,out] glob - the global data where profiles and localization present in
4579 * \a field, if any, are added.
4580 * \throw If either \a field or \a mesh or \a profile has an empty name.
4581 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4582 * \throw If the data array of \a field is not set.
4583 * \throw If \a this->_arr is already allocated but has different number of components
4585 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4586 * \sa setFieldNoProfileSBT()
4588 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4591 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4592 if(!arrOfVals || !arrOfVals->isAllocated())
4593 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4594 TypeOfField type=field->getTypeOfField();
4595 std::vector<DataArrayInt *> idsInPflPerType;
4596 std::vector<DataArrayInt *> idsPerType;
4597 std::vector<int> code,code2;
4598 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4601 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4602 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4603 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4604 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4606 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2=field->clone(false);
4607 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4608 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4610 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4611 throw INTERP_KERNEL::Exception(oss.str().c_str());
4614 int start=copyTinyInfoFrom(field,arrOfVals);
4615 code2=m->getDistributionOfTypes();
4617 int pos=addNewEntryIfNecessary(m);
4618 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4622 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4623 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4624 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4625 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4626 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4627 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4629 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4630 throw INTERP_KERNEL::Exception(oss.str().c_str());
4632 int start=copyTinyInfoFrom(field,arrOfVals);
4633 int pos=addNewEntryIfNecessary(m);
4634 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
4639 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
4641 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
4643 if(_nb_of_tuples_to_be_allocated>=0)
4644 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 !");
4645 DataArray *arr(getOrCreateAndGetArray());
4646 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
4647 _nb_of_tuples_to_be_allocated=-3;
4651 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
4652 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
4653 * larger by the size of \a field. Returns an id of the first not filled
4654 * tuple of \a this->_arr.
4655 * \param [in] field - the field to copy the info on components and the name from.
4656 * \return int - the id of first not initialized tuple of \a this->_arr.
4657 * \throw If the name of \a field is empty.
4658 * \throw If the data array of \a field is not set.
4659 * \throw If \a this->_arr is already allocated but has different number of components
4662 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
4665 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
4666 std::string name(field->getName());
4667 setName(name.c_str());
4668 setDtUnit(field->getTimeUnit());
4670 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
4672 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
4673 if(!arr->isAllocated())
4674 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
4675 _dt=field->getTime(_iteration,_order);
4676 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
4677 if(!getOrCreateAndGetArray()->isAllocated())
4679 allocNotFromFile(arr->getNumberOfTuples());
4684 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
4685 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
4686 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
4687 _nb_of_tuples_to_be_allocated=-3;
4688 return oldNbOfTuples;
4693 * Returns number of components in \a this field
4694 * \return int - the number of components.
4696 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
4698 return getOrCreateAndGetArray()->getNumberOfComponents();
4702 * Change info on components in \a this.
4703 * \throw If size of \a infos is not equal to the number of components already in \a this.
4705 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
4707 DataArray *arr=getOrCreateAndGetArray();
4708 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
4712 * Returns info on components of \a this field.
4713 * \return const std::vector<std::string>& - a sequence of strings each being an
4714 * information on _i_-th component.
4716 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
4718 const DataArray *arr=getOrCreateAndGetArray();
4719 return arr->getInfoOnComponents();
4723 * Returns a mutable info on components of \a this field.
4724 * \return std::vector<std::string>& - a sequence of strings each being an
4725 * information on _i_-th component.
4727 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
4729 DataArray *arr=getOrCreateAndGetArray();
4730 return arr->getInfoOnComponents();
4733 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
4735 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4737 const MEDFileFieldPerMesh *fpm(*it);
4740 if(fpm->presenceOfMultiDiscPerGeoType())
4747 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4748 * \param [in] type - a spatial discretization of the new field.
4749 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4750 * \param [in] mName - a name of the supporting mesh.
4751 * \param [in] renumPol - specifies how to permute values of the result field according to
4752 * the optional numbers of cells and nodes, if any. The valid values are
4753 * - 0 - do not permute.
4754 * - 1 - permute cells.
4755 * - 2 - permute nodes.
4756 * - 3 - permute cells and nodes.
4758 * \param [in] glob - the global data storing profiles and localization.
4759 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4760 * caller is to delete this field using decrRef() as it is no more needed.
4761 * \throw If the MED file is not readable.
4762 * \throw If there is no mesh named \a mName in the MED file.
4763 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4764 * \throw If no field of \a this is lying on the mesh \a mName.
4765 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4767 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4769 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4771 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4773 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4774 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4778 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4779 * \param [in] type - a spatial discretization of the new field.
4780 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4781 * \param [in] renumPol - specifies how to permute values of the result field according to
4782 * the optional numbers of cells and nodes, if any. The valid values are
4783 * - 0 - do not permute.
4784 * - 1 - permute cells.
4785 * - 2 - permute nodes.
4786 * - 3 - permute cells and nodes.
4788 * \param [in] glob - the global data storing profiles and localization.
4789 * \param [in] mesh - the supporting mesh.
4790 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4791 * caller is to delete this field using decrRef() as it is no more needed.
4792 * \throw If the MED file is not readable.
4793 * \throw If no field of \a this is lying on \a mesh.
4794 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4795 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4797 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4799 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax,false);
4800 const DataArrayInt *d=mesh->getNumberFieldAtLevel(meshDimRelToMax);
4801 const DataArrayInt *e=mesh->getNumberFieldAtLevel(1);
4802 if(meshDimRelToMax==1)
4803 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
4804 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
4808 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
4810 * \param [in] type - a spatial discretization of the new field.
4811 * \param [in] mName - a name of the supporting mesh.
4812 * \param [in] renumPol - specifies how to permute values of the result field according to
4813 * the optional numbers of cells and nodes, if any. The valid values are
4814 * - 0 - do not permute.
4815 * - 1 - permute cells.
4816 * - 2 - permute nodes.
4817 * - 3 - permute cells and nodes.
4819 * \param [in] glob - the global data storing profiles and localization.
4820 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4821 * caller is to delete this field using decrRef() as it is no more needed.
4822 * \throw If the MED file is not readable.
4823 * \throw If there is no mesh named \a mName in the MED file.
4824 * \throw If there are no mesh entities in the mesh.
4825 * \throw If no field values of the given \a type are available.
4827 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4829 MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
4831 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
4833 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
4834 int absDim=getDimension();
4835 int meshDimRelToMax=absDim-mm->getMeshDimension();
4836 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
4840 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
4841 * \param [in] type - a spatial discretization of the new field.
4842 * \param [in] renumPol - specifies how to permute values of the result field according to
4843 * the optional numbers of cells and nodes, if any. The valid values are
4844 * - 0 - do not permute.
4845 * - 1 - permute cells.
4846 * - 2 - permute nodes.
4847 * - 3 - permute cells and nodes.
4849 * \param [in] glob - the global data storing profiles and localization.
4850 * \param [in] mesh - the supporting mesh.
4851 * \param [in] cellRenum - the cell numbers array used for permutation of the result
4852 * field according to \a renumPol.
4853 * \param [in] nodeRenum - the node numbers array used for permutation of the result
4854 * field according to \a renumPol.
4855 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
4856 * caller is to delete this field using decrRef() as it is no more needed.
4857 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
4858 * \throw If no field of \a this is lying on \a mesh.
4859 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
4861 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
4863 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
4864 int meshId=getMeshIdFromMeshName(mesh->getName());
4866 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
4871 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4878 throw INTERP_KERNEL::Exception(msg1);
4879 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4882 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
4884 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4885 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
4886 throw INTERP_KERNEL::Exception(oss.str().c_str());
4888 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
4889 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
4890 std::vector<DataArray *> arrOut2(1,arrOut);
4891 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
4892 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
4893 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
4900 //no need to test _field_per_mesh.empty() because geMeshName has already done it
4902 throw INTERP_KERNEL::Exception(msg1);
4905 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
4907 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
4908 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
4909 throw INTERP_KERNEL::Exception(oss.str().c_str());
4911 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
4912 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
4913 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
4914 ret->renumberNodes(nodeRenumSafe->getConstPointer());
4919 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
4924 * Returns values and a profile of the field of a given type lying on a given support.
4925 * \param [in] type - a spatial discretization of the field.
4926 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
4927 * \param [in] mesh - the supporting mesh.
4928 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
4929 * field of interest lies on. If the field lies on all entities of the given
4930 * dimension, all ids in \a pfl are zero. The caller is to delete this array
4931 * using decrRef() as it is no more needed.
4932 * \param [in] glob - the global data storing profiles and localization.
4933 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
4934 * field. The caller is to delete this array using decrRef() as it is no more needed.
4935 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4936 * \throw If no field of \a this is lying on \a mesh.
4937 * \throw If no field values of the given \a type are available.
4939 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
4941 MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m=mesh->getGenMeshAtLevel(meshDimRelToMax);
4942 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
4943 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
4944 ret->setName(nasc.getName().c_str());
4948 //= MEDFileField1TSWithoutSDA
4951 * Throws if a given value is not a valid (non-extended) relative dimension.
4952 * \param [in] meshDimRelToMax - the relative dimension value.
4953 * \throw If \a meshDimRelToMax > 0.
4955 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
4957 if(meshDimRelToMax>0)
4958 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
4962 * Checks if elements of a given mesh are in the order suitable for writing
4963 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
4964 * vector describing types of elements and their number.
4965 * \param [in] mesh - the mesh to check.
4966 * \return std::vector<int> - a vector holding for each element type (1) item of
4967 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
4968 * These values are in full-interlace mode.
4969 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4971 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
4974 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
4975 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
4976 int nbOfTypes=geoTypes.size();
4977 std::vector<int> code(3*nbOfTypes);
4978 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr1=DataArrayInt::New();
4979 arr1->alloc(nbOfTypes,1);
4980 int *arrPtr=arr1->getPointer();
4981 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
4982 for(int i=0;i<nbOfTypes;i++,it++)
4983 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
4984 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
4985 const int *arrPtr2=arr2->getConstPointer();
4987 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
4990 int nbCells=mesh->getNumberOfCellsWithType(*it);
4991 code[3*pos]=(int)(*it);
4992 code[3*pos+1]=nbCells;
4993 code[3*pos+2]=-1;//no profiles
4995 std::vector<const DataArrayInt *> idsPerType;//no profiles
4996 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5000 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5005 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5007 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5011 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5012 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5013 * item of every of returned sequences refers to the _i_-th part of \a this field.
5014 * Thus all sequences returned by this method are of the same length equal to number
5015 * of different types of supporting entities.<br>
5016 * A field part can include sub-parts with several different spatial discretizations,
5017 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT"
5018 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5019 * of a nested sequence corresponds to a type of spatial discretization.<br>
5020 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5021 * The overhead is due to selecting values into new instances of DataArrayDouble.
5022 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5023 * for the case with only one underlying mesh. (Actually, the number of meshes is
5024 * not checked if \a mname == \c NULL).
5025 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5026 * a field part is returned.
5027 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5028 * A field part can include sub-parts with several different spatial discretizations,
5029 * \ref ParaMEDMEM::ON_CELLS "ON_CELLS" and
5030 * \ref ParaMEDMEM::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5031 * This sequence is of the same length as \a types.
5032 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5033 * discretization. A profile name can be empty.
5034 * Length of this and of nested sequences is the same as that of \a typesF.
5035 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5036 * discretization. A localization name can be empty.
5037 * Length of this and of nested sequences is the same as that of \a typesF.
5038 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5039 * per each type of spatial discretization within one mesh entity type.
5040 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5041 * Length of this and of nested sequences is the same as that of \a typesF.
5042 * \throw If no field is lying on \a mname.
5044 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
5048 meshId=getMeshIdFromMeshName(mname);
5050 if(_field_per_mesh.empty())
5051 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5052 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5053 int nbOfRet=ret0.size();
5054 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5055 for(int i=0;i<nbOfRet;i++)
5057 const std::vector< std::pair<int,int> >& p=ret0[i];
5058 int nbOfRet1=p.size();
5059 ret[i].resize(nbOfRet1);
5060 for(int j=0;j<nbOfRet1;j++)
5062 DataArrayDouble *tmp=_arr->selectByTupleId2(p[j].first,p[j].second,1);
5070 * Returns a pointer to the underground DataArrayDouble instance. So the
5071 * caller should not decrRef() it. This method allows for a direct access to the field
5072 * values. This method is quite unusable if there is more than a nodal field or a cell
5073 * field on single geometric cell type.
5074 * \return DataArrayDouble * - the pointer to the field values array.
5076 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
5078 const DataArrayDouble *ret=_arr;
5080 return const_cast<DataArrayDouble *>(ret);
5085 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5090 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5092 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5093 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5094 ret->deepCpyLeavesFrom(*this);
5095 const DataArrayDouble *arr(_arr);
5098 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2(arr->convertToIntArr());
5099 ret->setArray(arr2);
5105 * Returns a pointer to the underground DataArrayDouble instance. So the
5106 * caller should not decrRef() it. This method allows for a direct access to the field
5107 * values. This method is quite unusable if there is more than a nodal field or a cell
5108 * field on single geometric cell type.
5109 * \return DataArrayDouble * - the pointer to the field values array.
5111 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
5113 return getUndergroundDataArrayDouble();
5117 * Returns a pointer to the underground DataArrayDouble instance and a
5118 * sequence describing parameters of a support of each part of \a this field. The
5119 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5120 * direct access to the field values. This method is intended for the field lying on one
5122 * \param [in,out] entries - the sequence describing parameters of a support of each
5123 * part of \a this field. Each item of this sequence consists of two parts. The
5124 * first part describes a type of mesh entity and an id of discretization of a
5125 * current field part. The second part describes a range of values [begin,end)
5126 * within the returned array relating to the current field part.
5127 * \return DataArrayDouble * - the pointer to the field values array.
5128 * \throw If the number of underlying meshes is not equal to 1.
5129 * \throw If no field values are available.
5130 * \sa getUndergroundDataArray()
5132 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5134 if(_field_per_mesh.size()!=1)
5135 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5136 if(_field_per_mesh[0]==0)
5137 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5138 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5139 return getUndergroundDataArrayDouble();
5143 * Returns a pointer to the underground DataArrayDouble instance and a
5144 * sequence describing parameters of a support of each part of \a this field. The
5145 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5146 * direct access to the field values. This method is intended for the field lying on one
5148 * \param [in,out] entries - the sequence describing parameters of a support of each
5149 * part of \a this field. Each item of this sequence consists of two parts. The
5150 * first part describes a type of mesh entity and an id of discretization of a
5151 * current field part. The second part describes a range of values [begin,end)
5152 * within the returned array relating to the current field part.
5153 * \return DataArrayDouble * - the pointer to the field values array.
5154 * \throw If the number of underlying meshes is not equal to 1.
5155 * \throw If no field values are available.
5156 * \sa getUndergroundDataArray()
5158 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5160 return getUndergroundDataArrayDoubleExt(entries);
5163 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5165 DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
5166 arr->setInfoAndChangeNbOfCompo(infos);
5169 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5173 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5175 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5176 ret->deepCpyLeavesFrom(*this);
5180 MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const
5182 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret=static_cast<MEDFileField1TSWithoutSDA *>(shallowCpy());
5183 if((const DataArrayDouble *)_arr)
5184 ret->_arr=_arr->deepCpy();
5188 void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
5192 _nb_of_tuples_to_be_allocated=-1;
5196 DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
5198 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
5200 _nb_of_tuples_to_be_allocated=-3;
5205 DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5207 return DataArrayDouble::New();
5210 DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
5212 DataArrayDouble *ret=_arr;
5215 _arr=DataArrayDouble::New();
5219 DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
5221 return getOrCreateAndGetArrayDouble();
5224 const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
5226 const DataArrayDouble *ret=_arr;
5229 DataArrayDouble *ret2=DataArrayDouble::New();
5230 const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
5234 const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
5236 return getOrCreateAndGetArrayDouble();
5239 //= MEDFileIntField1TSWithoutSDA
5241 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5243 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5246 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
5250 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5251 const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
5253 DataArrayInt *arr(getOrCreateAndGetArrayInt());
5254 arr->setInfoAndChangeNbOfCompo(infos);
5257 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5262 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5264 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5265 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5266 ret->deepCpyLeavesFrom(*this);
5267 const DataArrayInt *arr(_arr);
5270 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr2(arr->convertToDblArr());
5271 ret->setArray(arr2);
5277 * Returns a pointer to the underground DataArrayInt instance. So the
5278 * caller should not decrRef() it. This method allows for a direct access to the field
5279 * values. This method is quite unusable if there is more than a nodal field or a cell
5280 * field on single geometric cell type.
5281 * \return DataArrayInt * - the pointer to the field values array.
5283 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
5285 return getUndergroundDataArrayInt();
5289 * Returns a pointer to the underground DataArrayInt instance. So the
5290 * caller should not decrRef() it. This method allows for a direct access to the field
5291 * values. This method is quite unusable if there is more than a nodal field or a cell
5292 * field on single geometric cell type.
5293 * \return DataArrayInt * - the pointer to the field values array.
5295 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
5297 const DataArrayInt *ret=_arr;
5299 return const_cast<DataArrayInt *>(ret);
5305 * Returns a pointer to the underground DataArrayInt instance and a
5306 * sequence describing parameters of a support of each part of \a this field. The
5307 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5308 * direct access to the field values. This method is intended for the field lying on one
5310 * \param [in,out] entries - the sequence describing parameters of a support of each
5311 * part of \a this field. Each item of this sequence consists of two parts. The
5312 * first part describes a type of mesh entity and an id of discretization of a
5313 * current field part. The second part describes a range of values [begin,end)
5314 * within the returned array relating to the current field part.
5315 * \return DataArrayInt * - the pointer to the field values array.
5316 * \throw If the number of underlying meshes is not equal to 1.
5317 * \throw If no field values are available.
5318 * \sa getUndergroundDataArray()
5320 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5322 return getUndergroundDataArrayIntExt(entries);
5326 * Returns a pointer to the underground DataArrayInt instance and a
5327 * sequence describing parameters of a support of each part of \a this field. The
5328 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5329 * direct access to the field values. This method is intended for the field lying on one
5331 * \param [in,out] entries - the sequence describing parameters of a support of each
5332 * part of \a this field. Each item of this sequence consists of two parts. The
5333 * first part describes a type of mesh entity and an id of discretization of a
5334 * current field part. The second part describes a range of values [begin,end)
5335 * within the returned array relating to the current field part.
5336 * \return DataArrayInt * - the pointer to the field values array.
5337 * \throw If the number of underlying meshes is not equal to 1.
5338 * \throw If no field values are available.
5339 * \sa getUndergroundDataArray()
5341 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5343 if(_field_per_mesh.size()!=1)
5344 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5345 if(_field_per_mesh[0]==0)
5346 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5347 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5348 return getUndergroundDataArrayInt();
5351 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5353 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5354 ret->deepCpyLeavesFrom(*this);
5358 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const
5360 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> ret=static_cast<MEDFileIntField1TSWithoutSDA *>(shallowCpy());
5361 if((const DataArrayInt *)_arr)
5362 ret->_arr=_arr->deepCpy();
5366 void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
5370 _nb_of_tuples_to_be_allocated=-1;
5374 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
5376 throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
5378 _nb_of_tuples_to_be_allocated=-3;
5383 DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
5385 return DataArrayInt::New();
5388 DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
5390 DataArrayInt *ret=_arr;
5393 _arr=DataArrayInt::New();
5397 DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
5399 return getOrCreateAndGetArrayInt();
5402 const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
5404 const DataArrayInt *ret=_arr;
5407 DataArrayInt *ret2=DataArrayInt::New();
5408 const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
5412 const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
5414 return getOrCreateAndGetArrayInt();
5417 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5421 //= MEDFileAnyTypeField1TS
5423 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5425 med_field_type typcha;
5427 std::vector<std::string> infos;
5428 std::string dtunit,fieldName;
5429 LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
5430 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5435 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5440 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5445 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] !";
5446 throw INTERP_KERNEL::Exception(oss.str().c_str());
5449 ret->setDtUnit(dtunit.c_str());
5450 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5452 med_int numdt,numit;
5454 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5455 ret->setTime(numdt,numit,dt);
5458 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5460 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5464 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
5465 try:MEDFileFieldGlobsReal(fileName)
5467 MEDFileUtilities::CheckFileForRead(fileName);
5468 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5469 _content=BuildContentFrom(fid,fileName,loadAll,ms);
5472 catch(INTERP_KERNEL::Exception& e)
5477 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5479 med_field_type typcha;
5480 std::vector<std::string> infos;
5483 int nbSteps=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5484 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5489 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5494 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5499 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] !";
5500 throw INTERP_KERNEL::Exception(oss.str().c_str());
5503 ret->setDtUnit(dtunit.c_str());
5504 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5508 std::ostringstream oss; oss << "MEDFileField1TS(fileName,fieldName) : file \'" << fileName << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5509 throw INTERP_KERNEL::Exception(oss.str().c_str());
5512 med_int numdt,numit;
5514 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5515 ret->setTime(numdt,numit,dt);
5518 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5520 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5524 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5525 try:MEDFileFieldGlobsReal(fileName)
5527 MEDFileUtilities::CheckFileForRead(fileName);
5528 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5529 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms);
5532 catch(INTERP_KERNEL::Exception& e)
5537 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName)
5540 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5541 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5543 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New();
5544 ret->setFileName(fileName);
5545 ret->_content=c; c->incrRef();
5548 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5550 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New();
5551 ret->setFileName(fileName);
5552 ret->_content=c; c->incrRef();
5555 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5558 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5560 MEDFileUtilities::CheckFileForRead(fileName);
5561 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5562 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
5563 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5564 ret->loadGlobals(fid);
5568 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5570 MEDFileUtilities::CheckFileForRead(fileName);
5571 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5572 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,loadAll,0);
5573 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5574 ret->loadGlobals(fid);
5578 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5580 MEDFileUtilities::CheckFileForRead(fileName);
5581 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5582 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> c=BuildContentFrom(fid,fileName,fieldName,iteration,order,loadAll,0);
5583 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=BuildNewInstanceFromContent(c,fileName);
5584 ret->loadGlobals(fid);
5588 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5590 med_field_type typcha;
5591 std::vector<std::string> infos;
5594 int nbOfStep2=LocateField(fid,fileName,fieldName,iii,typcha,infos,dtunit);
5595 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ret;
5600 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5605 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5610 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] !";
5611 throw INTERP_KERNEL::Exception(oss.str().c_str());
5614 ret->setDtUnit(dtunit.c_str());
5615 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5618 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5619 for(int i=0;i<nbOfStep2 && !found;i++)
5621 med_int numdt,numit;
5623 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5624 if(numdt==iteration && numit==order)
5630 dtits[i]=std::pair<int,int>(numdt,numit);
5634 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << fileName << "' ! Available iterations are : ";
5635 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5636 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5637 throw INTERP_KERNEL::Exception(oss.str().c_str());
5640 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5642 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5646 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5647 try:MEDFileFieldGlobsReal(fileName)
5649 MEDFileUtilities::CheckFileForRead(fileName);
5650 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
5651 _content=BuildContentFrom(fid,fileName.c_str(),fieldName.c_str(),iteration,order,loadAll,ms);
5654 catch(INTERP_KERNEL::Exception& e)
5660 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5661 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5663 * \warning this is a shallow copy constructor
5665 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5667 if(!shallowCopyOfContent)
5669 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5670 otherPtr->incrRef();
5671 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5675 _content=other.shallowCpy();
5679 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)
5683 int nbFields=MEDnField(fid);
5684 if(fieldIdCFormat>=nbFields)
5686 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << fileName << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5687 throw INTERP_KERNEL::Exception(oss.str().c_str());
5690 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5691 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5692 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5693 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5694 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5695 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5698 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5699 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5700 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5701 infos.clear(); infos.resize(ncomp);
5702 for(int j=0;j<ncomp;j++)
5703 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
5708 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
5711 * \return in case of success the number of time steps available for the field with name \a fieldName.
5713 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)
5715 int nbFields=MEDnField(fid);
5717 std::vector<std::string> fns(nbFields);
5719 for(int i=0;i<nbFields && !found;i++)
5722 nbOfStep2=LocateField2(fid,fileName,i,false,tmp,typcha,infos,dtunitOut);
5724 found=(tmp==fieldName);
5730 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << fileName << "' ! Available fields are : ";
5731 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
5732 oss << "\"" << *it << "\" ";
5733 throw INTERP_KERNEL::Exception(oss.str().c_str());
5739 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5740 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5741 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5742 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5743 * to keep a valid instance.
5744 * 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.
5745 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
5746 * 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.
5748 * \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.
5749 * \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.
5750 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5751 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5752 * \param [in] newLocName is the new localization name.
5753 * \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.
5754 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
5756 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
5758 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5759 std::string oldPflName=disc->getProfile();
5760 std::vector<std::string> vv=getPflsReallyUsedMulti();
5761 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
5762 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
5764 disc->setProfile(newPflName);
5765 DataArrayInt *pfl=getProfile(oldPflName.c_str());
5766 pfl->setName(newPflName);
5770 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
5771 throw INTERP_KERNEL::Exception(oss.str().c_str());
5776 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
5777 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
5778 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
5779 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
5780 * to keep a valid instance.
5781 * 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.
5782 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
5783 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
5784 * 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.
5786 * \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.
5787 * \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.
5788 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
5789 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
5790 * \param [in] newLocName is the new localization name.
5791 * \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.
5792 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
5794 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
5796 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
5797 std::string oldLocName=disc->getLocalization();
5798 std::vector<std::string> vv=getLocsReallyUsedMulti();
5799 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
5800 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
5802 disc->setLocalization(newLocName);
5803 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
5804 loc.setName(newLocName);
5808 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
5809 throw INTERP_KERNEL::Exception(oss.str().c_str());
5813 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
5815 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5817 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
5821 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
5823 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
5825 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
5830 * Writes \a this field into a MED file specified by its name.
5831 * \param [in] fileName - the MED file name.
5832 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
5833 * - 2 - erase; an existing file is removed.
5834 * - 1 - append; same data should not be present in an existing file.
5835 * - 0 - overwrite; same data present in an existing file is overwritten.
5836 * \throw If the field name is not set.
5837 * \throw If no field data is set.
5838 * \throw If \a mode == 1 and the same data is present in an existing file.
5840 void MEDFileAnyTypeField1TS::write(const std::string& fileName, int mode) const
5842 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
5843 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
5848 * This method alloc the arrays and load potentially huge arrays contained in this field.
5849 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
5850 * This method can be also called to refresh or reinit values from a file.
5852 * \throw If the fileName is not set or points to a non readable MED file.
5853 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5855 void MEDFileAnyTypeField1TS::loadArrays()
5857 if(getFileName().empty())
5858 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
5859 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5860 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
5864 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
5865 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
5866 * this method does not throw if \a this does not come from file read.
5868 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
5870 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
5872 if(!getFileName().empty())
5874 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
5875 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
5880 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
5881 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
5882 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
5884 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
5886 void MEDFileAnyTypeField1TS::unloadArrays()
5888 contentNotNullBase()->unloadArrays();
5892 * 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.
5893 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
5894 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
5896 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
5898 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
5900 if(!getFileName().empty())
5901 contentNotNullBase()->unloadArrays();
5904 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
5906 int nbComp=getNumberOfComponents();
5907 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5908 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
5909 for(int i=0;i<nbComp;i++)
5911 std::string info=getInfo()[i];
5913 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
5914 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
5915 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
5917 if(getName().empty())
5918 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
5919 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
5920 writeGlobals(fid,*this);
5921 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
5924 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
5926 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
5929 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
5931 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
5932 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
5937 * Returns a string describing \a this field. This string is outputted
5938 * by \c print Python command.
5940 std::string MEDFileAnyTypeField1TS::simpleRepr() const
5942 std::ostringstream oss;
5943 contentNotNullBase()->simpleRepr(0,oss,-1);
5944 simpleReprGlobs(oss);
5949 * This method returns all profiles whose name is non empty used.
5950 * \b WARNING If profile is used several times it will be reported \b only \b once.
5951 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
5953 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
5955 return contentNotNullBase()->getPflsReallyUsed2();
5959 * This method returns all localizations whose name is non empty used.
5960 * \b WARNING If localization is used several times it will be reported \b only \b once.
5962 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
5964 return contentNotNullBase()->getLocsReallyUsed2();
5968 * This method returns all profiles whose name is non empty used.
5969 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
5971 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
5973 return contentNotNullBase()->getPflsReallyUsedMulti2();
5977 * This method returns all localizations whose name is non empty used.
5978 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
5980 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
5982 return contentNotNullBase()->getLocsReallyUsedMulti2();
5985 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5987 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
5990 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
5992 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
5995 int MEDFileAnyTypeField1TS::getDimension() const
5997 return contentNotNullBase()->getDimension();
6000 int MEDFileAnyTypeField1TS::getIteration() const
6002 return contentNotNullBase()->getIteration();
6005 int MEDFileAnyTypeField1TS::getOrder() const
6007 return contentNotNullBase()->getOrder();
6010 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6012 return contentNotNullBase()->getTime(iteration,order);
6015 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6017 contentNotNullBase()->setTime(iteration,order,val);
6020 std::string MEDFileAnyTypeField1TS::getName() const
6022 return contentNotNullBase()->getName();
6025 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6027 contentNotNullBase()->setName(name);
6030 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6032 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6035 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6037 return contentNotNullBase()->getDtUnit();
6040 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6042 contentNotNullBase()->setDtUnit(dtUnit);
6045 std::string MEDFileAnyTypeField1TS::getMeshName() const
6047 return contentNotNullBase()->getMeshName();
6050 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6052 contentNotNullBase()->setMeshName(newMeshName);
6055 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6057 return contentNotNullBase()->changeMeshNames(modifTab);
6060 int MEDFileAnyTypeField1TS::getMeshIteration() const
6062 return contentNotNullBase()->getMeshIteration();
6065 int MEDFileAnyTypeField1TS::getMeshOrder() const
6067 return contentNotNullBase()->getMeshOrder();
6070 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6072 return contentNotNullBase()->getNumberOfComponents();
6075 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6077 return contentNotNullBase()->isDealingTS(iteration,order);
6080 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6082 return contentNotNullBase()->getDtIt();
6085 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6087 contentNotNullBase()->fillIteration(p);
6090 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6092 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6095 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6097 contentNotNullBase()->setInfo(infos);
6100 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6102 return contentNotNullBase()->getInfo();
6104 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6106 return contentNotNullBase()->getInfo();
6109 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6111 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6114 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6116 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6119 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6121 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6124 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6126 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6129 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6131 return contentNotNullBase()->getTypesOfFieldAvailable();
6134 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,
6135 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6137 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6141 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6142 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6143 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6145 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6147 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6149 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6150 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6151 std::size_t sz(contentsSplit.size());
6152 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6153 for(std::size_t i=0;i<sz;i++)
6155 ret[i]=shallowCpy();
6156 ret[i]->_content=contentsSplit[i];
6162 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6163 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6165 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6167 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6169 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6170 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6171 std::size_t sz(contentsSplit.size());
6172 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6173 for(std::size_t i=0;i<sz;i++)
6175 ret[i]=shallowCpy();
6176 ret[i]->_content=contentsSplit[i];
6182 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6183 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6185 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6187 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6189 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6190 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6191 std::size_t sz(contentsSplit.size());
6192 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > ret(sz);
6193 for(std::size_t i=0;i<sz;i++)
6195 ret[i]=shallowCpy();
6196 ret[i]->_content=contentsSplit[i];
6201 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCpy() const
6203 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> ret=shallowCpy();
6204 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6205 ret->_content=_content->deepCpy();
6206 ret->deepCpyGlobs(*this);
6210 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6212 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6218 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6219 * the first field that has been read from a specified MED file.
6220 * \param [in] fileName - the name of the MED file to read.
6221 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6222 * is to delete this field using decrRef() as it is no more needed.
6223 * \throw If reading the file fails.
6225 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6227 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,loadAll,0));
6228 ret->contentNotNull();
6233 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6234 * a given field that has been read from a specified MED file.
6235 * \param [in] fileName - the name of the MED file to read.
6236 * \param [in] fieldName - the name of the field to read.
6237 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6238 * is to delete this field using decrRef() as it is no more needed.
6239 * \throw If reading the file fails.
6240 * \throw If there is no field named \a fieldName in the file.
6242 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6244 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,loadAll,0));
6245 ret->contentNotNull();
6250 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6251 * a given field that has been read from a specified MED file.
6252 * \param [in] fileName - the name of the MED file to read.
6253 * \param [in] fieldName - the name of the field to read.
6254 * \param [in] iteration - the iteration number of a required time step.
6255 * \param [in] order - the iteration order number of required time step.
6256 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6257 * is to delete this field using decrRef() as it is no more needed.
6258 * \throw If reading the file fails.
6259 * \throw If there is no field named \a fieldName in the file.
6260 * \throw If the required time step is missing from the file.
6262 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6264 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret(new MEDFileField1TS(fileName,fieldName,iteration,order,loadAll,0));
6265 ret->contentNotNull();
6270 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6271 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6273 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6274 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6275 * \warning this is a shallow copy constructor
6276 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6277 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6278 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6279 * is to delete this field using decrRef() as it is no more needed.
6281 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6283 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
6284 ret->contentNotNull();
6289 * Returns a new empty instance of MEDFileField1TS.
6290 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6291 * is to delete this field using decrRef() as it is no more needed.
6293 MEDFileField1TS *MEDFileField1TS::New()
6295 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=new MEDFileField1TS;
6296 ret->contentNotNull();
6301 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6302 * following the given input policy.
6304 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6305 * By default (true) the globals are deeply copied.
6306 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6308 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6310 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret;
6311 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6314 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6316 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6317 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6318 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc,getFileName()));
6321 ret=MEDFileIntField1TS::New();
6323 ret->deepCpyGlobs(*this);
6325 ret->shallowCpyGlobs(*this);
6329 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6331 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6333 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6334 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6336 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 !");
6340 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6342 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6344 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6345 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6347 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 !");
6351 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6354 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6355 if(!((DataArray*)arr))
6356 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6357 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6359 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6360 f->setArray(arrOutC);
6363 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6365 if(!((DataArray*)arr))
6366 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6367 DataArrayDouble *arrOutC=dynamic_cast<DataArrayDouble *>((DataArray*)arr);
6369 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6374 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6375 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6378 catch(INTERP_KERNEL::Exception& e)
6381 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6382 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6385 catch(INTERP_KERNEL::Exception& e)
6388 MEDFileField1TS::MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6389 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6392 catch(INTERP_KERNEL::Exception& e)
6396 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6397 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6399 * \warning this is a shallow copy constructor
6401 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6402 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6405 catch(INTERP_KERNEL::Exception& e)
6408 MEDFileField1TS::MEDFileField1TS()
6410 _content=new MEDFileField1TSWithoutSDA;
6414 * Returns a new MEDCouplingFieldDouble of a given type lying on
6415 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6416 * has not been constructed via file reading, an exception is thrown.
6417 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6418 * \param [in] type - a spatial discretization of interest.
6419 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6420 * \param [in] renumPol - specifies how to permute values of the result field according to
6421 * the optional numbers of cells and nodes, if any. The valid values are
6422 * - 0 - do not permute.
6423 * - 1 - permute cells.
6424 * - 2 - permute nodes.
6425 * - 3 - permute cells and nodes.
6427 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6428 * caller is to delete this field using decrRef() as it is no more needed.
6429 * \throw If \a this field has not been constructed via file reading.
6430 * \throw If the MED file is not readable.
6431 * \throw If there is no mesh in the MED file.
6432 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6433 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6434 * \sa getFieldOnMeshAtLevel()
6436 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6438 if(getFileName().empty())
6439 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6440 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6441 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull());
6442 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6447 * Returns a new MEDCouplingFieldDouble of a given type lying on
6448 * the top level cells of the first mesh in MED file. If \a this field
6449 * has not been constructed via file reading, an exception is thrown.
6450 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6451 * \param [in] type - a spatial discretization of interest.
6452 * \param [in] renumPol - specifies how to permute values of the result field according to
6453 * the optional numbers of cells and nodes, if any. The valid values are
6454 * - 0 - do not permute.
6455 * - 1 - permute cells.
6456 * - 2 - permute nodes.
6457 * - 3 - permute cells and nodes.
6459 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6460 * caller is to delete this field using decrRef() as it is no more needed.
6461 * \throw If \a this field has not been constructed via file reading.
6462 * \throw If the MED file is not readable.
6463 * \throw If there is no mesh in the MED file.
6464 * \throw If no field values of the given \a type.
6465 * \throw If no field values lying on the top level support.
6466 * \sa getFieldAtLevel()
6468 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6470 if(getFileName().empty())
6471 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6472 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6473 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull());
6474 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6479 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6480 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6481 * \param [in] type - a spatial discretization of the new field.
6482 * \param [in] mesh - the supporting mesh.
6483 * \param [in] renumPol - specifies how to permute values of the result field according to
6484 * the optional numbers of cells and nodes, if any. The valid values are
6485 * - 0 - do not permute.
6486 * - 1 - permute cells.
6487 * - 2 - permute nodes.
6488 * - 3 - permute cells and nodes.
6490 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6491 * caller is to delete this field using decrRef() as it is no more needed.
6492 * \throw If no field of \a this is lying on \a mesh.
6493 * \throw If the mesh is empty.
6494 * \throw If no field values of the given \a type are available.
6495 * \sa getFieldAtLevel()
6496 * \sa getFieldOnMeshAtLevel()
6498 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6500 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6501 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull());
6502 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6507 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6508 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6509 * \param [in] type - a spatial discretization of interest.
6510 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6511 * \param [in] mesh - the supporting mesh.
6512 * \param [in] renumPol - specifies how to permute values of the result field according to
6513 * the optional numbers of cells and nodes, if any. The valid values are
6514 * - 0 - do not permute.
6515 * - 1 - permute cells.
6516 * - 2 - permute nodes.
6517 * - 3 - permute cells and nodes.
6519 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6520 * caller is to delete this field using decrRef() as it is no more needed.
6521 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6522 * \throw If no field of \a this is lying on \a mesh.
6523 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6524 * \sa getFieldAtLevel()
6525 * \sa getFieldOnMeshAtLevel()
6527 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6529 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6530 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull());
6531 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6536 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6537 * This method is called "Old" because in MED3 norm a field has only one meshName
6538 * attached, so this method is for readers of MED2 files. If \a this field
6539 * has not been constructed via file reading, an exception is thrown.
6540 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6541 * \param [in] type - a spatial discretization of interest.
6542 * \param [in] mName - a name of the supporting mesh.
6543 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6544 * \param [in] renumPol - specifies how to permute values of the result field according to
6545 * the optional numbers of cells and nodes, if any. The valid values are
6546 * - 0 - do not permute.
6547 * - 1 - permute cells.
6548 * - 2 - permute nodes.
6549 * - 3 - permute cells and nodes.
6551 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6552 * caller is to delete this field using decrRef() as it is no more needed.
6553 * \throw If the MED file is not readable.
6554 * \throw If there is no mesh named \a mName in the MED file.
6555 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6556 * \throw If \a this field has not been constructed via file reading.
6557 * \throw If no field of \a this is lying on the mesh named \a mName.
6558 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6559 * \sa getFieldAtLevel()
6561 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6563 if(getFileName().empty())
6564 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6565 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
6566 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
6567 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6572 * Returns values and a profile of the field of a given type lying on a given support.
6573 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6574 * \param [in] type - a spatial discretization of the field.
6575 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6576 * \param [in] mesh - the supporting mesh.
6577 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6578 * field of interest lies on. If the field lies on all entities of the given
6579 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6580 * using decrRef() as it is no more needed.
6581 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6582 * field. The caller is to delete this array using decrRef() as it is no more needed.
6583 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6584 * \throw If no field of \a this is lying on \a mesh.
6585 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6587 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6589 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6590 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6594 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6595 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6596 * "Sort By Type"), if not, an exception is thrown.
6597 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6598 * \param [in] field - the field to add to \a this.
6599 * \throw If the name of \a field is empty.
6600 * \throw If the data array of \a field is not set.
6601 * \throw If the data array is already allocated but has different number of components
6603 * \throw If the underlying mesh of \a field has no name.
6604 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6606 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6609 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6613 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6614 * can be an aggregation of several MEDCouplingFieldDouble instances.
6615 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6616 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6619 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6620 * A new profile is added only if no equal profile is missing.
6621 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6622 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6623 * \param [in] mesh - the supporting mesh of \a field.
6624 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6625 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6626 * \throw If either \a field or \a mesh or \a profile has an empty name.
6627 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6628 * \throw If the data array of \a field is not set.
6629 * \throw If the data array of \a this is already allocated but has different number of
6630 * components than \a field.
6631 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6632 * \sa setFieldNoProfileSBT()
6634 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6637 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6640 MEDFileAnyTypeField1TS *MEDFileField1TS::shallowCpy() const
6642 return new MEDFileField1TS(*this);
6645 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
6647 return contentNotNull()->getUndergroundDataArrayDouble();
6650 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
6652 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
6655 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
6656 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6658 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
6661 //= MEDFileIntField1TS
6663 MEDFileIntField1TS *MEDFileIntField1TS::New()
6665 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS;
6666 ret->contentNotNull();
6670 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
6672 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,loadAll,0));
6673 ret->contentNotNull();
6677 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6679 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,loadAll,0));
6680 ret->contentNotNull();
6684 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6686 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fileName,fieldName,iteration,order,loadAll,0));
6687 ret->contentNotNull();
6691 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
6693 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
6694 ret->contentNotNull();
6698 MEDFileIntField1TS::MEDFileIntField1TS()
6700 _content=new MEDFileIntField1TSWithoutSDA;
6703 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
6704 try:MEDFileAnyTypeField1TS(fileName,loadAll,ms)
6707 catch(INTERP_KERNEL::Exception& e)
6710 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6711 try:MEDFileAnyTypeField1TS(fileName,fieldName,loadAll,ms)
6714 catch(INTERP_KERNEL::Exception& e)
6717 MEDFileIntField1TS::MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6718 try:MEDFileAnyTypeField1TS(fileName,fieldName,iteration,order,loadAll,ms)
6721 catch(INTERP_KERNEL::Exception& e)
6725 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6726 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6728 * \warning this is a shallow copy constructor
6730 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6734 MEDFileAnyTypeField1TS *MEDFileIntField1TS::shallowCpy() const
6736 return new MEDFileIntField1TS(*this);
6740 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
6741 * following the given input policy.
6743 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6744 * By default (true) the globals are deeply copied.
6745 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
6747 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
6749 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret;
6750 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6753 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
6755 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
6756 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
6757 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc,getFileName()));
6760 ret=MEDFileField1TS::New();
6762 ret->deepCpyGlobs(*this);
6764 ret->shallowCpyGlobs(*this);
6769 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6770 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6771 * "Sort By Type"), if not, an exception is thrown.
6772 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6773 * \param [in] field - the field to add to \a this. The field double values are ignored.
6774 * \param [in] arrOfVals - the values of the field \a field used.
6775 * \throw If the name of \a field is empty.
6776 * \throw If the data array of \a field is not set.
6777 * \throw If the data array is already allocated but has different number of components
6779 * \throw If the underlying mesh of \a field has no name.
6780 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6782 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
6785 contentNotNull()->setFieldNoProfileSBT(field,arrOfVals,*this,*contentNotNull());
6789 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6790 * can be an aggregation of several MEDCouplingFieldDouble instances.
6791 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6792 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6795 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6796 * A new profile is added only if no equal profile is missing.
6797 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6798 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
6799 * \param [in] arrOfVals - the values of the field \a field used.
6800 * \param [in] mesh - the supporting mesh of \a field.
6801 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6802 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6803 * \throw If either \a field or \a mesh or \a profile has an empty name.
6804 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6805 * \throw If the data array of \a field is not set.
6806 * \throw If the data array of \a this is already allocated but has different number of
6807 * components than \a field.
6808 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
6809 * \sa setFieldNoProfileSBT()
6811 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
6814 contentNotNull()->setFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this,*contentNotNull());
6817 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
6819 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6821 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
6822 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
6824 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 !");
6828 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6830 if(getFileName().empty())
6831 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6832 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut2;
6833 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut2,*contentNotNull());
6834 DataArrayInt *arrOutC=dynamic_cast<DataArrayInt *>((DataArray *)arrOut2);
6836 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : mismatch between dataArrays type and MEDFileIntField1TS ! Expected int32 !");
6838 arrOut->incrRef(); // arrOut2 dies at the end of the func
6842 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr)
6844 if(!((DataArray *)arr))
6845 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
6846 DataArrayInt *arrC=dynamic_cast<DataArrayInt *>((DataArray *)arr);
6848 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
6854 * Returns a new MEDCouplingFieldDouble of a given type lying on
6855 * the top level cells of the first mesh in MED file. If \a this field
6856 * has not been constructed via file reading, an exception is thrown.
6857 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6858 * \param [in] type - a spatial discretization of interest.
6859 * \param [out] arrOut - the DataArrayInt containing values of field.
6860 * \param [in] renumPol - specifies how to permute values of the result field according to
6861 * the optional numbers of cells and nodes, if any. The valid values are
6862 * - 0 - do not permute.
6863 * - 1 - permute cells.
6864 * - 2 - permute nodes.
6865 * - 3 - permute cells and nodes.
6867 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6868 * caller is to delete this field using decrRef() as it is no more needed.
6869 * \throw If \a this field has not been constructed via file reading.
6870 * \throw If the MED file is not readable.
6871 * \throw If there is no mesh in the MED file.
6872 * \throw If no field values of the given \a type.
6873 * \throw If no field values lying on the top level support.
6874 * \sa getFieldAtLevel()
6876 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol) const
6878 if(getFileName().empty())
6879 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6880 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6881 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNull());
6882 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6887 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6888 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6889 * \param [in] type - a spatial discretization of the new field.
6890 * \param [in] mesh - the supporting mesh.
6891 * \param [out] arrOut - the DataArrayInt containing values of field.
6892 * \param [in] renumPol - specifies how to permute values of the result field according to
6893 * the optional numbers of cells and nodes, if any. The valid values are
6894 * - 0 - do not permute.
6895 * - 1 - permute cells.
6896 * - 2 - permute nodes.
6897 * - 3 - permute cells and nodes.
6899 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6900 * caller is to delete this field using decrRef() as it is no more needed.
6901 * \throw If no field of \a this is lying on \a mesh.
6902 * \throw If the mesh is empty.
6903 * \throw If no field values of the given \a type are available.
6904 * \sa getFieldAtLevel()
6905 * \sa getFieldOnMeshAtLevel()
6907 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6909 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6910 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNull());
6911 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6916 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6917 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6918 * \param [in] type - a spatial discretization of interest.
6919 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6920 * \param [out] arrOut - the DataArrayInt containing values of field.
6921 * \param [in] mesh - the supporting mesh.
6922 * \param [in] renumPol - specifies how to permute values of the result field according to
6923 * the optional numbers of cells and nodes, if any. The valid values are
6924 * - 0 - do not permute.
6925 * - 1 - permute cells.
6926 * - 2 - permute nodes.
6927 * - 3 - permute cells and nodes.
6929 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6930 * caller is to delete this field using decrRef() as it is no more needed.
6931 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6932 * \throw If no field of \a this is lying on \a mesh.
6933 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6934 * \sa getFieldAtLevel()
6935 * \sa getFieldOnMeshAtLevel()
6937 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
6939 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6940 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNull());
6941 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6946 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6947 * This method is called "Old" because in MED3 norm a field has only one meshName
6948 * attached, so this method is for readers of MED2 files. If \a this field
6949 * has not been constructed via file reading, an exception is thrown.
6950 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6951 * \param [in] type - a spatial discretization of interest.
6952 * \param [in] mName - a name of the supporting mesh.
6953 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6954 * \param [out] arrOut - the DataArrayInt containing values of field.
6955 * \param [in] renumPol - specifies how to permute values of the result field according to
6956 * the optional numbers of cells and nodes, if any. The valid values are
6957 * - 0 - do not permute.
6958 * - 1 - permute cells.
6959 * - 2 - permute nodes.
6960 * - 3 - permute cells and nodes.
6962 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6963 * caller is to delete this field using decrRef() as it is no more needed.
6964 * \throw If the MED file is not readable.
6965 * \throw If there is no mesh named \a mName in the MED file.
6966 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6967 * \throw If \a this field has not been constructed via file reading.
6968 * \throw If no field of \a this is lying on the mesh named \a mName.
6969 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6970 * \sa getFieldAtLevel()
6972 MEDCouplingFieldDouble *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
6974 if(getFileName().empty())
6975 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6976 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
6977 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNull());
6978 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
6983 * Returns values and a profile of the field of a given type lying on a given support.
6984 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6985 * \param [in] type - a spatial discretization of the field.
6986 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6987 * \param [in] mesh - the supporting mesh.
6988 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6989 * field of interest lies on. If the field lies on all entities of the given
6990 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6991 * using decrRef() as it is no more needed.
6992 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
6993 * field. The caller is to delete this array using decrRef() as it is no more needed.
6994 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6995 * \throw If no field of \a this is lying on \a mesh.
6996 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6998 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7000 MEDCouplingAutoRefCountObjectPtr<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7001 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7004 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7006 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7008 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7009 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7011 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 !");
7015 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7017 return contentNotNull()->getUndergroundDataArrayInt();
7020 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7022 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7026 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7031 * \param [in] fieldId field id in C mode
7033 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7035 med_field_type typcha;
7036 std::string dtunitOut;
7037 int nbOfStep=MEDFileAnyTypeField1TS::LocateField2(fid,"",fieldId,false,_name,typcha,_infos,dtunitOut);
7038 setDtUnit(dtunitOut.c_str());
7039 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7042 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)
7043 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7045 setDtUnit(dtunit.c_str());
7046 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7048 catch(INTERP_KERNEL::Exception& e)
7053 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7055 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA>));
7056 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7057 ret+=(*it).capacity();
7061 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7063 std::vector<const BigMemoryObject *> ret;
7064 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7065 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7070 * 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
7073 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7075 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7076 ret->setInfo(_infos);
7077 int sz=(int)_time_steps.size();
7078 for(const int *id=startIds;id!=endIds;id++)
7080 if(*id>=0 && *id<sz)
7082 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7083 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7087 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7089 ret->pushBackTimeStep(tse2);
7093 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7094 oss << " ! Should be in [0," << sz << ") !";
7095 throw INTERP_KERNEL::Exception(oss.str().c_str());
7098 if(ret->getNumberOfTS()>0)
7099 ret->synchronizeNameScope();
7100 ret->copyNameScope(*this);
7105 * 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
7108 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7110 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7111 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7112 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7113 ret->setInfo(_infos);
7114 int sz=(int)_time_steps.size();
7116 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7120 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7121 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7125 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7127 ret->pushBackTimeStep(tse2);
7131 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7132 oss << " ! Should be in [0," << sz << ") !";
7133 throw INTERP_KERNEL::Exception(oss.str().c_str());
7136 if(ret->getNumberOfTS()>0)
7137 ret->synchronizeNameScope();
7138 ret->copyNameScope(*this);
7142 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7145 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7146 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7148 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7151 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7152 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7153 ids->pushBackSilent(id);
7155 return buildFromTimeStepIds(ids->begin(),ids->end());
7158 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7161 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7162 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7164 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7167 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7168 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7169 ids->pushBackSilent(id);
7171 return buildFromTimeStepIds(ids->begin(),ids->end());
7174 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7176 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7178 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7181 if(cur->presenceOfMultiDiscPerGeoType())
7187 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7192 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7197 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7200 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7202 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7203 if(pt->isDealingTS(iteration,order))
7206 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7207 std::vector< std::pair<int,int> > vp=getIterations();
7208 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7209 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7210 throw INTERP_KERNEL::Exception(oss.str().c_str());
7213 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7215 return *_time_steps[getTimeStepPos(iteration,order)];
7218 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7220 return *_time_steps[getTimeStepPos(iteration,order)];
7223 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7225 if(_time_steps.empty())
7226 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7227 return _time_steps[0]->getMeshName();
7230 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7232 std::string oldName(getMeshName());
7233 std::vector< std::pair<std::string,std::string> > v(1);
7234 v[0].first=oldName; v[0].second=newMeshName;
7238 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7241 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7243 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7245 ret=cur->changeMeshNames(modifTab) || ret;
7251 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7253 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7255 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7259 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7261 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7263 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7266 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7267 MEDFileFieldGlobsReal& glob)
7270 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7272 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7274 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7279 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7281 std::string startLine(bkOffset,' ');
7282 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7284 oss << " (" << fmtsId << ")";
7285 oss << " has the following name: \"" << _name << "\"." << std::endl;
7286 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7287 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7289 oss << startLine << " - \"" << *it << "\"" << std::endl;
7292 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7294 std::string chapter(17,'0'+i);
7295 oss << startLine << chapter << std::endl;
7296 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7298 cur->simpleRepr(bkOffset+2,oss,i);
7300 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7301 oss << startLine << chapter << std::endl;
7305 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7307 std::size_t sz=_time_steps.size();
7308 std::vector< std::pair<int,int> > ret(sz);
7310 for(std::size_t i=0;i<sz;i++)
7312 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7315 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7319 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7320 throw INTERP_KERNEL::Exception(oss.str().c_str());
7326 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7328 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7330 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7331 checkCoherencyOfType(tse2);
7332 if(_time_steps.empty())
7334 setName(tse2->getName().c_str());
7335 setInfo(tse2->getInfo());
7337 checkThatComponentsMatch(tse2->getInfo());
7338 _time_steps.push_back(tse);
7341 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7343 std::size_t nbOfCompo=_infos.size();
7344 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7346 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7349 if((cur->getInfo()).size()!=nbOfCompo)
7351 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7352 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7353 throw INTERP_KERNEL::Exception(oss.str().c_str());
7355 cur->copyNameScope(*this);
7360 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)
7362 _time_steps.resize(nbPdt);
7363 for(int i=0;i<nbPdt;i++)
7365 std::vector< std::pair<int,int> > ts;
7366 med_int numdt=0,numo=0;
7367 med_int meshIt=0,meshOrder=0;
7369 MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder));
7374 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7379 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7383 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7386 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7388 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7392 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7394 if(_time_steps.empty())
7395 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7396 checkThatNbOfCompoOfTSMatchThis();
7397 std::vector<std::string> infos(getInfo());
7398 int nbComp=infos.size();
7399 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7400 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7401 for(int i=0;i<nbComp;i++)
7403 std::string info=infos[i];
7405 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7406 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7407 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7410 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7411 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7412 int nbOfTS=_time_steps.size();
7413 for(int i=0;i<nbOfTS;i++)
7414 _time_steps[i]->writeLL(fid,opts,*this);
7417 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7419 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7421 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7423 elt->loadBigArraysRecursively(fid,nasc);
7427 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7429 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7431 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7433 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7437 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7439 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7441 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7443 elt->unloadArrays();
7447 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7449 return _time_steps.size();
7452 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7454 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7455 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7457 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7459 newTS.push_back(*it);
7464 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7466 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7467 int maxId=(int)_time_steps.size();
7469 std::set<int> idsToDel;
7470 for(const int *id=startIds;id!=endIds;id++,ii++)
7472 if(*id>=0 && *id<maxId)
7474 idsToDel.insert(*id);
7478 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7479 throw INTERP_KERNEL::Exception(oss.str().c_str());
7482 for(int iii=0;iii<maxId;iii++)
7483 if(idsToDel.find(iii)==idsToDel.end())
7484 newTS.push_back(_time_steps[iii]);
7488 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
7490 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
7491 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7492 if(nbOfEntriesToKill==0)
7494 std::size_t sz=_time_steps.size();
7495 std::vector<bool> b(sz,true);
7497 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
7499 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7500 for(std::size_t i=0;i<sz;i++)
7502 newTS.push_back(_time_steps[i]);
7506 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
7509 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
7510 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7512 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7516 tmp->getTime(it2,ord);
7517 if(it2==iteration && order==ord)
7520 oss << "(" << it2 << "," << ord << "), ";
7523 throw INTERP_KERNEL::Exception(oss.str().c_str());
7526 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
7529 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
7531 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7533 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
7537 double ti=tmp->getTime(it2,ord);
7538 if(fabs(time-ti)<eps)
7544 throw INTERP_KERNEL::Exception(oss.str().c_str());
7547 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
7549 int lgth=_time_steps.size();
7550 std::vector< std::pair<int,int> > ret(lgth);
7551 for(int i=0;i<lgth;i++)
7552 _time_steps[i]->fillIteration(ret[i]);
7557 * 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'
7558 * This method returns two things.
7559 * - The absolute dimension of 'this' in first parameter.
7560 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
7561 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
7563 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
7564 * Only these 3 discretizations will be taken into account here.
7566 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
7567 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
7568 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
7570 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
7571 * 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'.
7573 * Let's consider the typical following case :
7574 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
7575 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
7576 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
7578 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
7580 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
7582 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
7583 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
7584 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
7585 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
7587 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
7589 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
7592 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
7594 if(pos<0 || pos>=(int)_time_steps.size())
7596 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7597 throw INTERP_KERNEL::Exception(oss.str().c_str());
7599 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7602 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7603 oss << "\nTry to use following method eraseEmptyTS !";
7604 throw INTERP_KERNEL::Exception(oss.str().c_str());
7609 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
7611 if(pos<0 || pos>=(int)_time_steps.size())
7613 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
7614 throw INTERP_KERNEL::Exception(oss.str().c_str());
7616 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
7619 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
7620 oss << "\nTry to use following method eraseEmptyTS !";
7621 throw INTERP_KERNEL::Exception(oss.str().c_str());
7626 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
7628 std::vector<std::string> ret;
7629 std::set<std::string> ret2;
7630 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7632 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
7633 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7634 if(ret2.find(*it2)==ret2.end())
7636 ret.push_back(*it2);
7643 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
7645 std::vector<std::string> ret;
7646 std::set<std::string> ret2;
7647 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7649 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
7650 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
7651 if(ret2.find(*it2)==ret2.end())
7653 ret.push_back(*it2);
7660 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
7662 std::vector<std::string> ret;
7663 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7665 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
7666 ret.insert(ret.end(),tmp.begin(),tmp.end());
7671 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
7673 std::vector<std::string> ret;
7674 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7676 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
7677 ret.insert(ret.end(),tmp.begin(),tmp.end());
7682 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7684 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7685 (*it)->changePflsRefsNamesGen2(mapOfModif);
7688 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
7690 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7691 (*it)->changeLocsRefsNamesGen2(mapOfModif);
7694 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
7696 int lgth=_time_steps.size();
7697 std::vector< std::vector<TypeOfField> > ret(lgth);
7698 for(int i=0;i<lgth;i++)
7699 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
7704 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
7706 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
7708 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
7711 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCpy() const
7713 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
7715 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7717 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
7718 ret->_time_steps[i]=(*it)->deepCpy();
7723 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
7725 std::size_t sz(_infos.size()),sz2(_time_steps.size());
7726 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
7727 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
7728 for(std::size_t i=0;i<sz;i++)
7730 ret[i]=shallowCpy();
7731 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
7733 for(std::size_t i=0;i<sz2;i++)
7735 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
7738 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
7739 throw INTERP_KERNEL::Exception(oss.str().c_str());
7743 for(std::size_t i=0;i<sz;i++)
7744 for(std::size_t j=0;j<sz2;j++)
7745 ret[i]->_time_steps[j]=ts[j][i];
7750 * This method splits into discretization each time steps in \a this.
7751 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
7753 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
7755 std::size_t sz(_time_steps.size());
7756 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7757 for(std::size_t i=0;i<sz;i++)
7759 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7762 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
7763 throw INTERP_KERNEL::Exception(oss.str().c_str());
7765 items[i]=timeStep->splitDiscretizations();
7768 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
7769 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
7770 std::vector< TypeOfField > types;
7771 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7772 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7774 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
7776 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
7777 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
7778 if(it2==types.end())
7779 types.push_back(ts[0]);
7781 ret.resize(types.size()); ret2.resize(types.size());
7782 for(std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
7783 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
7785 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
7786 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
7787 ret2[pos].push_back(*it1);
7789 for(std::size_t i=0;i<types.size();i++)
7791 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7792 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
7793 elt->pushBackTimeStep(*it1);//also updates infos in elt
7795 elt->MEDFileFieldNameScope::operator=(*this);
7801 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
7803 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
7805 std::size_t sz(_time_steps.size());
7806 std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
7807 std::size_t szOut(std::numeric_limits<std::size_t>::max());
7808 for(std::size_t i=0;i<sz;i++)
7810 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
7813 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
7814 throw INTERP_KERNEL::Exception(oss.str().c_str());
7816 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
7817 if(szOut==std::numeric_limits<std::size_t>::max())
7818 szOut=items[i].size();
7820 if(items[i].size()!=szOut)
7821 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
7823 if(szOut==std::numeric_limits<std::size_t>::max())
7824 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
7825 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
7826 for(std::size_t i=0;i<szOut;i++)
7828 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
7829 for(std::size_t j=0;j<sz;j++)
7830 elt->pushBackTimeStep(items[j][i]);
7832 elt->MEDFileFieldNameScope::operator=(*this);
7837 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
7839 _name=field->getName();
7841 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
7843 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
7844 _infos=arr->getInfoOnComponents();
7847 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
7849 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
7850 if(_name!=field->getName())
7852 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
7853 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
7854 throw INTERP_KERNEL::Exception(oss.str().c_str());
7857 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
7858 checkThatComponentsMatch(arr->getInfoOnComponents());
7861 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
7863 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
7864 if(getInfo().size()!=compos.size())
7866 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
7867 oss << " number of components of element to append (" << compos.size() << ") !";
7868 throw INTERP_KERNEL::Exception(oss.str().c_str());
7872 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
7873 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
7874 oss << " But compo in input fields are : ";
7875 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
7877 throw INTERP_KERNEL::Exception(oss.str().c_str());
7881 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
7883 std::size_t sz=_infos.size();
7885 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
7887 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7889 if(elt->getInfo().size()!=sz)
7891 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
7892 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
7893 throw INTERP_KERNEL::Exception(oss.str().c_str());
7898 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
7901 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7902 if(!_time_steps.empty())
7903 checkCoherencyOfTinyInfo(field,arr);
7904 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
7905 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7906 objC->setFieldNoProfileSBT(field,arr,glob,*this);
7907 copyTinyInfoFrom(field,arr);
7908 _time_steps.push_back(obj);
7911 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
7914 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
7915 if(!_time_steps.empty())
7916 checkCoherencyOfTinyInfo(field,arr);
7917 MEDFileField1TSWithoutSDA *objC=new MEDFileField1TSWithoutSDA;
7918 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
7919 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
7920 copyTinyInfoFrom(field,arr);
7921 _time_steps.push_back(obj);
7924 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts)
7926 int sz=(int)_time_steps.size();
7929 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
7930 throw INTERP_KERNEL::Exception(oss.str().c_str());
7932 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
7935 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
7937 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
7938 throw INTERP_KERNEL::Exception(oss.str().c_str());
7944 //= MEDFileFieldMultiTSWithoutSDA
7946 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)
7948 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
7951 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
7955 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
7960 * \param [in] fieldId field id in C mode
7962 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
7963 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
7966 catch(INTERP_KERNEL::Exception& e)
7969 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)
7970 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
7973 catch(INTERP_KERNEL::Exception& e)
7976 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
7978 return new MEDFileField1TSWithoutSDA;
7981 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
7984 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
7985 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
7987 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
7990 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
7992 return MEDFileField1TSWithoutSDA::TYPE_STR;
7995 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
7997 return new MEDFileFieldMultiTSWithoutSDA(*this);
8000 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8002 return new MEDFileFieldMultiTSWithoutSDA;
8006 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8007 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8009 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
8011 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8012 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8014 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8015 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8018 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8020 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8021 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8023 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8025 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8028 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8030 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8031 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8032 ret->setIteration(i,elt);
8038 //= MEDFileAnyTypeFieldMultiTS
8040 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8044 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8045 try:MEDFileFieldGlobsReal(fileName)
8047 MEDFileUtilities::CheckFileForRead(fileName);
8048 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8049 _content=BuildContentFrom(fid,fileName,loadAll,ms);
8052 catch(INTERP_KERNEL::Exception& e)
8057 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)
8059 med_field_type typcha;
8060 std::vector<std::string> infos;
8063 MEDFileAnyTypeField1TS::LocateField(fid,fileName,fieldName,i,typcha,infos,dtunit);
8064 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8069 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8074 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8079 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] !";
8080 throw INTERP_KERNEL::Exception(oss.str().c_str());
8083 ret->setDtUnit(dtunit.c_str());
8087 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
8089 med_field_type typcha;
8091 std::vector<std::string> infos;
8092 std::string dtunit,fieldName;
8093 MEDFileAnyTypeField1TS::LocateField2(fid,fileName,0,true,fieldName,typcha,infos,dtunit);
8094 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8099 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8104 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8109 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] !";
8110 throw INTERP_KERNEL::Exception(oss.str().c_str());
8113 ret->setDtUnit(dtunit.c_str());
8117 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName)
8120 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8121 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8123 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=MEDFileFieldMultiTS::New();
8124 ret->setFileName(fileName);
8125 ret->_content=c; c->incrRef();
8128 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8130 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=MEDFileIntFieldMultiTS::New();
8131 ret->setFileName(fileName);
8132 ret->_content=c; c->incrRef();
8135 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8138 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)
8139 try:MEDFileFieldGlobsReal(fileName)
8141 MEDFileUtilities::CheckFileForRead(fileName);
8142 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8143 _content=BuildContentFrom(fid,fileName,fieldName,loadAll,ms,entities);
8146 catch(INTERP_KERNEL::Exception& e)
8151 //= MEDFileIntFieldMultiTSWithoutSDA
8153 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)
8155 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8158 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8162 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8166 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)
8167 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8170 catch(INTERP_KERNEL::Exception& e)
8174 * \param [in] fieldId field id in C mode
8176 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
8177 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8180 catch(INTERP_KERNEL::Exception& e)
8183 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8185 return new MEDFileIntField1TSWithoutSDA;
8188 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8191 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8192 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8194 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8197 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8199 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8202 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8204 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8207 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8209 return new MEDFileIntFieldMultiTSWithoutSDA;
8212 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8214 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8215 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8217 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8219 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8222 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8224 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8225 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8226 ret->setIteration(i,elt);
8232 //= MEDFileAnyTypeFieldMultiTS
8235 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8236 * that has been read from a specified MED file.
8237 * \param [in] fileName - the name of the MED file to read.
8238 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8239 * is to delete this field using decrRef() as it is no more needed.
8240 * \throw If reading the file fails.
8242 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8244 MEDFileUtilities::CheckFileForRead(fileName);
8245 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8246 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=BuildContentFrom(fid,fileName,loadAll,0);
8247 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8248 ret->loadGlobals(fid);
8253 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8254 * that has been read from a specified MED file.
8255 * \param [in] fileName - the name of the MED file to read.
8256 * \param [in] fieldName - the name of the field to read.
8257 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8258 * is to delete this field using decrRef() as it is no more needed.
8259 * \throw If reading the file fails.
8260 * \throw If there is no field named \a fieldName in the file.
8262 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8264 MEDFileUtilities::CheckFileForRead(fileName);
8265 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
8266 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fileName,fieldName,loadAll,0,0));
8267 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=BuildNewInstanceFromContent(c,fileName);
8268 ret->loadGlobals(fid);
8273 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8274 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8276 * \warning this is a shallow copy constructor
8278 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8280 if(!shallowCopyOfContent)
8282 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8283 otherPtr->incrRef();
8284 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8288 _content=other.shallowCpy();
8292 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8294 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8296 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8300 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8302 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8304 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8308 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8310 return contentNotNullBase()->getPflsReallyUsed2();
8313 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8315 return contentNotNullBase()->getLocsReallyUsed2();
8318 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8320 return contentNotNullBase()->getPflsReallyUsedMulti2();
8323 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8325 return contentNotNullBase()->getLocsReallyUsedMulti2();
8328 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8330 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8333 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8335 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8338 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8340 return contentNotNullBase()->getNumberOfTS();
8343 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8345 contentNotNullBase()->eraseEmptyTS();
8348 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8350 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8353 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8355 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8358 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8360 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8361 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8366 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8368 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8369 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8374 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8376 return contentNotNullBase()->getIterations();
8379 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8381 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8382 pushBackTimeStep(*it);
8385 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8388 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8389 int nbOfTS(fmts->getNumberOfTS());
8390 for(int i=0;i<nbOfTS;i++)
8392 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8393 pushBackTimeStep(elt);
8397 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8400 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8401 checkCoherencyOfType(f1ts);
8403 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8404 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8406 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8407 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8408 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8409 _content->pushBackTimeStep(cSafe);
8410 appendGlobs(*f1ts,1e-12);
8413 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8415 contentNotNullBase()->synchronizeNameScope();
8418 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8420 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8423 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8425 return contentNotNullBase()->getPosGivenTime(time,eps);
8428 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8430 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8433 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8435 return contentNotNullBase()->getTypesOfFieldAvailable();
8438 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
8440 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8443 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8445 return contentNotNullBase()->getName();
8448 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8450 contentNotNullBase()->setName(name);
8453 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8455 return contentNotNullBase()->getDtUnit();
8458 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8460 contentNotNullBase()->setDtUnit(dtUnit);
8463 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8465 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8468 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8470 return contentNotNullBase()->getTimeSteps(ret1);
8473 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
8475 return contentNotNullBase()->getMeshName();
8478 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
8480 contentNotNullBase()->setMeshName(newMeshName);
8483 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
8485 return contentNotNullBase()->changeMeshNames(modifTab);
8488 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
8490 return contentNotNullBase()->getInfo();
8493 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
8495 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
8498 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
8500 return contentNotNullBase()->setInfo(info);
8503 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
8505 const std::vector<std::string> ret=getInfo();
8506 return (int)ret.size();
8509 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
8511 writeGlobals(fid,*this);
8512 contentNotNullBase()->writeLL(fid,*this);
8516 * Writes \a this field into a MED file specified by its name.
8517 * \param [in] fileName - the MED file name.
8518 * \param [in] mode - the writing mode. For more on \a mode, see \ref AdvMEDLoaderBasics.
8519 * - 2 - erase; an existing file is removed.
8520 * - 1 - append; same data should not be present in an existing file.
8521 * - 0 - overwrite; same data present in an existing file is overwritten.
8522 * \throw If the field name is not set.
8523 * \throw If no field data is set.
8524 * \throw If \a mode == 1 and the same data is present in an existing file.
8526 void MEDFileAnyTypeFieldMultiTS::write(const std::string& fileName, int mode) const
8528 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
8529 MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),medmod);
8534 * This method alloc the arrays and load potentially huge arrays contained in this field.
8535 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
8536 * This method can be also called to refresh or reinit values from a file.
8538 * \throw If the fileName is not set or points to a non readable MED file.
8540 void MEDFileAnyTypeFieldMultiTS::loadArrays()
8542 if(getFileName().empty())
8543 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
8544 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8545 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
8549 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
8550 * But once data loaded once, this method does nothing.
8552 * \throw If the fileName is not set or points to a non readable MED file.
8553 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
8555 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
8557 if(!getFileName().empty())
8559 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
8560 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
8565 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
8566 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
8567 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
8569 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
8571 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
8573 contentNotNullBase()->unloadArrays();
8577 * 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.
8578 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
8579 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
8581 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
8583 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
8585 if(!getFileName().empty())
8586 contentNotNullBase()->unloadArrays();
8589 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
8591 std::ostringstream oss;
8592 contentNotNullBase()->simpleRepr(0,oss,-1);
8593 simpleReprGlobs(oss);
8597 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
8599 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
8602 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
8604 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
8605 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
8610 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
8611 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
8612 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
8614 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
8616 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8618 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
8619 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
8620 std::size_t sz(contentsSplit.size());
8621 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8622 for(std::size_t i=0;i<sz;i++)
8624 ret[i]=shallowCpy();
8625 ret[i]->_content=contentsSplit[i];
8631 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
8632 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8634 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
8636 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8638 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
8639 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
8640 std::size_t sz(contentsSplit.size());
8641 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8642 for(std::size_t i=0;i<sz;i++)
8644 ret[i]=shallowCpy();
8645 ret[i]->_content=contentsSplit[i];
8651 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
8652 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
8654 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
8656 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
8658 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
8659 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
8660 std::size_t sz(contentsSplit.size());
8661 std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > ret(sz);
8662 for(std::size_t i=0;i<sz;i++)
8664 ret[i]=shallowCpy();
8665 ret[i]->_content=contentsSplit[i];
8670 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCpy() const
8672 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8673 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
8674 ret->_content=_content->deepCpy();
8675 ret->deepCpyGlobs(*this);
8679 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
8685 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8686 * \param [in] iteration - the iteration number of a required time step.
8687 * \param [in] order - the iteration order number of required time step.
8688 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
8689 * delete this field using decrRef() as it is no more needed.
8690 * \throw If there is no required time step in \a this field.
8692 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
8694 int pos=getPosOfTimeStep(iteration,order);
8695 return getTimeStepAtPos(pos);
8699 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
8700 * \param [in] time - the time of the time step of interest.
8701 * \param [in] eps - a precision used to compare time values.
8702 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
8703 * delete this field using decrRef() as it is no more needed.
8704 * \throw If there is no required time step in \a this field.
8706 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
8708 int pos=getPosGivenTime(time,eps);
8709 return getTimeStepAtPos(pos);
8713 * 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.
8714 * The float64 value of time attached to the pair of integers are not considered here.
8715 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
8717 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
8718 * \throw If there is a null pointer in \a vectFMTS.
8720 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
8722 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
8723 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8724 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8725 while(!lstFMTS.empty())
8727 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8728 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8730 throw INTERP_KERNEL::Exception(msg);
8731 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
8732 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8733 elt.push_back(curIt); it=lstFMTS.erase(it);
8734 while(it!=lstFMTS.end())
8738 throw INTERP_KERNEL::Exception(msg);
8739 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
8741 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8751 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
8752 * All returned instances in a subvector can be safely loaded, rendered along time
8753 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
8754 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
8755 * 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).
8756 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
8757 * 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.
8759 * \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().
8760 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
8761 * \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.
8762 * \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.
8764 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
8765 * \throw If an element in \a vectFMTS change of spatial discretization along time.
8766 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
8767 * \thorw If some elements in \a vectFMTS do not have the same times steps.
8768 * \throw If mesh is null.
8769 * \throw If an element in \a vectFMTS is null.
8770 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
8772 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc)
8774 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
8776 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
8777 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8778 if(vectFMTS.empty())
8780 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
8781 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
8783 throw INTERP_KERNEL::Exception(msg);
8785 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
8786 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
8787 for(;it!=vectFMTS.end();it++,i++)
8790 throw INTERP_KERNEL::Exception(msg);
8791 TypeOfField tof0,tof1;
8792 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
8795 vectFMTSNotNodes.push_back(*it);
8797 vectFMTSNodes.push_back(*it);
8800 vectFMTSNotNodes.push_back(*it);
8802 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> > cmps;
8803 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
8805 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
8808 bool isFetched(false);
8809 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
8812 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
8813 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
8814 { ret[i].push_back(*it2); isFetched=true; }
8818 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
8819 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
8820 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
8828 * 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.
8829 * \param [out] cmps - same size than the returned vector.
8831 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps)
8833 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
8834 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
8835 while(!lstFMTS.empty())
8837 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
8838 MEDFileAnyTypeFieldMultiTS *ref(*it);
8839 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
8840 elt.push_back(ref); it=lstFMTS.erase(it);
8841 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
8842 MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
8843 while(it!=lstFMTS.end())
8845 MEDFileAnyTypeFieldMultiTS *curIt(*it);
8846 if(cmp->isEqual(curIt))
8847 { elt.push_back(curIt); it=lstFMTS.erase(it); }
8851 ret.push_back(elt); cmps.push_back(cmp);
8857 * 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.
8858 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
8860 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
8861 * \throw If \a f0 or \a f1 change of spatial discretization along time.
8862 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
8863 * \thorw If \a f0 and \a f1 do not have the same times steps.
8864 * \throw If mesh is null.
8865 * \throw If \a f0 or \a f1 is null.
8866 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
8868 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
8871 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
8873 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
8874 if(f0->getMeshName()!=mesh->getName())
8876 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8877 throw INTERP_KERNEL::Exception(oss.str().c_str());
8879 if(f1->getMeshName()!=mesh->getName())
8881 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
8882 throw INTERP_KERNEL::Exception(oss.str().c_str());
8884 int nts=f0->getNumberOfTS();
8885 if(nts!=f1->getNumberOfTS())
8886 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
8889 for(int i=0;i<nts;i++)
8891 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
8892 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
8893 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
8894 if(tofs0.size()!=1 || tofs1.size()!=1)
8895 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
8898 if(tof0!=tofs0[0] || tof1!=tofs1[0])
8899 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
8902 { tof0=tofs0[0]; tof1=tofs1[0]; }
8903 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
8905 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() << ") !";
8906 throw INTERP_KERNEL::Exception(oss.str().c_str());
8908 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
8910 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() << ") !";
8911 throw INTERP_KERNEL::Exception(oss.str().c_str());
8913 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
8915 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() << ") !";
8916 throw INTERP_KERNEL::Exception(oss.str().c_str());
8922 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
8924 return new MEDFileAnyTypeFieldMultiTSIterator(this);
8927 //= MEDFileFieldMultiTS
8930 * Returns a new empty instance of MEDFileFieldMultiTS.
8931 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8932 * is to delete this field using decrRef() as it is no more needed.
8934 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
8936 return new MEDFileFieldMultiTS;
8940 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
8941 * that has been read from a specified MED file.
8942 * \param [in] fileName - the name of the MED file to read.
8943 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8944 * is to delete this field using decrRef() as it is no more needed.
8945 * \throw If reading the file fails.
8947 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
8949 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,loadAll,0);
8950 ret->contentNotNull();//to check that content type matches with \a this type.
8955 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
8956 * that has been read from a specified MED file.
8957 * \param [in] fileName - the name of the MED file to read.
8958 * \param [in] fieldName - the name of the field to read.
8959 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8960 * is to delete this field using decrRef() as it is no more needed.
8961 * \throw If reading the file fails.
8962 * \throw If there is no field named \a fieldName in the file.
8964 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8966 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret=new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0);
8967 ret->contentNotNull();//to check that content type matches with \a this type.
8972 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8973 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8975 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
8976 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
8977 * \warning this is a shallow copy constructor
8978 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
8979 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
8980 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
8981 * is to delete this field using decrRef() as it is no more needed.
8983 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8985 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
8988 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
8990 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fileName,fieldName,loadAll,0,&entities));
8991 ret->contentNotNull();//to check that content type matches with \a this type.
8995 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
8997 return new MEDFileFieldMultiTS(*this);
9000 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9003 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9004 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9006 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9010 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9011 * following the given input policy.
9013 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9014 * By default (true) the globals are deeply copied.
9015 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9017 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9019 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret;
9020 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9023 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9025 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9026 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9027 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc,getFileName()));
9030 ret=MEDFileIntFieldMultiTS::New();
9032 ret->deepCpyGlobs(*this);
9034 ret->shallowCpyGlobs(*this);
9039 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9040 * \param [in] pos - a time step id.
9041 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9042 * delete this field using decrRef() as it is no more needed.
9043 * \throw If \a pos is not a valid time step id.
9045 MEDFileAnyTypeField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9047 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9050 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9051 throw INTERP_KERNEL::Exception(oss.str().c_str());
9053 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9056 MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9057 ret->shallowCpyGlobs(*this);
9060 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9061 throw INTERP_KERNEL::Exception(oss.str().c_str());
9065 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9066 * mesh entities of a given dimension of the first mesh in MED file.
9067 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9068 * \param [in] type - a spatial discretization of interest.
9069 * \param [in] iteration - the iteration number of a required time step.
9070 * \param [in] order - the iteration order number of required time step.
9071 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9072 * \param [in] renumPol - specifies how to permute values of the result field according to
9073 * the optional numbers of cells and nodes, if any. The valid values are
9074 * - 0 - do not permute.
9075 * - 1 - permute cells.
9076 * - 2 - permute nodes.
9077 * - 3 - permute cells and nodes.
9079 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9080 * caller is to delete this field using decrRef() as it is no more needed.
9081 * \throw If the MED file is not readable.
9082 * \throw If there is no mesh in the MED file.
9083 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9084 * \throw If no field values of the required parameters are available.
9086 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9088 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9089 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9091 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9092 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9093 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9094 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9099 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9100 * the top level cells of the first mesh in MED file.
9101 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9102 * \param [in] type - a spatial discretization of interest.
9103 * \param [in] iteration - the iteration number of a required time step.
9104 * \param [in] order - the iteration order number of required time step.
9105 * \param [in] renumPol - specifies how to permute values of the result field according to
9106 * the optional numbers of cells and nodes, if any. The valid values are
9107 * - 0 - do not permute.
9108 * - 1 - permute cells.
9109 * - 2 - permute nodes.
9110 * - 3 - permute cells and nodes.
9112 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9113 * caller is to delete this field using decrRef() as it is no more needed.
9114 * \throw If the MED file is not readable.
9115 * \throw If there is no mesh in the MED file.
9116 * \throw If no field values of the required parameters are available.
9118 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9120 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9121 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9123 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9124 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9125 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9126 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9131 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9133 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9134 * \param [in] type - a spatial discretization of interest.
9135 * \param [in] iteration - the iteration number of a required time step.
9136 * \param [in] order - the iteration order number of required time step.
9137 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9138 * \param [in] mesh - the supporting mesh.
9139 * \param [in] renumPol - specifies how to permute values of the result field according to
9140 * the optional numbers of cells and nodes, if any. The valid values are
9141 * - 0 - do not permute.
9142 * - 1 - permute cells.
9143 * - 2 - permute nodes.
9144 * - 3 - permute cells and nodes.
9146 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9147 * caller is to delete this field using decrRef() as it is no more needed.
9148 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9149 * \throw If no field of \a this is lying on \a mesh.
9150 * \throw If no field values of the required parameters are available.
9152 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9154 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9155 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9157 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9158 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9159 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9160 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9165 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9167 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9168 * \param [in] type - a spatial discretization of the new field.
9169 * \param [in] iteration - the iteration number of a required time step.
9170 * \param [in] order - the iteration order number of required time step.
9171 * \param [in] mesh - the supporting mesh.
9172 * \param [in] renumPol - specifies how to permute values of the result field according to
9173 * the optional numbers of cells and nodes, if any. The valid values are
9174 * - 0 - do not permute.
9175 * - 1 - permute cells.
9176 * - 2 - permute nodes.
9177 * - 3 - permute cells and nodes.
9179 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9180 * caller is to delete this field using decrRef() as it is no more needed.
9181 * \throw If no field of \a this is lying on \a mesh.
9182 * \throw If no field values of the required parameters are available.
9184 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9186 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9187 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9189 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9190 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9191 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9192 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9197 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9198 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9199 * This method is useful for MED2 file format when field on different mesh was autorized.
9201 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9203 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9204 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9206 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9207 MEDCouplingAutoRefCountObjectPtr<DataArray> arrOut;
9208 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9209 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9214 * Returns values and a profile of the field of a given type, of a given time step,
9215 * lying on a given support.
9216 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9217 * \param [in] type - a spatial discretization of the field.
9218 * \param [in] iteration - the iteration number of a required time step.
9219 * \param [in] order - the iteration order number of required time step.
9220 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9221 * \param [in] mesh - the supporting mesh.
9222 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9223 * field of interest lies on. If the field lies on all entities of the given
9224 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9225 * using decrRef() as it is no more needed.
9226 * \param [in] glob - the global data storing profiles and localization.
9227 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9228 * field. The caller is to delete this array using decrRef() as it is no more needed.
9229 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9230 * \throw If no field of \a this is lying on \a mesh.
9231 * \throw If no field values of the required parameters are available.
9233 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9235 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9236 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9238 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9239 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9240 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9243 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9245 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9247 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9248 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9250 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 !");
9254 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9256 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9258 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9259 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9261 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 !");
9266 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9267 * the given field is checked if its elements are sorted suitable for writing to MED file
9268 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9269 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9270 * \param [in] field - the field to add to \a this.
9271 * \throw If the name of \a field is empty.
9272 * \throw If the data array of \a field is not set.
9273 * \throw If existing time steps have different name or number of components than \a field.
9274 * \throw If the underlying mesh of \a field has no name.
9275 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9277 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9279 const DataArrayDouble *arr=0;
9281 arr=field->getArray();
9282 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9286 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9287 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9288 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9291 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9292 * A new profile is added only if no equal profile is missing.
9293 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9294 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9295 * \param [in] mesh - the supporting mesh of \a field.
9296 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9297 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9298 * \throw If either \a field or \a mesh or \a profile has an empty name.
9299 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9300 * \throw If the data array of \a field is not set.
9301 * \throw If the data array of \a this is already allocated but has different number of
9302 * components than \a field.
9303 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9304 * \sa setFieldNoProfileSBT()
9306 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9308 const DataArrayDouble *arr=0;
9310 arr=field->getArray();
9311 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9314 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9316 _content=new MEDFileFieldMultiTSWithoutSDA;
9319 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9320 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9323 catch(INTERP_KERNEL::Exception& e)
9326 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)
9327 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9330 catch(INTERP_KERNEL::Exception& e)
9333 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9337 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
9339 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9342 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9344 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9347 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
9349 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
9352 //= MEDFileAnyTypeFieldMultiTSIterator
9354 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
9359 _nb_iter=fmts->getNumberOfTS();
9363 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
9367 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
9369 if(_iter_id<_nb_iter)
9371 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
9373 return fmts->getTimeStepAtPos(_iter_id++);
9381 //= MEDFileIntFieldMultiTS
9384 * Returns a new empty instance of MEDFileFieldMultiTS.
9385 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9386 * is to delete this field using decrRef() as it is no more needed.
9388 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
9390 return new MEDFileIntFieldMultiTS;
9394 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
9395 * that has been read from a specified MED file.
9396 * \param [in] fileName - the name of the MED file to read.
9397 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9398 * is to delete this field using decrRef() as it is no more needed.
9399 * \throw If reading the file fails.
9401 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
9403 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,loadAll,0);
9404 ret->contentNotNull();//to check that content type matches with \a this type.
9409 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
9410 * that has been read from a specified MED file.
9411 * \param [in] fileName - the name of the MED file to read.
9412 * \param [in] fieldName - the name of the field to read.
9413 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9414 * is to delete this field using decrRef() as it is no more needed.
9415 * \throw If reading the file fails.
9416 * \throw If there is no field named \a fieldName in the file.
9418 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9420 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0);
9421 ret->contentNotNull();//to check that content type matches with \a this type.
9426 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9427 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9429 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
9430 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9431 * \warning this is a shallow copy constructor
9432 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
9433 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9434 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
9435 * is to delete this field using decrRef() as it is no more needed.
9437 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9439 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
9442 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9444 MEDCouplingAutoRefCountObjectPtr<MEDFileIntFieldMultiTS> ret=new MEDFileIntFieldMultiTS(fileName,fieldName,loadAll,0,&entities);
9445 ret->contentNotNull();//to check that content type matches with \a this type.
9450 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
9451 * following the given input policy.
9453 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9454 * By default (true) the globals are deeply copied.
9455 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
9457 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
9459 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> ret;
9460 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9463 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
9465 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
9466 MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
9467 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc,getFileName()));
9470 ret=MEDFileFieldMultiTS::New();
9472 ret->deepCpyGlobs(*this);
9474 ret->shallowCpyGlobs(*this);
9478 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
9480 return new MEDFileIntFieldMultiTS(*this);
9483 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9486 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9487 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
9489 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
9493 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9494 * mesh entities of a given dimension of the first mesh in MED file.
9495 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9496 * \param [in] type - a spatial discretization of interest.
9497 * \param [in] iteration - the iteration number of a required time step.
9498 * \param [in] order - the iteration order number of required time step.
9499 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9500 * \param [out] arrOut - the DataArrayInt containing values of field.
9501 * \param [in] renumPol - specifies how to permute values of the result field according to
9502 * the optional numbers of cells and nodes, if any. The valid values are
9503 * - 0 - do not permute.
9504 * - 1 - permute cells.
9505 * - 2 - permute nodes.
9506 * - 3 - permute cells and nodes.
9508 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9509 * caller is to delete this field using decrRef() as it is no more needed.
9510 * \throw If the MED file is not readable.
9511 * \throw If there is no mesh in the MED file.
9512 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9513 * \throw If no field values of the required parameters are available.
9515 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9517 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9518 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9520 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
9521 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9522 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase());
9523 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9528 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9529 * the top level cells of the first mesh in MED file.
9530 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9531 * \param [in] type - a spatial discretization of interest.
9532 * \param [in] iteration - the iteration number of a required time step.
9533 * \param [in] order - the iteration order number of required time step.
9534 * \param [out] arrOut - the DataArrayInt containing values of field.
9535 * \param [in] renumPol - specifies how to permute values of the result field according to
9536 * the optional numbers of cells and nodes, if any. The valid values are
9537 * - 0 - do not permute.
9538 * - 1 - permute cells.
9539 * - 2 - permute nodes.
9540 * - 3 - permute cells and nodes.
9542 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9543 * caller is to delete this field using decrRef() as it is no more needed.
9544 * \throw If the MED file is not readable.
9545 * \throw If there is no mesh in the MED file.
9546 * \throw If no field values of the required parameters are available.
9548 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol) const
9550 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9551 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9553 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
9554 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9555 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase());
9556 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9561 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9563 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9564 * \param [in] type - a spatial discretization of interest.
9565 * \param [in] iteration - the iteration number of a required time step.
9566 * \param [in] order - the iteration order number of required time step.
9567 * \param [out] arrOut - the DataArrayInt containing values of field.
9568 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9569 * \param [in] mesh - the supporting mesh.
9570 * \param [in] renumPol - specifies how to permute values of the result field according to
9571 * the optional numbers of cells and nodes, if any. The valid values are
9572 * - 0 - do not permute.
9573 * - 1 - permute cells.
9574 * - 2 - permute nodes.
9575 * - 3 - permute cells and nodes.
9577 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9578 * caller is to delete this field using decrRef() as it is no more needed.
9579 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9580 * \throw If no field of \a this is lying on \a mesh.
9581 * \throw If no field values of the required parameters are available.
9583 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9585 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9586 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9588 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9589 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9590 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase());
9591 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9596 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9598 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9599 * \param [in] type - a spatial discretization of the new field.
9600 * \param [in] iteration - the iteration number of a required time step.
9601 * \param [in] order - the iteration order number of required time step.
9602 * \param [in] mesh - the supporting mesh.
9603 * \param [out] arrOut - the DataArrayInt containing values of field.
9604 * \param [in] renumPol - specifies how to permute values of the result field according to
9605 * the optional numbers of cells and nodes, if any. The valid values are
9606 * - 0 - do not permute.
9607 * - 1 - permute cells.
9608 * - 2 - permute nodes.
9609 * - 3 - permute cells and nodes.
9611 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9612 * caller is to delete this field using decrRef() as it is no more needed.
9613 * \throw If no field of \a this is lying on \a mesh.
9614 * \throw If no field values of the required parameters are available.
9616 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol) const
9618 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9619 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9621 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9622 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9623 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase());
9624 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9629 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
9630 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9631 * This method is useful for MED2 file format when field on different mesh was autorized.
9633 MEDCouplingFieldDouble *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol) const
9635 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9636 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9638 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
9639 MEDCouplingAutoRefCountObjectPtr<DataArray> arr;
9640 MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase());
9641 arrOut=MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
9646 * Returns values and a profile of the field of a given type, of a given time step,
9647 * lying on a given support.
9648 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9649 * \param [in] type - a spatial discretization of the field.
9650 * \param [in] iteration - the iteration number of a required time step.
9651 * \param [in] order - the iteration order number of required time step.
9652 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9653 * \param [in] mesh - the supporting mesh.
9654 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9655 * field of interest lies on. If the field lies on all entities of the given
9656 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9657 * using decrRef() as it is no more needed.
9658 * \param [in] glob - the global data storing profiles and localization.
9659 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
9660 * field. The caller is to delete this array using decrRef() as it is no more needed.
9661 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9662 * \throw If no field of \a this is lying on \a mesh.
9663 * \throw If no field values of the required parameters are available.
9665 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9667 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9668 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
9670 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
9671 MEDCouplingAutoRefCountObjectPtr<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9672 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
9676 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
9677 * \param [in] pos - a time step id.
9678 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
9679 * delete this field using decrRef() as it is no more needed.
9680 * \throw If \a pos is not a valid time step id.
9682 MEDFileAnyTypeField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
9684 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9687 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9688 throw INTERP_KERNEL::Exception(oss.str().c_str());
9690 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
9693 MEDCouplingAutoRefCountObjectPtr<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
9694 ret->shallowCpyGlobs(*this);
9697 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
9698 throw INTERP_KERNEL::Exception(oss.str().c_str());
9702 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9703 * the given field is checked if its elements are sorted suitable for writing to MED file
9704 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9705 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9706 * \param [in] field - the field to add to \a this.
9707 * \throw If the name of \a field is empty.
9708 * \throw If the data array of \a field is not set.
9709 * \throw If existing time steps have different name or number of components than \a field.
9710 * \throw If the underlying mesh of \a field has no name.
9711 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9713 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals)
9715 contentNotNull()->appendFieldNoProfileSBT(field,arrOfVals,*this);
9719 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9720 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9721 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9724 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9725 * A new profile is added only if no equal profile is missing.
9726 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9727 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
9728 * \param [in] arrOfVals - the values of the field \a field used.
9729 * \param [in] mesh - the supporting mesh of \a field.
9730 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9731 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9732 * \throw If either \a field or \a mesh or \a profile has an empty name.
9733 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9734 * \throw If the data array of \a field is not set.
9735 * \throw If the data array of \a this is already allocated but has different number of
9736 * components than \a field.
9737 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9738 * \sa setFieldNoProfileSBT()
9740 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9742 contentNotNull()->appendFieldProfile(field,arrOfVals,mesh,meshDimRelToMax,profile,*this);
9745 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
9747 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9749 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
9750 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9752 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 !");
9756 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
9758 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9760 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
9761 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
9763 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 !");
9767 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
9769 _content=new MEDFileIntFieldMultiTSWithoutSDA;
9772 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9776 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9777 try:MEDFileAnyTypeFieldMultiTS(fileName,loadAll,ms)
9780 catch(INTERP_KERNEL::Exception& e)
9783 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)
9784 try:MEDFileAnyTypeFieldMultiTS(fileName,fieldName,loadAll,ms,entities)
9787 catch(INTERP_KERNEL::Exception& e)
9790 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
9792 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
9797 MEDFileFields *MEDFileFields::New()
9799 return new MEDFileFields;
9802 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
9804 return new MEDFileFields(fileName,loadAll,0,0);
9807 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
9809 return new MEDFileFields(fileName,loadAll,ms,0);
9812 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9814 return new MEDFileFields(fileName,loadAll,0,&entities);
9817 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
9819 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
9820 ret+=_fields.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
9824 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
9826 std::vector<const BigMemoryObject *> ret;
9827 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9828 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
9832 MEDFileFields *MEDFileFields::deepCpy() const
9834 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
9836 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9838 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9839 ret->_fields[i]=(*it)->deepCpy();
9841 ret->deepCpyGlobs(*this);
9845 MEDFileFields *MEDFileFields::shallowCpy() const
9847 return new MEDFileFields(*this);
9851 * 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
9852 * 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.
9853 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
9855 * \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.
9856 * \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.
9858 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
9860 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
9862 std::set< std::pair<int,int> > s;
9863 bool firstShot=true;
9864 areThereSomeForgottenTS=false;
9865 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9867 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
9869 std::vector< std::pair<int,int> > v=(*it)->getIterations();
9870 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
9872 { s=s1; firstShot=false; }
9875 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
9877 areThereSomeForgottenTS=true;
9881 std::vector< std::pair<int,int> > ret;
9882 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
9886 int MEDFileFields::getNumberOfFields() const
9888 return _fields.size();
9891 std::vector<std::string> MEDFileFields::getFieldsNames() const
9893 std::vector<std::string> ret(_fields.size());
9895 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9897 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
9900 ret[i]=f->getName();
9904 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
9905 throw INTERP_KERNEL::Exception(oss.str().c_str());
9911 std::vector<std::string> MEDFileFields::getMeshesNames() const
9913 std::vector<std::string> ret;
9914 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
9916 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
9918 ret.push_back(cur->getMeshName());
9923 std::string MEDFileFields::simpleRepr() const
9925 std::ostringstream oss;
9926 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
9931 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
9933 int nbOfFields=getNumberOfFields();
9934 std::string startLine(bkOffset,' ');
9935 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
9937 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9939 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9942 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
9946 oss << startLine << " - not defined !" << std::endl;
9950 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
9952 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
9953 std::string chapter(17,'0'+i);
9954 oss << startLine << chapter << std::endl;
9957 cur->simpleRepr(bkOffset+2,oss,i);
9961 oss << startLine << " - not defined !" << std::endl;
9963 oss << startLine << chapter << std::endl;
9965 simpleReprGlobs(oss);
9968 MEDFileFields::MEDFileFields()
9972 MEDFileFields::MEDFileFields(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > *entities)
9973 try:MEDFileFieldGlobsReal(fileName)
9975 MEDFileUtilities::CheckFileForRead(fileName);
9976 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY));
9977 int nbFields(MEDnField(fid));
9978 _fields.resize(nbFields);
9979 med_field_type typcha;
9980 for(int i=0;i<nbFields;i++)
9982 std::vector<std::string> infos;
9983 std::string fieldName,dtunit;
9984 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fileName,i,false,fieldName,typcha,infos,dtunit));
9989 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9994 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
9999 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] !";
10000 throw INTERP_KERNEL::Exception(oss.str().c_str());
10004 loadAllGlobals(fid);
10006 catch(INTERP_KERNEL::Exception& e)
10011 void MEDFileFields::writeLL(med_idt fid) const
10014 writeGlobals(fid,*this);
10015 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10017 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10020 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10021 throw INTERP_KERNEL::Exception(oss.str().c_str());
10023 elt->writeLL(fid,*this);
10027 void MEDFileFields::write(const std::string& fileName, int mode) const
10029 med_access_mode medmod=MEDFileUtilities::TraduceWriteMode(mode);
10030 MEDFileUtilities::AutoFid fid(MEDfileOpen(fileName.c_str(),medmod));
10035 * This method alloc the arrays and load potentially huge arrays contained in this field.
10036 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10037 * This method can be also called to refresh or reinit values from a file.
10039 * \throw If the fileName is not set or points to a non readable MED file.
10041 void MEDFileFields::loadArrays()
10043 if(getFileName().empty())
10044 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10045 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10046 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10048 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10050 elt->loadBigArraysRecursively(fid,*elt);
10055 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10056 * But once data loaded once, this method does nothing.
10058 * \throw If the fileName is not set or points to a non readable MED file.
10059 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10061 void MEDFileFields::loadArraysIfNecessary()
10063 if(!getFileName().empty())
10065 MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName().c_str(),MED_ACC_RDONLY);
10066 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10068 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10070 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10076 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10077 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10078 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10080 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10082 void MEDFileFields::unloadArrays()
10084 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10086 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10088 elt->unloadArrays();
10093 * 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.
10094 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10095 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10097 * \sa MEDFileFields::loadArraysIfNecessary
10099 void MEDFileFields::unloadArraysWithoutDataLoss()
10101 if(!getFileName().empty())
10105 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10107 std::vector<std::string> ret;
10108 std::set<std::string> ret2;
10109 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10111 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10112 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10113 if(ret2.find(*it2)==ret2.end())
10115 ret.push_back(*it2);
10122 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10124 std::vector<std::string> ret;
10125 std::set<std::string> ret2;
10126 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10128 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10129 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10130 if(ret2.find(*it2)==ret2.end())
10132 ret.push_back(*it2);
10139 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10141 std::vector<std::string> ret;
10142 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10144 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
10145 ret.insert(ret.end(),tmp.begin(),tmp.end());
10150 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10152 std::vector<std::string> ret;
10153 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10155 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
10156 ret.insert(ret.end(),tmp.begin(),tmp.end());
10161 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10163 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10164 (*it)->changePflsRefsNamesGen2(mapOfModif);
10167 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10169 for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10170 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10173 void MEDFileFields::resize(int newSize)
10175 _fields.resize(newSize);
10178 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10180 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10184 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10187 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10188 _fields.push_back(field->getContent());
10189 appendGlobs(*field,1e-12);
10192 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10195 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10196 if(i>=(int)_fields.size())
10197 _fields.resize(i+1);
10198 _fields[i]=field->getContent();
10199 appendGlobs(*field,1e-12);
10202 void MEDFileFields::destroyFieldAtPos(int i)
10204 destroyFieldsAtPos(&i,&i+1);
10207 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10209 std::vector<bool> b(_fields.size(),true);
10210 for(const int *i=startIds;i!=endIds;i++)
10212 if(*i<0 || *i>=(int)_fields.size())
10214 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10215 throw INTERP_KERNEL::Exception(oss.str().c_str());
10219 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10221 for(std::size_t i=0;i<_fields.size();i++)
10223 fields[j++]=_fields[i];
10227 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10229 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10230 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
10231 std::vector<bool> b(_fields.size(),true);
10233 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10235 if(k<0 || k>=(int)_fields.size())
10237 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10238 throw INTERP_KERNEL::Exception(oss.str().c_str());
10242 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10244 for(std::size_t i=0;i<_fields.size();i++)
10246 fields[j++]=_fields[i];
10250 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10253 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10255 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10257 ret=cur->changeMeshNames(modifTab) || ret;
10263 * \param [in] meshName the name of the mesh that will be renumbered.
10264 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10265 * This code corresponds to the distribution of types in the corresponding mesh.
10266 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10267 * \param [in] renumO2N the old to new renumber array.
10268 * \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
10269 * field in \a this.
10271 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10274 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10276 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10279 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
10285 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
10287 if(i<0 || i>=(int)_fields.size())
10289 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
10290 throw INTERP_KERNEL::Exception(oss.str().c_str());
10292 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
10295 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> ret;
10296 const MEDFileFieldMultiTSWithoutSDA *fmtsC=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts);
10297 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts);
10299 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
10301 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
10304 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
10305 throw INTERP_KERNEL::Exception(oss.str().c_str());
10307 ret->shallowCpyGlobs(*this);
10312 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
10313 * This method is accessible in python using __getitem__ with a list in input.
10314 * \return a new object that the caller should deal with.
10316 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
10318 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=shallowCpy();
10319 std::size_t sz=std::distance(startIds,endIds);
10320 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
10322 for(const int *i=startIds;i!=endIds;i++,j++)
10324 if(*i<0 || *i>=(int)_fields.size())
10326 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10327 throw INTERP_KERNEL::Exception(oss.str().c_str());
10329 fields[j]=_fields[*i];
10331 ret->_fields=fields;
10335 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
10337 return getFieldAtPos(getPosFromFieldName(fieldName));
10341 * This method removes, if any, fields in \a this having no time steps.
10342 * 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.
10344 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
10346 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
10348 std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
10349 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10351 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10354 if(elt->getNumberOfTS()>0)
10355 newFields.push_back(*it);
10358 if(_fields.size()==newFields.size())
10365 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
10366 * This method can be seen as a filter applied on \a this, that returns an object containing
10367 * 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
10368 * shallow copied from \a this.
10370 * \param [in] meshName - the name of the mesh on w
10371 * \return a new object that the caller should deal with.
10373 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
10375 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10376 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10378 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10381 if(cur->getMeshName()==meshName)
10384 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
10385 ret->_fields.push_back(cur2);
10388 ret->shallowCpyOnlyUsedGlobs(*this);
10393 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
10394 * Input time steps are specified using a pair of integer (iteration, order).
10395 * 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,
10396 * but for each multitimestep only the time steps in \a timeSteps are kept.
10397 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
10399 * The returned object points to shallow copy of elements in \a this.
10401 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
10402 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
10403 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10405 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10407 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10408 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10410 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10413 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
10414 ret->_fields.push_back(elt);
10416 ret->shallowCpyOnlyUsedGlobs(*this);
10421 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
10423 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
10425 MEDCouplingAutoRefCountObjectPtr<MEDFileFields> ret=MEDFileFields::New();
10426 for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10428 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10431 MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
10432 if(elt->getNumberOfTS()!=0)
10433 ret->_fields.push_back(elt);
10435 ret->shallowCpyOnlyUsedGlobs(*this);
10439 MEDFileFieldsIterator *MEDFileFields::iterator()
10441 return new MEDFileFieldsIterator(this);
10444 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
10446 std::string tmp(fieldName);
10447 std::vector<std::string> poss;
10448 for(std::size_t i=0;i<_fields.size();i++)
10450 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=_fields[i];
10453 std::string fname(f->getName());
10457 poss.push_back(fname);
10460 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
10461 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
10463 throw INTERP_KERNEL::Exception(oss.str().c_str());
10466 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
10471 _nb_iter=fs->getNumberOfFields();
10475 MEDFileFieldsIterator::~MEDFileFieldsIterator()
10479 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
10481 if(_iter_id<_nb_iter)
10483 MEDFileFields *fs(_fs);
10485 return fs->getFieldAtPos(_iter_id++);