1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDFileField.txx"
22 #include "MEDFileMesh.hxx"
23 #include "MEDLoaderBase.hxx"
24 #include "MEDLoaderTraits.hxx"
25 #include "MEDFileSafeCaller.txx"
26 #include "MEDFileFieldOverView.hxx"
28 #include "MEDCouplingFieldDouble.hxx"
29 #include "MEDCouplingFieldTemplate.hxx"
30 #include "MEDCouplingFieldDiscretization.hxx"
32 #include "InterpKernelAutoPtr.hxx"
33 #include "CellModel.hxx"
38 extern med_geometry_type typmai[MED_N_CELL_FIXED_GEO];
39 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
40 extern med_geometry_type typmainoeud[1];
41 extern med_geometry_type typmai3[34];
43 using namespace MEDCoupling;
45 template class MEDFileField1TSTemplateWithoutSDA<int>;
46 template class MEDFileField1TSTemplateWithoutSDA<double>;
48 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
49 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
51 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, const std::string& locName)
53 return new MEDFileFieldLoc(fid,locName);
56 MEDFileFieldLoc *MEDFileFieldLoc::New(med_idt fid, int id)
58 return new MEDFileFieldLoc(fid,id);
61 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)
63 return new MEDFileFieldLoc(locName,geoType,refCoo,gsCoo,w);
66 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, const std::string& locName):_name(locName)
68 med_geometry_type geotype;
69 med_geometry_type sectiongeotype;
71 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
72 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
73 MEDlocalizationInfoByName(fid,locName.c_str(),&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
74 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
75 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
76 _nb_node_per_cell=cm.getNumberOfNodes();
77 _ref_coo.resize(_dim*_nb_node_per_cell);
78 _gs_coo.resize(_dim*_nb_gauss_pt);
79 _w.resize(_nb_gauss_pt);
80 MEDlocalizationRd(fid,locName.c_str(),MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
83 MEDFileFieldLoc::MEDFileFieldLoc(med_idt fid, int id)
85 med_geometry_type geotype;
86 med_geometry_type sectiongeotype;
88 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
89 INTERP_KERNEL::AutoPtr<char> geointerpname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
90 INTERP_KERNEL::AutoPtr<char> sectionmeshname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
91 MEDlocalizationInfo(fid,id+1,locName,&geotype,&_dim,&_nb_gauss_pt,geointerpname,sectionmeshname,&nsectionmeshcell,§iongeotype);
93 _geo_type=(INTERP_KERNEL::NormalizedCellType)(std::distance(typmai3,std::find(typmai3,typmai3+34,geotype)));
94 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
95 _nb_node_per_cell=cm.getNumberOfNodes();
96 _ref_coo.resize(_dim*_nb_node_per_cell);
97 _gs_coo.resize(_dim*_nb_gauss_pt);
98 _w.resize(_nb_gauss_pt);
99 MEDlocalizationRd(fid,locName,MED_FULL_INTERLACE,&_ref_coo[0],&_gs_coo[0],&_w[0]);
102 MEDFileFieldLoc::MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType,
103 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),
106 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
107 _dim=cm.getDimension();
108 _nb_node_per_cell=cm.getNumberOfNodes();
109 _nb_gauss_pt=_w.size();
112 MEDFileFieldLoc *MEDFileFieldLoc::deepCopy() const
114 return new MEDFileFieldLoc(*this);
117 std::size_t MEDFileFieldLoc::getHeapMemorySizeWithoutChildren() const
119 return (_ref_coo.capacity()+_gs_coo.capacity()+_w.capacity())*sizeof(double)+_name.capacity();
122 std::vector<const BigMemoryObject *> MEDFileFieldLoc::getDirectChildrenWithNull() const
124 return std::vector<const BigMemoryObject *>();
127 void MEDFileFieldLoc::simpleRepr(std::ostream& oss) const
129 static const char OFF7[]="\n ";
130 oss << "\"" << _name << "\"" << OFF7;
131 oss << "GeoType=" << INTERP_KERNEL::CellModel::GetCellModel(_geo_type).getRepr() << OFF7;
132 oss << "Dimension=" << _dim << OFF7;
133 oss << "Number of Gauss points=" << _nb_gauss_pt << OFF7;
134 oss << "Number of nodes per cell=" << _nb_node_per_cell << OFF7;
135 oss << "RefCoords="; std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
136 oss << "Weights="; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," ")); oss << OFF7;
137 oss << "GaussPtsCoords="; std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," ")); oss << std::endl;
140 void MEDFileFieldLoc::setName(const std::string& name)
145 bool MEDFileFieldLoc::isEqual(const MEDFileFieldLoc& other, double eps) const
147 if(_name!=other._name)
151 if(_nb_gauss_pt!=other._nb_gauss_pt)
153 if(_nb_node_per_cell!=other._nb_node_per_cell)
155 if(_geo_type!=other._geo_type)
157 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_ref_coo,other._ref_coo,eps))
159 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_gs_coo,other._gs_coo,eps))
161 if(!MEDCouplingGaussLocalization::AreAlmostEqual(_w,other._w,eps))
167 void MEDFileFieldLoc::writeLL(med_idt fid) const
169 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);
172 std::string MEDFileFieldLoc::repr() const
174 std::ostringstream oss; oss.precision(15);
175 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
176 oss << "Localization \"" << _name << "\" :\n" << " - Geometric Type : " << cm.getRepr();
177 oss << "\n - Dimension : " << _dim << "\n - Number of gauss points : ";
178 oss << _nb_gauss_pt << "\n - Number of nodes in cell : " << _nb_node_per_cell;
179 oss << "\n - Ref coords are : ";
180 int sz=_ref_coo.size();
183 int nbOfTuples=sz/_dim;
184 for(int i=0;i<nbOfTuples;i++)
187 for(int j=0;j<_dim;j++)
188 { oss << _ref_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
193 std::copy(_ref_coo.begin(),_ref_coo.end(),std::ostream_iterator<double>(oss," "));
194 oss << "\n - Gauss coords in reference element : ";
198 int nbOfTuples=sz/_dim;
199 for(int i=0;i<nbOfTuples;i++)
202 for(int j=0;j<_dim;j++)
203 { oss << _gs_coo[i*_dim+j]; if(j!=_dim-1) oss << ", "; }
208 std::copy(_gs_coo.begin(),_gs_coo.end(),std::ostream_iterator<double>(oss," "));
209 oss << "\n - Weights of Gauss coords are : "; std::copy(_w.begin(),_w.end(),std::ostream_iterator<double>(oss," "));
213 void MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
215 _type=field->getTypeOfField();
221 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,offset,offset+nbOfCells,1);
222 _end=_start+nbOfCells;
228 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(field->getMesh());
229 const int *arrPtr=arr->getConstPointer();
230 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,arrPtr[offset],arrPtr[offset+nbOfCells],1);
231 _end=_start+(arrPtr[offset+nbOfCells]-arrPtr[offset]);
237 const MEDCouplingFieldDiscretization *disc(field->getDiscretization());
238 const MEDCouplingGaussLocalization& gsLoc(field->getGaussLocalization(_loc_id));
239 const MEDCouplingFieldDiscretizationGauss *disc2(dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc));
241 throw INTERP_KERNEL::Exception("assignFieldNoProfile : invalid call to this method ! Internal Error !");
242 const DataArrayInt *dai(disc2->getArrayOfDiscIds());
243 MCAuto<DataArrayInt> dai2(disc2->getOffsetArr(field->getMesh()));
244 const int *dai2Ptr(dai2->getConstPointer());
245 int nbi(gsLoc.getWeights().size());
246 MCAuto<DataArrayInt> da2(dai->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1));
247 MCAuto<DataArrayInt> da3(da2->findIdsEqual(_loc_id));
248 const int *da3Ptr(da3->getConstPointer());
249 if(da3->getNumberOfTuples()!=nbOfCells)
250 {//profile : for gauss even in NoProfile !!!
251 std::ostringstream oss; oss << "Pfl_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
253 da3->setName(_profile.c_str());
254 glob.appendProfile(da3);
256 MCAuto<DataArrayInt> da4(DataArrayInt::New());
257 _nval=da3->getNbOfElems();
258 da4->alloc(_nval*nbi,1);
259 int *da4Ptr(da4->getPointer());
260 for(int i=0;i<_nval;i++)
262 int ref=dai2Ptr[offset+da3Ptr[i]];
263 for(int j=0;j<nbi;j++)
266 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
267 _localization=oss2.str();
268 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,da4);
269 _end=_start+_nval*nbi;
270 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
274 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldNoProfile : not implemented yet for such discretization type of field !");
280 * Leaf method of field with profile assignement. This method is the most general one. No optimization is done here.
281 * \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).
282 * \param [in] multiTypePfl is the end user profile specified in high level API
283 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
284 * \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.
285 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
286 * \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.
288 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)
291 _type=field->getTypeOfField();
292 std::string pflName(multiTypePfl->getName());
293 std::ostringstream oss; oss << pflName;
297 { const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType()); oss << "_" << cm.getRepr(); }
304 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : existing profile with empty name !");
305 if(_type!=ON_GAUSS_PT)
307 locIds->setName(oss.str());
308 glob.appendProfile(locIds);
317 _nval=idsInPfl->getNumberOfTuples();
318 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,arrr->getNumberOfTuples(),1);
324 _nval=idsInPfl->getNumberOfTuples();
325 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,idsInPfl);
331 MCAuto<DataArrayInt> arr=field->getDiscretization()->getOffsetArr(mesh);
332 MCAuto<DataArrayInt> arr2=arr->deltaShiftIndex();
333 MCAuto<DataArrayInt> arr3=arr2->selectByTupleId(multiTypePfl->begin(),multiTypePfl->end());
334 arr3->computeOffsetsFull();
335 MCAuto<DataArrayInt> tmp=idsInPfl->buildExplicitArrByRanges(arr3);
336 int trueNval=tmp->getNumberOfTuples();
337 _nval=idsInPfl->getNumberOfTuples();
338 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
339 _end=_start+trueNval;
344 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(field->getDiscretization());
346 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
347 const DataArrayInt *da1=disc2->getArrayOfDiscIds();
348 const MEDCouplingGaussLocalization& gsLoc=field->getGaussLocalization(_loc_id);
349 MCAuto<DataArrayInt> da2=da1->selectByTupleId(idsInPfl->begin(),idsInPfl->end());
350 MCAuto<DataArrayInt> da3=da2->findIdsEqual(_loc_id);
351 MCAuto<DataArrayInt> da4=idsInPfl->selectByTupleId(da3->begin(),da3->end());
353 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPart(multiTypePfl->begin(),multiTypePfl->end());
354 MCAuto<DataArrayInt> arr=disc2->getOffsetArr(mesh2);
356 MCAuto<DataArrayInt> tmp=DataArrayInt::New();
358 for(const int *pt=da4->begin();pt!=da4->end();pt++)
359 trueNval+=arr->getIJ(*pt+1,0)-arr->getIJ(*pt,0);
360 tmp->alloc(trueNval,1);
361 int *tmpPtr=tmp->getPointer();
362 for(const int *pt=da4->begin();pt!=da4->end();pt++)
363 for(int j=arr->getIJ(*pt,0);j<arr->getIJ(*pt+1,0);j++)
366 _nval=da4->getNumberOfTuples();
367 getOrCreateAndGetArray()->setContigPartOfSelectedValues(_start,arrr,tmp);
368 _end=_start+trueNval;
369 oss << "_loc_" << _loc_id;
372 MCAuto<DataArrayInt> da5=locIds->selectByTupleId(da3->begin(),da3->end());
373 da5->setName(oss.str());
374 glob.appendProfile(da5);
379 if(!da3->isIota(nbOfEltsInWholeMesh))
381 da3->setName(oss.str());
382 glob.appendProfile(da3);
386 std::ostringstream oss2; oss2 << "Loc_" << nasc.getName() << "_" << INTERP_KERNEL::CellModel::GetCellModel(getGeoType()).getRepr() << "_" << _loc_id;
387 _localization=oss2.str();
388 glob.appendLoc(_localization.c_str(),getGeoType(),gsLoc.getRefCoords(),gsLoc.getGaussCoords(),gsLoc.getWeights());
392 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::assignFieldProfile : not implemented yet for such discretization type of field !");
397 void MEDFileFieldPerMeshPerTypePerDisc::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob)
400 _nval=arrr->getNumberOfTuples();
401 getOrCreateAndGetArray()->setContigPartOfSelectedValuesSlice(_start,arrr,0,_nval,1);
406 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd)
408 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,profileIt,pd);
411 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId)
413 return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId,std::string());
416 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(const MEDFileFieldPerMeshPerTypePerDisc& other)
418 return new MEDFileFieldPerMeshPerTypePerDisc(other);
421 std::size_t MEDFileFieldPerMeshPerTypePerDisc::getHeapMemorySizeWithoutChildren() const
423 return _profile.capacity()+_localization.capacity()+sizeof(MEDFileFieldPerMeshPerTypePerDisc);
426 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypePerDisc::getDirectChildrenWithNull() const
428 std::vector<const BigMemoryObject *> ret(1);
429 ret[0]=(const PartDefinition*)_pd;
433 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const
435 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(*this));
440 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField atype, int profileIt, const PartDefinition *pd)
441 try:_type(atype),_father(fath),_profile_it(profileIt),_pd(const_cast<PartDefinition *>(pd))
446 catch(INTERP_KERNEL::Exception& e)
451 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId, const std::string& dummy):_type(type),_father(fath),_loc_id(locId)
455 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)
459 MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc():_type(ON_CELLS),_father(0),_start(-std::numeric_limits<int>::max()),_end(-std::numeric_limits<int>::max()),
460 _nval(-std::numeric_limits<int>::max()),_loc_id(-std::numeric_limits<int>::max())
464 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)
466 const PartDefinition *pd(_pd);
469 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
471 med_int nbValsInFile(MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi));
472 if(_end-_start!=nbValsInFile*nbi)
474 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 !";
475 throw INTERP_KERNEL::Exception(oss.str());
477 MEDFILESAFECALLERRD0(MEDfieldValueWithProfileRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,_profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,startFeedingPtr));
481 if(!_profile.empty())
482 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile : not implemented !");
483 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE)),locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
485 int overallNval(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
486 const SlicePartDefinition *spd(dynamic_cast<const SlicePartDefinition *>(pd));
490 spd->getSlice(start,stop,step);
491 int nbOfEltsToLoad(DataArray::GetNumberOfItemGivenBES(start,stop,step,"MEDFileFieldPerMeshPerTypePerDisc::goReadZeValuesInFile"));
492 med_filter filter=MED_FILTER_INIT;
493 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
494 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
495 /*start*/start+1,/*stride*/step,/*count*/1,/*blocksize*/nbOfEltsToLoad,
496 /*lastblocksize=useless because count=1*/0,&filter);
497 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,startFeedingPtr));
498 MEDfilterClose(&filter);
501 const DataArrayPartDefinition *dpd(dynamic_cast<const DataArrayPartDefinition *>(pd));
504 dpd->checkConsistencyLight();
505 MCAuto<DataArrayInt> myIds(dpd->toDAI());
506 int a(myIds->getMinValueInArray()),b(myIds->getMaxValueInArray());
507 myIds=myIds->deepCopy();// WARNING deep copy here because _pd is modified by applyLin !!!
508 myIds->applyLin(1,-a);
509 int nbOfEltsToLoad(b-a+1);
510 med_filter filter=MED_FILTER_INIT;
511 {//TODO : manage int32 !
512 MCAuto<DataArrayDouble> tmp(DataArrayDouble::New());
513 tmp->alloc(nbOfEltsToLoad,nbOfCompo);
514 MEDfilterBlockOfEntityCr(fid,/*nentity*/overallNval,/*nvaluesperentity*/nbi,/*nconstituentpervalue*/nbOfCompo,
515 MED_ALL_CONSTITUENT,MED_FULL_INTERLACE,MED_COMPACT_STMODE,MED_NO_PROFILE,
516 /*start*/a+1,/*stride*/1,/*count*/1,/*blocksize*/nbOfEltsToLoad,
517 /*lastblocksize=useless because count=1*/0,&filter);
518 MEDFILESAFECALLERRD0(MEDfieldValueAdvancedRd,(fid,fieldName.c_str(),iteration,order,menti,mgeoti,&filter,reinterpret_cast<unsigned char *>(tmp->getPointer())));
519 MCAuto<DataArrayDouble> feeder(DataArrayDouble::New());
520 feeder->useExternalArrayWithRWAccess(reinterpret_cast<double *>(startFeedingPtr),_nval,nbOfCompo);
521 feeder->setContigPartOfSelectedValues(0,tmp,myIds);
523 MEDfilterClose(&filter);
526 throw INTERP_KERNEL::Exception("Not implemented yet for not slices!");
530 const MEDFileFieldPerMeshPerTypeCommon *MEDFileFieldPerMeshPerTypePerDisc::getFather() const
535 void MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
537 INTERP_KERNEL::AutoPtr<char> locname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
538 INTERP_KERNEL::AutoPtr<char> pflname(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
539 std::string fieldName(nasc.getName()),meshName(getMeshName());
540 int iteration(getIteration()),order(getOrder()),profilesize,nbi;
541 TypeOfField type(getType());
542 med_geometry_type mgeoti;
543 med_entity_type menti;
544 _father->entriesForMEDfile(type,mgeoti,menti);
545 int zeNVal(MEDfieldnValueWithProfile(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile_it+1,MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi));
546 _profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
547 _localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
548 const PartDefinition *pd(_pd);
555 if(!_profile.empty())
556 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadOnlyStructureOfDataRecursively : profiles are not managed yet with part of def !");
557 _nval=pd->getNumberOfElems();
560 _end=start+_nval*nbi;
562 if(type==ON_CELLS && !_localization.empty())
564 if(_localization!="MED_GAUSS_ELNO")//For compatibily with MED2.3
565 setType(ON_GAUSS_PT);
568 setType(ON_GAUSS_NE);
569 _localization.clear();
574 void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc)
576 std::string fieldName(nasc.getName()),meshName(getMeshName());
577 int iteration(getIteration()),order(getOrder());
578 TypeOfField type(getType());
579 med_geometry_type mgeoti;
580 med_entity_type menti;
581 _father->entriesForMEDfile(type,mgeoti,menti);
583 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !");
586 DataArray *arr(getOrCreateAndGetArray());//arr is not null due to the spec of getOrCreateAndGetArray
587 if(_start<0 || _start>=arr->getNumberOfTuples())
589 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !";
590 throw INTERP_KERNEL::Exception(oss.str());
592 if(_end<0 || _end>arr->getNumberOfTuples())
594 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !";
595 throw INTERP_KERNEL::Exception(oss.str());
597 int nbOfCompo(arr->getNumberOfComponents());
598 DataArrayDouble *arrD(dynamic_cast<DataArrayDouble *>(arr));
601 double *startFeeding(arrD->getPointer()+_start*nbOfCompo);
602 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
605 DataArrayInt *arrI(dynamic_cast<DataArrayInt *>(arr));
608 int *startFeeding(arrI->getPointer()+_start*nbOfCompo);
609 goReadZeValuesInFile(fid,fieldName,nbOfCompo,iteration,order,menti,mgeoti,reinterpret_cast<unsigned char*>(startFeeding));
612 throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
616 * Set a \c this->_start **and** \c this->_end keeping the same delta between the two.
618 void MEDFileFieldPerMeshPerTypePerDisc::setNewStart(int newValueOfStart)
620 int delta=_end-_start;
621 _start=newValueOfStart;
625 int MEDFileFieldPerMeshPerTypePerDisc::getIteration() const
627 return _father->getIteration();
630 int MEDFileFieldPerMeshPerTypePerDisc::getOrder() const
632 return _father->getOrder();
635 double MEDFileFieldPerMeshPerTypePerDisc::getTime() const
637 return _father->getTime();
640 std::string MEDFileFieldPerMeshPerTypePerDisc::getMeshName() const
642 return _father->getMeshName();
645 void MEDFileFieldPerMeshPerTypePerDisc::simpleRepr(int bkOffset, std::ostream& oss, int id) const
647 const char startLine[]=" ## ";
648 std::string startLine2(bkOffset,' ');
649 startLine2+=startLine;
650 INTERP_KERNEL::AutoCppPtr<MEDCouplingFieldDiscretization> tmp(MEDCouplingFieldDiscretization::New(_type));
651 oss << startLine2 << "Localization #" << id << "." << std::endl;
652 oss << startLine2 << " Type=" << tmp->getRepr() << "." << std::endl;
653 oss << startLine2 << " This type discretization lies on profile : \"" << _profile << "\" and on the following localization : \"" << _localization << "\"." << std::endl;
654 oss << startLine2 << " This type discretization has " << _end-_start << " tuples (start=" << _start << ", end=" << _end << ")." << std::endl;
655 oss << startLine2 << " This type discretization has " << (_end-_start)/_nval << " integration points." << std::endl;
658 TypeOfField MEDFileFieldPerMeshPerTypePerDisc::getType() const
663 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypePerDisc::getGeoType() const
665 return _father->getGeoType();
668 void MEDFileFieldPerMeshPerTypePerDisc::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
673 void MEDFileFieldPerMeshPerTypePerDisc::setType(TypeOfField newType)
678 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfComponents() const
680 return _father->getNumberOfComponents();
683 int MEDFileFieldPerMeshPerTypePerDisc::getNumberOfTuples() const
688 DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray()
690 return _father->getOrCreateAndGetArray();
693 const DataArray *MEDFileFieldPerMeshPerTypePerDisc::getOrCreateAndGetArray() const
695 const MEDFileFieldPerMeshPerTypeCommon *fath=_father;
696 return fath->getOrCreateAndGetArray();
699 const std::vector<std::string>& MEDFileFieldPerMeshPerTypePerDisc::getInfo() const
701 return _father->getInfo();
704 std::string MEDFileFieldPerMeshPerTypePerDisc::getProfile() const
709 void MEDFileFieldPerMeshPerTypePerDisc::setProfile(const std::string& newPflName)
714 std::string MEDFileFieldPerMeshPerTypePerDisc::getLocalization() const
716 return _localization;
719 void MEDFileFieldPerMeshPerTypePerDisc::setLocalization(const std::string& newLocName)
721 _localization=newLocName;
724 void MEDFileFieldPerMeshPerTypePerDisc::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
726 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
728 if(std::find((*it2).first.begin(),(*it2).first.end(),_profile)!=(*it2).first.end())
730 _profile=(*it2).second;
736 void MEDFileFieldPerMeshPerTypePerDisc::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
738 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
740 if(std::find((*it2).first.begin(),(*it2).first.end(),_localization)!=(*it2).first.end())
742 _localization=(*it2).second;
748 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
752 dads.push_back(std::pair<int,int>(_start,_end));
753 geoTypes.push_back(getGeoType());
758 pfls.push_back(glob->getProfile(_profile.c_str()));
760 if(_localization.empty())
764 locs.push_back(glob->getLocalizationId(_localization.c_str()));
768 void MEDFileFieldPerMeshPerTypePerDisc::fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
770 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));
774 void MEDFileFieldPerMeshPerTypePerDisc::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
776 TypeOfField type=getType();
777 INTERP_KERNEL::NormalizedCellType geoType(getGeoType());
778 med_geometry_type mgeoti;
779 med_entity_type menti;
780 _father->entriesForMEDfile(getType(),mgeoti,menti);
781 const DataArray *arr(getOrCreateAndGetArray());
783 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : no array set !");
784 if(!arr->isAllocated())
785 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : the array to be written is not allocated !");
786 const DataArrayDouble *arrD=dynamic_cast<const DataArrayDouble *>(arr);
787 const DataArrayInt *arrI=dynamic_cast<const DataArrayInt *>(arr);
788 const unsigned char *locToWrite=0;
790 locToWrite=reinterpret_cast<const unsigned char *>(arrD->getConstPointer()+_start*arr->getNumberOfComponents());
792 locToWrite=reinterpret_cast<const unsigned char *>(arrI->getConstPointer()+_start*arr->getNumberOfComponents());
794 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::writeLL : not recognized type of values ! Supported are FLOAT64 and INT32 !");
795 MEDFILESAFECALLERWR0(MEDfieldValueWithProfileWr,(fid,nasc.getName().c_str(),getIteration(),getOrder(),getTime(),menti,mgeoti,
796 MED_COMPACT_PFLMODE,_profile.c_str(),_localization.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,_nval,
800 void MEDFileFieldPerMeshPerTypePerDisc::getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const
805 dad.first=_start; dad.second=_end;
809 * \param [in] codeOfMesh is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
810 * This code corresponds to the distribution of types in the corresponding mesh.
811 * \param [out] ptToFill memory zone where the output will be stored.
812 * \return the size of data pushed into output param \a ptToFill
814 int MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const
817 std::ostringstream oss;
818 std::size_t nbOfType=codeOfMesh.size()/3;
820 for(std::size_t i=0;i<nbOfType && found==-1;i++)
821 if(getGeoType()==(INTERP_KERNEL::NormalizedCellType)codeOfMesh[3*i])
825 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
826 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : not found geometric type " << cm.getRepr() << " in the referenced mesh of field !";
827 throw INTERP_KERNEL::Exception(oss.str());
832 if(_nval!=codeOfMesh[3*found+1])
834 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
835 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << " number of elt ids in mesh is equal to " << _nval;
836 oss << " whereas mesh has " << codeOfMesh[3*found+1] << " for this geometric type !";
837 throw INTERP_KERNEL::Exception(oss.str());
839 for(int ii=codeOfMesh[3*found+2];ii<codeOfMesh[3*found+2]+_nval;ii++)
844 const DataArrayInt *pfl=glob.getProfile(_profile.c_str());
845 if(pfl->getNumberOfTuples()!=_nval)
847 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getGeoType());
848 oss << "MEDFileFieldPerMeshPerTypePerDisc::fillEltIdsFromCode : for geometric type " << cm.getRepr() << ", field is defined on profile \"" << _profile << "\" and size of profile is ";
850 oss << pfl->getNumberOfTuples() << " whereas the number of ids is set to " << _nval << " for this geometric type !";
851 throw INTERP_KERNEL::Exception(oss.str());
853 int offset2=codeOfMesh[3*found+2];
854 for(const int *pflId=pfl->begin();pflId!=pfl->end();pflId++)
856 if(*pflId<codeOfMesh[3*found+1])
857 *work++=offset2+*pflId;
863 int MEDFileFieldPerMeshPerTypePerDisc::fillTupleIds(int *ptToFill) const
865 for(int i=_start;i<_end;i++)
870 int MEDFileFieldPerMeshPerTypePerDisc::ConvertType(TypeOfField type, int locId)
881 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::ConvertType : not managed type of field !");
885 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries)
888 std::map<std::pair<std::string,TypeOfField>,int> m;
889 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > ret;
890 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
891 if(m.find(std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType()))==m.end())
892 m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]=id++;
894 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entries.begin();it!=entries.end();it++)
895 ret[m[std::pair<std::string,TypeOfField>((*it)->getLocalization(),(*it)->getType())]].push_back(*it);
900 * - \c this->_loc_id mutable attribute is used for elt id in mesh offsets.
902 * \param [in] offset the offset id used to take into account that \a result is not compulsary empty in input
903 * \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.
904 * \param [in] explicitIdsInMesh ids in mesh of the considered chunk.
905 * \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)
906 * \param [in,out] glob if necessary by the method, new profiles can be added to it
907 * \param [in,out] arr after the call of this method \a arr is renumbered to be compliant with added entries to \a result.
908 * \param [out] result All new entries will be appended on it.
909 * \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 !)
911 bool MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
912 const DataArrayInt *explicitIdsInMesh,
913 const std::vector<int>& newCode,
914 MEDFileFieldGlobsReal& glob, DataArrayDouble *arr,
915 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result)
917 if(entriesOnSameDisc.empty())
919 TypeOfField type=entriesOnSameDisc[0]->getType();
920 int szEntities=0,szTuples=0;
921 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++)
922 { szEntities+=(*it)->_nval; szTuples+=(*it)->_end-(*it)->_start; }
923 int nbi=szTuples/szEntities;
924 if(szTuples%szEntities!=0)
925 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks : internal error the splitting into same dicretization failed !");
926 MCAuto<DataArrayInt> renumTuples=DataArrayInt::New(); renumTuples->alloc(szTuples,1);
927 MCAuto<DataArrayInt> ranges=MEDCouplingUMesh::ComputeRangesFromTypeDistribution(newCode);
928 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk(entriesOnSameDisc.size());
929 std::vector< const DataArrayInt * > newGeoTypesPerChunk2(entriesOnSameDisc.size());
930 std::vector< MCAuto<DataArrayInt> > newGeoTypesPerChunk_bis(entriesOnSameDisc.size());
931 std::vector< const DataArrayInt * > newGeoTypesPerChunk3(entriesOnSameDisc.size());
932 MCAuto<DataArrayInt> newGeoTypesPerChunk4=DataArrayInt::New(); newGeoTypesPerChunk4->alloc(szEntities,nbi);
934 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesOnSameDisc.begin();it!=entriesOnSameDisc.end();it++,id++)
936 int startOfEltIdOfChunk=(*it)->_start;
937 MCAuto<DataArrayInt> newEltIds=explicitIdsInMesh->subArray(startOfEltIdOfChunk,startOfEltIdOfChunk+(*it)->_nval);
938 MCAuto<DataArrayInt> rangeIdsForChunk=newEltIds->findRangeIdForEachTuple(ranges);
939 MCAuto<DataArrayInt> idsInRrangeForChunk=newEltIds->findIdInRangeForEachTuple(ranges);
941 MCAuto<DataArrayInt> tmp=rangeIdsForChunk->duplicateEachTupleNTimes(nbi); rangeIdsForChunk->rearrange(nbi);
942 newGeoTypesPerChunk4->setPartOfValues1(tmp,(*it)->_tmp_work1-offset,(*it)->_tmp_work1+(*it)->_nval*nbi-offset,1,0,nbi,1);
944 newGeoTypesPerChunk[id]=rangeIdsForChunk; newGeoTypesPerChunk2[id]=rangeIdsForChunk;
945 newGeoTypesPerChunk_bis[id]=idsInRrangeForChunk; newGeoTypesPerChunk3[id]=idsInRrangeForChunk;
947 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather=DataArrayInt::Aggregate(newGeoTypesPerChunk2); newGeoTypesPerChunk.clear(); newGeoTypesPerChunk2.clear();
948 MCAuto<DataArrayInt> newGeoTypesEltIdsAllGather2=DataArrayInt::Aggregate(newGeoTypesPerChunk3); newGeoTypesPerChunk_bis.clear(); newGeoTypesPerChunk3.clear();
949 MCAuto<DataArrayInt> diffVals=newGeoTypesEltIdsAllGather->getDifferentValues();
950 MCAuto<DataArrayInt> renumEltIds=newGeoTypesEltIdsAllGather->buildPermArrPerLevel();
952 MCAuto<DataArrayInt> renumTupleIds=newGeoTypesPerChunk4->buildPermArrPerLevel();
954 MCAuto<DataArrayDouble> arrPart=arr->subArray(offset,offset+szTuples);
955 arrPart->renumberInPlace(renumTupleIds->begin());
956 arr->setPartOfValues1(arrPart,offset,offset+szTuples,1,0,arrPart->getNumberOfComponents(),1);
958 const int *idIt=diffVals->begin();
959 std::list<const MEDFileFieldPerMeshPerTypePerDisc *> li(entriesOnSameDisc.begin(),entriesOnSameDisc.end());
961 for(int i=0;i<diffVals->getNumberOfTuples();i++,idIt++)
963 MCAuto<DataArrayInt> ids=newGeoTypesEltIdsAllGather->findIdsEqual(*idIt);
964 MCAuto<DataArrayInt> subIds=newGeoTypesEltIdsAllGather2->selectByTupleId(ids->begin(),ids->end());
965 int nbEntityElts=subIds->getNumberOfTuples();
967 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> eltToAdd=MEDFileFieldPerMeshPerTypePerDisc::
968 NewObjectOnSameDiscThanPool(type,(INTERP_KERNEL::NormalizedCellType)newCode[3*(*idIt)],subIds,!subIds->isIota(newCode[3*(*idIt)+1]),nbi,
972 result.push_back(eltToAdd);
973 offset2+=nbEntityElts*nbi;
975 ret=ret || li.empty();
980 * \param [in] typeF type of field of new chunk
981 * \param [in] geoType the geometric type of the chunk
982 * \param [in] idsOfMeshElt the entity ids of mesh (cells or nodes) of the new chunk.
983 * \param [in] isPfl specifies if a profile is requested regarding size of \a idsOfMeshElt and the number of such entities regarding underlying mesh.
984 * \param [in] nbi number of integration points
985 * \param [in] offset The offset in the **global array of data**.
986 * \param [in,out] entriesOnSameDisc the pool **on the same discretization** inside which it will be attempted to find an existing entry corresponding exactly
987 * to the new chunk to create.
988 * \param [in,out] glob the global shared info that will be requested for existing profiles or to append a new profile if needed.
989 * \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
990 * and corresponding entry erased from \a entriesOnSameDisc.
991 * \return a newly allocated chunk
993 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
994 bool isPfl, int nbi, int offset,
995 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
996 MEDFileFieldGlobsReal& glob,
999 int nbMeshEntities=idsOfMeshElt->getNumberOfTuples();
1000 std::list< const MEDFileFieldPerMeshPerTypePerDisc *>::iterator it=entriesOnSameDisc.begin();
1001 for(;it!=entriesOnSameDisc.end();it++)
1003 if(((INTERP_KERNEL::NormalizedCellType)(*it)->_loc_id)==geoType && (*it)->_nval==nbMeshEntities)
1007 if((*it)->_profile.empty())
1010 if(!(*it)->_profile.empty())
1012 const DataArrayInt *pfl=glob.getProfile((*it)->_profile.c_str());
1013 if(pfl->isEqualWithoutConsideringStr(*idsOfMeshElt))
1019 if(it==entriesOnSameDisc.end())
1022 MEDFileFieldPerMeshPerTypePerDisc *ret=new MEDFileFieldPerMeshPerTypePerDisc;
1024 ret->_loc_id=(int)geoType;
1025 ret->_nval=nbMeshEntities;
1027 ret->_end=ret->_start+ret->_nval*nbi;
1030 idsOfMeshElt->setName(glob.createNewNameOfPfl().c_str());
1031 glob.appendProfile(idsOfMeshElt);
1032 ret->_profile=idsOfMeshElt->getName();
1034 //tony treatment of localization
1039 notInExisting=false;
1040 MEDFileFieldPerMeshPerTypePerDisc *ret=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
1041 ret->_loc_id=(int)geoType;
1042 ret->setNewStart(offset);
1043 entriesOnSameDisc.erase(it);
1049 ////////////////////////////////////
1051 MEDFileFieldPerMeshPerTypeCommon::~MEDFileFieldPerMeshPerTypeCommon()
1055 void MEDFileFieldPerMeshPerTypeCommon::setFather(MEDFileFieldPerMesh *father)
1060 void MEDFileFieldPerMeshPerTypeCommon::deepCopyElements()
1063 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1065 if((const MEDFileFieldPerMeshPerTypePerDisc *)*it)
1066 _field_pm_pt_pd[i]=(*it)->deepCopy(this);
1070 std::size_t MEDFileFieldPerMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
1072 return _field_pm_pt_pd.capacity()*sizeof(MCAuto<MEDFileFieldPerMeshPerTypePerDisc>);
1075 std::vector<const BigMemoryObject *> MEDFileFieldPerMeshPerTypeCommon::getDirectChildrenWithNull() const
1077 std::vector<const BigMemoryObject *> ret;
1078 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1079 ret.push_back((const MEDFileFieldPerMeshPerTypePerDisc *)*it);
1083 void MEDFileFieldPerMeshPerTypeCommon::assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1085 std::vector<int> pos=addNewEntryIfNecessary(field,offset,nbOfCells);
1086 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1087 _field_pm_pt_pd[*it]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1091 * This method is the most general one. No optimization is done here.
1092 * \param [in] multiTypePfl is the end user profile specified in high level API
1093 * \param [in] idsInPfl is the selection into the \a multiTypePfl whole profile that corresponds to the current geometric type.
1094 * \param [in] locIds is the profile needed to be created for MED file format. It can be null if all cells of current geometric type are fetched in \a multiTypePfl.
1095 * \b WARNING if not null the MED file profile can be subdivided again in case of Gauss points.
1096 * \param [in] nbOfEltsInWholeMesh nb of elts of type \a this->_geo_type in \b WHOLE mesh
1097 * \param [in] mesh is the mesh coming from the MEDFileMesh instance in correspondance with the MEDFileField. The mesh inside the \a field is simply ignored.
1099 void MEDFileFieldPerMeshPerTypeCommon::assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1101 std::vector<int> pos=addNewEntryIfNecessary(field,idsInPfl);
1102 for(std::vector<int>::const_iterator it=pos.begin();it!=pos.end();it++)
1103 _field_pm_pt_pd[*it]->assignFieldProfile(isPflAlone,start,multiTypePfl,idsInPfl,locIds,nbOfEltsInWholeMesh,field,arr,mesh,glob,nasc);
1106 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1108 _field_pm_pt_pd.resize(1);
1109 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1110 _field_pm_pt_pd[0]->assignNodeFieldNoProfile(start,field,arr,glob);
1113 void MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1115 MCAuto<DataArrayInt> pfl2=pfl->deepCopy();
1116 if(!arr || !arr->isAllocated())
1117 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::assignNodeFieldProfile : input array is null, or not allocated !");
1118 _field_pm_pt_pd.resize(1);
1119 _field_pm_pt_pd[0]=MEDFileFieldPerMeshPerTypePerDisc::New(this,ON_NODES,-3);
1120 _field_pm_pt_pd[0]->assignFieldProfile(true,start,pfl,pfl2,pfl2,-1,field,arr,0,glob,nasc);//mesh is not requested so 0 is send.
1123 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1125 TypeOfField type=field->getTypeOfField();
1126 if(type!=ON_GAUSS_PT)
1128 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1129 int sz=_field_pm_pt_pd.size();
1131 for(int j=0;j<sz && !found;j++)
1133 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1135 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1141 _field_pm_pt_pd.resize(sz+1);
1142 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1144 std::vector<int> ret(1,(int)sz);
1149 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,offset,nbOfCells);
1150 int sz2=ret2.size();
1151 std::vector<int> ret3(sz2);
1153 for(int i=0;i<sz2;i++)
1155 int sz=_field_pm_pt_pd.size();
1156 int locIdToFind=ret2[i];
1158 for(int j=0;j<sz && !found;j++)
1160 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1162 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1169 _field_pm_pt_pd.resize(sz+1);
1170 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1178 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells)
1180 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1181 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1183 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1184 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1186 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss (no profile) : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1187 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafeSlice(offset,offset+nbOfCells,1);
1188 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1189 if(retTmp->presenceOfValue(-1))
1190 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1191 std::vector<int> ret(retTmp->begin(),retTmp->end());
1195 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1197 TypeOfField type=field->getTypeOfField();
1198 if(type!=ON_GAUSS_PT)
1200 int locIdToFind=MEDFileFieldPerMeshPerTypePerDisc::ConvertType(type,0);
1201 int sz=_field_pm_pt_pd.size();
1203 for(int j=0;j<sz && !found;j++)
1205 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1207 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1213 _field_pm_pt_pd.resize(sz+1);
1214 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1216 std::vector<int> ret(1,0);
1221 std::vector<int> ret2=addNewEntryIfNecessaryGauss(field,subCells);
1222 int sz2=ret2.size();
1223 std::vector<int> ret3(sz2);
1225 for(int i=0;i<sz2;i++)
1227 int sz=_field_pm_pt_pd.size();
1228 int locIdToFind=ret2[i];
1230 for(int j=0;j<sz && !found;j++)
1232 if(_field_pm_pt_pd[j]->getLocId()==locIdToFind)
1234 _field_pm_pt_pd[j]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1241 _field_pm_pt_pd.resize(sz+1);
1242 _field_pm_pt_pd[sz]=MEDFileFieldPerMeshPerTypePerDisc::New(this,type,locIdToFind);
1250 std::vector<int> MEDFileFieldPerMeshPerTypeCommon::addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells)
1252 const MEDCouplingFieldDiscretization *disc=field->getDiscretization();
1253 const MEDCouplingFieldDiscretizationGauss *disc2=dynamic_cast<const MEDCouplingFieldDiscretizationGauss *>(disc);
1255 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : invalid call to this method ! Internal Error !");
1256 const DataArrayInt *da=disc2->getArrayOfDiscIds();
1258 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : no localization ids per cell array available ! The input Gauss node field is maybe invalid !");
1259 MCAuto<DataArrayInt> da2=da->selectByTupleIdSafe(subCells->getConstPointer(),subCells->getConstPointer()+subCells->getNumberOfTuples());
1260 MCAuto<DataArrayInt> retTmp=da2->getDifferentValues();
1261 if(retTmp->presenceOfValue(-1))
1262 throw INTERP_KERNEL::Exception("addNewEntryIfNecessaryGauss : some cells have no dicretization description !");
1263 std::vector<int> ret(retTmp->begin(),retTmp->end());
1267 const MEDFileFieldPerMesh *MEDFileFieldPerMeshPerTypeCommon::getFather() const
1272 bool MEDFileFieldPerMeshPerTypeCommon::isUniqueLevel(int& dim) const
1274 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(getGeoType()));
1275 int curDim((int)cm.getDimension());
1276 if(dim!=std::numeric_limits<int>::max())
1286 void MEDFileFieldPerMeshPerTypeCommon::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1288 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1290 (*it)->fillTypesOfFieldAvailable(types);
1294 void MEDFileFieldPerMeshPerTypeCommon::fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const
1296 int sz=_field_pm_pt_pd.size();
1297 dads.resize(sz); types.resize(sz); pfls.resize(sz); locs.resize(sz);
1298 for(int i=0;i<sz;i++)
1300 _field_pm_pt_pd[i]->getCoarseData(types[i],dads[i],pfls[i],locs[i]);
1304 int MEDFileFieldPerMeshPerTypeCommon::getIteration() const
1306 return _father->getIteration();
1309 int MEDFileFieldPerMeshPerTypeCommon::getOrder() const
1311 return _father->getOrder();
1314 double MEDFileFieldPerMeshPerTypeCommon::getTime() const
1316 return _father->getTime();
1319 std::string MEDFileFieldPerMeshPerTypeCommon::getMeshName() const
1321 return _father->getMeshName();
1324 void MEDFileFieldPerMeshPerTypeCommon::getSizes(int& globalSz, int& nbOfEntries) const
1326 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1328 globalSz+=(*it)->getNumberOfTuples();
1330 nbOfEntries+=(int)_field_pm_pt_pd.size();
1333 int MEDFileFieldPerMeshPerTypeCommon::getNumberOfComponents() const
1335 return _father->getNumberOfComponents();
1338 bool MEDFileFieldPerMeshPerTypeCommon::presenceOfMultiDiscPerGeoType() const
1341 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1343 const MEDFileFieldPerMeshPerTypePerDisc *fmtd(*it);
1350 void MEDFileFieldPerMeshPerTypeCommon::pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc)
1352 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt;
1354 _field_pm_pt_pd.push_back(elt);
1357 DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray()
1359 return _father->getOrCreateAndGetArray();
1362 const DataArray *MEDFileFieldPerMeshPerTypeCommon::getOrCreateAndGetArray() const
1364 const MEDFileFieldPerMesh *fath=_father;
1365 return fath->getOrCreateAndGetArray();
1368 const std::vector<std::string>& MEDFileFieldPerMeshPerTypeCommon::getInfo() const
1370 return _father->getInfo();
1373 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsed() const
1375 std::vector<std::string> ret;
1376 std::set<std::string> ret2;
1377 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1379 std::string tmp=(*it1)->getProfile();
1381 if(ret2.find(tmp)==ret2.end())
1390 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsed() const
1392 std::vector<std::string> ret;
1393 std::set<std::string> ret2;
1394 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1396 std::string tmp=(*it1)->getLocalization();
1397 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1398 if(ret2.find(tmp)==ret2.end())
1407 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getPflsReallyUsedMulti() const
1409 std::vector<std::string> ret;
1410 std::set<std::string> ret2;
1411 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1413 std::string tmp=(*it1)->getProfile();
1420 std::vector<std::string> MEDFileFieldPerMeshPerTypeCommon::getLocsReallyUsedMulti() const
1422 std::vector<std::string> ret;
1423 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1425 std::string tmp=(*it1)->getLocalization();
1426 if(!tmp.empty() && tmp!=MED_GAUSS_ELNO)
1432 void MEDFileFieldPerMeshPerTypeCommon::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1434 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1435 (*it1)->changePflsRefsNamesGen(mapOfModif);
1438 void MEDFileFieldPerMeshPerTypeCommon::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
1440 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it1=_field_pm_pt_pd.begin();it1!=_field_pm_pt_pd.end();it1++)
1441 (*it1)->changeLocsRefsNamesGen(mapOfModif);
1444 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId)
1446 if(_field_pm_pt_pd.empty())
1448 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1449 throw INTERP_KERNEL::Exception(oss.str());
1451 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1452 return _field_pm_pt_pd[locId];
1453 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1454 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1455 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1456 return static_cast<MEDFileFieldPerMeshPerTypePerDisc*>(0);
1459 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId(int locId) const
1461 if(_field_pm_pt_pd.empty())
1463 std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no localizations for geotype \"" << getGeoTypeRepr() << "\" !";
1464 throw INTERP_KERNEL::Exception(oss.str());
1466 if(locId>=0 && locId<(int)_field_pm_pt_pd.size())
1467 return _field_pm_pt_pd[locId];
1468 std::ostringstream oss2; oss2 << "MEDFileFieldPerMeshPerTypeCommon::getLeafGivenLocId : no such locId available (" << locId;
1469 oss2 << ") for geometric type \"" << getGeoTypeRepr() << "\" It should be in [0," << _field_pm_pt_pd.size() << ") !";
1470 throw INTERP_KERNEL::Exception(oss2.str().c_str());
1471 return static_cast<const MEDFileFieldPerMeshPerTypePerDisc*>(0);
1474 void MEDFileFieldPerMeshPerTypeCommon::fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1477 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1479 (*it)->fillValues(i,startEntryId,entries);
1483 void MEDFileFieldPerMeshPerTypeCommon::setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
1485 _field_pm_pt_pd=leaves;
1486 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1487 (*it)->setFather(this);
1491 * \param [in,out] globalNum a global numbering counter for the renumbering.
1492 * \param [out] its - list of pair (start,stop) kept
1493 * \return bool - false if the type of field \a tof is not contained in \a this.
1495 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
1498 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd;
1499 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1500 if((*it)->getType()==tof)
1502 newPmPtPd.push_back(*it);
1503 std::pair<int,int> bgEnd; bgEnd.first=(*it)->getStart(); bgEnd.second=(*it)->getEnd();
1504 (*it)->setNewStart(globalNum);
1505 globalNum=(*it)->getEnd();
1506 its.push_back(bgEnd);
1510 _field_pm_pt_pd=newPmPtPd;
1515 * \param [in,out] globalNum a global numbering counter for the renumbering.
1516 * \param [out] its - list of pair (start,stop) kept
1517 * \return bool - false if the type of field \a tof is not contained in \a this.
1519 bool MEDFileFieldPerMeshPerTypeCommon::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
1521 if(_field_pm_pt_pd.size()<=idOfDisc)
1523 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt(_field_pm_pt_pd[idOfDisc]);
1524 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > newPmPtPd(1,elt);
1525 std::pair<int,int> bgEnd; bgEnd.first=_field_pm_pt_pd[idOfDisc]->getStart(); bgEnd.second=_field_pm_pt_pd[idOfDisc]->getEnd();
1526 elt->setNewStart(globalNum);
1527 globalNum=elt->getEnd();
1528 its.push_back(bgEnd);
1529 _field_pm_pt_pd=newPmPtPd;
1533 void MEDFileFieldPerMeshPerTypeCommon::loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc)
1535 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1536 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1539 void MEDFileFieldPerMeshPerTypeCommon::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1541 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1542 (*it)->loadBigArray(fid,nasc);
1545 void MEDFileFieldPerMeshPerTypeCommon::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1547 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1549 (*it)->copyOptionsFrom(*this);
1550 (*it)->writeLL(fid,nasc);
1554 med_entity_type MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType)
1559 medfGeoType=typmai3[(int)ikGeoType];
1562 medfGeoType=MED_NONE;
1565 medfGeoType=typmai3[(int)ikGeoType];
1566 return MED_NODE_ELEMENT;
1568 medfGeoType=typmai3[(int)ikGeoType];
1571 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType : unexpected entity type ! internal error");
1573 return MED_UNDEF_ENTITY_TYPE;
1576 //////////////////////////////////////////////////
1578 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd)
1580 return new MEDFileFieldPerMeshPerType(fid,fath,type,geoType,nasc,pd);
1583 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType)
1585 return new MEDFileFieldPerMeshPerType(fath,geoType);
1588 MEDFileFieldPerMeshPerType *MEDFileFieldPerMeshPerType::deepCopy(MEDFileFieldPerMesh *father) const
1590 MCAuto<MEDFileFieldPerMeshPerType> ret=new MEDFileFieldPerMeshPerType(*this);
1591 ret->setFather(father);
1592 ret->deepCopyElements();
1596 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
1598 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1600 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1601 if(meshDim!=(int)cm.getDimension())
1604 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++)
1605 (*it)->getFieldAtLevel(type,glob,dads,pfls,locs,geoTypes);
1608 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerType::getGeoType() const
1613 void MEDFileFieldPerMeshPerType::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1615 ent=MEDFileFieldPerMeshPerTypeCommon::ConvertIntoMEDFileType(mct,_geo_type,gt);
1618 void MEDFileFieldPerMeshPerType::getDimension(int& dim) const
1620 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1621 int curDim((int)cm.getDimension());
1622 dim=std::max(dim,curDim);
1625 void MEDFileFieldPerMeshPerType::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1627 const char startLine[]=" ## ";
1628 std::string startLine2(bkOffset,' ');
1629 std::string startLine3(startLine2);
1630 startLine3+=startLine;
1631 if(_geo_type!=INTERP_KERNEL::NORM_ERROR)
1633 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(_geo_type);
1634 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry types " << cm.getRepr() << "." << std::endl;
1637 oss << startLine3 << "Entry geometry type #" << id << " is lying on NODES." << std::endl;
1638 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1640 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1642 const MEDFileFieldPerMeshPerTypePerDisc *cur=(*it);
1644 cur->simpleRepr(bkOffset,oss,i);
1647 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1652 std::string MEDFileFieldPerMeshPerType::getGeoTypeRepr() const
1654 const INTERP_KERNEL::CellModel& cm(INTERP_KERNEL::CellModel::GetCellModel(_geo_type));
1655 return std::string(cm.getRepr());
1658 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt):MEDFileFieldPerMeshPerTypeCommon(father),_geo_type(gt)
1662 MEDFileFieldPerMeshPerType::MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd):MEDFileFieldPerMeshPerTypeCommon(fath),_geo_type(geoType)
1664 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1665 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1666 med_geometry_type mgeoti;
1667 med_entity_type menti(ConvertIntoMEDFileType(type,geoType,mgeoti));
1668 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),menti,mgeoti,pflName,locName));
1669 _field_pm_pt_pd.resize(nbProfiles);
1670 for(int i=0;i<nbProfiles;i++)
1672 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,type,i,pd);
1676 int nbProfiles2(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,mgeoti,pflName,locName));
1677 for(int i=0;i<nbProfiles2;i++)
1678 _field_pm_pt_pd.push_back(MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,ON_GAUSS_NE,i,pd));
1682 MCAuto<MEDFileFieldPerMeshPerType> MEDFileFieldPerMeshPerType::Aggregate(int &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
1684 MCAuto<MEDFileFieldPerMeshPerType> ret(MEDFileFieldPerMeshPerType::New(father,gt));
1685 std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > > m;
1686 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerType *> >::const_iterator it=pms.begin();it!=pms.end();it++)
1688 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it2=(*it).second->_field_pm_pt_pd.begin();it2!=(*it).second->_field_pm_pt_pd.end();it2++)
1689 m[(*it2)->getType()].push_back(std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * >((*it).first,*it2));
1691 for(std::map<TypeOfField, std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc * > > >::const_iterator it=m.begin();it!=m.end();it++)
1693 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> agg(MEDFileFieldPerMeshPerTypePerDisc::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
1694 ret->_field_pm_pt_pd.push_back(agg);
1699 //////////////////////////////////////////////////
1701 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc)
1704 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : null pointer !");
1705 const MEDFileAllStaticEntitiesPlusDyn *entities2(dynamic_cast<const MEDFileAllStaticEntitiesPlusDyn *>(entities));
1707 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypeDyn::NewOnRead : invalid type of entities !");
1708 const MEDFileStructureElement *se(entities2->getWithGT(idGT));
1709 return new MEDFileFieldPerMeshPerTypeDyn(fid,fath,se,nasc);
1712 MEDFileFieldPerMeshPerTypeDyn::MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc):MEDFileFieldPerMeshPerTypeCommon(fath)
1715 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1716 INTERP_KERNEL::AutoPtr<char> locName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
1717 int nbProfiles(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,_se->getDynGT(),pflName,locName));
1718 _field_pm_pt_pd.resize(nbProfiles);
1719 for(int i=0;i<nbProfiles;i++)
1721 _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::NewOnRead(this,_se->getEntity(),i,NULL);
1725 int MEDFileFieldPerMeshPerTypeDyn::getDynGT() const
1727 return _se->getDynGT();
1730 std::string MEDFileFieldPerMeshPerTypeDyn::getModelName() const
1732 return _se->getName();
1735 void MEDFileFieldPerMeshPerTypeDyn::getDimension(int& dim) const
1737 throw INTERP_KERNEL::Exception("not implemented yet !");
1740 void MEDFileFieldPerMeshPerTypeDyn::entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const
1743 ent=MED_STRUCT_ELEMENT;
1746 INTERP_KERNEL::NormalizedCellType MEDFileFieldPerMeshPerTypeDyn::getGeoType() const
1748 throw INTERP_KERNEL::Exception("not implemented yet !");
1751 void MEDFileFieldPerMeshPerTypeDyn::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1753 const char startLine[]=" ## ";
1754 std::string startLine2(bkOffset,' ');
1755 std::string startLine3(startLine2);
1756 startLine3+=startLine;
1757 oss << startLine3 << "Entry geometry type #" << id << " is lying on geometry STRUCTURE_ELEMENT type " << getDynGT() << "." << std::endl;
1758 oss << startLine3 << "Entry is defined on " << _field_pm_pt_pd.size() << " localizations." << std::endl;
1760 for(std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >::const_iterator it=_field_pm_pt_pd.begin();it!=_field_pm_pt_pd.end();it++,i++)
1762 if((*it).isNotNull())
1763 (*it)->simpleRepr(bkOffset,oss,i);
1766 oss << startLine2 << " ## " << "Localization #" << i << " is empty !" << std::endl;
1771 std::string MEDFileFieldPerMeshPerTypeDyn::getGeoTypeRepr() const
1773 throw INTERP_KERNEL::Exception("not implemented yet !");
1776 MEDFileFieldPerMeshPerTypeDyn *MEDFileFieldPerMeshPerTypeDyn::deepCopy(MEDFileFieldPerMesh *father) const
1778 MCAuto<MEDFileFieldPerMeshPerTypeDyn> ret(new MEDFileFieldPerMeshPerTypeDyn(*this));
1779 ret->setFather(father);
1780 ret->deepCopyElements();
1784 void MEDFileFieldPerMeshPerTypeDyn::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
1786 throw INTERP_KERNEL::Exception("not implemented yet !");
1789 //////////////////////////////////////////////////
1791 MEDFileFieldPerMesh *MEDFileFieldPerMesh::NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities)
1793 return new MEDFileFieldPerMesh(fid,fath,meshCsit,meshIteration,meshOrder,nasc,mm,entities);
1796 MEDFileFieldPerMesh *MEDFileFieldPerMesh::New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh)
1798 return new MEDFileFieldPerMesh(fath,mesh);
1801 std::size_t MEDFileFieldPerMesh::getHeapMemorySizeWithoutChildren() const
1803 return _mesh_name.capacity()+_field_pm_pt.capacity()*sizeof(MCAuto< MEDFileFieldPerMeshPerType >);
1806 std::vector<const BigMemoryObject *> MEDFileFieldPerMesh::getDirectChildrenWithNull() const
1808 std::vector<const BigMemoryObject *> ret;
1809 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1814 MEDFileFieldPerMesh *MEDFileFieldPerMesh::deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const
1816 MCAuto< MEDFileFieldPerMesh > ret=new MEDFileFieldPerMesh(*this);
1817 ret->_father=father;
1819 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1821 if((*it).isNotNull())
1822 ret->_field_pm_pt[i]=(*it)->deepCopy((MEDFileFieldPerMesh *)(ret));
1827 void MEDFileFieldPerMesh::simpleRepr(int bkOffset, std::ostream& oss, int id) const
1829 std::string startLine(bkOffset,' ');
1830 oss << startLine << "## Field part (" << id << ") lying on mesh \"" << _mesh_name << "\", Mesh iteration=" << _mesh_iteration << ". Mesh order=" << _mesh_order << "." << std::endl;
1831 oss << startLine << "## Field is defined on " << _field_pm_pt.size() << " types." << std::endl;
1833 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
1835 if((*it).isNotNull())
1836 (*it)->simpleRepr(bkOffset,oss,i);
1839 oss << startLine << " ## Entry geometry type #" << i << " is empty !" << std::endl;
1844 void MEDFileFieldPerMesh::copyTinyInfoFrom(const MEDCouplingMesh *mesh)
1846 _mesh_name=mesh->getName();
1847 mesh->getTime(_mesh_iteration,_mesh_order);
1850 void MEDFileFieldPerMesh::assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1852 int nbOfTypes=code.size()/3;
1854 for(int i=0;i<nbOfTypes;i++)
1856 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1857 int nbOfCells=code[3*i+1];
1858 int pos=addNewEntryIfNecessary(type);
1859 _field_pm_pt[pos]->assignFieldNoProfile(start,offset,nbOfCells,field,arr,glob,nasc);
1865 * This method is the most general one. No optimization is done here.
1866 * \param [in] multiTypePfl is the end user profile specified in high level API
1867 * \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].
1868 * \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.
1869 * \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.
1870 * \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.
1871 * \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.
1873 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)
1875 int nbOfTypes(code.size()/3);
1876 for(int i=0;i<nbOfTypes;i++)
1878 INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)code[3*i];
1879 int pos=addNewEntryIfNecessary(type);
1880 DataArrayInt *pfl=0;
1882 pfl=idsPerType[code[3*i+2]];
1883 int nbOfTupes2=code2.size()/3;
1885 for(;found<nbOfTupes2;found++)
1886 if(code[3*i]==code2[3*found])
1888 if(found==nbOfTupes2)
1889 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::assignFieldProfile : internal problem ! Should never happen ! Please report bug to anthony.geay@cea.fr !");
1890 _field_pm_pt[pos]->assignFieldProfile(nbOfTypes==1,start,multiTypePfl,idsInPflPerType[i],pfl,code2[3*found+1],field,arr,mesh,glob,nasc);
1894 void MEDFileFieldPerMesh::assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
1896 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1897 _field_pm_pt[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
1900 void MEDFileFieldPerMesh::assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
1902 int pos=addNewEntryIfNecessary(INTERP_KERNEL::NORM_ERROR);
1903 _field_pm_pt[pos]->assignNodeFieldProfile(start,pfl,field,arr,glob,nasc);
1906 void MEDFileFieldPerMesh::loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc)
1908 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1909 (*it)->loadOnlyStructureOfDataRecursively(fid,start,nasc);
1912 void MEDFileFieldPerMesh::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
1914 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1915 (*it)->loadBigArraysRecursively(fid,nasc);
1918 void MEDFileFieldPerMesh::writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const
1920 int nbOfTypes=_field_pm_pt.size();
1921 for(int i=0;i<nbOfTypes;i++)
1923 _field_pm_pt[i]->copyOptionsFrom(*this);
1924 _field_pm_pt[i]->writeLL(fid,nasc);
1928 void MEDFileFieldPerMesh::getDimension(int& dim) const
1930 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1931 (*it)->getDimension(dim);
1934 bool MEDFileFieldPerMesh::isUniqueLevel(int& dim) const
1936 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1937 if(!(*it)->isUniqueLevel(dim))
1942 void MEDFileFieldPerMesh::fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const
1944 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1945 (*it)->fillTypesOfFieldAvailable(types);
1948 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
1950 int sz=_field_pm_pt.size();
1951 std::vector< std::vector<std::pair<int,int> > > ret(sz);
1952 types.resize(sz); typesF.resize(sz); pfls.resize(sz); locs.resize(sz);
1953 for(int i=0;i<sz;i++)
1955 types[i]=_field_pm_pt[i]->getGeoType();
1956 _field_pm_pt[i]->fillFieldSplitedByType(ret[i],typesF[i],pfls[i],locs[i]);
1961 double MEDFileFieldPerMesh::getTime() const
1964 return _father->getTime(tmp1,tmp2);
1967 int MEDFileFieldPerMesh::getIteration() const
1969 return _father->getIteration();
1972 int MEDFileFieldPerMesh::getOrder() const
1974 return _father->getOrder();
1977 int MEDFileFieldPerMesh::getNumberOfComponents() const
1979 return _father->getNumberOfComponents();
1982 bool MEDFileFieldPerMesh::presenceOfMultiDiscPerGeoType() const
1984 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1988 if((*it)->presenceOfMultiDiscPerGeoType())
1994 bool MEDFileFieldPerMesh::presenceOfStructureElements() const
1996 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
1997 if((*it).isNotNull())
1999 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2006 bool MEDFileFieldPerMesh::onlyStructureElements() const
2008 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2009 if((*it).isNotNull())
2011 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2018 void MEDFileFieldPerMesh::killStructureElements()
2020 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2021 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2023 if((*it).isNotNull())
2025 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2033 void MEDFileFieldPerMesh::keepOnlyStructureElements()
2035 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2036 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2038 if((*it).isNotNull())
2040 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2048 void MEDFileFieldPerMesh::keepOnlyOnSE(const std::string& seName)
2050 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > res;
2051 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2053 if((*it).isNotNull())
2055 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2057 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::keepOnlyOnSE : presence of non SE !");
2058 if(pt->getModelName()==seName)
2065 void MEDFileFieldPerMesh::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
2067 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2069 if((*it).isNotNull())
2071 const MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<const MEDFileFieldPerMeshPerTypeDyn *>((const MEDFileFieldPerMeshPerTypeCommon *)*it));
2074 ps.push_back(std::pair<std::string,std::string>(getMeshName(),pt->getModelName()));
2077 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getMeshSENames : presence of a non structure element part !");
2082 DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray()
2085 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2086 return _father->getOrCreateAndGetArray();
2089 const DataArray *MEDFileFieldPerMesh::getOrCreateAndGetArray() const
2092 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getOrCreateAndGetArray : no father ! internal error !");
2093 return _father->getOrCreateAndGetArray();
2096 const std::vector<std::string>& MEDFileFieldPerMesh::getInfo() const
2098 return _father->getInfo();
2102 * type,geoTypes,dads,pfls,locs are input parameters. They should have the same size.
2103 * 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.
2104 * It returns 2 output vectors :
2105 * - 'code' of size 3*sz where sz is the number of different values into 'geoTypes'
2106 * - 'notNullPfls' contains sz2 values that are extracted from 'pfls' in which null profiles have been removed.
2107 * 'code' and 'notNullPfls' are in MEDCouplingUMesh::checkTypeConsistencyAndContig format.
2109 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)
2111 int notNullPflsSz=0;
2112 int nbOfArrs=geoTypes.size();
2113 for(int i=0;i<nbOfArrs;i++)
2116 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes3(geoTypes.begin(),geoTypes.end());
2117 int nbOfDiffGeoTypes=geoTypes3.size();
2118 code.resize(3*nbOfDiffGeoTypes);
2119 notNullPfls.resize(notNullPflsSz);
2122 for(int i=0;i<nbOfDiffGeoTypes;i++)
2125 INTERP_KERNEL::NormalizedCellType refType=geoTypes[j];
2126 std::vector<const DataArrayInt *> notNullTmp;
2128 notNullTmp.push_back(pfls[j]);
2130 for(;j<nbOfArrs;j++)
2131 if(geoTypes[j]==refType)
2134 notNullTmp.push_back(pfls[j]);
2138 std::vector< std::pair<int,int> > tmpDads(dads.begin()+startZone,dads.begin()+j);
2139 std::vector<const DataArrayInt *> tmpPfls(pfls.begin()+startZone,pfls.begin()+j);
2140 std::vector<int> tmpLocs(locs.begin()+startZone,locs.begin()+j);
2141 code[3*i]=(int)refType;
2142 std::vector<INTERP_KERNEL::NormalizedCellType> refType2(1,refType);
2143 code[3*i+1]=ComputeNbOfElems(glob,type,refType2,tmpDads,tmpLocs);
2144 if(notNullTmp.empty())
2148 notNullPfls[notNullPflsSz]=DataArrayInt::Aggregate(notNullTmp);
2149 code[3*i+2]=notNullPflsSz++;
2155 * 'dads' 'geoTypes' and 'locs' are input parameters that should have same size sz. sz should be >=1.
2157 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)
2161 for(int i=0;i<sz;i++)
2165 if(type!=ON_GAUSS_NE)
2166 ret+=dads[i].second-dads[i].first;
2169 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(geoTypes[i]);
2170 ret+=(dads[i].second-dads[i].first)/cm.getNumberOfNodes();
2175 int nbOfGaussPtPerCell=glob->getNbOfGaussPtPerCell(locs[i]);
2176 ret+=(dads[i].second-dads[i].first)/nbOfGaussPtPerCell;
2182 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsed() const
2184 std::vector<std::string> ret;
2185 std::set<std::string> ret2;
2186 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2188 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
2189 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2190 if(ret2.find(*it2)==ret2.end())
2192 ret.push_back(*it2);
2199 std::vector<std::string> MEDFileFieldPerMesh::getPflsReallyUsedMulti() const
2201 std::vector<std::string> ret;
2202 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2204 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
2205 ret.insert(ret.end(),tmp.begin(),tmp.end());
2210 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsed() const
2212 std::vector<std::string> ret;
2213 std::set<std::string> ret2;
2214 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2216 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
2217 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
2218 if(ret2.find(*it2)==ret2.end())
2220 ret.push_back(*it2);
2227 std::vector<std::string> MEDFileFieldPerMesh::getLocsReallyUsedMulti() const
2229 std::vector<std::string> ret;
2230 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2232 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
2233 ret.insert(ret.end(),tmp.begin(),tmp.end());
2238 bool MEDFileFieldPerMesh::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2240 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=modifTab.begin();it!=modifTab.end();it++)
2242 if((*it).first==_mesh_name)
2244 _mesh_name=(*it).second;
2251 void MEDFileFieldPerMesh::convertMedBallIntoClassic()
2253 if(_field_pm_pt.size()!=1)
2254 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : Only managed for single mesh !");
2255 if(_field_pm_pt[0].isNull())
2256 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : null pointer !");
2257 MEDFileFieldPerMeshPerTypeDyn *pt(dynamic_cast<MEDFileFieldPerMeshPerTypeDyn *>((MEDFileFieldPerMeshPerTypeCommon *)_field_pm_pt[0]));
2259 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : this is expected to be marked as structure element !");
2260 if(pt->getNumberOfLoc()!=1)
2261 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : only one loc managed !");
2262 const MEDFileFieldPerMeshPerTypePerDisc *disc(pt->getLeafGivenLocId(0));
2264 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::convertMedBallIntoClassic : internal error !");
2265 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> disc2(MEDFileFieldPerMeshPerTypePerDisc::New(*disc));
2266 disc2->setType(ON_NODES);
2267 MCAuto<MEDFileFieldPerMeshPerType> pt2(MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR));
2268 disc2->setFather(pt2);
2269 pt2->setFather(this);
2270 pt2->pushDiscretization(disc2);
2271 _field_pm_pt[0]=DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(pt2);
2274 bool MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
2275 MEDFileFieldGlobsReal& glob)
2277 if(_mesh_name!=meshName)
2279 std::set<INTERP_KERNEL::NormalizedCellType> typesToKeep;
2280 for(std::size_t i=0;i<oldCode.size()/3;i++) typesToKeep.insert((INTERP_KERNEL::NormalizedCellType)oldCode[3*i]);
2281 std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > > entries;
2282 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKept;
2283 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> otherEntries;
2284 getUndergroundDataArrayExt(entries);
2285 DataArray *arr0(getOrCreateAndGetArray());//tony
2287 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values of field is null !");
2288 DataArrayDouble *arr(dynamic_cast<DataArrayDouble *>(arr0));//tony
2290 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArray storing values is double ! Not managed for the moment !");
2293 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::renumberEntitiesLyingOnMesh : DataArrayDouble storing values of field is null !");
2294 for(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >::const_iterator it=entries.begin();it!=entries.end();it++)
2296 if(typesToKeep.find((*it).first.first)!=typesToKeep.end())
2298 entriesKept.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2299 sz+=(*it).second.second-(*it).second.first;
2302 otherEntries.push_back(getLeafGivenTypeAndLocId((*it).first.first,(*it).first.second));
2304 MCAuto<DataArrayInt> renumDefrag=DataArrayInt::New(); renumDefrag->alloc(arr->getNumberOfTuples(),1); renumDefrag->fillWithZero();
2305 ////////////////////
2306 MCAuto<DataArrayInt> explicitIdsOldInMesh=DataArrayInt::New(); explicitIdsOldInMesh->alloc(sz,1);//sz is a majorant of the real size. A realloc will be done after
2307 int *workI2=explicitIdsOldInMesh->getPointer();
2308 int sz1=0,sz2=0,sid=1;
2309 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptML=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKept);
2310 // std::vector<int> tupleIdOfStartOfNewChuncksV(entriesKeptML.size());
2311 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator itL1=entriesKeptML.begin();itL1!=entriesKeptML.end();itL1++,sid++)
2313 // tupleIdOfStartOfNewChuncksV[sid-1]=sz2;
2314 MCAuto<DataArrayInt> explicitIdsOldInArr=DataArrayInt::New(); explicitIdsOldInArr->alloc(sz,1);
2315 int *workI=explicitIdsOldInArr->getPointer();
2316 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*itL1).begin();itL2!=(*itL1).end();itL2++)
2318 int delta1=(*itL2)->fillTupleIds(workI); workI+=delta1; sz1+=delta1;
2319 (*itL2)->setLocId(sz2);
2320 (*itL2)->_tmp_work1=(*itL2)->getStart();
2321 int delta2=(*itL2)->fillEltIdsFromCode(sz2,oldCode,glob,workI2); workI2+=delta2; sz2+=delta2;
2323 renumDefrag->setPartOfValuesSimple3(sid,explicitIdsOldInArr->begin(),explicitIdsOldInArr->end(),0,1,1);
2325 explicitIdsOldInMesh->reAlloc(sz2);
2326 int tupleIdOfStartOfNewChuncks=arr->getNumberOfTuples()-sz2;
2327 ////////////////////
2328 MCAuto<DataArrayInt> permArrDefrag=renumDefrag->buildPermArrPerLevel(); renumDefrag=0;
2329 // perform redispatching of non concerned MEDFileFieldPerMeshPerTypePerDisc
2330 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > otherEntriesNew;
2331 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=otherEntries.begin();it!=otherEntries.end();it++)
2333 otherEntriesNew.push_back(MEDFileFieldPerMeshPerTypePerDisc::New(*(*it)));
2334 otherEntriesNew.back()->setNewStart(permArrDefrag->getIJ((*it)->getStart(),0));
2335 otherEntriesNew.back()->setLocId((*it)->getGeoType());
2337 std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > entriesKeptNew;
2338 std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> entriesKeptNew2;
2339 for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator it=entriesKept.begin();it!=entriesKept.end();it++)
2341 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> elt=MEDFileFieldPerMeshPerTypePerDisc::New(*(*it));
2342 int newStart=elt->getLocId();
2343 elt->setLocId((*it)->getGeoType());
2344 elt->setNewStart(newStart);
2345 elt->_tmp_work1=permArrDefrag->getIJ(elt->_tmp_work1,0);
2346 entriesKeptNew.push_back(elt);
2347 entriesKeptNew2.push_back(elt);
2349 MCAuto<DataArrayDouble> arr2=arr->renumber(permArrDefrag->getConstPointer());
2350 // perform redispatching of concerned MEDFileFieldPerMeshPerTypePerDisc -> values are in arr2
2351 MCAuto<DataArrayInt> explicitIdsNewInMesh=renumO2N->selectByTupleId(explicitIdsOldInMesh->begin(),explicitIdsOldInMesh->end());
2352 std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > entriesKeptPerDisc=MEDFileFieldPerMeshPerTypePerDisc::SplitPerDiscretization(entriesKeptNew2);
2354 for(std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it4=entriesKeptPerDisc.begin();it4!=entriesKeptPerDisc.end();it4++)
2357 /*for(std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>::const_iterator itL2=(*it4).begin();itL2!=(*it4).end();itL2++)
2359 MEDFileFieldPerMeshPerTypePerDisc *curNC=const_cast<MEDFileFieldPerMeshPerTypePerDisc *>(*itL2);
2360 curNC->setNewStart(permArrDefrag->getIJ((*itL2)->getStart(),0)-tupleIdOfStartOfNewChuncks+tupleIdOfStartOfNewChuncksV[sid]);
2362 ret=MEDFileFieldPerMeshPerTypePerDisc::RenumberChunks(tupleIdOfStartOfNewChuncks,*it4,explicitIdsNewInMesh,newCode,
2363 glob,arr2,otherEntriesNew) || ret;
2367 // Assign new dispatching
2368 assignNewLeaves(otherEntriesNew);
2369 arr->deepCopyFrom(*arr2);
2374 * \param [in,out] globalNum a global numbering counter for the renumbering.
2375 * \param [out] its - list of pair (start,stop) kept
2377 void MEDFileFieldPerMesh::keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its)
2379 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2380 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2382 std::vector< std::pair<int,int> > its2;
2383 if((*it)->keepOnlySpatialDiscretization(tof,globalNum,its2))
2386 its.insert(its.end(),its2.begin(),its2.end());
2393 * \param [in,out] globalNum a global numbering counter for the renumbering.
2394 * \param [out] its - list of pair (start,stop) kept
2396 void MEDFileFieldPerMesh::keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair<int,int> >& its)
2398 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > ret;
2399 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2401 std::vector< std::pair<int,int> > its2;
2402 if((*it)->keepOnlyGaussDiscretization(idOfDisc,globalNum,its2))
2405 its.insert(its.end(),its2.begin(),its2.end());
2411 void MEDFileFieldPerMesh::assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves)
2413 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > > types;
2414 for( std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >::const_iterator it=leaves.begin();it!=leaves.end();it++)
2415 types[(INTERP_KERNEL::NormalizedCellType)(*it)->getLocId()].push_back(*it);
2417 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > fieldPmPt(types.size());
2418 std::map<INTERP_KERNEL::NormalizedCellType,std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc> > >::const_iterator it1=types.begin();
2419 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=fieldPmPt.begin();
2420 for(;it1!=types.end();it1++,it2++)
2422 MCAuto<MEDFileFieldPerMeshPerType> elt=MEDFileFieldPerMeshPerType::New(this,(INTERP_KERNEL::NormalizedCellType)((*it1).second[0]->getLocId()));
2423 elt->setLeaves((*it1).second);
2424 MCAuto<MEDFileFieldPerMeshPerTypeCommon> elt2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(elt));
2427 _field_pm_pt=fieldPmPt;
2430 void MEDFileFieldPerMesh::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2432 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2433 (*it)->changePflsRefsNamesGen(mapOfModif);
2436 void MEDFileFieldPerMesh::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2438 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2439 (*it)->changeLocsRefsNamesGen(mapOfModif);
2443 * \param [in] mesh is the whole mesh
2445 MEDCouplingFieldDouble *MEDFileFieldPerMesh::getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2447 if(_field_pm_pt.empty())
2448 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2450 std::vector< std::pair<int,int> > dads;
2451 std::vector<const DataArrayInt *> pfls;
2452 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2453 std::vector<int> locs,code;
2454 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2455 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2456 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2458 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2461 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2462 throw INTERP_KERNEL::Exception(oss.str());
2465 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2466 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2469 DataArrayInt *arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2471 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2474 MCAuto<DataArrayInt> arr2(arr);
2475 return finishField2(type,glob,dads,locs,geoTypes,mesh,arr,isPfl,arrOut,nasc);
2481 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2485 if(nb!=mesh->getNumberOfNodes())
2487 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2488 oss << " nodes in mesh !";
2489 throw INTERP_KERNEL::Exception(oss.str());
2491 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2494 return finishFieldNode2(glob,dads,locs,mesh,notNullPflsPerGeoType3[0],isPfl,arrOut,nasc);
2498 DataArray *MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
2500 if(_field_pm_pt.empty())
2501 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : no types field set !");
2503 std::vector<std::pair<int,int> > dads;
2504 std::vector<const DataArrayInt *> pfls;
2505 std::vector<DataArrayInt *> notNullPflsPerGeoType;
2506 std::vector<int> locs,code;
2507 std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes;
2508 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2509 (*it)->getFieldAtLevel(mesh->getMeshDimension(),type,glob,dads,pfls,locs,geoTypes);
2511 SortArraysPerType(glob,type,geoTypes,dads,pfls,locs,code,notNullPflsPerGeoType);
2514 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevelWithPfl : " << "The field \"" << nasc.getName() << "\" exists but not with such spatial discretization or such dimension specified !";
2515 throw INTERP_KERNEL::Exception(oss.str());
2517 std::vector< MCAuto<DataArrayInt> > notNullPflsPerGeoType2(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2518 std::vector< const DataArrayInt *> notNullPflsPerGeoType3(notNullPflsPerGeoType.begin(),notNullPflsPerGeoType.end());
2521 MCAuto<DataArrayInt> arr=mesh->checkTypeConsistencyAndContig(code,notNullPflsPerGeoType3);
2522 return finishField4(dads,arr,mesh->getNumberOfCells(),pfl);
2527 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::getFieldOnMeshAtLevel : internal error #1 !");
2531 if(nb!=mesh->getNumberOfNodes())
2533 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getFieldOnMeshAtLevel : There is a problem there is " << nb << " nodes in field whereas there is " << mesh->getNumberOfNodes();
2534 oss << " nodes in mesh !";
2535 throw INTERP_KERNEL::Exception(oss.str());
2538 return finishField4(dads,code[2]==-1?0:notNullPflsPerGeoType3[0],mesh->getNumberOfNodes(),pfl);
2544 void MEDFileFieldPerMesh::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
2548 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2550 (*it)->getSizes(globalSz,nbOfEntries);
2552 entries.resize(nbOfEntries);
2554 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2556 (*it)->fillValues(nbOfEntries,entries);
2560 MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId)
2562 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2564 if((*it)->getGeoType()==typ)
2565 return (*it)->getLeafGivenLocId(locId);
2567 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2568 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2569 oss << "Possiblities are : ";
2570 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2572 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2573 oss << "\"" << cm2.getRepr() << "\", ";
2575 throw INTERP_KERNEL::Exception(oss.str());
2578 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMesh::getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const
2580 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2582 if((*it)->getGeoType()==typ)
2583 return (*it)->getLeafGivenLocId(locId);
2585 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
2586 std::ostringstream oss; oss << "MEDFileFieldPerMesh::getLeafGivenTypeAndLocId : no such geometric type \"" << cm.getRepr() << "\" in this !" << std::endl;
2587 oss << "Possiblities are : ";
2588 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++)
2590 const INTERP_KERNEL::CellModel& cm2=INTERP_KERNEL::CellModel::GetCellModel((*it)->getGeoType());
2591 oss << "\"" << cm2.getRepr() << "\", ";
2593 throw INTERP_KERNEL::Exception(oss.str());
2597 * \param [in,out] start - Integer that gives the current position in the final aggregated array
2598 * \param [in] pms - list of elements to aggregate. integer gives the mesh id
2599 * \param [in] dts - (Distribution of types) = level 1 : meshes to aggregate. Level 2 : all geo type. Level 3 pair specifying geo type and number of elem in geotype.
2600 * \param [out] extractInfo - Gives information about the where the data comes from. It is a vector of triplet. First element in the triplet the mesh pos. The 2nd one the start pos. The 3rd the end pos.
2602 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> MEDFileFieldPerMeshPerTypePerDisc::Aggregate(int &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2604 MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
2606 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
2607 for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
2610 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
2611 if(!(*it).second->getProfile().empty())
2612 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
2613 if(!(*it).second->getLocalization().empty())
2614 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
2616 INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
2618 std::vector< std::pair<int,int> > filteredDTS;
2619 for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
2620 for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
2621 if((*it2).first==gt)
2622 filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
2623 if(pms.size()!=filteredDTS.size())
2624 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
2625 std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
2626 std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
2627 int zeStart(start),nval(0);
2628 for(;it1!=pms.end();it1++,it2++)
2630 if((*it1).first!=(*it2).first)
2631 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
2632 int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
2633 extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
2635 nval+=((*it1).second)->getNumberOfVals();
2637 ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
2641 MCAuto<MEDFileFieldPerMesh> MEDFileFieldPerMesh::Aggregate(int &start, const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
2643 MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
2644 std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
2646 for(std::vector<const MEDFileFieldPerMesh *>::const_iterator it=pms.begin();it!=pms.end();it++,i++)
2648 const std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >& v((*it)->_field_pm_pt);
2649 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::const_iterator it2=v.begin();it2!=v.end();it2++)
2651 INTERP_KERNEL::NormalizedCellType gt((*it2)->getGeoType());
2652 const MEDFileFieldPerMeshPerType *elt(dynamic_cast<const MEDFileFieldPerMeshPerType *>((const MEDFileFieldPerMeshPerTypeCommon *)(*it2)));
2654 throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::Aggregate : not managed for structelement !");
2655 m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,elt));
2658 for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
2660 MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
2661 MCAuto<MEDFileFieldPerMeshPerTypeCommon> agg2(DynamicCast<MEDFileFieldPerMeshPerType,MEDFileFieldPerMeshPerTypeCommon>(agg));
2662 ret->_field_pm_pt.push_back(agg2);
2667 int MEDFileFieldPerMesh::addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type)
2670 int pos=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,type));
2671 std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it2=_field_pm_pt.begin();
2672 for(std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > >::iterator it=_field_pm_pt.begin();it!=_field_pm_pt.end();it++,i++)
2674 INTERP_KERNEL::NormalizedCellType curType=(*it)->getGeoType();
2679 int pos2=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,curType));
2684 int ret=std::distance(_field_pm_pt.begin(),it2);
2685 _field_pm_pt.insert(it2,MEDFileFieldPerMeshPerType::New(this,type));
2690 * 'dads' and 'locs' input parameters have the same number of elements
2691 * \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
2693 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2694 const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
2695 const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2698 MCAuto<MEDCouplingFieldDouble> ret=MEDCouplingFieldDouble::New(type,ONE_TIME);
2699 ret->setMesh(mesh); ret->setName(nasc.getName().c_str()); ret->setTime(getTime(),getIteration(),getOrder()); ret->setTimeUnit(nasc.getDtUnit().c_str());
2700 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2701 const std::vector<std::string>& infos=getInfo();
2702 da->setInfoOnComponents(infos);
2704 if(type==ON_GAUSS_PT)
2707 int nbOfArrs=dads.size();
2708 for(int i=0;i<nbOfArrs;i++)
2710 std::vector<std::pair<int,int> > dads2(1,dads[i]); const std::vector<int> locs2(1,locs[i]);
2711 const std::vector<INTERP_KERNEL::NormalizedCellType> geoTypes2(1,INTERP_KERNEL::NORM_ERROR);
2712 int nbOfElems=ComputeNbOfElems(glob,type,geoTypes2,dads2,locs2);
2713 MCAuto<DataArrayInt> di=DataArrayInt::New();
2714 di->alloc(nbOfElems,1);
2716 const MEDFileFieldLoc& fl=glob->getLocalizationFromId(locs[i]);
2717 ret->setGaussLocalizationOnCells(di->getConstPointer(),di->getConstPointer()+nbOfElems,fl.getRefCoords(),fl.getGaussCoords(),fl.getGaussWeights());
2726 * 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.
2727 * 'dads', 'locs' and 'geoTypes' input parameters have the same number of elements.
2728 * No check of this is performed. 'da' array contains an array in old2New style to be applyied to mesh to obtain the right support.
2729 * The order of cells in the returned field is those imposed by the profile.
2730 * \param [in] mesh is the global mesh.
2732 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
2733 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2734 const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
2735 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2737 if(da->isIota(mesh->getNumberOfCells()))
2738 return finishField(type,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2739 MCAuto<MEDCouplingMesh> m2=mesh->buildPart(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2740 m2->setName(mesh->getName().c_str());
2741 MCAuto<MEDCouplingFieldDouble> ret=finishField(type,glob,dads,locs,m2,isPfl,arrOut,nasc);
2747 * This method is the complement of MEDFileFieldPerMesh::finishField2 method except that this method works for node profiles.
2749 MEDCouplingFieldDouble *MEDFileFieldPerMesh::finishFieldNode2(const MEDFileFieldGlobsReal *glob,
2750 const std::vector<std::pair<int,int> >& dads, const std::vector<int>& locs,
2751 const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
2753 if(da->isIota(mesh->getNumberOfNodes()))
2754 return finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2755 // Treatment of particular case where nodal field on pfl is requested with a meshDimRelToMax=1.
2756 const MEDCouplingUMesh *meshu=dynamic_cast<const MEDCouplingUMesh *>(mesh);
2759 if(meshu->getNodalConnectivity()==0)
2761 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_CELLS,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2762 int nb=da->getNbOfElems();
2763 const int *ptr=da->getConstPointer();
2764 MEDCouplingUMesh *meshuc=const_cast<MEDCouplingUMesh *>(meshu);
2765 meshuc->allocateCells(nb);
2766 for(int i=0;i<nb;i++)
2767 meshuc->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,ptr+i);
2768 meshuc->finishInsertingCells();
2769 ret->setMesh(meshuc);
2770 const MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
2771 if(!disc) throw INTERP_KERNEL::Exception("MEDFileFieldPerMesh::finishFieldNode2 : internal error, no discretization on field !");
2772 disc->checkCoherencyBetween(meshuc,arrOut);
2777 MCAuto<MEDCouplingFieldDouble> ret=finishField(ON_NODES,glob,dads,locs,mesh,isPfl,arrOut,nasc);
2779 DataArrayInt *arr2=0;
2780 MCAuto<DataArrayInt> cellIds=mesh->getCellIdsFullyIncludedInNodeIds(da->getConstPointer(),da->getConstPointer()+da->getNbOfElems());
2781 MCAuto<MEDCouplingMesh> mesh2=mesh->buildPartAndReduceNodes(cellIds->getConstPointer(),cellIds->getConstPointer()+cellIds->getNbOfElems(),arr2);
2782 MCAuto<DataArrayInt> arr3(arr2);
2783 int nnodes=mesh2->getNumberOfNodes();
2784 if(nnodes==(int)da->getNbOfElems())
2786 MCAuto<DataArrayInt> da3=da->transformWithIndArrR(arr2->begin(),arr2->end());
2787 arrOut->renumberInPlace(da3->getConstPointer());
2788 mesh2->setName(mesh->getName().c_str());
2789 ret->setMesh(mesh2);
2794 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 !!!";
2795 oss << "So it is impossible to return a well definied MEDCouplingFieldDouble instance on specified mesh on a specified meshDim !" << std::endl;
2796 oss << "To retrieve correctly such a field you have 3 possibilities :" << std::endl;
2797 oss << " - use an another meshDim compatible with the field on nodes (MED file does not have such information)" << std::endl;
2798 oss << " - use an another a meshDimRelToMax equal to 1 -> it will return a mesh with artificial cell POINT1 containing the profile !" << std::endl;
2799 oss << " - if definitely the node profile has no link with mesh connectivity use MEDFileField1TS::getFieldWithProfile or MEDFileFieldMultiTS::getFieldWithProfile methods instead !";
2800 throw INTERP_KERNEL::Exception(oss.str());
2806 * This method is the most light method of field retrieving.
2808 DataArray *MEDFileFieldPerMesh::finishField4(const std::vector<std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const
2812 pflOut=DataArrayInt::New();
2813 pflOut->alloc(nbOfElems,1);
2818 pflOut=const_cast<DataArrayInt*>(pflIn);
2821 MCAuto<DataArrayInt> safePfl(pflOut);
2822 MCAuto<DataArray> da=getOrCreateAndGetArray()->selectByTupleRanges(dads);
2823 const std::vector<std::string>& infos=getInfo();
2824 int nbOfComp=infos.size();
2825 for(int i=0;i<nbOfComp;i++)
2826 da->setInfoOnComponent(i,infos[i].c_str());
2837 static MFFPMIter *NewCell(const MEDFileEntities *entities);
2838 static bool IsPresenceOfNode(const MEDFileEntities *entities);
2839 virtual ~MFFPMIter() { }
2840 virtual void begin() = 0;
2841 virtual bool finished() const = 0;
2842 virtual void next() = 0;
2843 virtual int current() const = 0;
2846 class MFFPMIterSimple : public MFFPMIter
2849 MFFPMIterSimple():_pos(0) { }
2850 void begin() { _pos=0; }
2851 bool finished() const { return _pos>=MED_N_CELL_FIXED_GEO; }
2852 void next() { _pos++; }
2853 int current() const { return _pos; }
2858 class MFFPMIter2 : public MFFPMIter
2861 MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts);
2862 void begin() { _it=_ids.begin(); }
2863 bool finished() const { return _it==_ids.end(); }
2864 void next() { _it++; }
2865 int current() const { return *_it; }
2867 std::vector<int> _ids;
2868 std::vector<int>::const_iterator _it;
2871 MFFPMIter *MFFPMIter::NewCell(const MEDFileEntities *entities)
2874 return new MFFPMIterSimple;
2877 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2880 std::vector<INTERP_KERNEL::NormalizedCellType> tmp;
2881 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2882 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2884 if((*it).first==ON_CELLS || (*it).first==ON_GAUSS_NE || (*it).first==ON_GAUSS_PT)
2885 tmp.push_back((*it).second);
2887 return new MFFPMIter2(tmp);
2889 return new MFFPMIterSimple;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn cells are in
2893 bool MFFPMIter::IsPresenceOfNode(const MEDFileEntities *entities)
2899 const MEDFileStaticEntities *entities2(dynamic_cast<const MEDFileStaticEntities *>(entities));
2902 const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& myEnt(entities2->getEntries());
2903 for(std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >::const_iterator it=myEnt.begin();it!=myEnt.end();it++)
2904 if((*it).first==ON_NODES)
2908 return true;// for MEDFileAllStaticEntites and MEDFileAllStaticEntitiesPlusDyn nodes are in
2912 MFFPMIter2::MFFPMIter2(const std::vector<INTERP_KERNEL::NormalizedCellType>& cts)
2914 std::size_t sz(cts.size());
2916 for(std::size_t i=0;i<sz;i++)
2918 INTERP_KERNEL::NormalizedCellType *loc(std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,cts[i]));
2919 if(loc!=typmai2+MED_N_CELL_FIXED_GEO)
2920 _ids[i]=(int)std::distance(typmai2,loc);
2922 throw INTERP_KERNEL::Exception("MFFPMIter2 : The specified geo type does not exists !");
2928 MEDFileFieldPerMesh::MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities):_mesh_iteration(meshIteration),_mesh_order(meshOrder),
2931 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2932 INTERP_KERNEL::AutoPtr<char> pflName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2933 INTERP_KERNEL::AutoPtr<char> locName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2934 const MEDFileUMesh *mmu(dynamic_cast<const MEDFileUMesh *>(mm));
2935 INTERP_KERNEL::AutoCppPtr<MFFPMIter> iter0(MFFPMIter::NewCell(entities));
2936 for(iter0->begin();!iter0->finished();iter0->next())
2938 int nbProfile (MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_CELL ,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2939 std::string name0(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2940 int nbProfile2(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[iter0->current()],meshCsit+1,meshName,pflName,locName));
2941 std::string name1(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
2942 if(nbProfile>0 || nbProfile2>0)
2944 const PartDefinition *pd(0);
2946 pd=mmu->getPartDefAtLevel(mmu->getRelativeLevOnGeoType(typmai2[iter0->current()]),typmai2[iter0->current()]);
2947 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_CELLS,typmai2[iter0->current()],nasc,pd));
2954 if(MFFPMIter::IsPresenceOfNode(entities))
2956 int nbProfile(MEDfield23nProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,meshCsit+1,meshName,pflName,locName));
2959 const PartDefinition *pd(0);
2961 pd=mmu->getPartDefAtLevel(1,INTERP_KERNEL::NORM_ERROR);
2962 _field_pm_pt.push_back(MEDFileFieldPerMeshPerType::NewOnRead(fid,this,ON_NODES,INTERP_KERNEL::NORM_ERROR,nasc,pd));
2963 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2968 std::vector<int> dynGT(entities->getDynGTAvail());
2969 for(std::vector<int>::const_iterator it=dynGT.begin();it!=dynGT.end();it++)
2971 int nbPfl(MEDfieldnProfile(fid,nasc.getName().c_str(),getIteration(),getOrder(),MED_STRUCT_ELEMENT,*it,pflName,locName));
2974 _field_pm_pt.push_back(MEDFileFieldPerMeshPerTypeDyn::NewOnRead(fid,this,entities,*it,nasc));
2975 _mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
2980 MEDFileFieldPerMesh::MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh):_father(fath)
2982 copyTinyInfoFrom(mesh);
2985 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
2987 if(id>=(int)_pfls.size())
2989 _pfls[id]=DataArrayInt::New();
2990 int lgth(MEDprofileSizeByName(fid,pflName.c_str()));
2991 _pfls[id]->setName(pflName);
2992 _pfls[id]->alloc(lgth,1);
2993 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName.c_str(),_pfls[id]->getPointer()));
2994 _pfls[id]->applyLin(1,-1,0);//Converting into C format
2997 void MEDFileFieldGlobs::loadProfileInFile(med_idt fid, int i)
2999 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3001 MEDFILESAFECALLERRD0(MEDprofileInfo,(fid,i+1,pflName,&sz));
3002 std::string pflCpp=MEDLoaderBase::buildStringFromFortran(pflName,MED_NAME_SIZE);
3003 if(i>=(int)_pfls.size())
3005 _pfls[i]=DataArrayInt::New();
3006 _pfls[i]->alloc(sz,1);
3007 _pfls[i]->setName(pflCpp.c_str());
3008 MEDFILESAFECALLERRD0(MEDprofileRd,(fid,pflName,_pfls[i]->getPointer()));
3009 _pfls[i]->applyLin(1,-1,0);//Converting into C format
3012 void MEDFileFieldGlobs::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3014 int nbOfPfls=_pfls.size();
3015 for(int i=0;i<nbOfPfls;i++)
3017 MCAuto<DataArrayInt> cpy=_pfls[i]->deepCopy();
3018 cpy->applyLin(1,1,0);
3019 INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
3020 MEDLoaderBase::safeStrCpy(_pfls[i]->getName().c_str(),MED_NAME_SIZE,pflName,opt.getTooLongStrPolicy());
3021 MEDFILESAFECALLERWR0(MEDprofileWr,(fid,pflName,_pfls[i]->getNumberOfTuples(),cpy->getConstPointer()));
3024 int nbOfLocs=_locs.size();
3025 for(int i=0;i<nbOfLocs;i++)
3026 _locs[i]->writeLL(fid);
3029 void MEDFileFieldGlobs::appendGlobs(const MEDFileFieldGlobs& other, double eps)
3031 std::vector<std::string> pfls=getPfls();
3032 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=other._pfls.begin();it!=other._pfls.end();it++)
3034 std::vector<std::string>::iterator it2=std::find(pfls.begin(),pfls.end(),(*it)->getName());
3037 _pfls.push_back(*it);
3041 int id=std::distance(pfls.begin(),it2);
3042 if(!(*it)->isEqual(*_pfls[id]))
3044 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Profile \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3045 throw INTERP_KERNEL::Exception(oss.str());
3049 std::vector<std::string> locs=getLocs();
3050 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=other._locs.begin();it!=other._locs.end();it++)
3052 std::vector<std::string>::iterator it2=std::find(locs.begin(),locs.end(),(*it)->getName());
3055 _locs.push_back(*it);
3059 int id=std::distance(locs.begin(),it2);
3060 if(!(*it)->isEqual(*_locs[id],eps))
3062 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendGlobs : Localization \"" << (*it)->getName() << "\" already exists and is different from those expecting to be append !";
3063 throw INTERP_KERNEL::Exception(oss.str());
3069 void MEDFileFieldGlobs::checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const
3071 for(std::vector<std::string>::const_iterator it=pflsUsed.begin();it!=pflsUsed.end();it++)
3072 getProfile((*it).c_str());
3075 void MEDFileFieldGlobs::checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const
3077 for(std::vector<std::string>::const_iterator it=locsUsed.begin();it!=locsUsed.end();it++)
3078 getLocalization((*it).c_str());
3081 void MEDFileFieldGlobs::loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real)
3083 std::vector<std::string> profiles=real.getPflsReallyUsed();
3084 int sz=profiles.size();
3086 for(int i=0;i<sz;i++)
3087 loadProfileInFile(fid,i,profiles[i].c_str());
3089 std::vector<std::string> locs=real.getLocsReallyUsed();
3092 for(int i=0;i<sz;i++)
3093 _locs[i]=MEDFileFieldLoc::New(fid,locs[i].c_str());
3096 void MEDFileFieldGlobs::loadAllGlobals(med_idt fid)
3098 int nProfil=MEDnProfile(fid);
3099 for(int i=0;i<nProfil;i++)
3100 loadProfileInFile(fid,i);
3101 int sz=MEDnLocalization(fid);
3103 for(int i=0;i<sz;i++)
3105 _locs[i]=MEDFileFieldLoc::New(fid,i);
3109 MEDFileFieldGlobs *MEDFileFieldGlobs::New(med_idt fid)
3111 return new MEDFileFieldGlobs(fid);
3114 MEDFileFieldGlobs *MEDFileFieldGlobs::New()
3116 return new MEDFileFieldGlobs;
3119 std::size_t MEDFileFieldGlobs::getHeapMemorySizeWithoutChildren() const
3121 return _file_name.capacity()+_pfls.capacity()*sizeof(MCAuto<DataArrayInt>)+_locs.capacity()*sizeof(MCAuto<MEDFileFieldLoc>);
3124 std::vector<const BigMemoryObject *> MEDFileFieldGlobs::getDirectChildrenWithNull() const
3126 std::vector<const BigMemoryObject *> ret;
3127 for(std::vector< MCAuto< DataArrayInt > >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3128 ret.push_back((const DataArrayInt *)*it);
3129 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3130 ret.push_back((const MEDFileFieldLoc *)*it);
3134 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCopy() const
3136 MCAuto<MEDFileFieldGlobs> ret=new MEDFileFieldGlobs(*this);
3138 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3140 if((const DataArrayInt *)*it)
3141 ret->_pfls[i]=(*it)->deepCopy();
3144 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3146 if((const MEDFileFieldLoc*)*it)
3147 ret->_locs[i]=(*it)->deepCopy();
3153 * \throw if a profile in \a pfls in not in \a this.
3154 * \throw if a localization in \a locs in not in \a this.
3155 * \sa MEDFileFieldGlobs::deepCpyPart
3157 MEDFileFieldGlobs *MEDFileFieldGlobs::shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3159 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3160 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3162 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3164 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! pfl null !");
3166 MCAuto<DataArrayInt> pfl2(pfl);
3167 ret->_pfls.push_back(pfl2);
3169 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3171 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3173 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::shallowCpyPart : internal error ! loc null !");
3175 MCAuto<MEDFileFieldLoc> loc2(loc);
3176 ret->_locs.push_back(loc2);
3178 ret->setFileName(getFileName());
3183 * \throw if a profile in \a pfls in not in \a this.
3184 * \throw if a localization in \a locs in not in \a this.
3185 * \sa MEDFileFieldGlobs::shallowCpyPart
3187 MEDFileFieldGlobs *MEDFileFieldGlobs::deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const
3189 MCAuto<MEDFileFieldGlobs> ret=MEDFileFieldGlobs::New();
3190 for(std::vector<std::string>::const_iterator it1=pfls.begin();it1!=pfls.end();it1++)
3192 DataArrayInt *pfl=const_cast<DataArrayInt *>(getProfile((*it1).c_str()));
3194 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! pfl null !");
3195 ret->_pfls.push_back(pfl->deepCopy());
3197 for(std::vector<std::string>::const_iterator it2=locs.begin();it2!=locs.end();it2++)
3199 MEDFileFieldLoc *loc=const_cast<MEDFileFieldLoc *>(&getLocalization((*it2).c_str()));
3201 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::deepCpyPart : internal error ! loc null !");
3202 ret->_locs.push_back(loc->deepCopy());
3204 ret->setFileName(getFileName());
3208 MEDFileFieldGlobs::MEDFileFieldGlobs(med_idt fid):_file_name(MEDFileWritable::FileNameFromFID(fid))
3212 MEDFileFieldGlobs::MEDFileFieldGlobs()
3216 MEDFileFieldGlobs::~MEDFileFieldGlobs()
3220 void MEDFileFieldGlobs::simpleRepr(std::ostream& oss) const
3222 oss << "Profiles :\n";
3223 std::size_t n=_pfls.size();
3224 for(std::size_t i=0;i<n;i++)
3226 oss << " - #" << i << " ";
3227 const DataArrayInt *pfl=_pfls[i];
3229 oss << "\"" << pfl->getName() << "\"\n";
3234 oss << "Localizations :\n";
3235 for(std::size_t i=0;i<n;i++)
3237 oss << " - #" << i << " ";
3238 const MEDFileFieldLoc *loc=_locs[i];
3240 loc->simpleRepr(oss);
3246 void MEDFileFieldGlobs::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3248 for(std::vector< MCAuto<DataArrayInt> >::iterator it=_pfls.begin();it!=_pfls.end();it++)
3250 DataArrayInt *elt(*it);
3253 std::string name(elt->getName());
3254 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3256 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3258 elt->setName((*it2).second.c_str());
3266 void MEDFileFieldGlobs::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3268 for(std::vector< MCAuto<MEDFileFieldLoc> >::iterator it=_locs.begin();it!=_locs.end();it++)
3270 MEDFileFieldLoc *elt(*it);
3273 std::string name(elt->getName());
3274 for(std::vector< std::pair<std::vector<std::string>, std::string > >::const_iterator it2=mapOfModif.begin();it2!=mapOfModif.end();it2++)
3276 if(std::find((*it2).first.begin(),(*it2).first.end(),name)!=(*it2).first.end())
3278 elt->setName((*it2).second.c_str());
3286 int MEDFileFieldGlobs::getNbOfGaussPtPerCell(int locId) const
3288 if(locId<0 || locId>=(int)_locs.size())
3289 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getNbOfGaussPtPerCell : Invalid localization id !");
3290 return _locs[locId]->getNbOfGaussPtPerCell();
3293 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName) const
3295 return getLocalizationFromId(getLocalizationId(locName));
3298 const MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId) const
3300 if(locId<0 || locId>=(int)_locs.size())
3301 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3302 return *_locs[locId];
3306 namespace MEDCouplingImpl
3311 LocFinder(const std::string& loc):_loc(loc) { }
3312 bool operator() (const MCAuto<MEDFileFieldLoc>& loc) { return loc->isName(_loc); }
3314 const std::string &_loc;
3320 PflFinder(const std::string& pfl):_pfl(pfl) { }
3321 bool operator() (const MCAuto<DataArrayInt>& pfl) { return _pfl==pfl->getName(); }
3323 const std::string& _pfl;
3328 int MEDFileFieldGlobs::getLocalizationId(const std::string& loc) const
3330 std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=std::find_if(_locs.begin(),_locs.end(),MEDCouplingImpl::LocFinder(loc));
3333 std::ostringstream oss; oss << "MEDFileFieldGlobs::getLocalisationId : no such localisation name : \"" << loc << "\" Possible localizations are : ";
3334 for(it=_locs.begin();it!=_locs.end();it++)
3335 oss << "\"" << (*it)->getName() << "\", ";
3336 throw INTERP_KERNEL::Exception(oss.str());
3338 return std::distance(_locs.begin(),it);
3342 * The returned value is never null.
3344 const DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName) const
3346 std::string pflNameCpp(pflName);
3347 std::vector< MCAuto<DataArrayInt> >::const_iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3350 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3351 for(it=_pfls.begin();it!=_pfls.end();it++)
3352 oss << "\"" << (*it)->getName() << "\", ";
3353 throw INTERP_KERNEL::Exception(oss.str());
3358 const DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId) const
3360 if(pflId<0 || pflId>=(int)_pfls.size())
3361 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3362 return _pfls[pflId];
3365 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalizationFromId(int locId)
3367 if(locId<0 || locId>=(int)_locs.size())
3368 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getLocalizationFromId : Invalid localization id !");
3369 return *_locs[locId];
3372 MEDFileFieldLoc& MEDFileFieldGlobs::getLocalization(const std::string& locName)
3374 return getLocalizationFromId(getLocalizationId(locName));
3378 * The returned value is never null.
3380 DataArrayInt *MEDFileFieldGlobs::getProfile(const std::string& pflName)
3382 std::string pflNameCpp(pflName);
3383 std::vector< MCAuto<DataArrayInt> >::iterator it=std::find_if(_pfls.begin(),_pfls.end(),MEDCouplingImpl::PflFinder(pflNameCpp));
3386 std::ostringstream oss; oss << "MEDFileFieldGlobs::getProfile: no such profile name : \"" << pflNameCpp << "\" Possible profiles are : ";
3387 for(it=_pfls.begin();it!=_pfls.end();it++)
3388 oss << "\"" << (*it)->getName() << "\", ";
3389 throw INTERP_KERNEL::Exception(oss.str());
3394 DataArrayInt *MEDFileFieldGlobs::getProfileFromId(int pflId)
3396 if(pflId<0 || pflId>=(int)_pfls.size())
3397 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::getProfileFromId : Invalid profile id !");
3398 return _pfls[pflId];
3401 void MEDFileFieldGlobs::killProfileIds(const std::vector<int>& pflIds)
3403 std::vector< MCAuto<DataArrayInt> > newPfls;
3405 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3407 if(std::find(pflIds.begin(),pflIds.end(),i)==pflIds.end())
3408 newPfls.push_back(*it);
3413 void MEDFileFieldGlobs::killLocalizationIds(const std::vector<int>& locIds)
3415 std::vector< MCAuto<MEDFileFieldLoc> > newLocs;
3417 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++,i++)
3419 if(std::find(locIds.begin(),locIds.end(),i)==locIds.end())
3420 newLocs.push_back(*it);
3425 std::vector<std::string> MEDFileFieldGlobs::getPfls() const
3427 int sz=_pfls.size();
3428 std::vector<std::string> ret(sz);
3429 for(int i=0;i<sz;i++)
3430 ret[i]=_pfls[i]->getName();
3434 std::vector<std::string> MEDFileFieldGlobs::getLocs() const
3436 int sz=_locs.size();
3437 std::vector<std::string> ret(sz);
3438 for(int i=0;i<sz;i++)
3439 ret[i]=_locs[i]->getName();
3443 bool MEDFileFieldGlobs::existsPfl(const std::string& pflName) const
3445 std::vector<std::string> v=getPfls();
3446 std::string s(pflName);
3447 return std::find(v.begin(),v.end(),s)!=v.end();
3450 bool MEDFileFieldGlobs::existsLoc(const std::string& locName) const
3452 std::vector<std::string> v=getLocs();
3453 std::string s(locName);
3454 return std::find(v.begin(),v.end(),s)!=v.end();
3457 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualProfiles() const
3459 std::map<int,std::vector<int> > m;
3461 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++,i++)
3463 const DataArrayInt *tmp=(*it);
3466 m[tmp->getHashCode()].push_back(i);
3469 std::vector< std::vector<int> > ret;
3470 for(std::map<int,std::vector<int> >::const_iterator it2=m.begin();it2!=m.end();it2++)
3472 if((*it2).second.size()>1)
3474 std::vector<int> ret0;
3475 bool equalityOrNot=false;
3476 for(std::vector<int>::const_iterator it3=(*it2).second.begin();it3!=(*it2).second.end();it3++)
3478 std::vector<int>::const_iterator it4=it3; it4++;
3479 for(;it4!=(*it2).second.end();it4++)
3481 if(_pfls[*it3]->isEqualWithoutConsideringStr(*_pfls[*it4]))
3484 ret0.push_back(*it3);
3485 ret0.push_back(*it4);
3491 ret.push_back(ret0);
3497 std::vector< std::vector<int> > MEDFileFieldGlobs::whichAreEqualLocs(double eps) const
3499 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::whichAreEqualLocs : no implemented yet ! Sorry !");
3502 void MEDFileFieldGlobs::appendProfile(DataArrayInt *pfl)
3504 std::string name(pfl->getName());
3506 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendProfile : unsupported profiles with no name !");
3507 for(std::vector< MCAuto<DataArrayInt> >::const_iterator it=_pfls.begin();it!=_pfls.end();it++)
3508 if(name==(*it)->getName())
3510 if(!pfl->isEqual(*(*it)))
3512 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendProfile : profile \"" << name << "\" already exists and is different from existing !";
3513 throw INTERP_KERNEL::Exception(oss.str());
3517 _pfls.push_back(pfl);
3520 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)
3522 std::string name(locName);
3524 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::appendLoc : unsupported localizations with no name !");
3525 MCAuto<MEDFileFieldLoc> obj=MEDFileFieldLoc::New(locName,geoType,refCoo,gsCoo,w);
3526 for(std::vector< MCAuto<MEDFileFieldLoc> >::const_iterator it=_locs.begin();it!=_locs.end();it++)
3527 if((*it)->isName(locName))
3529 if(!(*it)->isEqual(*obj,1e-12))
3531 std::ostringstream oss; oss << "MEDFileFieldGlobs::appendLoc : localization \"" << name << "\" already exists and is different from existing !";
3532 throw INTERP_KERNEL::Exception(oss.str());
3535 _locs.push_back(obj);
3538 std::string MEDFileFieldGlobs::createNewNameOfPfl() const
3540 std::vector<std::string> names=getPfls();
3541 return CreateNewNameNotIn("NewPfl_",names);
3544 std::string MEDFileFieldGlobs::createNewNameOfLoc() const
3546 std::vector<std::string> names=getLocs();
3547 return CreateNewNameNotIn("NewLoc_",names);
3550 std::string MEDFileFieldGlobs::CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid)
3552 for(std::size_t sz=0;sz<100000;sz++)
3554 std::ostringstream tryName;
3555 tryName << prefix << sz;
3556 if(std::find(namesToAvoid.begin(),namesToAvoid.end(),tryName.str())==namesToAvoid.end())
3557 return tryName.str();
3559 throw INTERP_KERNEL::Exception("MEDFileFieldGlobs::CreateNewNameNotIn : impossible to create an additional profile limit of 100000 profiles reached !");
3563 * Creates a MEDFileFieldGlobsReal on a given file name. Nothing is read here.
3564 * \param [in] fname - the file name.
3566 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal(med_idt fid):_globals(MEDFileFieldGlobs::New(fid))
3571 * Creates an empty MEDFileFieldGlobsReal.
3573 MEDFileFieldGlobsReal::MEDFileFieldGlobsReal():_globals(MEDFileFieldGlobs::New())
3577 std::size_t MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren() const
3582 std::vector<const BigMemoryObject *> MEDFileFieldGlobsReal::getDirectChildrenWithNull() const
3584 std::vector<const BigMemoryObject *> ret;
3585 ret.push_back((const MEDFileFieldGlobs *)_globals);
3590 * Returns a string describing profiles and Gauss points held in \a this.
3591 * \return std::string - the description string.
3593 void MEDFileFieldGlobsReal::simpleReprGlobs(std::ostream& oss) const
3595 const MEDFileFieldGlobs *glob=_globals;
3596 std::ostringstream oss2; oss2 << glob;
3597 std::string stars(oss2.str().length(),'*');
3598 oss << "Globals information on fields (at " << oss2.str() << "):" << "\n************************************" << stars << "\n\n";
3600 glob->simpleRepr(oss);
3602 oss << "NO GLOBAL INFORMATION !\n";
3605 void MEDFileFieldGlobsReal::resetContent()
3607 _globals=MEDFileFieldGlobs::New();
3610 MEDFileFieldGlobsReal::~MEDFileFieldGlobsReal()
3615 * Copies references to profiles and Gauss points from another MEDFileFieldGlobsReal.
3616 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3618 void MEDFileFieldGlobsReal::shallowCpyGlobs(const MEDFileFieldGlobsReal& other)
3620 _globals=other._globals;
3624 * Copies references to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3625 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3627 void MEDFileFieldGlobsReal::shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3629 const MEDFileFieldGlobs *otherg(other._globals);
3632 _globals=otherg->shallowCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3636 * Copies deeply to ** only used ** by \a this, profiles and Gauss points from another MEDFileFieldGlobsReal.
3637 * \param [in] other - the other MEDFileFieldGlobsReal to copy data from.
3639 void MEDFileFieldGlobsReal::deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other)
3641 const MEDFileFieldGlobs *otherg(other._globals);
3644 _globals=otherg->deepCpyPart(getPflsReallyUsed(),getLocsReallyUsed());
3647 void MEDFileFieldGlobsReal::deepCpyGlobs(const MEDFileFieldGlobsReal& other)
3649 _globals=other._globals;
3650 if((const MEDFileFieldGlobs *)_globals)
3651 _globals=other._globals->deepCopy();
3655 * Adds profiles and Gauss points held by another MEDFileFieldGlobsReal to \a this one.
3656 * \param [in] other - the MEDFileFieldGlobsReal to copy data from.
3657 * \param [in] eps - a precision used to compare Gauss points with same name held by
3658 * \a this and \a other MEDFileFieldGlobsReal.
3659 * \throw If \a this and \a other hold profiles with equal names but different ids.
3660 * \throw If \a this and \a other hold different Gauss points with equal names.
3662 void MEDFileFieldGlobsReal::appendGlobs(const MEDFileFieldGlobsReal& other, double eps)
3664 const MEDFileFieldGlobs *thisGlobals(_globals),*otherGlobals(other._globals);
3665 if(thisGlobals==otherGlobals)
3669 _globals=other._globals;
3672 _globals->appendGlobs(*other._globals,eps);
3675 void MEDFileFieldGlobsReal::checkGlobsCoherency() const
3677 checkGlobsPflsPartCoherency();
3678 checkGlobsLocsPartCoherency();
3681 void MEDFileFieldGlobsReal::checkGlobsPflsPartCoherency() const
3683 contentNotNull()->checkGlobsPflsPartCoherency(getPflsReallyUsed());
3686 void MEDFileFieldGlobsReal::checkGlobsLocsPartCoherency() const
3688 contentNotNull()->checkGlobsLocsPartCoherency(getLocsReallyUsed());
3691 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id, const std::string& pflName)
3693 contentNotNull()->loadProfileInFile(fid,id,pflName);
3696 void MEDFileFieldGlobsReal::loadProfileInFile(med_idt fid, int id)
3698 contentNotNull()->loadProfileInFile(fid,id);
3701 void MEDFileFieldGlobsReal::loadGlobals(med_idt fid)
3703 contentNotNull()->loadGlobals(fid,*this);
3706 void MEDFileFieldGlobsReal::loadAllGlobals(med_idt fid)
3708 contentNotNull()->loadAllGlobals(fid);
3711 void MEDFileFieldGlobsReal::writeGlobals(med_idt fid, const MEDFileWritable& opt) const
3713 contentNotNull()->writeGlobals(fid,opt);
3717 * Returns names of all profiles. To get only used profiles call getPflsReallyUsed()
3718 * or getPflsReallyUsedMulti().
3719 * \return std::vector<std::string> - a sequence of names of all profiles.
3721 std::vector<std::string> MEDFileFieldGlobsReal::getPfls() const
3723 return contentNotNull()->getPfls();
3727 * Returns names of all localizations. To get only used localizations call getLocsReallyUsed()
3728 * or getLocsReallyUsedMulti().
3729 * \return std::vector<std::string> - a sequence of names of all localizations.
3731 std::vector<std::string> MEDFileFieldGlobsReal::getLocs() const
3733 return contentNotNull()->getLocs();
3737 * Checks if the profile with a given name exists.
3738 * \param [in] pflName - the profile name of interest.
3739 * \return bool - \c true if the profile named \a pflName exists.
3741 bool MEDFileFieldGlobsReal::existsPfl(const std::string& pflName) const
3743 return contentNotNull()->existsPfl(pflName);
3747 * Checks if the localization with a given name exists.
3748 * \param [in] locName - the localization name of interest.
3749 * \return bool - \c true if the localization named \a locName exists.
3751 bool MEDFileFieldGlobsReal::existsLoc(const std::string& locName) const
3753 return contentNotNull()->existsLoc(locName);
3756 std::string MEDFileFieldGlobsReal::createNewNameOfPfl() const
3758 return contentNotNull()->createNewNameOfPfl();
3761 std::string MEDFileFieldGlobsReal::createNewNameOfLoc() const
3763 return contentNotNull()->createNewNameOfLoc();
3767 * Sets the name of a MED file.
3768 * \param [inout] fileName - the file name.
3770 void MEDFileFieldGlobsReal::setFileName(const std::string& fileName)
3772 contentNotNull()->setFileName(fileName);
3776 * Finds equal profiles. Two profiles are considered equal if they contain the same ids
3777 * in the same order.
3778 * \return std::vector< std::vector<int> > - a sequence of groups of equal profiles.
3779 * Each item of this sequence is a vector containing ids of equal profiles.
3781 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualProfiles() const
3783 return contentNotNull()->whichAreEqualProfiles();
3787 * Finds equal localizations.
3788 * \param [in] eps - a precision used to compare real values of the localizations.
3789 * \return std::vector< std::vector<int> > - a sequence of groups of equal localizations.
3790 * Each item of this sequence is a vector containing ids of equal localizations.
3792 std::vector< std::vector<int> > MEDFileFieldGlobsReal::whichAreEqualLocs(double eps) const
3794 return contentNotNull()->whichAreEqualLocs(eps);
3798 * Renames the profiles. References to profiles (a reference is a profile name) are not changed.
3799 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3800 * this sequence is a pair whose
3801 * - the first item is a vector of profile names to replace by the second item,
3802 * - the second item is a profile name to replace every profile name of the first item.
3804 void MEDFileFieldGlobsReal::changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3806 contentNotNull()->changePflsNamesInStruct(mapOfModif);
3810 * Renames the localizations. References to localizations (a reference is a localization name) are not changed.
3811 * \param [in] mapOfModif - a sequence describing required renaming. Each element of
3812 * this sequence is a pair whose
3813 * - the first item is a vector of localization names to replace by the second item,
3814 * - the second item is a localization name to replace every localization name of the first item.
3816 void MEDFileFieldGlobsReal::changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3818 contentNotNull()->changeLocsNamesInStruct(mapOfModif);
3822 * Replaces references to some profiles (a reference is a profile name) by references
3823 * to other profiles and, contrary to changePflsRefsNamesGen(), renames the profiles
3824 * them-selves accordingly. <br>
3825 * This method is a generalization of changePflName().
3826 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3827 * this sequence is a pair whose
3828 * - the first item is a vector of profile names to replace by the second item,
3829 * - the second item is a profile name to replace every profile of the first item.
3830 * \sa changePflsRefsNamesGen()
3831 * \sa changePflName()
3833 void MEDFileFieldGlobsReal::changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3835 changePflsRefsNamesGen(mapOfModif);
3836 changePflsNamesInStruct(mapOfModif);
3840 * Replaces references to some localizations (a reference is a localization name) by references
3841 * to other localizations and, contrary to changeLocsRefsNamesGen(), renames the localizations
3842 * them-selves accordingly. <br>
3843 * This method is a generalization of changeLocName().
3844 * \param [in] mapOfModif - a sequence describing required replacements. Each element of
3845 * this sequence is a pair whose
3846 * - the first item is a vector of localization names to replace by the second item,
3847 * - the second item is a localization name to replace every localization of the first item.
3848 * \sa changeLocsRefsNamesGen()
3849 * \sa changeLocName()
3851 void MEDFileFieldGlobsReal::changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
3853 changeLocsRefsNamesGen(mapOfModif);
3854 changeLocsNamesInStruct(mapOfModif);
3858 * Renames the profile having a given name and updates references to this profile.
3859 * \param [in] oldName - the name of the profile to rename.
3860 * \param [in] newName - a new name of the profile.
3861 * \sa changePflsNames().
3863 void MEDFileFieldGlobsReal::changePflName(const std::string& oldName, const std::string& newName)
3865 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3866 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3868 changePflsNames(mapOfModif);
3872 * Renames the localization having a given name and updates references to this localization.
3873 * \param [in] oldName - the name of the localization to rename.
3874 * \param [in] newName - a new name of the localization.
3875 * \sa changeLocsNames().
3877 void MEDFileFieldGlobsReal::changeLocName(const std::string& oldName, const std::string& newName)
3879 std::vector< std::pair<std::vector<std::string>, std::string > > mapOfModif(1);
3880 std::pair<std::vector<std::string>, std::string > p(std::vector<std::string>(1,std::string(oldName)),std::string(newName));
3882 changeLocsNames(mapOfModif);
3886 * Removes duplicated profiles. Returns a map used to update references to removed
3887 * profiles via changePflsRefsNamesGen().
3888 * Equal profiles are found using whichAreEqualProfiles().
3889 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3890 * a sequence describing the performed replacements of profiles. Each element of
3891 * this sequence is a pair whose
3892 * - the first item is a vector of profile names replaced by the second item,
3893 * - the second item is a profile name replacing every profile of the first item.
3895 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipPflsNames()
3897 std::vector< std::vector<int> > pseudoRet=whichAreEqualProfiles();
3898 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3900 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3902 std::vector< std::string > tmp((*it).size());
3904 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3905 tmp[j]=std::string(getProfileFromId(*it2)->getName());
3906 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3908 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3909 killProfileIds(tmp2);
3911 changePflsRefsNamesGen(ret);
3916 * Removes duplicated localizations. Returns a map used to update references to removed
3917 * localizations via changeLocsRefsNamesGen().
3918 * Equal localizations are found using whichAreEqualLocs().
3919 * \param [in] eps - a precision used to compare real values of the localizations.
3920 * \return std::vector< std::pair<std::vector<std::string>, std::string > > -
3921 * a sequence describing the performed replacements of localizations. Each element of
3922 * this sequence is a pair whose
3923 * - the first item is a vector of localization names replaced by the second item,
3924 * - the second item is a localization name replacing every localization of the first item.
3926 std::vector< std::pair<std::vector<std::string>, std::string > > MEDFileFieldGlobsReal::zipLocsNames(double eps)
3928 std::vector< std::vector<int> > pseudoRet=whichAreEqualLocs(eps);
3929 std::vector< std::pair<std::vector<std::string>, std::string > > ret(pseudoRet.size());
3931 for(std::vector< std::vector<int> >::const_iterator it=pseudoRet.begin();it!=pseudoRet.end();it++,i++)
3933 std::vector< std::string > tmp((*it).size());
3935 for(std::vector<int>::const_iterator it2=(*it).begin();it2!=(*it).end();it2++,j++)
3936 tmp[j]=std::string(getLocalizationFromId(*it2).getName());
3937 std::pair<std::vector<std::string>, std::string > p(tmp,tmp.front());
3939 std::vector<int> tmp2((*it).begin()+1,(*it).end());
3940 killLocalizationIds(tmp2);
3942 changeLocsRefsNamesGen(ret);
3947 * Returns number of Gauss points per cell in a given localization.
3948 * \param [in] locId - an id of the localization of interest.
3949 * \return int - the number of the Gauss points per cell.
3951 int MEDFileFieldGlobsReal::getNbOfGaussPtPerCell(int locId) const
3953 return contentNotNull()->getNbOfGaussPtPerCell(locId);
3957 * Returns an id of a localization by its name.
3958 * \param [in] loc - the localization name of interest.
3959 * \return int - the id of the localization.
3960 * \throw If there is no a localization named \a loc.
3962 int MEDFileFieldGlobsReal::getLocalizationId(const std::string& loc) const
3964 return contentNotNull()->getLocalizationId(loc);
3968 * Returns the name of the MED file.
3969 * \return const std::string& - the MED file name.
3971 std::string MEDFileFieldGlobsReal::getFileName() const
3973 return contentNotNull()->getFileName();
3977 * Returns a localization object by its name.
3978 * \param [in] locName - the name of the localization of interest.
3979 * \return const MEDFileFieldLoc& - the localization object having the name \a locName.
3980 * \throw If there is no a localization named \a locName.
3982 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName) const
3984 return contentNotNull()->getLocalization(locName);
3988 * Returns a localization object by its id.
3989 * \param [in] locId - the id of the localization of interest.
3990 * \return const MEDFileFieldLoc& - the localization object having the id \a locId.
3991 * \throw If there is no a localization with id \a locId.
3993 const MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId) const
3995 return contentNotNull()->getLocalizationFromId(locId);
3999 * Returns a profile array by its name.
4000 * \param [in] pflName - the name of the profile of interest.
4001 * \return const DataArrayInt * - the profile array having the name \a pflName.
4002 * \throw If there is no a profile named \a pflName.
4004 const DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName) const
4006 return contentNotNull()->getProfile(pflName);
4010 * Returns a profile array by its id.
4011 * \param [in] pflId - the id of the profile of interest.
4012 * \return const DataArrayInt * - the profile array having the id \a pflId.
4013 * \throw If there is no a profile with id \a pflId.
4015 const DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId) const
4017 return contentNotNull()->getProfileFromId(pflId);
4021 * Returns a localization object, apt for modification, by its id.
4022 * \param [in] locId - the id of the localization of interest.
4023 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4024 * having the id \a locId.
4025 * \throw If there is no a localization with id \a locId.
4027 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalizationFromId(int locId)
4029 return contentNotNull()->getLocalizationFromId(locId);
4033 * Returns a localization object, apt for modification, by its name.
4034 * \param [in] locName - the name of the localization of interest.
4035 * \return MEDFileFieldLoc& - a non-const reference to the localization object
4036 * having the name \a locName.
4037 * \throw If there is no a localization named \a locName.
4039 MEDFileFieldLoc& MEDFileFieldGlobsReal::getLocalization(const std::string& locName)
4041 return contentNotNull()->getLocalization(locName);
4045 * Returns a profile array, apt for modification, by its name.
4046 * \param [in] pflName - the name of the profile of interest.
4047 * \return DataArrayInt * - a non-const pointer to the profile array having the name \a pflName.
4048 * \throw If there is no a profile named \a pflName.
4050 DataArrayInt *MEDFileFieldGlobsReal::getProfile(const std::string& pflName)
4052 return contentNotNull()->getProfile(pflName);
4056 * Returns a profile array, apt for modification, by its id.
4057 * \param [in] pflId - the id of the profile of interest.
4058 * \return DataArrayInt * - a non-const pointer to the profile array having the id \a pflId.
4059 * \throw If there is no a profile with id \a pflId.
4061 DataArrayInt *MEDFileFieldGlobsReal::getProfileFromId(int pflId)
4063 return contentNotNull()->getProfileFromId(pflId);
4067 * Removes profiles given by their ids. No data is updated to track this removal.
4068 * \param [in] pflIds - a sequence of ids of the profiles to remove.
4070 void MEDFileFieldGlobsReal::killProfileIds(const std::vector<int>& pflIds)
4072 contentNotNull()->killProfileIds(pflIds);
4076 * Removes localizations given by their ids. No data is updated to track this removal.
4077 * \param [in] locIds - a sequence of ids of the localizations to remove.
4079 void MEDFileFieldGlobsReal::killLocalizationIds(const std::vector<int>& locIds)
4081 contentNotNull()->killLocalizationIds(locIds);
4085 * Stores a profile array.
4086 * \param [in] pfl - the profile array to store.
4087 * \throw If the name of \a pfl is empty.
4088 * \throw If a profile with the same name as that of \a pfl already exists but contains
4091 void MEDFileFieldGlobsReal::appendProfile(DataArrayInt *pfl)
4093 contentNotNull()->appendProfile(pfl);
4097 * Adds a new localization of Gauss points.
4098 * \param [in] locName - the name of the new localization.
4099 * \param [in] geoType - a geometrical type of the reference cell.
4100 * \param [in] refCoo - coordinates of points of the reference cell. Size of this vector
4101 * must be \c nbOfNodesPerCell * \c dimOfType.
4102 * \param [in] gsCoo - coordinates of Gauss points on the reference cell. Size of this vector
4103 * must be _wg_.size() * \c dimOfType.
4104 * \param [in] w - the weights of Gauss points.
4105 * \throw If \a locName is empty.
4106 * \throw If a localization with the name \a locName already exists but is
4107 * different form the new one.
4109 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)
4111 contentNotNull()->appendLoc(locName,geoType,refCoo,gsCoo,w);
4114 MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull()
4116 MEDFileFieldGlobs *g(_globals);
4118 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in not const !");
4122 const MEDFileFieldGlobs *MEDFileFieldGlobsReal::contentNotNull() const
4124 const MEDFileFieldGlobs *g(_globals);
4126 throw INTERP_KERNEL::Exception("MEDFileFieldGlobsReal::contentNotNull : no content in const !");
4130 //= MEDFileFieldNameScope
4132 MEDFileFieldNameScope::MEDFileFieldNameScope()
4136 MEDFileFieldNameScope::MEDFileFieldNameScope(const std::string& fieldName):_name(fieldName)
4141 * Returns the name of \a this field.
4142 * \return std::string - a string containing the field name.
4144 std::string MEDFileFieldNameScope::getName() const
4150 * Sets name of \a this field
4151 * \param [in] name - the new field name.
4153 void MEDFileFieldNameScope::setName(const std::string& fieldName)
4158 std::string MEDFileFieldNameScope::getDtUnit() const
4163 void MEDFileFieldNameScope::setDtUnit(const std::string& dtUnit)
4168 void MEDFileFieldNameScope::copyNameScope(const MEDFileFieldNameScope& other)
4171 _dt_unit=other._dt_unit;
4174 //= MEDFileAnyTypeField1TSWithoutSDA
4176 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
4178 _field_per_mesh.resize(other._field_per_mesh.size());
4180 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
4182 if((const MEDFileFieldPerMesh *)*it)
4183 _field_per_mesh[i]=(*it)->deepCopy(this);
4188 * Prints a string describing \a this field into a stream. This string is outputted
4189 * by \c print Python command.
4190 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
4191 * \param [in,out] oss - the out stream.
4192 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
4193 * info id printed, else, not.
4195 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
4197 std::string startOfLine(bkOffset,' ');
4198 oss << startOfLine << "Field ";
4200 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
4201 oss << "on one time Step ";
4203 oss << "(" << f1tsId << ") ";
4204 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
4205 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
4206 const DataArray *arr=getUndergroundDataArray();
4209 const std::vector<std::string> &comps=arr->getInfoOnComponents();
4212 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
4213 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
4214 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
4216 if(arr->isAllocated())
4218 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
4221 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
4225 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
4227 oss << startOfLine << "----------------------" << std::endl;
4228 if(!_field_per_mesh.empty())
4231 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
4233 const MEDFileFieldPerMesh *cur=(*it2);
4235 cur->simpleRepr(bkOffset,oss,i);
4237 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
4242 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
4244 oss << startOfLine << "----------------------" << std::endl;
4247 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
4249 const DataArray *arr(getUndergroundDataArray());
4251 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
4252 int nbOfCompo=arr->getNumberOfComponents();
4253 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
4254 for(int i=0;i<nbOfCompo;i++)
4257 std::vector<int> v(1,i);
4258 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
4259 ret[i]->setArray(arr2);
4264 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)
4268 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
4273 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
4274 * empty. Returns -1 if this in on nodes.
4275 * \return int - the dimension of \a this.
4277 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
4280 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4281 (*it)->getDimension(ret);
4286 * Returns the mesh name.
4287 * \return std::string - a string holding the mesh name.
4288 * \throw If \c _field_per_mesh.empty()
4290 std::string MEDFileAnyTypeField1TSWithoutSDA::getMeshName() const
4292 if(_field_per_mesh.empty())
4293 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshName : No field set !");
4294 return _field_per_mesh[0]->getMeshName();
4297 void MEDFileAnyTypeField1TSWithoutSDA::setMeshName(const std::string& newMeshName)
4299 std::string oldName(getMeshName());
4300 std::vector< std::pair<std::string,std::string> > v(1);
4301 v[0].first=oldName; v[0].second=newMeshName;
4305 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
4308 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4310 MEDFileFieldPerMesh *cur(*it);
4312 ret=cur->changeMeshNames(modifTab) || ret;
4318 * Returns the number of iteration of the state of underlying mesh.
4319 * \return int - the iteration number.
4320 * \throw If \c _field_per_mesh.empty()
4322 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
4324 if(_field_per_mesh.empty())
4325 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
4326 return _field_per_mesh[0]->getMeshIteration();
4330 * Returns the order number of iteration of the state of underlying mesh.
4331 * \return int - the order number.
4332 * \throw If \c _field_per_mesh.empty()
4334 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
4336 if(_field_per_mesh.empty())
4337 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
4338 return _field_per_mesh[0]->getMeshOrder();
4342 * Checks if \a this field is tagged by a given iteration number and a given
4343 * iteration order number.
4344 * \param [in] iteration - the iteration number of interest.
4345 * \param [in] order - the iteration order number of interest.
4346 * \return bool - \c true if \a this->getIteration() == \a iteration &&
4347 * \a this->getOrder() == \a order.
4349 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
4351 return iteration==_iteration && order==_order;
4355 * Returns number of iteration and order number of iteration when
4356 * \a this field has been calculated.
4357 * \return std::pair<int,int> - a pair of the iteration number and the iteration
4360 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
4362 std::pair<int,int> p;
4368 * Returns number of iteration and order number of iteration when
4369 * \a this field has been calculated.
4370 * \param [in,out] p - a pair returning the iteration number and the iteration
4373 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
4380 * Returns all types of spatial discretization of \a this field.
4381 * \param [in,out] types - a sequence of types of \a this field.
4383 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
4385 std::set<TypeOfField> types2;
4386 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4388 (*it)->fillTypesOfFieldAvailable(types2);
4390 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
4391 std::copy(types2.begin(),types2.end(),bi);
4395 * Returns all types of spatial discretization of \a this field.
4396 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
4399 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
4401 std::vector<TypeOfField> ret;
4402 fillTypesOfFieldAvailable(ret);
4406 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
4408 std::vector<std::string> ret;
4409 std::set<std::string> ret2;
4410 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4412 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
4413 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4414 if(ret2.find(*it2)==ret2.end())
4416 ret.push_back(*it2);
4423 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
4425 std::vector<std::string> ret;
4426 std::set<std::string> ret2;
4427 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4429 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
4430 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
4431 if(ret2.find(*it2)==ret2.end())
4433 ret.push_back(*it2);
4440 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
4442 std::vector<std::string> ret;
4443 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4445 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
4446 ret.insert(ret.end(),tmp.begin(),tmp.end());
4451 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
4453 std::vector<std::string> ret;
4454 std::set<std::string> ret2;
4455 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4457 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
4458 ret.insert(ret.end(),tmp.begin(),tmp.end());
4463 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4465 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4466 (*it)->changePflsRefsNamesGen(mapOfModif);
4469 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
4471 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4472 (*it)->changeLocsRefsNamesGen(mapOfModif);
4476 * Returns all attributes of parts of \a this field lying on a given mesh.
4477 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
4478 * item of every of returned sequences refers to the _i_-th part of \a this field.
4479 * Thus all sequences returned by this method are of the same length equal to number
4480 * of different types of supporting entities.<br>
4481 * A field part can include sub-parts with several different spatial discretizations,
4482 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
4483 * for example. Hence, some of the returned sequences contains nested sequences, and an item
4484 * of a nested sequence corresponds to a type of spatial discretization.<br>
4485 * This method allows for iteration over MEDFile DataStructure without any overhead.
4486 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4487 * for the case with only one underlying mesh. (Actually, the number of meshes is
4488 * not checked if \a mname == \c NULL).
4489 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
4490 * a field part is returned.
4491 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
4492 * This sequence is of the same length as \a types.
4493 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
4494 * discretization. A profile name can be empty.
4495 * Length of this and of nested sequences is the same as that of \a typesF.
4496 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
4497 * discretization. A localization name can be empty.
4498 * Length of this and of nested sequences is the same as that of \a typesF.
4499 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
4500 * of ids of tuples within the data array, per each type of spatial
4501 * discretization within one mesh entity type.
4502 * Length of this and of nested sequences is the same as that of \a typesF.
4503 * \throw If no field is lying on \a mname.
4505 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
4509 meshId=getMeshIdFromMeshName(mname);
4511 if(_field_per_mesh.empty())
4512 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
4513 return _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4517 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
4518 * maximal absolute dimension and values returned via the out parameter \a levs are
4519 * dimensions relative to the maximal absolute dimension. <br>
4520 * This method is designed for MEDFileField1TS instances that have a discretization
4521 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
4522 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
4523 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
4524 * Only these 3 discretizations will be taken into account here. If \a this is
4525 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
4526 * This method is useful to make the link between the dimension of the underlying mesh
4527 * and the levels of \a this, because it is possible that the highest dimension of \a this
4528 * field is not equal to the dimension of the underlying mesh.
4530 * Let's consider the following case:
4531 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
4532 * TETRA4, HEXA8, TRI3 and SEG2.
4533 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
4534 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
4536 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
4537 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
4538 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
4539 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
4540 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
4541 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
4543 * to retrieve the highest level of
4544 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
4545 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
4546 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
4547 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
4548 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
4549 * for the case with only one underlying mesh. (Actually, the number of meshes is
4550 * not checked if \a mname == \c NULL).
4551 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
4552 * absolute one. They are in decreasing order. This sequence is cleared before
4554 * \return int - the maximal absolute dimension of elements \a this fields lies on.
4555 * \throw If no field is lying on \a mname.
4557 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
4560 int meshId=getMeshIdFromMeshName(mname);
4561 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4562 std::vector< std::vector<TypeOfField> > typesF;
4563 std::vector< std::vector<std::string> > pfls, locs;
4564 _field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
4566 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
4567 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
4568 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
4570 st.erase(INTERP_KERNEL::NORM_ERROR);
4572 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
4574 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
4575 ret1.insert((int)cm.getDimension());
4577 int ret=*std::max_element(ret1.begin(),ret1.end());
4578 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
4579 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
4583 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
4585 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
4586 if((*it).isNotNull())
4587 (*it)->convertMedBallIntoClassic();
4591 * \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.
4592 * \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.
4593 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4594 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4596 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
4598 int mid=getMeshIdFromMeshName(mName);
4599 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4603 * \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.
4604 * \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.
4605 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
4606 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
4608 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
4610 int mid=getMeshIdFromMeshName(mName);
4611 return _field_per_mesh[mid]->getLeafGivenTypeAndLocId(typ,locId);
4615 * \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.
4617 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
4619 if(_field_per_mesh.empty())
4620 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
4623 std::string mName2(mName);
4625 std::vector<std::string> msg;
4626 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
4627 if(mName2==(*it)->getMeshName())
4630 msg.push_back((*it)->getMeshName());
4631 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
4632 oss << "Possible meshes are : ";
4633 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
4634 oss << "\"" << (*it2) << "\" ";
4635 throw INTERP_KERNEL::Exception(oss.str());
4638 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
4641 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
4642 std::string tmp(mesh->getName());
4644 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
4645 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
4647 for(;it!=_field_per_mesh.end();it++,i++)
4649 if((*it)->getMeshName()==tmp)
4652 int sz=_field_per_mesh.size();
4653 _field_per_mesh.resize(sz+1);
4654 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
4658 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
4659 MEDFileFieldGlobsReal& glob)
4662 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4664 MEDFileFieldPerMesh *fpm(*it);
4666 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
4672 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
4673 * splitting that leads to single spatial discretization of this.
4675 * \sa splitMultiDiscrPerGeoTypes
4677 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
4679 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4680 std::vector< std::vector<TypeOfField> > typesF;
4681 std::vector< std::vector<std::string> > pfls,locs;
4682 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4683 std::set<TypeOfField> allEnt;
4684 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
4685 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4686 allEnt.insert(*it2);
4687 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
4688 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
4689 for(std::size_t i=0;i<allEnt.size();i++,it3++)
4691 std::vector< std::pair<int,int> > its;
4692 ret[i]=shallowCpy();
4693 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
4694 ret[i]->updateData(newLgth,its);
4700 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest spliting level that can be done.
4701 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
4703 * \sa splitDiscretizations
4705 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
4707 std::vector<INTERP_KERNEL::NormalizedCellType> types;
4708 std::vector< std::vector<TypeOfField> > typesF;
4709 std::vector< std::vector<std::string> > pfls,locs;
4710 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
4711 std::set<TypeOfField> allEnt;
4712 std::size_t nbOfMDPGT(0),ii(0);
4713 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
4715 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
4716 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
4717 allEnt.insert(*it2);
4719 if(allEnt.size()!=1)
4720 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
4722 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
4725 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
4726 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
4729 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
4730 for(std::size_t i=0;i<nbOfMDPGT;i++)
4732 std::vector< std::pair<int,int> > its;
4733 ret[i]=shallowCpy();
4734 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
4735 ret[i]->updateData(newLgth,its);
4740 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
4742 int globalCounter(0);
4743 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4744 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
4745 return globalCounter;
4748 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
4750 int globalCounter(0);
4751 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4752 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
4753 return globalCounter;
4756 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
4758 if(_nb_of_tuples_to_be_allocated>=0)
4760 _nb_of_tuples_to_be_allocated=newLgth;
4761 const DataArray *oldArr(getUndergroundDataArray());
4764 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4765 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
4767 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
4771 if(_nb_of_tuples_to_be_allocated==-1)
4773 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4775 const DataArray *oldArr(getUndergroundDataArray());
4776 if(!oldArr || !oldArr->isAllocated())
4777 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
4778 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
4779 newArr->alloc(newLgth,getNumberOfComponents());
4781 newArr->copyStringInfoFrom(*oldArr);
4783 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
4785 if((*it).second<(*it).first)
4786 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
4787 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
4788 pos+=(*it).second-(*it).first;
4793 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
4796 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
4798 if(_field_per_mesh.empty())
4799 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
4800 if(_field_per_mesh.size()>1)
4801 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writting mode only ONE underlying mesh supported !");
4802 _field_per_mesh[0]->copyOptionsFrom(opts);
4803 _field_per_mesh[0]->writeLL(fid,nasc);
4807 * 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.
4808 * If false is returned the memory allocation is not required.
4810 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
4812 if(_nb_of_tuples_to_be_allocated>=0)
4814 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
4815 _nb_of_tuples_to_be_allocated=-2;
4818 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
4820 if(_nb_of_tuples_to_be_allocated==-1)
4821 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
4822 if(_nb_of_tuples_to_be_allocated<-3)
4823 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4824 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
4827 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4829 med_int numdt,numit;
4833 med_int meshnumdt,meshnumit;
4834 INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
4835 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
4836 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit));
4837 if(_iteration!=numdt || _order!=numit)
4838 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
4839 _field_per_mesh.resize(nmesh);
4844 std::string meshNameCpp(MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1));
4845 mm=ms->getMeshWithName(meshNameCpp);
4848 for(int i=0;i<nmesh;i++)
4849 _field_per_mesh[i]=MEDFileFieldPerMesh::NewOnRead(fid,this,i,meshnumdt,meshnumit,nasc,mm,entities);
4850 _nb_of_tuples_to_be_allocated=0;
4851 for(int i=0;i<nmesh;i++)
4852 _field_per_mesh[i]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
4855 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
4857 allocIfNecessaryTheArrayToReceiveDataFromFile();
4858 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4859 (*it)->loadBigArraysRecursively(fid,nasc);
4862 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
4864 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
4865 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4866 (*it)->loadBigArraysRecursively(fid,nasc);
4869 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
4871 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
4872 loadBigArraysRecursively(fid,nasc);
4875 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
4877 DataArray *thisArr(getUndergroundDataArray());
4878 if(thisArr && thisArr->isAllocated())
4880 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
4881 thisArr->desallocate();
4885 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
4887 return _dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
4890 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
4892 std::vector<const BigMemoryObject *> ret;
4893 if(getUndergroundDataArray())
4894 ret.push_back(getUndergroundDataArray());
4895 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
4896 ret.push_back((const MEDFileFieldPerMesh *)*it);
4901 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
4902 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
4903 * "Sort By Type"), if not, an exception is thrown.
4904 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
4905 * \param [in] arr - the array of values.
4906 * \param [in,out] glob - the global data where profiles and localization present in
4907 * \a field, if any, are added.
4908 * \throw If the name of \a field is empty.
4909 * \throw If the data array of \a field is not set.
4910 * \throw If \a this->_arr is already allocated but has different number of components
4912 * \throw If the underlying mesh of \a field has no name.
4913 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
4915 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4917 const MEDCouplingMesh *mesh=field->getMesh();
4919 TypeOfField type=field->getTypeOfField();
4920 std::vector<DataArrayInt *> dummy;
4921 int start=copyTinyInfoFrom(field,arr);
4922 int pos=addNewEntryIfNecessary(mesh);
4925 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
4926 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
4929 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
4933 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
4934 * of a given mesh are used as the support of the given field (a real support is not used).
4935 * Elements of the given mesh must be sorted suitable for writing to MED file.
4936 * Order of underlying mesh entities of the given field specified by \a profile parameter
4937 * is not prescribed; this method permutes field values to have them sorted by element
4938 * type as required for writing to MED file. A new profile is added only if no equal
4939 * profile is missing.
4940 * \param [in] field - the field to add to \a this. The field double values are ignored.
4941 * \param [in] arrOfVals - the values of the field \a field used.
4942 * \param [in] mesh - the supporting mesh of \a field.
4943 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
4944 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
4945 * \param [in,out] glob - the global data where profiles and localization present in
4946 * \a field, if any, are added.
4947 * \throw If either \a field or \a mesh or \a profile has an empty name.
4948 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
4949 * \throw If the data array of \a field is not set.
4950 * \throw If \a this->_arr is already allocated but has different number of components
4952 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
4953 * \sa setFieldNoProfileSBT()
4955 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
4958 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
4959 if(!arrOfVals || !arrOfVals->isAllocated())
4960 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
4961 TypeOfField type=field->getTypeOfField();
4962 std::vector<DataArrayInt *> idsInPflPerType;
4963 std::vector<DataArrayInt *> idsPerType;
4964 std::vector<int> code,code2;
4965 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
4968 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
4969 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
4970 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
4971 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
4973 MCAuto<MEDCouplingFieldDouble> field2=field->clone(false);
4974 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
4975 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4977 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4978 throw INTERP_KERNEL::Exception(oss.str());
4981 int start=copyTinyInfoFrom(field,arrOfVals);
4982 code2=m->getDistributionOfTypes();
4984 int pos=addNewEntryIfNecessary(m);
4985 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
4989 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
4990 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
4991 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
4992 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
4993 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
4994 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
4996 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
4997 throw INTERP_KERNEL::Exception(oss.str());
4999 int start=copyTinyInfoFrom(field,arrOfVals);
5000 int pos=addNewEntryIfNecessary(m);
5001 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
5006 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
5008 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
5010 if(_nb_of_tuples_to_be_allocated>=0)
5011 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 !");
5012 DataArray *arr(getOrCreateAndGetArray());
5013 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
5014 _nb_of_tuples_to_be_allocated=-3;
5018 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
5019 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
5020 * larger by the size of \a field. Returns an id of the first not filled
5021 * tuple of \a this->_arr.
5022 * \param [in] field - the field to copy the info on components and the name from.
5023 * \return int - the id of first not initialized tuple of \a this->_arr.
5024 * \throw If the name of \a field is empty.
5025 * \throw If the data array of \a field is not set.
5026 * \throw If \a this->_arr is already allocated but has different number of components
5029 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
5032 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
5033 std::string name(field->getName());
5034 setName(name.c_str());
5035 setDtUnit(field->getTimeUnit());
5037 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
5039 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
5040 if(!arr->isAllocated())
5041 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
5042 _dt=field->getTime(_iteration,_order);
5043 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
5044 if(!getOrCreateAndGetArray()->isAllocated())
5046 allocNotFromFile(arr->getNumberOfTuples());
5051 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
5052 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
5053 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
5054 _nb_of_tuples_to_be_allocated=-3;
5055 return oldNbOfTuples;
5060 * Returns number of components in \a this field
5061 * \return int - the number of components.
5063 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
5065 return getOrCreateAndGetArray()->getNumberOfComponents();
5069 * Change info on components in \a this.
5070 * \throw If size of \a infos is not equal to the number of components already in \a this.
5072 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
5074 DataArray *arr=getOrCreateAndGetArray();
5075 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
5079 * Returns info on components of \a this field.
5080 * \return const std::vector<std::string>& - a sequence of strings each being an
5081 * information on _i_-th component.
5083 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
5085 const DataArray *arr=getOrCreateAndGetArray();
5086 return arr->getInfoOnComponents();
5090 * Returns a mutable info on components of \a this field.
5091 * \return std::vector<std::string>& - a sequence of strings each being an
5092 * information on _i_-th component.
5094 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
5096 DataArray *arr=getOrCreateAndGetArray();
5097 return arr->getInfoOnComponents();
5100 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
5102 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5104 const MEDFileFieldPerMesh *fpm(*it);
5107 if(fpm->presenceOfMultiDiscPerGeoType())
5113 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
5115 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5116 if((*it).isNotNull())
5117 if((*it)->presenceOfStructureElements())
5122 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
5124 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5125 if((*it).isNotNull())
5126 if(!(*it)->onlyStructureElements())
5131 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
5133 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5134 if((*it).isNotNull())
5135 (*it)->killStructureElements();
5138 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
5140 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5141 if((*it).isNotNull())
5142 (*it)->keepOnlyStructureElements();
5145 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
5147 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5148 if((*it).isNotNull())
5149 (*it)->keepOnlyOnSE(seName);
5152 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
5154 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
5155 if((*it).isNotNull())
5156 (*it)->getMeshSENames(ps);
5159 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5161 static const char MSG0[]="MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is too complex to be able to be extracted with \"field\" method ! Call getFieldOnMeshAtLevel method instead to deal with complexity !";
5162 if(_field_per_mesh.empty())
5163 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
5164 if(_field_per_mesh.size()>1)
5165 throw INTERP_KERNEL::Exception(MSG0);
5166 if(_field_per_mesh[0].isNull())
5167 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
5168 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
5169 std::set<TypeOfField> types;
5170 pm->fillTypesOfFieldAvailable(types);
5172 throw INTERP_KERNEL::Exception(MSG0);
5173 TypeOfField type(*types.begin());
5174 int meshDimRelToMax(0);
5179 int myDim(std::numeric_limits<int>::max());
5180 bool isUnique(pm->isUniqueLevel(myDim));
5182 throw INTERP_KERNEL::Exception(MSG0);
5183 meshDimRelToMax=myDim-mesh->getMeshDimension();
5184 if(meshDimRelToMax>0)
5185 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
5187 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
5191 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5192 * \param [in] type - a spatial discretization of the new field.
5193 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5194 * \param [in] mName - a name of the supporting mesh.
5195 * \param [in] renumPol - specifies how to permute values of the result field according to
5196 * the optional numbers of cells and nodes, if any. The valid values are
5197 * - 0 - do not permute.
5198 * - 1 - permute cells.
5199 * - 2 - permute nodes.
5200 * - 3 - permute cells and nodes.
5202 * \param [in] glob - the global data storing profiles and localization.
5203 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5204 * caller is to delete this field using decrRef() as it is no more needed.
5205 * \throw If the MED file is not readable.
5206 * \throw If there is no mesh named \a mName in the MED file.
5207 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5208 * \throw If no field of \a this is lying on the mesh \a mName.
5209 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5211 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5213 MCAuto<MEDFileMesh> mm;
5215 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5217 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5218 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5222 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5223 * \param [in] type - a spatial discretization of the new field.
5224 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5225 * \param [in] renumPol - specifies how to permute values of the result field according to
5226 * the optional numbers of cells and nodes, if any. The valid values are
5227 * - 0 - do not permute.
5228 * - 1 - permute cells.
5229 * - 2 - permute nodes.
5230 * - 3 - permute cells and nodes.
5232 * \param [in] glob - the global data storing profiles and localization.
5233 * \param [in] mesh - the supporting mesh.
5234 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5235 * caller is to delete this field using decrRef() as it is no more needed.
5236 * \throw If the MED file is not readable.
5237 * \throw If no field of \a this is lying on \a mesh.
5238 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5239 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5241 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5243 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
5244 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
5245 if(meshDimRelToMax==1)
5246 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
5247 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
5251 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
5253 * \param [in] type - a spatial discretization of the new field.
5254 * \param [in] mName - a name of the supporting mesh.
5255 * \param [in] renumPol - specifies how to permute values of the result field according to
5256 * the optional numbers of cells and nodes, if any. The valid values are
5257 * - 0 - do not permute.
5258 * - 1 - permute cells.
5259 * - 2 - permute nodes.
5260 * - 3 - permute cells and nodes.
5262 * \param [in] glob - the global data storing profiles and localization.
5263 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5264 * caller is to delete this field using decrRef() as it is no more needed.
5265 * \throw If the MED file is not readable.
5266 * \throw If there is no mesh named \a mName in the MED file.
5267 * \throw If there are no mesh entities in the mesh.
5268 * \throw If no field values of the given \a type are available.
5270 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5272 MCAuto<MEDFileMesh> mm;
5274 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
5276 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
5277 int absDim=getDimension();
5278 int meshDimRelToMax=absDim-mm->getMeshDimension();
5279 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
5283 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
5284 * \param [in] type - a spatial discretization of the new field.
5285 * \param [in] renumPol - specifies how to permute values of the result field according to
5286 * the optional numbers of cells and nodes, if any. The valid values are
5287 * - 0 - do not permute.
5288 * - 1 - permute cells.
5289 * - 2 - permute nodes.
5290 * - 3 - permute cells and nodes.
5292 * \param [in] glob - the global data storing profiles and localization.
5293 * \param [in] mesh - the supporting mesh.
5294 * \param [in] cellRenum - the cell numbers array used for permutation of the result
5295 * field according to \a renumPol.
5296 * \param [in] nodeRenum - the node numbers array used for permutation of the result
5297 * field according to \a renumPol.
5298 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
5299 * caller is to delete this field using decrRef() as it is no more needed.
5300 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
5301 * \throw If no field of \a this is lying on \a mesh.
5302 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
5304 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
5306 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
5307 int meshId=getMeshIdFromMeshName(mesh->getName());
5309 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
5314 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5321 throw INTERP_KERNEL::Exception(msg1);
5322 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5325 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
5327 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5328 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
5329 throw INTERP_KERNEL::Exception(oss.str());
5331 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
5332 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
5333 std::vector<DataArray *> arrOut2(1,arrOut);
5334 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
5335 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
5336 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
5343 //no need to test _field_per_mesh.empty() because geMeshName has already done it
5345 throw INTERP_KERNEL::Exception(msg1);
5348 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
5350 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
5351 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
5352 throw INTERP_KERNEL::Exception(oss.str());
5354 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
5355 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
5356 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
5357 ret->renumberNodes(nodeRenumSafe->getConstPointer());
5362 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
5367 * Returns values and a profile of the field of a given type lying on a given support.
5368 * \param [in] type - a spatial discretization of the field.
5369 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
5370 * \param [in] mesh - the supporting mesh.
5371 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
5372 * field of interest lies on. If the field lies on all entities of the given
5373 * dimension, all ids in \a pfl are zero. The caller is to delete this array
5374 * using decrRef() as it is no more needed.
5375 * \param [in] glob - the global data storing profiles and localization.
5376 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
5377 * field. The caller is to delete this array using decrRef() as it is no more needed.
5378 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
5379 * \throw If no field of \a this is lying on \a mesh.
5380 * \throw If no field values of the given \a type are available.
5382 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
5384 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
5385 int meshId=getMeshIdFromMeshName(mesh->getName().c_str());
5386 MCAuto<DataArray> ret=_field_per_mesh[meshId]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
5387 ret->setName(nasc.getName().c_str());
5391 //= MEDFileField1TSWithoutSDA
5394 * Throws if a given value is not a valid (non-extended) relative dimension.
5395 * \param [in] meshDimRelToMax - the relative dimension value.
5396 * \throw If \a meshDimRelToMax > 0.
5398 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
5400 if(meshDimRelToMax>0)
5401 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
5405 * Checks if elements of a given mesh are in the order suitable for writing
5406 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
5407 * vector describing types of elements and their number.
5408 * \param [in] mesh - the mesh to check.
5409 * \return std::vector<int> - a vector holding for each element type (1) item of
5410 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
5411 * These values are in full-interlace mode.
5412 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
5414 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
5417 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
5418 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
5419 int nbOfTypes=geoTypes.size();
5420 std::vector<int> code(3*nbOfTypes);
5421 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
5422 arr1->alloc(nbOfTypes,1);
5423 int *arrPtr=arr1->getPointer();
5424 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
5425 for(int i=0;i<nbOfTypes;i++,it++)
5426 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
5427 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
5428 const int *arrPtr2=arr2->getConstPointer();
5430 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
5433 int nbCells=mesh->getNumberOfCellsWithType(*it);
5434 code[3*pos]=(int)(*it);
5435 code[3*pos+1]=nbCells;
5436 code[3*pos+2]=-1;//no profiles
5438 std::vector<const DataArrayInt *> idsPerType;//no profiles
5439 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
5443 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
5448 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5450 return new MEDFileField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5454 * Returns all attributes and values of parts of \a this field lying on a given mesh.
5455 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
5456 * item of every of returned sequences refers to the _i_-th part of \a this field.
5457 * Thus all sequences returned by this method are of the same length equal to number
5458 * of different types of supporting entities.<br>
5459 * A field part can include sub-parts with several different spatial discretizations,
5460 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
5461 * for example. Hence, some of the returned sequences contains nested sequences, and an item
5462 * of a nested sequence corresponds to a type of spatial discretization.<br>
5463 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
5464 * The overhead is due to selecting values into new instances of DataArrayDouble.
5465 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
5466 * for the case with only one underlying mesh. (Actually, the number of meshes is
5467 * not checked if \a mname == \c NULL).
5468 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
5469 * a field part is returned.
5470 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
5471 * A field part can include sub-parts with several different spatial discretizations,
5472 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
5473 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
5474 * This sequence is of the same length as \a types.
5475 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
5476 * discretization. A profile name can be empty.
5477 * Length of this and of nested sequences is the same as that of \a typesF.
5478 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
5479 * discretization. A localization name can be empty.
5480 * Length of this and of nested sequences is the same as that of \a typesF.
5481 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
5482 * per each type of spatial discretization within one mesh entity type.
5483 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
5484 * Length of this and of nested sequences is the same as that of \a typesF.
5485 * \throw If no field is lying on \a mname.
5487 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
5491 meshId=getMeshIdFromMeshName(mname);
5493 if(_field_per_mesh.empty())
5494 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
5495 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[meshId]->getFieldSplitedByType(types,typesF,pfls,locs);
5496 int nbOfRet=ret0.size();
5497 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
5498 for(int i=0;i<nbOfRet;i++)
5500 const std::vector< std::pair<int,int> >& p=ret0[i];
5501 int nbOfRet1=p.size();
5502 ret[i].resize(nbOfRet1);
5503 for(int j=0;j<nbOfRet1;j++)
5505 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
5512 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
5517 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
5519 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
5520 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5521 ret->deepCpyLeavesFrom(*this);
5522 const DataArrayDouble *arr(_arr);
5525 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
5526 ret->setArray(arr2);
5532 * Returns a pointer to the underground DataArrayDouble instance and a
5533 * sequence describing parameters of a support of each part of \a this field. The
5534 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5535 * direct access to the field values. This method is intended for the field lying on one
5537 * \param [in,out] entries - the sequence describing parameters of a support of each
5538 * part of \a this field. Each item of this sequence consists of two parts. The
5539 * first part describes a type of mesh entity and an id of discretization of a
5540 * current field part. The second part describes a range of values [begin,end)
5541 * within the returned array relating to the current field part.
5542 * \return DataArrayDouble * - the pointer to the field values array.
5543 * \throw If the number of underlying meshes is not equal to 1.
5544 * \throw If no field values are available.
5545 * \sa getUndergroundDataArray()
5547 DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5549 if(_field_per_mesh.size()!=1)
5550 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5551 if(_field_per_mesh[0]==0)
5552 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5553 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5554 return getUndergroundDataArrayTemplate();
5558 * Returns a pointer to the underground DataArrayDouble instance and a
5559 * sequence describing parameters of a support of each part of \a this field. The
5560 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
5561 * direct access to the field values. This method is intended for the field lying on one
5563 * \param [in,out] entries - the sequence describing parameters of a support of each
5564 * part of \a this field. Each item of this sequence consists of two parts. The
5565 * first part describes a type of mesh entity and an id of discretization of a
5566 * current field part. The second part describes a range of values [begin,end)
5567 * within the returned array relating to the current field part.
5568 * \return DataArrayDouble * - the pointer to the field values array.
5569 * \throw If the number of underlying meshes is not equal to 1.
5570 * \throw If no field values are available.
5571 * \sa getUndergroundDataArray()
5573 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5575 return getUndergroundDataArrayDoubleExt(entries);
5578 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
5580 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
5581 arr->setInfoAndChangeNbOfCompo(infos);
5584 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
5588 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
5590 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
5591 ret->deepCpyLeavesFrom(*this);
5595 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
5597 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
5598 if(_arr.isNotNull())
5599 ret->_arr=_arr->deepCopy();
5603 //= MEDFileIntField1TSWithoutSDA
5605 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
5607 return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
5610 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
5614 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
5615 const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
5617 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
5618 arr->setInfoAndChangeNbOfCompo(infos);
5621 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
5626 MEDFileField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::convertToDouble() const
5628 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA);
5629 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
5630 ret->deepCpyLeavesFrom(*this);
5631 const DataArrayInt *arr(_arr);
5634 MCAuto<DataArrayDouble> arr2(arr->convertToDblArr());
5635 ret->setArray(arr2);
5641 * Returns a pointer to the underground DataArrayInt instance and a
5642 * sequence describing parameters of a support of each part of \a this field. The
5643 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5644 * direct access to the field values. This method is intended for the field lying on one
5646 * \param [in,out] entries - the sequence describing parameters of a support of each
5647 * part of \a this field. Each item of this sequence consists of two parts. The
5648 * first part describes a type of mesh entity and an id of discretization of a
5649 * current field part. The second part describes a range of values [begin,end)
5650 * within the returned array relating to the current field part.
5651 * \return DataArrayInt * - the pointer to the field values array.
5652 * \throw If the number of underlying meshes is not equal to 1.
5653 * \throw If no field values are available.
5654 * \sa getUndergroundDataArray()
5656 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5658 return getUndergroundDataArrayIntExt(entries);
5662 * Returns a pointer to the underground DataArrayInt instance and a
5663 * sequence describing parameters of a support of each part of \a this field. The
5664 * caller should not decrRef() the returned DataArrayInt. This method allows for a
5665 * direct access to the field values. This method is intended for the field lying on one
5667 * \param [in,out] entries - the sequence describing parameters of a support of each
5668 * part of \a this field. Each item of this sequence consists of two parts. The
5669 * first part describes a type of mesh entity and an id of discretization of a
5670 * current field part. The second part describes a range of values [begin,end)
5671 * within the returned array relating to the current field part.
5672 * \return DataArrayInt * - the pointer to the field values array.
5673 * \throw If the number of underlying meshes is not equal to 1.
5674 * \throw If no field values are available.
5675 * \sa getUndergroundDataArray()
5677 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
5679 if(_field_per_mesh.size()!=1)
5680 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
5681 if(_field_per_mesh[0]==0)
5682 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
5683 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
5684 return getUndergroundDataArrayTemplate();
5687 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
5689 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
5690 ret->deepCpyLeavesFrom(*this);
5694 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
5696 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
5697 if(_arr.isNotNull())
5698 ret->_arr=_arr->deepCopy();
5702 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
5706 //= MEDFileAnyTypeField1TS
5708 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5710 med_field_type typcha;
5712 std::vector<std::string> infos;
5713 std::string dtunit,fieldName;
5714 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
5715 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5720 ret=MEDFileField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5725 ret=MEDFileIntField1TSWithoutSDA::New(fieldName.c_str(),-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5730 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
5731 throw INTERP_KERNEL::Exception(oss.str());
5734 ret->setDtUnit(dtunit.c_str());
5735 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5737 med_int numdt,numit;
5739 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5740 ret->setTime(numdt,numit,dt);
5743 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5745 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5749 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
5750 try:MEDFileFieldGlobsReal(fid)
5752 _content=BuildContentFrom(fid,loadAll,ms);
5755 catch(INTERP_KERNEL::Exception& e)
5760 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5762 med_field_type typcha;
5763 std::vector<std::string> infos;
5766 int nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit);
5767 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5772 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5777 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
5782 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5783 throw INTERP_KERNEL::Exception(oss.str());
5786 ret->setDtUnit(dtunit.c_str());
5787 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5791 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
5792 throw INTERP_KERNEL::Exception(oss.str());
5795 med_int numdt,numit;
5797 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
5798 ret->setTime(numdt,numit,dt);
5801 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5803 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5807 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
5808 try:MEDFileFieldGlobsReal(fid)
5810 _content=BuildContentFrom(fid,fieldName,loadAll,ms);
5813 catch(INTERP_KERNEL::Exception& e)
5818 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
5821 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
5822 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
5824 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
5825 ret->_content=c; c->incrRef();
5828 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
5830 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
5831 ret->_content=c; c->incrRef();
5834 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
5837 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
5839 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
5840 ret->setFileName(FileNameFromFID(fid));
5844 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
5846 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5847 return New(fid,loadAll);
5850 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
5852 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
5853 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5854 ret->loadGlobals(fid);
5858 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
5860 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5861 return New(fid,fieldName,loadAll);
5864 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
5866 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0));
5867 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5868 ret->loadGlobals(fid);
5872 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
5874 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
5875 return New(fid,fieldName,iteration,order,loadAll);
5878 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
5880 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0));
5881 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
5882 ret->loadGlobals(fid);
5886 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5888 med_field_type typcha;
5889 std::vector<std::string> infos;
5892 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit));
5893 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
5898 ret=MEDFileField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5903 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,-1,iteration,order,std::vector<std::string>());
5908 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::BuildContentFrom(fid,fieldName,iteration,order) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
5909 throw INTERP_KERNEL::Exception(oss.str());
5912 ret->setDtUnit(dtunit.c_str());
5913 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
5916 std::vector< std::pair<int,int> > dtits(nbOfStep2);
5917 for(int i=0;i<nbOfStep2 && !found;i++)
5919 med_int numdt,numit;
5921 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
5922 if(numdt==iteration && numit==order)
5928 dtits[i]=std::pair<int,int>(numdt,numit);
5932 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
5933 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
5934 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
5935 throw INTERP_KERNEL::Exception(oss.str());
5938 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5940 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,0);
5944 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
5945 try:MEDFileFieldGlobsReal(fid)
5947 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms);
5950 catch(INTERP_KERNEL::Exception& e)
5956 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
5957 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
5959 * \warning this is a shallow copy constructor
5961 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
5963 if(!shallowCopyOfContent)
5965 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
5966 otherPtr->incrRef();
5967 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
5971 _content=other.shallowCpy();
5975 int MEDFileAnyTypeField1TS::LocateField2(med_idt fid, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
5979 int nbFields=MEDnField(fid);
5980 if(fieldIdCFormat>=nbFields)
5982 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
5983 throw INTERP_KERNEL::Exception(oss.str());
5986 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
5987 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5988 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE);
5989 INTERP_KERNEL::AutoPtr<char> dtunit=MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE);
5990 INTERP_KERNEL::AutoPtr<char> nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5991 INTERP_KERNEL::AutoPtr<char> nomMaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
5994 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
5995 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
5996 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
5997 infos.clear(); infos.resize(ncomp);
5998 for(int j=0;j<ncomp;j++)
5999 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
6004 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
6007 * \return in case of success the number of time steps available for the field with name \a fieldName.
6009 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut)
6011 int nbFields=MEDnField(fid);
6013 std::vector<std::string> fns(nbFields);
6015 for(int i=0;i<nbFields && !found;i++)
6018 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut);
6020 found=(tmp==fieldName);
6026 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
6027 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
6028 oss << "\"" << *it << "\" ";
6029 throw INTERP_KERNEL::Exception(oss.str());
6035 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6036 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6037 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6038 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6039 * to keep a valid instance.
6040 * 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.
6041 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
6042 * 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.
6044 * \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.
6045 * \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.
6046 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6047 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6048 * \param [in] newLocName is the new localization name.
6049 * \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.
6050 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
6052 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
6054 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6055 std::string oldPflName=disc->getProfile();
6056 std::vector<std::string> vv=getPflsReallyUsedMulti();
6057 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
6058 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
6060 disc->setProfile(newPflName);
6061 DataArrayInt *pfl=getProfile(oldPflName.c_str());
6062 pfl->setName(newPflName);
6066 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
6067 throw INTERP_KERNEL::Exception(oss.str());
6072 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
6073 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
6074 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
6075 * It is the responsability of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
6076 * to keep a valid instance.
6077 * 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.
6078 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
6079 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
6080 * 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.
6082 * \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.
6083 * \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.
6084 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
6085 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
6086 * \param [in] newLocName is the new localization name.
6087 * \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.
6088 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
6090 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
6092 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6093 std::string oldLocName=disc->getLocalization();
6094 std::vector<std::string> vv=getLocsReallyUsedMulti();
6095 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
6096 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
6098 disc->setLocalization(newLocName);
6099 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
6100 loc.setName(newLocName);
6104 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
6105 throw INTERP_KERNEL::Exception(oss.str());
6109 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
6111 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6113 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
6117 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
6119 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
6121 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
6126 * This method alloc the arrays and load potentially huge arrays contained in this field.
6127 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
6128 * This method can be also called to refresh or reinit values from a file.
6130 * \throw If the fileName is not set or points to a non readable MED file.
6131 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6133 void MEDFileAnyTypeField1TS::loadArrays()
6135 if(getFileName().empty())
6136 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
6137 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6138 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
6142 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
6143 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
6144 * this method does not throw if \a this does not come from file read.
6146 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
6148 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
6150 if(!getFileName().empty())
6152 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
6153 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
6158 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
6159 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
6160 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
6162 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
6164 void MEDFileAnyTypeField1TS::unloadArrays()
6166 contentNotNullBase()->unloadArrays();
6170 * 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.
6171 * This method is the symetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
6172 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
6174 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
6176 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
6178 if(!getFileName().empty())
6179 contentNotNullBase()->unloadArrays();
6182 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
6184 int nbComp(getNumberOfComponents());
6185 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6186 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
6187 for(int i=0;i<nbComp;i++)
6189 std::string info=getInfo()[i];
6191 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
6192 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
6193 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
6195 if(getName().empty())
6196 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
6197 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
6198 writeGlobals(fid,*this);
6199 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
6202 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
6204 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
6207 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
6209 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
6210 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
6215 * Returns a string describing \a this field. This string is outputted
6216 * by \c print Python command.
6218 std::string MEDFileAnyTypeField1TS::simpleRepr() const
6220 std::ostringstream oss;
6221 contentNotNullBase()->simpleRepr(0,oss,-1);
6222 simpleReprGlobs(oss);
6227 * This method returns all profiles whose name is non empty used.
6228 * \b WARNING If profile is used several times it will be reported \b only \b once.
6229 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
6231 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
6233 return contentNotNullBase()->getPflsReallyUsed2();
6237 * This method returns all localizations whose name is non empty used.
6238 * \b WARNING If localization is used several times it will be reported \b only \b once.
6240 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
6242 return contentNotNullBase()->getLocsReallyUsed2();
6246 * This method returns all profiles whose name is non empty used.
6247 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
6249 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
6251 return contentNotNullBase()->getPflsReallyUsedMulti2();
6255 * This method returns all localizations whose name is non empty used.
6256 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
6258 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
6260 return contentNotNullBase()->getLocsReallyUsedMulti2();
6263 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6265 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
6268 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
6270 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
6273 int MEDFileAnyTypeField1TS::getDimension() const
6275 return contentNotNullBase()->getDimension();
6278 int MEDFileAnyTypeField1TS::getIteration() const
6280 return contentNotNullBase()->getIteration();
6283 int MEDFileAnyTypeField1TS::getOrder() const
6285 return contentNotNullBase()->getOrder();
6288 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
6290 return contentNotNullBase()->getTime(iteration,order);
6293 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
6295 contentNotNullBase()->setTime(iteration,order,val);
6298 std::string MEDFileAnyTypeField1TS::getName() const
6300 return contentNotNullBase()->getName();
6303 void MEDFileAnyTypeField1TS::setName(const std::string& name)
6305 contentNotNullBase()->setName(name);
6308 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
6310 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
6313 std::string MEDFileAnyTypeField1TS::getDtUnit() const
6315 return contentNotNullBase()->getDtUnit();
6318 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
6320 contentNotNullBase()->setDtUnit(dtUnit);
6323 std::string MEDFileAnyTypeField1TS::getMeshName() const
6325 return contentNotNullBase()->getMeshName();
6328 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
6330 contentNotNullBase()->setMeshName(newMeshName);
6333 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
6335 return contentNotNullBase()->changeMeshNames(modifTab);
6338 int MEDFileAnyTypeField1TS::getMeshIteration() const
6340 return contentNotNullBase()->getMeshIteration();
6343 int MEDFileAnyTypeField1TS::getMeshOrder() const
6345 return contentNotNullBase()->getMeshOrder();
6348 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
6350 return contentNotNullBase()->getNumberOfComponents();
6353 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
6355 return contentNotNullBase()->isDealingTS(iteration,order);
6358 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
6360 return contentNotNullBase()->getDtIt();
6363 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
6365 contentNotNullBase()->fillIteration(p);
6368 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
6370 contentNotNullBase()->fillTypesOfFieldAvailable(types);
6373 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
6375 contentNotNullBase()->setInfo(infos);
6378 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
6380 return contentNotNullBase()->getInfo();
6382 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
6384 return contentNotNullBase()->getInfo();
6387 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
6389 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
6392 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
6394 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6397 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
6399 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
6402 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
6404 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
6407 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
6409 return contentNotNullBase()->convertMedBallIntoClassic();
6412 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
6414 return contentNotNullBase()->getTypesOfFieldAvailable();
6417 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,
6418 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
6420 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
6424 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
6425 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
6426 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
6428 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
6430 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6432 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
6433 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
6434 std::size_t sz(contentsSplit.size());
6435 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6436 for(std::size_t i=0;i<sz;i++)
6438 ret[i]=shallowCpy();
6439 ret[i]->_content=contentsSplit[i];
6445 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
6446 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6448 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
6450 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6452 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
6453 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
6454 std::size_t sz(contentsSplit.size());
6455 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6456 for(std::size_t i=0;i<sz;i++)
6458 ret[i]=shallowCpy();
6459 ret[i]->_content=contentsSplit[i];
6465 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
6466 * The returned instances are shallowed copied of \a this except that for globals that are share with those contained in \a this.
6468 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
6470 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6472 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
6473 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
6474 std::size_t sz(contentsSplit.size());
6475 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
6476 for(std::size_t i=0;i<sz;i++)
6478 ret[i]=shallowCpy();
6479 ret[i]->_content=contentsSplit[i];
6484 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
6486 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
6487 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
6488 ret->_content=_content->deepCopy();
6489 ret->deepCpyGlobs(*this);
6493 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
6495 return contentNotNullBase()->copyTinyInfoFrom(field,arr);
6501 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6502 * the first field that has been read from a specified MED file.
6503 * \param [in] fileName - the name of the MED file to read.
6504 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6505 * is to delete this field using decrRef() as it is no more needed.
6506 * \throw If reading the file fails.
6508 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, bool loadAll)
6510 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6511 return New(fid,loadAll);
6514 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, bool loadAll)
6516 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,loadAll,0));
6517 ret->contentNotNull();
6522 * Returns a new instance of MEDFileField1TS holding data of the first time step of
6523 * a given field that has been read from a specified MED file.
6524 * \param [in] fileName - the name of the MED file to read.
6525 * \param [in] fieldName - the name of the field to read.
6526 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6527 * is to delete this field using decrRef() as it is no more needed.
6528 * \throw If reading the file fails.
6529 * \throw If there is no field named \a fieldName in the file.
6531 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
6533 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6534 return New(fid,fieldName,loadAll);
6537 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
6539 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,loadAll,0));
6540 ret->contentNotNull();
6545 * Returns a new instance of MEDFileField1TS holding data of a given time step of
6546 * a given field that has been read from a specified MED file.
6547 * \param [in] fileName - the name of the MED file to read.
6548 * \param [in] fieldName - the name of the field to read.
6549 * \param [in] iteration - the iteration number of a required time step.
6550 * \param [in] order - the iteration order number of required time step.
6551 * \return MEDFileField1TS * - a new instance of MEDFileFieldMultiTS. The caller
6552 * is to delete this field using decrRef() as it is no more needed.
6553 * \throw If reading the file fails.
6554 * \throw If there is no field named \a fieldName in the file.
6555 * \throw If the required time step is missing from the file.
6557 MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
6559 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
6560 return New(fid,fieldName,iteration,order,loadAll);
6563 MEDFileField1TS *MEDFileField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
6565 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(fid,fieldName,iteration,order,loadAll,0));
6566 ret->contentNotNull();
6571 * Returns a new instance of MEDFileField1TS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6572 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6574 * Returns a new instance of MEDFileField1TS holding either a shallow copy
6575 * of a given MEDFileField1TSWithoutSDA ( \a other ) or \a other itself.
6576 * \warning this is a shallow copy constructor
6577 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
6578 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
6579 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6580 * is to delete this field using decrRef() as it is no more needed.
6582 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6584 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
6585 ret->contentNotNull();
6590 * Returns a new empty instance of MEDFileField1TS.
6591 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller
6592 * is to delete this field using decrRef() as it is no more needed.
6594 MEDFileField1TS *MEDFileField1TS::New()
6596 MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
6597 ret->contentNotNull();
6602 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
6603 * following the given input policy.
6605 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
6606 * By default (true) the globals are deeply copied.
6607 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
6609 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
6611 MCAuto<MEDFileIntField1TS> ret;
6612 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
6615 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
6617 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
6618 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
6619 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
6622 ret=MEDFileIntField1TS::New();
6624 ret->deepCpyGlobs(*this);
6626 ret->shallowCpyGlobs(*this);
6630 const MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull() const
6632 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6634 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the content pointer is null !");
6635 const MEDFileField1TSWithoutSDA *ret=dynamic_cast<const MEDFileField1TSWithoutSDA *>(pt);
6637 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 !");
6641 MEDFileField1TSWithoutSDA *MEDFileField1TS::contentNotNull()
6643 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
6645 throw INTERP_KERNEL::Exception("MEDFileField1TS::contentNotNull : the non const content pointer is null !");
6646 MEDFileField1TSWithoutSDA *ret=dynamic_cast<MEDFileField1TSWithoutSDA *>(pt);
6648 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 !");
6652 void MEDFileField1TS::SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
6655 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : input field is NULL !");
6657 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : no array !");
6658 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6660 throw INTERP_KERNEL::Exception("MEDFileField1TS::SetDataArrayDoubleInField : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6661 f->setArray(arrOutC);
6664 DataArrayDouble *MEDFileField1TS::ReturnSafelyDataArrayDouble(MCAuto<DataArray>& arr)
6667 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : no array !");
6668 DataArrayDouble *arrOutC(dynamic_cast<DataArrayDouble *>((DataArray*)arr));
6670 throw INTERP_KERNEL::Exception("MEDFileField1TS::ReturnSafelyDataArrayDouble : mismatch between dataArrays type and MEDFileField1TS ! Expected double !");
6676 * Return an extraction of \a this using \a extractDef map to specify the extraction.
6677 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
6679 * \return A new object that the caller is responsible to deallocate.
6680 * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart , MEDFileUMesh::extractPart
6682 MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
6685 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : input mesh is NULL !");
6686 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
6687 std::vector<TypeOfField> tof(getTypesOfFieldAvailable());
6688 for(std::vector<TypeOfField>::const_iterator it0=tof.begin();it0!=tof.end();it0++)
6690 if((*it0)!=ON_NODES)
6692 std::vector<int> levs;
6693 getNonEmptyLevels(mm->getName(),levs);
6694 for(std::vector<int>::const_iterator lev=levs.begin();lev!=levs.end();lev++)
6696 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(*lev));
6697 if(it2!=extractDef.end())
6699 MCAuto<DataArrayInt> t((*it2).second);
6701 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6702 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_CELLS,(*lev),mm));
6703 MCAuto<MEDCouplingFieldDouble> fOut(f->buildSubPart(t));
6704 ret->setFieldNoProfileSBT(fOut);
6710 std::map<int, MCAuto<DataArrayInt> >::const_iterator it2(extractDef.find(1));
6711 if(it2==extractDef.end())
6712 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a NODE field and no extract array available for NODE !");
6713 MCAuto<DataArrayInt> t((*it2).second);
6715 throw INTERP_KERNEL::Exception("MEDFileField1TS::extractPart : presence of a value with null pointer 1 !");
6716 MCAuto<MEDCouplingFieldDouble> f(getFieldOnMeshAtLevel(ON_NODES,0,mm));
6717 MCAuto<MEDCouplingFieldDouble> fOut(f->deepCopy());
6718 DataArrayDouble *arr(f->getArray());
6719 MCAuto<DataArrayDouble> newArr(arr->selectByTupleIdSafe(t->begin(),t->end()));
6720 fOut->setArray(newArr);
6721 ret->setFieldNoProfileSBT(fOut);
6727 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
6728 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
6731 catch(INTERP_KERNEL::Exception& e)
6734 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
6735 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
6738 catch(INTERP_KERNEL::Exception& e)
6741 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
6742 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
6745 catch(INTERP_KERNEL::Exception& e)
6749 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
6750 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
6752 * \warning this is a shallow copy constructor
6754 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
6755 try:MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
6758 catch(INTERP_KERNEL::Exception& e)
6761 MEDFileField1TS::MEDFileField1TS()
6763 _content=new MEDFileField1TSWithoutSDA;
6767 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
6768 * method should be called (getFieldOnMeshAtLevel for example).
6769 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
6771 * \param [in] mesh - the mesh the field is lying on
6772 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6773 * caller is to delete this field using decrRef() as it is no more needed.
6775 MEDCouplingFieldDouble *MEDFileField1TS::field(const MEDFileMesh *mesh) const
6777 MCAuto<DataArray> arrOut;
6778 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
6779 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6784 * Returns a new MEDCouplingFieldDouble of a given type lying on
6785 * mesh entities of a given dimension of the first mesh in MED file. If \a this field
6786 * has not been constructed via file reading, an exception is thrown.
6787 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6788 * \param [in] type - a spatial discretization of interest.
6789 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6790 * \param [in] renumPol - specifies how to permute values of the result field according to
6791 * the optional numbers of cells and nodes, if any. The valid values are
6792 * - 0 - do not permute.
6793 * - 1 - permute cells.
6794 * - 2 - permute nodes.
6795 * - 3 - permute cells and nodes.
6797 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6798 * caller is to delete this field using decrRef() as it is no more needed.
6799 * \throw If \a this field has not been constructed via file reading.
6800 * \throw If the MED file is not readable.
6801 * \throw If there is no mesh in the MED file.
6802 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6803 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6804 * \sa getFieldOnMeshAtLevel()
6806 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
6808 if(getFileName().empty())
6809 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6810 MCAuto<DataArray> arrOut;
6811 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
6812 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6817 * Returns a new MEDCouplingFieldDouble of a given type lying on
6818 * the top level cells of the first mesh in MED file. If \a this field
6819 * has not been constructed via file reading, an exception is thrown.
6820 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6821 * \param [in] type - a spatial discretization of interest.
6822 * \param [in] renumPol - specifies how to permute values of the result field according to
6823 * the optional numbers of cells and nodes, if any. The valid values are
6824 * - 0 - do not permute.
6825 * - 1 - permute cells.
6826 * - 2 - permute nodes.
6827 * - 3 - permute cells and nodes.
6829 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6830 * caller is to delete this field using decrRef() as it is no more needed.
6831 * \throw If \a this field has not been constructed via file reading.
6832 * \throw If the MED file is not readable.
6833 * \throw If there is no mesh in the MED file.
6834 * \throw If no field values of the given \a type.
6835 * \throw If no field values lying on the top level support.
6836 * \sa getFieldAtLevel()
6838 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
6840 if(getFileName().empty())
6841 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
6842 MCAuto<DataArray> arrOut;
6843 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
6844 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6849 * Returns a new MEDCouplingFieldDouble of given type lying on a given mesh.
6850 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6851 * \param [in] type - a spatial discretization of the new field.
6852 * \param [in] mesh - the supporting mesh.
6853 * \param [in] renumPol - specifies how to permute values of the result field according to
6854 * the optional numbers of cells and nodes, if any. The valid values are
6855 * - 0 - do not permute.
6856 * - 1 - permute cells.
6857 * - 2 - permute nodes.
6858 * - 3 - permute cells and nodes.
6860 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6861 * caller is to delete this field using decrRef() as it is no more needed.
6862 * \throw If no field of \a this is lying on \a mesh.
6863 * \throw If the mesh is empty.
6864 * \throw If no field values of the given \a type are available.
6865 * \sa getFieldAtLevel()
6866 * \sa getFieldOnMeshAtLevel()
6868 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
6870 MCAuto<DataArray> arrOut;
6871 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
6872 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6877 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6878 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6879 * \param [in] type - a spatial discretization of interest.
6880 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6881 * \param [in] mesh - the supporting mesh.
6882 * \param [in] renumPol - specifies how to permute values of the result field according to
6883 * the optional numbers of cells and nodes, if any. The valid values are
6884 * - 0 - do not permute.
6885 * - 1 - permute cells.
6886 * - 2 - permute nodes.
6887 * - 3 - permute cells and nodes.
6889 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6890 * caller is to delete this field using decrRef() as it is no more needed.
6891 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6892 * \throw If no field of \a this is lying on \a mesh.
6893 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6894 * \sa getFieldAtLevel()
6895 * \sa getFieldOnMeshAtLevel()
6897 MEDCouplingFieldDouble *MEDFileField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
6899 MCAuto<DataArray> arrOut;
6900 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
6901 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6906 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
6907 * This method is called "Old" because in MED3 norm a field has only one meshName
6908 * attached, so this method is for readers of MED2 files. If \a this field
6909 * has not been constructed via file reading, an exception is thrown.
6910 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6911 * \param [in] type - a spatial discretization of interest.
6912 * \param [in] mName - a name of the supporting mesh.
6913 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6914 * \param [in] renumPol - specifies how to permute values of the result field according to
6915 * the optional numbers of cells and nodes, if any. The valid values are
6916 * - 0 - do not permute.
6917 * - 1 - permute cells.
6918 * - 2 - permute nodes.
6919 * - 3 - permute cells and nodes.
6921 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
6922 * caller is to delete this field using decrRef() as it is no more needed.
6923 * \throw If the MED file is not readable.
6924 * \throw If there is no mesh named \a mName in the MED file.
6925 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
6926 * \throw If \a this field has not been constructed via file reading.
6927 * \throw If no field of \a this is lying on the mesh named \a mName.
6928 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6929 * \sa getFieldAtLevel()
6931 MEDCouplingFieldDouble *MEDFileField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
6933 if(getFileName().empty())
6934 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
6935 MCAuto<DataArray> arrOut;
6936 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull()));
6937 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
6942 * Returns values and a profile of the field of a given type lying on a given support.
6943 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6944 * \param [in] type - a spatial discretization of the field.
6945 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
6946 * \param [in] mesh - the supporting mesh.
6947 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
6948 * field of interest lies on. If the field lies on all entities of the given
6949 * dimension, all ids in \a pfl are zero. The caller is to delete this array
6950 * using decrRef() as it is no more needed.
6951 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
6952 * field. The caller is to delete this array using decrRef() as it is no more needed.
6953 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6954 * \throw If no field of \a this is lying on \a mesh.
6955 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
6957 DataArrayDouble *MEDFileField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
6959 MCAuto<DataArray> ret=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
6960 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
6964 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
6965 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
6966 * "Sort By Type"), if not, an exception is thrown.
6967 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6968 * \param [in] field - the field to add to \a this.
6969 * \throw If the name of \a field is empty.
6970 * \throw If the data array of \a field is not set.
6971 * \throw If the data array is already allocated but has different number of components
6973 * \throw If the underlying mesh of \a field has no name.
6974 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
6976 void MEDFileField1TS::setFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
6979 contentNotNull()->setFieldNoProfileSBT(field,field->getArray(),*this,*contentNotNull());
6983 * Adds a MEDCouplingFieldDouble to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
6984 * can be an aggregation of several MEDCouplingFieldDouble instances.
6985 * The mesh support of input parameter \a field is ignored here, it can be NULL.
6986 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
6989 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
6990 * A new profile is added only if no equal profile is missing.
6991 * For more info, see \ref AdvMEDLoaderAPIFieldRW
6992 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
6993 * \param [in] mesh - the supporting mesh of \a field.
6994 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
6995 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
6996 * \throw If either \a field or \a mesh or \a profile has an empty name.
6997 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
6998 * \throw If the data array of \a field is not set.
6999 * \throw If the data array of \a this is already allocated but has different number of
7000 * components than \a field.
7001 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7002 * \sa setFieldNoProfileSBT()
7004 void MEDFileField1TS::setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7007 contentNotNull()->setFieldProfile(field,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7010 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
7012 return new MEDFileField1TS(*this);
7015 DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
7017 return contentNotNull()->getUndergroundDataArrayTemplate();
7020 DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7022 return contentNotNull()->getUndergroundDataArrayDoubleExt(entries);
7025 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
7026 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
7028 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
7031 //= MEDFileIntField1TS
7033 MEDFileIntField1TS *MEDFileIntField1TS::New()
7035 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS);
7036 ret->contentNotNull();
7040 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, bool loadAll)
7042 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7043 return MEDFileIntField1TS::New(fid,loadAll);
7046 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, bool loadAll)
7048 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,loadAll,0));
7049 ret->contentNotNull();
7053 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
7055 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7056 return MEDFileIntField1TS::New(fid,fieldName,loadAll);
7059 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
7061 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,loadAll,0));
7062 ret->contentNotNull();
7066 MEDFileIntField1TS *MEDFileIntField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
7068 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
7069 return MEDFileIntField1TS::New(fid,fieldName,iteration,order,loadAll);
7072 MEDFileIntField1TS *MEDFileIntField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
7074 MCAuto<MEDFileIntField1TS> ret(new MEDFileIntField1TS(fid,fieldName,iteration,order,loadAll,0));
7075 ret->contentNotNull();
7079 MEDFileIntField1TS *MEDFileIntField1TS::New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent)
7081 MCAuto<MEDFileIntField1TS> ret=new MEDFileIntField1TS(other,shallowCopyOfContent);
7082 ret->contentNotNull();
7086 MEDFileIntField1TS::MEDFileIntField1TS()
7088 _content=new MEDFileIntField1TSWithoutSDA;
7091 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
7092 try:MEDFileAnyTypeField1TS(fid,loadAll,ms)
7095 catch(INTERP_KERNEL::Exception& e)
7098 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
7099 try:MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms)
7102 catch(INTERP_KERNEL::Exception& e)
7105 MEDFileIntField1TS::MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
7106 try:MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms)
7109 catch(INTERP_KERNEL::Exception& e)
7113 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
7114 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
7116 * \warning this is a shallow copy constructor
7118 MEDFileIntField1TS::MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent)
7122 MEDFileIntField1TS *MEDFileIntField1TS::shallowCpy() const
7124 return new MEDFileIntField1TS(*this);
7128 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
7129 * following the given input policy.
7131 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
7132 * By default (true) the globals are deeply copied.
7133 * \return MEDFileField1TS * - a new object that is the result of the conversion of \a this to float64 field.
7135 MEDFileField1TS *MEDFileIntField1TS::convertToDouble(bool isDeepCpyGlobs) const
7137 MCAuto<MEDFileField1TS> ret;
7138 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
7141 const MEDFileIntField1TSWithoutSDA *contc=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(content);
7143 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
7144 MCAuto<MEDFileField1TSWithoutSDA> newc(contc->convertToDouble());
7145 ret=static_cast<MEDFileField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileField1TSWithoutSDA *)newc));
7148 ret=MEDFileField1TS::New();
7150 ret->deepCpyGlobs(*this);
7152 ret->shallowCpyGlobs(*this);
7157 * Adds a MEDCouplingFieldInt to \a this. The underlying mesh of the given field is
7158 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
7159 * "Sort By Type"), if not, an exception is thrown.
7160 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7161 * \param [in] field - the field to add to \a this.
7162 * \throw If the name of \a field is empty.
7163 * \throw If the data array of \a field is not set.
7164 * \throw If the data array is already allocated but has different number of components
7166 * \throw If the underlying mesh of \a field has no name.
7167 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
7169 void MEDFileIntField1TS::setFieldNoProfileSBT(const MEDCouplingFieldInt *field)
7171 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7173 contentNotNull()->setFieldNoProfileSBT(field2,field->getArray(),*this,*contentNotNull());
7177 * Adds a MEDCouplingFieldInt to \a this. As described in \ref MEDLoaderMainC a field in MED file sense
7178 * can be an aggregation of several MEDCouplingFieldDouble instances.
7179 * The mesh support of input parameter \a field is ignored here, it can be NULL.
7180 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
7183 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
7184 * A new profile is added only if no equal profile is missing.
7185 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7186 * \param [in] field - the field to add to \a this.
7187 * \param [in] mesh - the supporting mesh of \a field.
7188 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
7189 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
7190 * \throw If either \a field or \a mesh or \a profile has an empty name.
7191 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7192 * \throw If the data array of \a field is not set.
7193 * \throw If the data array of \a this is already allocated but has different number of
7194 * components than \a field.
7195 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
7196 * \sa setFieldNoProfileSBT()
7198 void MEDFileIntField1TS::setFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
7200 MCAuto<MEDCouplingFieldDouble> field2(ConvertFieldIntToFieldDouble(field));
7202 contentNotNull()->setFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this,*contentNotNull());
7205 const MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull() const
7207 const MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7209 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the content pointer is null !");
7210 const MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(pt);
7212 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 !");
7216 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol) const
7218 if(getFileName().empty())
7219 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7220 MCAuto<DataArray> arrOut;
7221 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNull()));
7222 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7226 DataArrayInt *MEDFileIntField1TS::ReturnSafelyDataArrayInt(MCAuto<DataArray>& arr)
7229 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is NULL !");
7230 DataArrayInt *arrC(dynamic_cast<DataArrayInt *>((DataArray *)arr));
7232 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ReturnSafelyDataArrayInt : input DataArray is not of type INT32 !");
7237 MCAuto<MEDCouplingFieldInt> MEDFileIntField1TS::SetDataArrayDoubleInIntField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr)
7240 double t0(f->getTime(t1,t2));
7241 MCAuto<DataArrayInt> arr2(DynamicCastSafe<DataArray,DataArrayInt>(arr));
7242 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7243 MCAuto<MEDCouplingFieldInt> ret(MEDCouplingFieldInt::New(*ft));
7244 ret->setTime(t0,t1,t2); ret->setArray(arr2);
7248 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
7251 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
7253 double t0(f->getTime(t1,t2));
7254 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
7255 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
7256 ret->setTime(t0,t1,t2);
7260 MEDFileIntField1TS *MEDFileIntField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
7262 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::extractPart : not implemented yet !");
7266 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
7267 * method should be called (getFieldOnMeshAtLevel for example).
7268 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
7270 * \param [in] mesh - the mesh the field is lying on
7271 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
7272 * caller is to delete this field using decrRef() as it is no more needed.
7274 MEDCouplingFieldInt *MEDFileIntField1TS::field(const MEDFileMesh *mesh) const
7276 MCAuto<DataArray> arrOut;
7277 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->fieldOnMesh(this,mesh,arrOut,*contentNotNull()));
7278 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7283 * Returns a new MEDCouplingFieldInt of a given type lying on
7284 * the top level cells of the first mesh in MED file. If \a this field
7285 * has not been constructed via file reading, an exception is thrown.
7286 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7287 * \param [in] type - a spatial discretization of interest.
7288 * \param [in] renumPol - specifies how to permute values of the result field according to
7289 * the optional numbers of cells and nodes, if any. The valid values are
7290 * - 0 - do not permute.
7291 * - 1 - permute cells.
7292 * - 2 - permute nodes.
7293 * - 3 - permute cells and nodes.
7295 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7296 * caller is to delete this field using decrRef() as it is no more needed.
7297 * \throw If \a this field has not been constructed via file reading.
7298 * \throw If the MED file is not readable.
7299 * \throw If there is no mesh in the MED file.
7300 * \throw If no field values of the given \a type.
7301 * \throw If no field values lying on the top level support.
7302 * \sa getFieldAtLevel()
7304 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtTopLevel(TypeOfField type, int renumPol) const
7306 if(getFileName().empty())
7307 throw INTERP_KERNEL::Exception("MEDFileField1TS::getFieldAtTopLevel : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtTopLevel method instead !");
7308 MCAuto<DataArray> arrOut;
7309 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNull()));
7310 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7315 * Returns a new MEDCouplingFieldInt of given type lying on a given mesh.
7316 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7317 * \param [in] type - a spatial discretization of the new field.
7318 * \param [in] mesh - the supporting mesh.
7319 * \param [in] renumPol - specifies how to permute values of the result field according to
7320 * the optional numbers of cells and nodes, if any. The valid values are
7321 * - 0 - do not permute.
7322 * - 1 - permute cells.
7323 * - 2 - permute nodes.
7324 * - 3 - permute cells and nodes.
7326 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7327 * caller is to delete this field using decrRef() as it is no more needed.
7328 * \throw If no field of \a this is lying on \a mesh.
7329 * \throw If the mesh is empty.
7330 * \throw If no field values of the given \a type are available.
7331 * \sa getFieldAtLevel()
7332 * \sa getFieldOnMeshAtLevel()
7334 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol) const
7336 MCAuto<DataArray> arrOut;
7337 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNull()));
7338 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7343 * Returns a new MEDCouplingFieldInt of a given type lying on a given support.
7344 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7345 * \param [in] type - a spatial discretization of interest.
7346 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7347 * \param [in] mesh - the supporting mesh.
7348 * \param [in] renumPol - specifies how to permute values of the result field according to
7349 * the optional numbers of cells and nodes, if any. The valid values are
7350 * - 0 - do not permute.
7351 * - 1 - permute cells.
7352 * - 2 - permute nodes.
7353 * - 3 - permute cells and nodes.
7355 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7356 * caller is to delete this field using decrRef() as it is no more needed.
7357 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7358 * \throw If no field of \a this is lying on \a mesh.
7359 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7360 * \sa getFieldAtLevel()
7361 * \sa getFieldOnMeshAtLevel()
7363 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
7365 MCAuto<DataArray> arrOut;
7366 MCAuto<MEDCouplingFieldDouble> ret(contentNotNull()->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNull()));
7367 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7372 * Returns a new MEDCouplingFieldDouble of a given type lying on a given support.
7373 * This method is called "Old" because in MED3 norm a field has only one meshName
7374 * attached, so this method is for readers of MED2 files. If \a this field
7375 * has not been constructed via file reading, an exception is thrown.
7376 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7377 * \param [in] type - a spatial discretization of interest.
7378 * \param [in] mName - a name of the supporting mesh.
7379 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7380 * \param [in] renumPol - specifies how to permute values of the result field according to
7381 * the optional numbers of cells and nodes, if any. The valid values are
7382 * - 0 - do not permute.
7383 * - 1 - permute cells.
7384 * - 2 - permute nodes.
7385 * - 3 - permute cells and nodes.
7387 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
7388 * caller is to delete this field using decrRef() as it is no more needed.
7389 * \throw If the MED file is not readable.
7390 * \throw If there is no mesh named \a mName in the MED file.
7391 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
7392 * \throw If \a this field has not been constructed via file reading.
7393 * \throw If no field of \a this is lying on the mesh named \a mName.
7394 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7395 * \sa getFieldAtLevel()
7397 MEDCouplingFieldInt *MEDFileIntField1TS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol) const
7399 if(getFileName().empty())
7400 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::getFieldAtLevelOld : Request for a method that can be used for instances coming from file loading ! Use getFieldOnMeshAtLevel method instead !");
7401 MCAuto<DataArray> arrOut;
7402 MCAuto<MEDCouplingFieldDouble> ret=contentNotNull()->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNull());
7403 MCAuto<MEDCouplingFieldInt> ret2(SetDataArrayDoubleInIntField(ret,arrOut));
7408 * Returns values and a profile of the field of a given type lying on a given support.
7409 * For more info, see \ref AdvMEDLoaderAPIFieldRW
7410 * \param [in] type - a spatial discretization of the field.
7411 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
7412 * \param [in] mesh - the supporting mesh.
7413 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
7414 * field of interest lies on. If the field lies on all entities of the given
7415 * dimension, all ids in \a pfl are zero. The caller is to delete this array
7416 * using decrRef() as it is no more needed.
7417 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
7418 * field. The caller is to delete this array using decrRef() as it is no more needed.
7419 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
7420 * \throw If no field of \a this is lying on \a mesh.
7421 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
7423 DataArrayInt *MEDFileIntField1TS::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
7425 MCAuto<DataArray> arr=contentNotNull()->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNull());
7426 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(arr);
7429 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TS::contentNotNull()
7431 MEDFileAnyTypeField1TSWithoutSDA *pt(_content);
7433 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::contentNotNull : the non const content pointer is null !");
7434 MEDFileIntField1TSWithoutSDA *ret=dynamic_cast<MEDFileIntField1TSWithoutSDA *>(pt);
7436 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 !");
7440 DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
7442 return contentNotNull()->getUndergroundDataArrayTemplate();
7445 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
7447 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
7451 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileFieldNameScope(fieldName)
7456 * \param [in] fieldId field id in C mode
7458 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7460 med_field_type typcha;
7461 std::string dtunitOut;
7462 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,fieldId,false,_name,typcha,_infos,dtunitOut));
7463 setDtUnit(dtunitOut.c_str());
7464 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,typcha,loadAll,ms,entities);
7467 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 MEDFileEntities *entities)
7468 try:MEDFileFieldNameScope(fieldName),_infos(infos)
7470 setDtUnit(dtunit.c_str());
7471 loadStructureOrStructureAndBigArraysRecursively(fid,nbOfStep,fieldTyp,loadAll,ms,entities);
7473 catch(INTERP_KERNEL::Exception& e)
7478 std::size_t MEDFileAnyTypeFieldMultiTSWithoutSDA::getHeapMemorySizeWithoutChildren() const
7480 std::size_t ret(_name.capacity()+_infos.capacity()*sizeof(std::string)+_time_steps.capacity()*sizeof(MCAuto<MEDFileField1TSWithoutSDA>));
7481 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7482 ret+=(*it).capacity();
7486 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTSWithoutSDA::getDirectChildrenWithNull() const
7488 std::vector<const BigMemoryObject *> ret;
7489 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7490 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)*it);
7495 * 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
7498 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds(const int *startIds, const int *endIds) const
7500 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7501 ret->setInfo(_infos);
7502 int sz=(int)_time_steps.size();
7503 for(const int *id=startIds;id!=endIds;id++)
7505 if(*id>=0 && *id<sz)
7507 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[*id];
7508 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7512 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7514 ret->pushBackTimeStep(tse2);
7518 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << std::distance(startIds,id) << " value is " << *id;
7519 oss << " ! Should be in [0," << sz << ") !";
7520 throw INTERP_KERNEL::Exception(oss.str());
7523 if(ret->getNumberOfTS()>0)
7524 ret->synchronizeNameScope();
7525 ret->copyNameScope(*this);
7530 * 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
7533 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2(int bg, int end, int step) const
7535 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds2";
7536 int nbOfEntriesToKeep=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
7537 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=createNew();
7538 ret->setInfo(_infos);
7539 int sz=(int)_time_steps.size();
7541 for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
7545 const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
7546 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
7550 tse2=(const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(tse));
7552 ret->pushBackTimeStep(tse2);
7556 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::buildFromTimeStepIds : At pos #" << i << " value is " << j;
7557 oss << " ! Should be in [0," << sz << ") !";
7558 throw INTERP_KERNEL::Exception(oss.str());
7561 if(ret->getNumberOfTS()>0)
7562 ret->synchronizeNameScope();
7563 ret->copyNameScope(*this);
7567 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7570 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7571 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7573 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7576 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7577 if(std::find(timeSteps.begin(),timeSteps.end(),p)!=timeSteps.end())
7578 ids->pushBackSilent(id);
7580 return buildFromTimeStepIds(ids->begin(),ids->end());
7583 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
7586 MCAuto<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(0,1);
7587 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,id++)
7589 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7592 std::pair<int,int> p(cur->getIteration(),cur->getOrder());
7593 if(std::find(timeSteps.begin(),timeSteps.end(),p)==timeSteps.end())
7594 ids->pushBackSilent(id);
7596 return buildFromTimeStepIds(ids->begin(),ids->end());
7599 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfStructureElements() const
7601 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7602 if((*it).isNotNull())
7603 if((*it)->presenceOfStructureElements())
7608 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::onlyStructureElements() const
7610 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7611 if((*it).isNotNull())
7612 if(!(*it)->onlyStructureElements())
7617 void MEDFileAnyTypeFieldMultiTSWithoutSDA::killStructureElements()
7619 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7620 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7621 if((*it).isNotNull())
7623 if((*it)->presenceOfStructureElements())
7625 if(!(*it)->onlyStructureElements())
7627 (*it)->killStructureElements();
7639 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyStructureElements()
7641 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7642 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7643 if((*it).isNotNull())
7645 if((*it)->presenceOfStructureElements())
7647 if(!(*it)->onlyStructureElements())
7648 (*it)->keepOnlyStructureElements();
7655 void MEDFileAnyTypeFieldMultiTSWithoutSDA::keepOnlyOnSE(const std::string& seName)
7657 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret;
7658 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7659 if((*it).isNotNull())
7660 (*it)->keepOnlyOnSE(seName);
7663 void MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
7665 std::vector< std::pair<std::string,std::string> > ps2;
7666 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7667 if((*it).isNotNull())
7669 (*it)->getMeshSENames(ps2);
7673 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : this appears to not contain SE only !");
7674 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7675 if((*it).isNotNull())
7677 std::vector< std::pair<std::string,std::string> > ps3;
7678 (*it)->getMeshSENames(ps3);
7680 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshSENames : For the moment only homogeneous SE def through time managed !");
7682 for(std::vector< std::pair<std::string,std::string> >::const_iterator it=ps2.begin();it!=ps2.end();it++)
7684 std::vector< std::pair<std::string,std::string> >::iterator it2(std::find(ps.begin(),ps.end(),*it));
7690 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::presenceOfMultiDiscPerGeoType() const
7692 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7694 const MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7697 if(cur->presenceOfMultiDiscPerGeoType())
7703 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTSWithoutSDA::getInfo() const
7708 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setInfo(const std::vector<std::string>& info)
7713 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepPos(int iteration, int order) const
7716 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
7718 const MEDFileAnyTypeField1TSWithoutSDA *pt(*it);
7719 if(pt->isDealingTS(iteration,order))
7722 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepPos : Muli timestep field on time (" << iteration << "," << order << ") does not exist ! Available (iteration,order) are :\n";
7723 std::vector< std::pair<int,int> > vp=getIterations();
7724 for(std::vector< std::pair<int,int> >::const_iterator it2=vp.begin();it2!=vp.end();it2++)
7725 oss << "(" << (*it2).first << "," << (*it2).second << ") ";
7726 throw INTERP_KERNEL::Exception(oss.str());
7729 const MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order) const
7731 return *_time_steps[getTimeStepPos(iteration,order)];
7734 MEDFileAnyTypeField1TSWithoutSDA& MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepEntry(int iteration, int order)
7736 return *_time_steps[getTimeStepPos(iteration,order)];
7739 std::string MEDFileAnyTypeFieldMultiTSWithoutSDA::getMeshName() const
7741 if(_time_steps.empty())
7742 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getMeshName : not time steps !");
7743 return _time_steps[0]->getMeshName();
7746 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setMeshName(const std::string& newMeshName)
7748 std::string oldName(getMeshName());
7749 std::vector< std::pair<std::string,std::string> > v(1);
7750 v[0].first=oldName; v[0].second=newMeshName;
7754 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
7757 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7759 MEDFileAnyTypeField1TSWithoutSDA *cur(*it);
7761 ret=cur->changeMeshNames(modifTab) || ret;
7767 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArray
7769 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArray(int iteration, int order) const
7771 return getTimeStepEntry(iteration,order).getUndergroundDataArray();
7775 * See doc at MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt
7777 DataArray *MEDFileAnyTypeFieldMultiTSWithoutSDA::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
7779 return getTimeStepEntry(iteration,order).getUndergroundDataArrayExt(entries);
7782 bool MEDFileAnyTypeFieldMultiTSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
7783 MEDFileFieldGlobsReal& glob)
7786 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7788 MEDFileAnyTypeField1TSWithoutSDA *f1ts(*it);
7790 ret=f1ts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
7795 void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
7797 std::string startLine(bkOffset,' ');
7798 oss << startLine << "Field multi time steps [Type=" << getTypeStr() << "]";
7800 oss << " (" << fmtsId << ")";
7801 oss << " has the following name: \"" << _name << "\"." << std::endl;
7802 oss << startLine << "Field multi time steps has " << _infos.size() << " components with the following infos :" << std::endl;
7803 for(std::vector<std::string>::const_iterator it=_infos.begin();it!=_infos.end();it++)
7805 oss << startLine << " - \"" << *it << "\"" << std::endl;
7808 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
7810 std::string chapter(17,'0'+i);
7811 oss << startLine << chapter << std::endl;
7812 const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7814 cur->simpleRepr(bkOffset+2,oss,i);
7816 oss << startLine << " Field on one time step #" << i << " is not defined !" << std::endl;
7817 oss << startLine << chapter << std::endl;
7821 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeSteps(std::vector<double>& ret1) const
7823 std::size_t sz=_time_steps.size();
7824 std::vector< std::pair<int,int> > ret(sz);
7826 for(std::size_t i=0;i<sz;i++)
7828 const MEDFileAnyTypeField1TSWithoutSDA *f1ts=_time_steps[i];
7831 ret1[i]=f1ts->getTime(ret[i].first,ret[i].second);
7835 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getTimeSteps : At rank #" << i << " time step is not defined. Invoke eraseEmptyTS method !";
7836 throw INTERP_KERNEL::Exception(oss.str());
7842 void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTypeField1TSWithoutSDA>& tse)
7844 MEDFileAnyTypeField1TSWithoutSDA *tse2(tse);
7846 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input content object is null !");
7847 checkCoherencyOfType(tse2);
7848 if(_time_steps.empty())
7850 setName(tse2->getName().c_str());
7851 setInfo(tse2->getInfo());
7853 checkThatComponentsMatch(tse2->getInfo());
7854 if(getDtUnit().empty() && !tse->getDtUnit().empty())
7855 setDtUnit(tse->getDtUnit());
7856 _time_steps.push_back(tse);
7859 void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
7861 std::size_t nbOfCompo=_infos.size();
7862 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7864 MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
7867 if((cur->getInfo()).size()!=nbOfCompo)
7869 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope : Mismatch in the number of components of parts ! Should be " << nbOfCompo;
7870 oss << " ! but the field at iteration=" << cur->getIteration() << " order=" << cur->getOrder() << " has " << (cur->getInfo()).size() << " components !";
7871 throw INTERP_KERNEL::Exception(oss.str());
7873 cur->copyNameScope(*this);
7878 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
7880 _time_steps.resize(nbPdt);
7881 for(int i=0;i<nbPdt;i++)
7883 std::vector< std::pair<int,int> > ts;
7884 med_int numdt=0,numo=0;
7886 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,_name.c_str(),i+1,&numdt,&numo,&dt));
7891 _time_steps[i]=MEDFileField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7896 _time_steps[i]=MEDFileIntField1TSWithoutSDA::New(_name.c_str(),i+1,numdt,numo,_infos);
7900 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32 !");
7903 _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
7905 _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
7906 synchronizeNameScope();
7910 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
7912 if(_time_steps.empty())
7913 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::writeLL : no time steps set !");
7914 checkThatNbOfCompoOfTSMatchThis();
7915 std::vector<std::string> infos(getInfo());
7916 int nbComp=infos.size();
7917 INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7918 INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE);
7919 for(int i=0;i<nbComp;i++)
7921 std::string info=infos[i];
7923 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
7924 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7925 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,opts.getTooLongStrPolicy());
7928 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::write : MED file does not accept field with empty name !");
7929 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,_name.c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
7930 int nbOfTS=_time_steps.size();
7931 for(int i=0;i<nbOfTS;i++)
7932 _time_steps[i]->writeLL(fid,opts,*this);
7935 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
7937 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7939 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7941 elt->loadBigArraysRecursively(fid,nasc);
7945 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
7947 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7949 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7951 elt->loadBigArraysRecursivelyIfNecessary(fid,nasc);
7955 void MEDFileAnyTypeFieldMultiTSWithoutSDA::unloadArrays()
7957 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7959 MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
7961 elt->unloadArrays();
7965 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const
7967 return _time_steps.size();
7970 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseEmptyTS()
7972 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7973 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
7975 const MEDFileAnyTypeField1TSWithoutSDA *tmp=(*it);
7977 newTS.push_back(*it);
7982 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds(const int *startIds, const int *endIds)
7984 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
7985 int maxId=(int)_time_steps.size();
7987 std::set<int> idsToDel;
7988 for(const int *id=startIds;id!=endIds;id++,ii++)
7990 if(*id>=0 && *id<maxId)
7992 idsToDel.insert(*id);
7996 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::eraseTimeStepIds : At pos #" << ii << " request for id=" << *id << " not in [0," << maxId << ") !";
7997 throw INTERP_KERNEL::Exception(oss.str());
8000 for(int iii=0;iii<maxId;iii++)
8001 if(idsToDel.find(iii)==idsToDel.end())
8002 newTS.push_back(_time_steps[iii]);
8006 void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, int step)
8008 static const char msg[]="MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2";
8009 int nbOfEntriesToKill=DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg);
8010 if(nbOfEntriesToKill==0)
8012 std::size_t sz=_time_steps.size();
8013 std::vector<bool> b(sz,true);
8015 for(int i=0;i<nbOfEntriesToKill;i++,j+=step)
8017 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > newTS;
8018 for(std::size_t i=0;i<sz;i++)
8020 newTS.push_back(_time_steps[i]);
8024 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
8027 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
8028 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8030 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8034 tmp->getTime(it2,ord);
8035 if(it2==iteration && order==ord)
8038 oss << "(" << it2 << "," << ord << "), ";
8041 throw INTERP_KERNEL::Exception(oss.str());
8044 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosGivenTime(double time, double eps) const
8047 std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosGivenTime : No such time step " << time << "! \nPossibilities are : ";
8049 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
8051 const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
8055 double ti=tmp->getTime(it2,ord);
8056 if(fabs(time-ti)<eps)
8062 throw INTERP_KERNEL::Exception(oss.str());
8065 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getIterations() const
8067 int lgth=_time_steps.size();
8068 std::vector< std::pair<int,int> > ret(lgth);
8069 for(int i=0;i<lgth;i++)
8070 _time_steps[i]->fillIteration(ret[i]);
8075 * 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'
8076 * This method returns two things.
8077 * - The absolute dimension of 'this' in first parameter.
8078 * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
8079 * to the first output parameter. The values in 'levs' will be returned in decreasing order.
8081 * This method is designed for MEDFileFieldMultiTS instances that have a discritization ON_CELLS, ON_GAUSS_NE and ON_GAUSS.
8082 * Only these 3 discretizations will be taken into account here.
8084 * If 'this' is empty this method will throw an INTERP_KERNEL::Exception.
8085 * If there is \b only node fields defined in 'this' -1 is returned and 'levs' output parameter will be empty. In this
8086 * case the caller has to know the underlying mesh it refers to. By defaut it is the level 0 of the corresponding mesh.
8088 * This method is usefull to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
8089 * 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'.
8091 * Let's consider the typical following case :
8092 * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
8093 * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
8094 * - 'f1' lies on 'm1' and is defined on 3D and 1D cells for example
8096 * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
8098 * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
8100 * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
8101 * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
8102 * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
8103 * To retrieve the lowest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+(-1));//absDim-meshDim+relativeLev
8105 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8107 return getTimeStepEntry(iteration,order).getNonEmptyLevels(mname,levs);
8110 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos) const
8112 if(pos<0 || pos>=(int)_time_steps.size())
8114 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8115 throw INTERP_KERNEL::Exception(oss.str());
8117 const MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8120 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8121 oss << "\nTry to use following method eraseEmptyTS !";
8122 throw INTERP_KERNEL::Exception(oss.str());
8127 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2(int pos)
8129 if(pos<0 || pos>=(int)_time_steps.size())
8131 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << " whereas should be in [0," << _time_steps.size() << ") !";
8132 throw INTERP_KERNEL::Exception(oss.str());
8134 MEDFileAnyTypeField1TSWithoutSDA *item=_time_steps[pos];
8137 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::getTimeStepAtPos2 : request for pos #" << pos << ", this pos id exists but the underlying Field1TS is null !";
8138 oss << "\nTry to use following method eraseEmptyTS !";
8139 throw INTERP_KERNEL::Exception(oss.str());
8144 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsed2() const
8146 std::vector<std::string> ret;
8147 std::set<std::string> ret2;
8148 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8150 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
8151 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8152 if(ret2.find(*it2)==ret2.end())
8154 ret.push_back(*it2);
8161 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsed2() const
8163 std::vector<std::string> ret;
8164 std::set<std::string> ret2;
8165 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8167 std::vector<std::string> tmp=(*it)->getLocsReallyUsed2();
8168 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
8169 if(ret2.find(*it2)==ret2.end())
8171 ret.push_back(*it2);
8178 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getPflsReallyUsedMulti2() const
8180 std::vector<std::string> ret;
8181 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8183 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti2();
8184 ret.insert(ret.end(),tmp.begin(),tmp.end());
8189 std::vector<std::string> MEDFileAnyTypeFieldMultiTSWithoutSDA::getLocsReallyUsedMulti2() const
8191 std::vector<std::string> ret;
8192 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8194 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti2();
8195 ret.insert(ret.end(),tmp.begin(),tmp.end());
8200 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8202 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8203 (*it)->changePflsRefsNamesGen2(mapOfModif);
8206 void MEDFileAnyTypeFieldMultiTSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8208 for(std::vector< MCAuto< MEDFileAnyTypeField1TSWithoutSDA > >::iterator it=_time_steps.begin();it!=_time_steps.end();it++)
8209 (*it)->changeLocsRefsNamesGen2(mapOfModif);
8212 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getTypesOfFieldAvailable() const
8214 int lgth=_time_steps.size();
8215 std::vector< std::vector<TypeOfField> > ret(lgth);
8216 for(int i=0;i<lgth;i++)
8217 _time_steps[i]->fillTypesOfFieldAvailable(ret[i]);
8222 * entry point for users that want to iterate into MEDFile DataStructure without any overhead.
8224 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
8226 return getTimeStepEntry(iteration,order).getFieldSplitedByType(mname,types,typesF,pfls,locs);
8229 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::deepCopy() const
8231 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret=shallowCpy();
8233 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8235 if((const MEDFileAnyTypeField1TSWithoutSDA *)*it)
8236 ret->_time_steps[i]=(*it)->deepCopy();
8241 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents() const
8243 std::size_t sz(_infos.size()),sz2(_time_steps.size());
8244 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(sz);
8245 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ts(sz2);
8246 for(std::size_t i=0;i<sz;i++)
8248 ret[i]=shallowCpy();
8249 ret[i]->_infos.resize(1); ret[i]->_infos[0]=_infos[i];
8251 for(std::size_t i=0;i<sz2;i++)
8253 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret1=_time_steps[i]->splitComponents();
8256 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitComponents : At rank #" << i << " number of components is " << ret1.size() << " whereas it should be for all time steps " << sz << " !";
8257 throw INTERP_KERNEL::Exception(oss.str());
8261 for(std::size_t i=0;i<sz;i++)
8262 for(std::size_t j=0;j<sz2;j++)
8263 ret[i]->_time_steps[j]=ts[j][i];
8268 * This method splits into discretization each time steps in \a this.
8269 * ** WARNING ** the returned instances are not compulsary defined on the same time steps series !
8271 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations() const
8273 std::size_t sz(_time_steps.size());
8274 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8275 for(std::size_t i=0;i<sz;i++)
8277 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8280 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
8281 throw INTERP_KERNEL::Exception(oss.str());
8283 items[i]=timeStep->splitDiscretizations();
8286 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
8287 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > ret2;
8288 std::vector< TypeOfField > types;
8289 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8290 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8292 std::vector<TypeOfField> ts=(*it1)->getTypesOfFieldAvailable();
8294 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : it appears that the splitting of MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations has returned invalid result !");
8295 std::vector< TypeOfField >::iterator it2=std::find(types.begin(),types.end(),ts[0]);
8296 if(it2==types.end())
8297 types.push_back(ts[0]);
8299 ret.resize(types.size()); ret2.resize(types.size());
8300 for(std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > >::const_iterator it0=items.begin();it0!=items.end();it0++)
8301 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it1=(*it0).begin();it1!=(*it0).end();it1++)
8303 TypeOfField typ=(*it1)->getTypesOfFieldAvailable()[0];
8304 std::size_t pos=std::distance(types.begin(),std::find(types.begin(),types.end(),typ));
8305 ret2[pos].push_back(*it1);
8307 for(std::size_t i=0;i<types.size();i++)
8309 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8310 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::iterator it1=ret2[i].begin();it1!=ret2[i].end();it1++)
8311 elt->pushBackTimeStep(*it1);//also updates infos in elt
8313 elt->MEDFileFieldNameScope::operator=(*this);
8319 * Contrary to splitDiscretizations method this method makes the hypothesis that the times series are **NOT** impacted by the splitting of multi discretization.
8321 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes() const
8323 std::size_t sz(_time_steps.size());
8324 std::vector< std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > > items(sz);
8325 std::size_t szOut(std::numeric_limits<std::size_t>::max());
8326 for(std::size_t i=0;i<sz;i++)
8328 const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
8331 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : time step #" << i << " is null !";
8332 throw INTERP_KERNEL::Exception(oss.str());
8334 items[i]=timeStep->splitMultiDiscrPerGeoTypes();
8335 if(szOut==std::numeric_limits<std::size_t>::max())
8336 szOut=items[i].size();
8338 if(items[i].size()!=szOut)
8339 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : The splitting per discretization is expected to be same among time steps !");
8341 if(szOut==std::numeric_limits<std::size_t>::max())
8342 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
8343 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret(szOut);
8344 for(std::size_t i=0;i<szOut;i++)
8346 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt(createNew());
8347 for(std::size_t j=0;j<sz;j++)
8348 elt->pushBackTimeStep(items[j][i]);
8350 elt->MEDFileFieldNameScope::operator=(*this);
8355 void MEDFileAnyTypeFieldMultiTSWithoutSDA::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
8357 _name=field->getName();
8359 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
8361 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::copyTinyInfoFrom : no array set !");
8362 _infos=arr->getInfoOnComponents();
8365 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const
8367 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : invalid ";
8368 if(_name!=field->getName())
8370 std::ostringstream oss; oss << MSG << "name ! should be \"" << _name;
8371 oss << "\" and it is set in input field to \"" << field->getName() << "\" !";
8372 throw INTERP_KERNEL::Exception(oss.str());
8375 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfTinyInfo : no array set !");
8376 checkThatComponentsMatch(arr->getInfoOnComponents());
8379 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatComponentsMatch(const std::vector<std::string>& compos) const
8381 static const char MSG[]="MEDFileFieldMultiTSWithoutSDA::checkThatComponentsMatch : ";
8382 if(getInfo().size()!=compos.size())
8384 std::ostringstream oss; oss << MSG << "mismatch of number of components between this (" << getInfo().size() << ") and ";
8385 oss << " number of components of element to append (" << compos.size() << ") !";
8386 throw INTERP_KERNEL::Exception(oss.str());
8390 std::ostringstream oss; oss << MSG << "components have same size but are different ! should be \"";
8391 std::copy(_infos.begin(),_infos.end(),std::ostream_iterator<std::string>(oss,", "));
8392 oss << " But compo in input fields are : ";
8393 std::copy(compos.begin(),compos.end(),std::ostream_iterator<std::string>(oss,", "));
8395 throw INTERP_KERNEL::Exception(oss.str());
8399 void MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis() const
8401 std::size_t sz=_infos.size();
8403 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,j++)
8405 const MEDFileAnyTypeField1TSWithoutSDA *elt(*it);
8407 if(elt->getInfo().size()!=sz)
8409 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::checkThatNbOfCompoOfTSMatchThis : At pos #" << j << " the number of components is equal to ";
8410 oss << elt->getInfo().size() << " whereas it is expected to be equal to " << sz << " !";
8411 throw INTERP_KERNEL::Exception(oss.str());
8416 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob)
8419 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8420 if(!_time_steps.empty())
8421 checkCoherencyOfTinyInfo(field,arr);
8422 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8423 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8424 objC->setFieldNoProfileSBT(field,arr,glob,*this);
8425 copyTinyInfoFrom(field,arr);
8426 _time_steps.push_back(obj);
8429 void MEDFileAnyTypeFieldMultiTSWithoutSDA::appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob)
8432 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::appendFieldNoProfileSBT : input field is NULL !");
8433 if(!_time_steps.empty())
8434 checkCoherencyOfTinyInfo(field,arr);
8435 MEDFileAnyTypeField1TSWithoutSDA *objC=createNew1TSWithoutSDAEmptyInstance();
8436 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> obj(objC);
8437 objC->setFieldProfile(field,arr,mesh,meshDimRelToMax,profile,glob,*this);
8438 copyTinyInfoFrom(field,arr);
8439 _time_steps.push_back(obj);
8442 void MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration(int i, MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ts)
8444 int sz=(int)_time_steps.size();
8447 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element at place #" << i << " should be in [0," << sz << ") !";
8448 throw INTERP_KERNEL::Exception(oss.str());
8450 const MEDFileAnyTypeField1TSWithoutSDA *tsPtr(ts);
8453 if(tsPtr->getNumberOfComponents()!=(int)_infos.size())
8455 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::setIteration : trying to set element with " << tsPtr->getNumberOfComponents() << " components ! Should be " << _infos.size() << " !";
8456 throw INTERP_KERNEL::Exception(oss.str());
8462 //= MEDFileFieldMultiTSWithoutSDA
8464 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 MEDFileEntities *entities)
8466 return new MEDFileFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8469 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA()
8473 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8478 * \param [in] fieldId field id in C mode
8480 MEDFileFieldMultiTSWithoutSDA::MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8481 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8484 catch(INTERP_KERNEL::Exception& e)
8487 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 MEDFileEntities *entities)
8488 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8491 catch(INTERP_KERNEL::Exception& e)
8494 MEDFileAnyTypeField1TSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8496 return new MEDFileField1TSWithoutSDA;
8499 void MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8502 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8503 const MEDFileField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(f1ts);
8505 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
8508 const char *MEDFileFieldMultiTSWithoutSDA::getTypeStr() const
8510 return MEDFileField1TSWithoutSDA::TYPE_STR;
8513 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::shallowCpy() const
8515 return new MEDFileFieldMultiTSWithoutSDA(*this);
8518 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::createNew() const
8520 return new MEDFileFieldMultiTSWithoutSDA;
8524 * entry point for users that want to iterate into MEDFile DataStructure with a reduced overhead because output arrays are extracted (created) specially
8525 * for the call of this method. That's why the DataArrayDouble instance in returned vector of vector should be dealed by the caller.
8527 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
8529 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=getTimeStepEntry(iteration,order);
8530 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
8532 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::getFieldSplitedByType2 : mismatch of type of field expecting FLOAT64 !");
8533 return myF1TSC->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
8536 MEDFileIntFieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt() const
8538 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> ret(new MEDFileIntFieldMultiTSWithoutSDA);
8539 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8541 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8543 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8546 const MEDFileField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(eltToConv);
8548 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type FLOAT64 !");
8549 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToInt();
8550 ret->setIteration(i,elt);
8556 //= MEDFileAnyTypeFieldMultiTS
8558 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
8562 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8563 try:MEDFileFieldGlobsReal(fid)
8565 _content=BuildContentFrom(fid,loadAll,ms);
8568 catch(INTERP_KERNEL::Exception& e)
8573 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8575 med_field_type typcha;
8576 std::vector<std::string> infos;
8579 MEDFileAnyTypeField1TS::LocateField(fid,fieldName,i,typcha,infos,dtunit);
8580 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8585 ret=new MEDFileFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8590 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,i,loadAll,ms,entities);
8595 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
8596 throw INTERP_KERNEL::Exception(oss.str());
8599 ret->setDtUnit(dtunit.c_str());
8603 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
8605 med_field_type typcha;
8607 std::vector<std::string> infos;
8608 std::string dtunit,fieldName;
8609 MEDFileAnyTypeField1TS::LocateField2(fid,0,true,fieldName,typcha,infos,dtunit);
8610 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> ret;
8615 ret=new MEDFileFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8620 ret=new MEDFileIntFieldMultiTSWithoutSDA(fid,0,loadAll,ms,0);
8625 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::BuildContentFrom(fid) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but the type of the first field is not in [MED_FLOAT64, MED_INT32] !";
8626 throw INTERP_KERNEL::Exception(oss.str());
8629 ret->setDtUnit(dtunit.c_str());
8633 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c)
8636 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
8637 if(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(c))
8639 MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
8640 ret->_content=c; c->incrRef();
8643 if(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(c))
8645 MCAuto<MEDFileIntFieldMultiTS> ret(MEDFileIntFieldMultiTS::New());
8646 ret->_content=c; c->incrRef();
8649 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 and INT32 has been built but not intercepted !");
8652 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
8654 MEDFileAnyTypeFieldMultiTS *ret(BuildNewInstanceFromContent(c));
8655 std::string fileName(FileNameFromFID(fid));
8656 ret->setFileName(fileName);
8660 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8661 try:MEDFileFieldGlobsReal(fid)
8663 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
8666 catch(INTERP_KERNEL::Exception& e)
8671 //= MEDFileIntFieldMultiTSWithoutSDA
8673 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 MEDFileEntities *entities)
8675 return new MEDFileIntFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities);
8678 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA()
8682 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName)
8686 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 MEDFileEntities *entities)
8687 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities)
8690 catch(INTERP_KERNEL::Exception& e)
8694 * \param [in] fieldId field id in C mode
8696 MEDFileIntFieldMultiTSWithoutSDA::MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
8697 try:MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities)
8700 catch(INTERP_KERNEL::Exception& e)
8703 MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew1TSWithoutSDAEmptyInstance() const
8705 return new MEDFileIntField1TSWithoutSDA;
8708 void MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const
8711 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
8712 const MEDFileIntField1TSWithoutSDA *f1tsC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(f1ts);
8714 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::checkCoherencyOfType : the input field1TS is not a INT32 type !");
8717 const char *MEDFileIntFieldMultiTSWithoutSDA::getTypeStr() const
8719 return MEDFileIntField1TSWithoutSDA::TYPE_STR;
8722 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::shallowCpy() const
8724 return new MEDFileIntFieldMultiTSWithoutSDA(*this);
8727 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::createNew() const
8729 return new MEDFileIntFieldMultiTSWithoutSDA;
8732 MEDFileFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTSWithoutSDA::convertToDouble() const
8734 MCAuto<MEDFileFieldMultiTSWithoutSDA> ret(new MEDFileFieldMultiTSWithoutSDA);
8735 ret->MEDFileAnyTypeFieldMultiTSWithoutSDA::operator =(*this);
8737 for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
8739 const MEDFileAnyTypeField1TSWithoutSDA *eltToConv(*it);
8742 const MEDFileIntField1TSWithoutSDA *eltToConvC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(eltToConv);
8744 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTSWithoutSDA::convertToInt : presence of an invalid 1TS type ! Should be of type INT32 !");
8745 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> elt=eltToConvC->convertToDouble();
8746 ret->setIteration(i,elt);
8752 //= MEDFileAnyTypeFieldMultiTS
8755 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of the first field
8756 * that has been read from a specified MED file.
8757 * \param [in] fileName - the name of the MED file to read.
8758 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8759 * is to delete this field using decrRef() as it is no more needed.
8760 * \throw If reading the file fails.
8762 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, bool loadAll)
8764 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8765 return New(fid,loadAll);
8768 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, bool loadAll)
8770 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,loadAll,0));
8771 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8772 ret->loadGlobals(fid);
8777 * Returns a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS holding data of a given field
8778 * that has been read from a specified MED file.
8779 * \param [in] fileName - the name of the MED file to read.
8780 * \param [in] fieldName - the name of the field to read.
8781 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS or MEDFileIntFieldMultiTS. The caller
8782 * is to delete this field using decrRef() as it is no more needed.
8783 * \throw If reading the file fails.
8784 * \throw If there is no field named \a fieldName in the file.
8786 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
8788 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
8789 return New(fid,fieldName,loadAll);
8792 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
8794 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
8795 MCAuto<MEDFileAnyTypeFieldMultiTS> ret(BuildNewInstanceFromContent(c,fid));
8796 ret->loadGlobals(fid);
8801 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
8802 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
8804 * \warning this is a shallow copy constructor
8806 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
8808 if(!shallowCopyOfContent)
8810 const MEDFileAnyTypeFieldMultiTSWithoutSDA *otherPtr(&other);
8811 otherPtr->incrRef();
8812 _content=const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(otherPtr);
8816 _content=other.shallowCpy();
8820 MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase()
8822 MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8824 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : content is expected to be not null !");
8828 const MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTS::contentNotNullBase() const
8830 const MEDFileAnyTypeFieldMultiTSWithoutSDA *ret=_content;
8832 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS : const content is expected to be not null !");
8836 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsed() const
8838 return contentNotNullBase()->getPflsReallyUsed2();
8841 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsed() const
8843 return contentNotNullBase()->getLocsReallyUsed2();
8846 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getPflsReallyUsedMulti() const
8848 return contentNotNullBase()->getPflsReallyUsedMulti2();
8851 std::vector<std::string> MEDFileAnyTypeFieldMultiTS::getLocsReallyUsedMulti() const
8853 return contentNotNullBase()->getLocsReallyUsedMulti2();
8856 void MEDFileAnyTypeFieldMultiTS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8858 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
8861 void MEDFileAnyTypeFieldMultiTS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
8863 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
8866 int MEDFileAnyTypeFieldMultiTS::getNumberOfTS() const
8868 return contentNotNullBase()->getNumberOfTS();
8871 void MEDFileAnyTypeFieldMultiTS::eraseEmptyTS()
8873 contentNotNullBase()->eraseEmptyTS();
8876 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds(const int *startIds, const int *endIds)
8878 contentNotNullBase()->eraseTimeStepIds(startIds,endIds);
8881 void MEDFileAnyTypeFieldMultiTS::eraseTimeStepIds2(int bg, int end, int step)
8883 contentNotNullBase()->eraseTimeStepIds2(bg,end,step);
8886 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPart(const int *startIds, const int *endIds) const
8888 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds(startIds,endIds);
8889 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8894 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::buildSubPartSlice(int bg, int end, int step) const
8896 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> c=contentNotNullBase()->buildFromTimeStepIds2(bg,end,step);
8897 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
8902 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getIterations() const
8904 return contentNotNullBase()->getIterations();
8907 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts)
8909 for(std::vector<MEDFileAnyTypeField1TS *>::const_iterator it=f1ts.begin();it!=f1ts.end();it++)
8910 pushBackTimeStep(*it);
8913 void MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts)
8916 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::pushBackTimeSteps : Input fmts is NULL !");
8917 int nbOfTS(fmts->getNumberOfTS());
8918 for(int i=0;i<nbOfTS;i++)
8920 MCAuto<MEDFileAnyTypeField1TS> elt(fmts->getTimeStepAtPos(i));
8921 pushBackTimeStep(elt);
8925 void MEDFileAnyTypeFieldMultiTS::pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts)
8928 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : input pointer is NULL !");
8929 checkCoherencyOfType(f1ts);
8931 MCAuto<MEDFileAnyTypeField1TS> f1tsSafe(f1ts);
8932 MEDFileAnyTypeField1TSWithoutSDA *c=f1ts->contentNotNullBase();
8934 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> cSafe(c);
8935 if(!((MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content))
8936 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep : no content in this !");
8937 _content->pushBackTimeStep(cSafe);
8938 appendGlobs(*f1ts,1e-12);
8941 void MEDFileAnyTypeFieldMultiTS::synchronizeNameScope()
8943 contentNotNullBase()->synchronizeNameScope();
8946 int MEDFileAnyTypeFieldMultiTS::getPosOfTimeStep(int iteration, int order) const
8948 return contentNotNullBase()->getPosOfTimeStep(iteration,order);
8951 int MEDFileAnyTypeFieldMultiTS::getPosGivenTime(double time, double eps) const
8953 return contentNotNullBase()->getPosGivenTime(time,eps);
8956 int MEDFileAnyTypeFieldMultiTS::getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const
8958 return contentNotNullBase()->getNonEmptyLevels(iteration,order,mname,levs);
8961 std::vector< std::vector<TypeOfField> > MEDFileAnyTypeFieldMultiTS::getTypesOfFieldAvailable() const
8963 return contentNotNullBase()->getTypesOfFieldAvailable();
8966 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
8968 return contentNotNullBase()->getFieldSplitedByType(iteration,order,mname,types,typesF,pfls,locs);
8971 std::string MEDFileAnyTypeFieldMultiTS::getName() const
8973 return contentNotNullBase()->getName();
8976 void MEDFileAnyTypeFieldMultiTS::setName(const std::string& name)
8978 contentNotNullBase()->setName(name);
8981 std::string MEDFileAnyTypeFieldMultiTS::getDtUnit() const
8983 return contentNotNullBase()->getDtUnit();
8986 void MEDFileAnyTypeFieldMultiTS::setDtUnit(const std::string& dtUnit)
8988 contentNotNullBase()->setDtUnit(dtUnit);
8991 void MEDFileAnyTypeFieldMultiTS::simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const
8993 contentNotNullBase()->simpleRepr(bkOffset,oss,fmtsId);
8996 std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTS::getTimeSteps(std::vector<double>& ret1) const
8998 return contentNotNullBase()->getTimeSteps(ret1);
9001 std::string MEDFileAnyTypeFieldMultiTS::getMeshName() const
9003 return contentNotNullBase()->getMeshName();
9006 void MEDFileAnyTypeFieldMultiTS::setMeshName(const std::string& newMeshName)
9008 contentNotNullBase()->setMeshName(newMeshName);
9011 bool MEDFileAnyTypeFieldMultiTS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
9013 return contentNotNullBase()->changeMeshNames(modifTab);
9016 const std::vector<std::string>& MEDFileAnyTypeFieldMultiTS::getInfo() const
9018 return contentNotNullBase()->getInfo();
9021 bool MEDFileAnyTypeFieldMultiTS::presenceOfMultiDiscPerGeoType() const
9023 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
9026 void MEDFileAnyTypeFieldMultiTS::setInfo(const std::vector<std::string>& info)
9028 return contentNotNullBase()->setInfo(info);
9031 int MEDFileAnyTypeFieldMultiTS::getNumberOfComponents() const
9033 const std::vector<std::string> ret=getInfo();
9034 return (int)ret.size();
9037 void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
9039 writeGlobals(fid,*this);
9040 contentNotNullBase()->writeLL(fid,*this);
9044 * This method alloc the arrays and load potentially huge arrays contained in this field.
9045 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
9046 * This method can be also called to refresh or reinit values from a file.
9048 * \throw If the fileName is not set or points to a non readable MED file.
9050 void MEDFileAnyTypeFieldMultiTS::loadArrays()
9052 if(getFileName().empty())
9053 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::loadArrays : the structure does not come from a file !");
9054 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9055 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
9059 * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
9060 * But once data loaded once, this method does nothing.
9062 * \throw If the fileName is not set or points to a non readable MED file.
9063 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
9065 void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
9067 if(!getFileName().empty())
9069 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
9070 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
9075 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
9076 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
9077 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
9079 * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
9081 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
9083 contentNotNullBase()->unloadArrays();
9087 * 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.
9088 * This method is the symetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
9089 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
9091 * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
9093 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
9095 if(!getFileName().empty())
9096 contentNotNullBase()->unloadArrays();
9099 std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const
9101 std::ostringstream oss;
9102 contentNotNullBase()->simpleRepr(0,oss,-1);
9103 simpleReprGlobs(oss);
9107 std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySizeWithoutChildren() const
9109 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
9112 std::vector<const BigMemoryObject *> MEDFileAnyTypeFieldMultiTS::getDirectChildrenWithNull() const
9114 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
9115 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content);
9120 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this.
9121 * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this.
9122 * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field !
9124 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitComponents() const
9126 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9128 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitComponents : no content in this ! Unable to split components !");
9129 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit=content->splitComponents();
9130 std::size_t sz(contentsSplit.size());
9131 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9132 for(std::size_t i=0;i<sz;i++)
9134 ret[i]=shallowCpy();
9135 ret[i]->_content=contentsSplit[i];
9141 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of discretizations over time steps in \a this.
9142 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9144 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitDiscretizations() const
9146 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9148 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitDiscretizations : no content in this ! Unable to split discretizations !");
9149 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitDiscretizations());
9150 std::size_t sz(contentsSplit.size());
9151 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9152 for(std::size_t i=0;i<sz;i++)
9154 ret[i]=shallowCpy();
9155 ret[i]->_content=contentsSplit[i];
9161 * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of sub-discretizations over time steps in \a this.
9162 * The returned instances are shallow copied of \a this included globals that are share with those contained in \a this.
9164 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes() const
9166 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9168 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretizations !");
9169 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
9170 std::size_t sz(contentsSplit.size());
9171 std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > ret(sz);
9172 for(std::size_t i=0;i<sz;i++)
9174 ret[i]=shallowCpy();
9175 ret[i]->_content=contentsSplit[i];
9180 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::deepCopy() const
9182 MCAuto<MEDFileAnyTypeFieldMultiTS> ret=shallowCpy();
9183 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)_content)
9184 ret->_content=_content->deepCopy();
9185 ret->deepCpyGlobs(*this);
9189 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> MEDFileAnyTypeFieldMultiTS::getContent()
9195 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9196 * \param [in] iteration - the iteration number of a required time step.
9197 * \param [in] order - the iteration order number of required time step.
9198 * \return MEDFileField1TS * or MEDFileIntField1TS *- a new instance of MEDFileField1TS or MEDFileIntField1TS. The caller is to
9199 * delete this field using decrRef() as it is no more needed.
9200 * \throw If there is no required time step in \a this field.
9202 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStep(int iteration, int order) const
9204 int pos=getPosOfTimeStep(iteration,order);
9205 return getTimeStepAtPos(pos);
9209 * Returns a new MEDFileField1TS or MEDFileIntField1TS holding data of a given time step of \a this field.
9210 * \param [in] time - the time of the time step of interest.
9211 * \param [in] eps - a precision used to compare time values.
9212 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9213 * delete this field using decrRef() as it is no more needed.
9214 * \throw If there is no required time step in \a this field.
9216 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTS::getTimeStepGivenTime(double time, double eps) const
9218 int pos=getPosGivenTime(time,eps);
9219 return getTimeStepAtPos(pos);
9223 * 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.
9224 * The float64 value of time attached to the pair of integers are not considered here.
9225 * WARNING the returned pointers are not incremented. The caller is \b not responsible to deallocate them ! This method only reorganizes entries in \a vectFMTS.
9227 * \param [in] vectFMTS - vector of not null fields defined on a same global data pointer.
9228 * \throw If there is a null pointer in \a vectFMTS.
9230 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS)
9232 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries : presence of null instance in input vector !";
9233 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9234 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9235 while(!lstFMTS.empty())
9237 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9238 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9240 throw INTERP_KERNEL::Exception(msg);
9241 std::vector< std::pair<int,int> > refIts=curIt->getIterations();
9242 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9243 elt.push_back(curIt); it=lstFMTS.erase(it);
9244 while(it!=lstFMTS.end())
9248 throw INTERP_KERNEL::Exception(msg);
9249 std::vector< std::pair<int,int> > curIts=curIt->getIterations();
9251 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9261 * This method splits the input list \a vectFMTS considering the aspect of the geometrical support over time.
9262 * All returned instances in a subvector can be safely loaded, rendered along time
9263 * All items must be defined on the same time step ids ( see MEDFileAnyTypeFieldMultiTS::SplitIntoCommonTimeSeries method ).
9264 * Each item in \a vectFMTS is expected to have one and exactly one spatial discretization along time.
9265 * 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).
9266 * All items in \a vectFMTS whose spatial discretization is not ON_NODES will appear once.
9267 * 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.
9269 * \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().
9270 * \param [in] mesh - the mesh shared by all items in \a vectFMTS across time.
9271 * \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.
9272 * \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.
9274 * \throw If an element in \a vectFMTS has not only one spatial discretization set.
9275 * \throw If an element in \a vectFMTS change of spatial discretization along time.
9276 * \throw If an element in \a vectFMTS lies on a mesh with meshname different from those in \a mesh.
9277 * \thorw If some elements in \a vectFMTS do not have the same times steps.
9278 * \throw If mesh is null.
9279 * \throw If an element in \a vectFMTS is null.
9280 * \sa MEDFileAnyTypeFieldMultiTS::AreOnSameSupportAcrossTime
9282 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& fsc)
9284 static const char msg[]="MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : presence of a null instance in the input vector !";
9286 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : input mesh is null !");
9287 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9288 if(vectFMTS.empty())
9290 std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it(vectFMTS.begin());
9291 MEDFileAnyTypeFieldMultiTS *frstElt(*it);
9293 throw INTERP_KERNEL::Exception(msg);
9295 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNotNodes;
9296 std::vector<MEDFileAnyTypeFieldMultiTS *> vectFMTSNodes;
9297 for(;it!=vectFMTS.end();it++,i++)
9300 throw INTERP_KERNEL::Exception(msg);
9301 TypeOfField tof0,tof1;
9302 if(CheckSupportAcrossTime(frstElt,*it,mesh,tof0,tof1)>0)
9305 vectFMTSNotNodes.push_back(*it);
9307 vectFMTSNodes.push_back(*it);
9310 vectFMTSNotNodes.push_back(*it);
9312 std::vector< MCAuto<MEDFileFastCellSupportComparator> > cmps;
9313 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > retCell=SplitPerCommonSupportNotNodesAlg(vectFMTSNotNodes,mesh,cmps);
9315 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it2=vectFMTSNodes.begin();it2!=vectFMTSNodes.end();it2++)
9318 bool isFetched(false);
9319 for(std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> >::const_iterator it0=retCell.begin();it0!=retCell.end();it0++,i++)
9322 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport : internal error !");
9323 if(cmps[i]->isCompatibleWithNodesDiscr(*it2))
9324 { ret[i].push_back(*it2); isFetched=true; }
9328 std::vector<MEDFileAnyTypeFieldMultiTS *> tmp(1,*it2);
9329 MCAuto<MEDFileMeshStruct> tmp2(MEDFileMeshStruct::New(mesh));
9330 ret.push_back(tmp); retCell.push_back(tmp); cmps.push_back(MEDFileFastCellSupportComparator::New(tmp2,*it2));
9338 * 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.
9339 * \param [out] cmps - same size than the returned vector.
9341 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto<MEDFileFastCellSupportComparator> >& cmps)
9343 std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > ret;
9344 std::list<MEDFileAnyTypeFieldMultiTS *> lstFMTS(vectFMTS.begin(),vectFMTS.end());
9345 while(!lstFMTS.empty())
9347 std::list<MEDFileAnyTypeFieldMultiTS *>::iterator it(lstFMTS.begin());
9348 MEDFileAnyTypeFieldMultiTS *ref(*it);
9349 std::vector<MEDFileAnyTypeFieldMultiTS *> elt;
9350 elt.push_back(ref); it=lstFMTS.erase(it);
9351 MCAuto<MEDFileMeshStruct> mst(MEDFileMeshStruct::New(mesh));
9352 MCAuto<MEDFileFastCellSupportComparator> cmp(MEDFileFastCellSupportComparator::New(mst,ref));
9353 while(it!=lstFMTS.end())
9355 MEDFileAnyTypeFieldMultiTS *curIt(*it);
9356 if(cmp->isEqual(curIt))
9357 { elt.push_back(curIt); it=lstFMTS.erase(it); }
9361 ret.push_back(elt); cmps.push_back(cmp);
9367 * 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.
9368 * \a f0 and \a f1 must be defined each only on a same spatial discretization even if this can be different each other.
9370 * \throw If \a f0 or \a f1 has not only one spatial discretization set.
9371 * \throw If \a f0 or \a f1 change of spatial discretization along time.
9372 * \throw If \a f0 or \a f1 on a mesh with meshname different from those in \a mesh.
9373 * \thorw If \a f0 and \a f1 do not have the same times steps.
9374 * \throw If mesh is null.
9375 * \throw If \a f0 or \a f1 is null.
9376 * \sa MEDFileAnyTypeFieldMultiTS::SplitPerCommonSupport
9378 int MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1)
9381 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : input mesh is null !");
9383 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : presence of null instance in fields over time !");
9384 if(f0->getMeshName()!=mesh->getName())
9386 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : first field points to mesh \""<< f0->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9387 throw INTERP_KERNEL::Exception(oss.str());
9389 if(f1->getMeshName()!=mesh->getName())
9391 std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : second field points to mesh \""<< f1->getMeshName() << "\" and input mesh to compare has name \"" << mesh->getName() << "\" !";
9392 throw INTERP_KERNEL::Exception(oss.str());
9394 int nts=f0->getNumberOfTS();
9395 if(nts!=f1->getNumberOfTS())
9396 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : number of time steps are not the same !");
9399 for(int i=0;i<nts;i++)
9401 MCAuto<MEDFileAnyTypeField1TS> f0cur=f0->getTimeStepAtPos(i);
9402 MCAuto<MEDFileAnyTypeField1TS> f1cur=f1->getTimeStepAtPos(i);
9403 std::vector<TypeOfField> tofs0(f0cur->getTypesOfFieldAvailable()),tofs1(f1cur->getTypesOfFieldAvailable());
9404 if(tofs0.size()!=1 || tofs1.size()!=1)
9405 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : All time steps must be defined on only one spatial discretization !");
9408 if(tof0!=tofs0[0] || tof1!=tofs1[0])
9409 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::CheckSupportAcrossTime : Across times steps MEDFileAnyTypeFieldMultiTS instances have to keep the same unique spatial discretization !");
9412 { tof0=tofs0[0]; tof1=tofs1[0]; }
9413 if(f0cur->getMeshIteration()!=mesh->getIteration() || f0cur->getMeshOrder()!=mesh->getOrder())
9415 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() << ") !";
9416 throw INTERP_KERNEL::Exception(oss.str());
9418 if(f1cur->getMeshIteration()!=mesh->getIteration() || f1cur->getMeshOrder()!=mesh->getOrder())
9420 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() << ") !";
9421 throw INTERP_KERNEL::Exception(oss.str());
9423 if(f0cur->getIteration()!=f1cur->getIteration() || f0cur->getOrder()!=f1cur->getOrder())
9425 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() << ") !";
9426 throw INTERP_KERNEL::Exception(oss.str());
9433 * Return an extraction of \a this using \a extractDef map to specify the extraction.
9434 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
9436 * \return A new object that the caller is responsible to deallocate.
9438 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
9441 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::extractPart : mesh is null !");
9442 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(buildNewEmpty());
9443 int nbTS(getNumberOfTS());
9444 for(int i=0;i<nbTS;i++)
9446 MCAuto<MEDFileAnyTypeField1TS> f1ts(getTimeStepAtPos(i));
9447 MCAuto<MEDFileAnyTypeField1TS> f1tsOut(f1ts->extractPart(extractDef,mm));
9448 fmtsOut->pushBackTimeStep(f1tsOut);
9450 return fmtsOut.retn();
9454 MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename MLFieldTraits<T>::F1TSType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9456 MCAuto< typename MLFieldTraits<T>::F1TSType > ret(MLFieldTraits<T>::F1TSType::New());
9458 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : empty vector !");
9459 std::size_t sz(f1tss.size()),i(0);
9460 std::vector< typename MLFieldTraits<T>::F1TSWSDAType const *> f1tsw(sz);
9461 for(typename std::vector< typename MLFieldTraits<T>::F1TSType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,i++)
9463 typename MLFieldTraits<T>::F1TSType const *elt(*it);
9465 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : presence of a null pointer !");
9466 f1tsw[i]=dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType const *>(elt->contentNotNullBase());
9468 typename MLFieldTraits<T>::F1TSWSDAType *retc(dynamic_cast<typename MLFieldTraits<T>::F1TSWSDAType *>(ret->contentNotNullBase()));
9470 throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
9471 retc->aggregate(f1tsw,dts);
9472 ret->setDtUnit(f1tss[0]->getDtUnit());
9473 return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
9477 MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< typename MLFieldTraits<T>::FMTSType const *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9479 MCAuto< typename MLFieldTraits<T>::FMTSType > ret(MLFieldTraits<T>::FMTSType::New());
9481 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : empty vector !");
9482 std::size_t sz(fmtss.size());
9483 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9485 typename MLFieldTraits<T>::FMTSType const *elt(*it);
9487 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : presence of null pointer !");
9489 int nbTS(fmtss[0]->getNumberOfTS());
9490 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9491 if((*it)->getNumberOfTS()!=nbTS)
9492 throw INTERP_KERNEL::Exception("AggregateHelperFMTS : all fields must have the same number of TS !");
9493 for(int iterTS=0;iterTS<nbTS;iterTS++)
9496 std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
9497 std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
9498 for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
9499 { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
9500 MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
9501 ret->pushBackTimeStep(f1ts);
9502 ret->setDtUnit(f1ts->getDtUnit());
9504 return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
9508 * \a dts and \a ftmss are expected to have same size.
9510 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,int> > >& dts)
9513 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : input vector is empty !");
9514 std::size_t sz(fmtss.size());
9515 std::vector<const MEDFileFieldMultiTS *> fmtss1;
9516 std::vector<const MEDFileIntFieldMultiTS *> fmtss2;
9517 for(std::vector<const MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++)
9520 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : presence of null instance in input vector !");
9521 const MEDFileFieldMultiTS *elt1(dynamic_cast<const MEDFileFieldMultiTS *>(*it));
9524 fmtss1.push_back(elt1);
9527 const MEDFileIntFieldMultiTS *elt2(dynamic_cast<const MEDFileIntFieldMultiTS *>(*it));
9530 fmtss2.push_back(elt2);
9533 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not recognized type !");
9535 if(fmtss1.size()!=sz && fmtss2.size()!=sz)
9536 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : type of data is not homogeneous !");
9537 if(fmtss1.size()==sz)
9538 return AggregateHelperFMTS<double>(fmtss1,dts);
9539 if(fmtss2.size()!=sz)
9540 return AggregateHelperFMTS<int>(fmtss2,dts);
9541 throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::Aggregate : not implemented yet !");
9544 MEDFileAnyTypeFieldMultiTSIterator *MEDFileAnyTypeFieldMultiTS::iterator()
9546 return new MEDFileAnyTypeFieldMultiTSIterator(this);
9549 //= MEDFileFieldMultiTS
9552 * Returns a new empty instance of MEDFileFieldMultiTS.
9553 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9554 * is to delete this field using decrRef() as it is no more needed.
9556 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New()
9558 return new MEDFileFieldMultiTS;
9562 * Returns a new instance of MEDFileFieldMultiTS holding data of the first field
9563 * that has been read from a specified MED file.
9564 * \param [in] fileName - the name of the MED file to read.
9565 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9566 * is to delete this field using decrRef() as it is no more needed.
9567 * \throw If reading the file fails.
9569 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, bool loadAll)
9571 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9572 return New(fid,loadAll);
9575 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, bool loadAll)
9577 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,loadAll,0));
9578 ret->contentNotNull();//to check that content type matches with \a this type.
9583 * Returns a new instance of MEDFileFieldMultiTS holding data of a given field
9584 * that has been read from a specified MED file.
9585 * \param [in] fileName - the name of the MED file to read.
9586 * \param [in] fieldName - the name of the field to read.
9587 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9588 * is to delete this field using decrRef() as it is no more needed.
9589 * \throw If reading the file fails.
9590 * \throw If there is no field named \a fieldName in the file.
9592 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
9594 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9595 return New(fid,fieldName,loadAll);
9598 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
9600 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0));
9601 ret->contentNotNull();//to check that content type matches with \a this type.
9606 * Returns a new instance of MEDFileFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
9607 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
9609 * Returns a new instance of MEDFileFieldMultiTS holding either a shallow copy
9610 * of a given MEDFileFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
9611 * \warning this is a shallow copy constructor
9612 * \param [in] other - a MEDFileField1TSWithoutSDA to copy.
9613 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
9614 * \return MEDFileFieldMultiTS * - a new instance of MEDFileFieldMultiTS. The caller
9615 * is to delete this field using decrRef() as it is no more needed.
9617 MEDFileFieldMultiTS *MEDFileFieldMultiTS::New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
9619 return new MEDFileFieldMultiTS(other,shallowCopyOfContent);
9622 MEDFileFieldMultiTS *MEDFileFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
9624 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
9625 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
9626 MCAuto<MEDFileFieldMultiTS> ret(new MEDFileFieldMultiTS(fid,fieldName,loadAll,0,ent));
9627 ret->contentNotNull();//to check that content type matches with \a this type.
9631 MEDFileAnyTypeFieldMultiTS *MEDFileFieldMultiTS::shallowCpy() const
9633 return new MEDFileFieldMultiTS(*this);
9636 void MEDFileFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
9639 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
9640 const MEDFileField1TS *f1tsC=dynamic_cast<const MEDFileField1TS *>(f1ts);
9642 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::checkCoherencyOfType : the input field1TS is not a FLOAT64 type !");
9646 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
9647 * following the given input policy.
9649 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
9650 * By default (true) the globals are deeply copied.
9651 * \return MEDFileIntFieldMultiTS * - a new object that is the result of the conversion of \a this to int32 field.
9653 MEDFileIntFieldMultiTS *MEDFileFieldMultiTS::convertToInt(bool isDeepCpyGlobs) const
9655 MCAuto<MEDFileIntFieldMultiTS> ret;
9656 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
9659 const MEDFileFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(content);
9661 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
9662 MCAuto<MEDFileIntFieldMultiTSWithoutSDA> newc(contc->convertToInt());
9663 ret=static_cast<MEDFileIntFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileIntFieldMultiTSWithoutSDA *)newc));
9666 ret=MEDFileIntFieldMultiTS::New();
9668 ret->deepCpyGlobs(*this);
9670 ret->shallowCpyGlobs(*this);
9675 * Returns a new MEDFileField1TS holding data of a given time step of \a this field.
9676 * \param [in] pos - a time step id.
9677 * \return MEDFileField1TS * - a new instance of MEDFileField1TS. The caller is to
9678 * delete this field using decrRef() as it is no more needed.
9679 * \throw If \a pos is not a valid time step id.
9681 MEDFileField1TS *MEDFileFieldMultiTS::getTimeStepAtPos(int pos) const
9683 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
9686 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
9687 throw INTERP_KERNEL::Exception(oss.str());
9689 const MEDFileField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(item);
9692 MCAuto<MEDFileField1TS> ret=MEDFileField1TS::New(*itemC,false);
9693 ret->shallowCpyGlobs(*this);
9696 std::ostringstream oss; oss << "MEDFileFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not FLOAT64 !";
9697 throw INTERP_KERNEL::Exception(oss.str());
9701 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9702 * mesh entities of a given dimension of the first mesh in MED file.
9703 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9704 * \param [in] type - a spatial discretization of interest.
9705 * \param [in] iteration - the iteration number of a required time step.
9706 * \param [in] order - the iteration order number of required time step.
9707 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9708 * \param [in] renumPol - specifies how to permute values of the result field according to
9709 * the optional numbers of cells and nodes, if any. The valid values are
9710 * - 0 - do not permute.
9711 * - 1 - permute cells.
9712 * - 2 - permute nodes.
9713 * - 3 - permute cells and nodes.
9715 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9716 * caller is to delete this field using decrRef() as it is no more needed.
9717 * \throw If the MED file is not readable.
9718 * \throw If there is no mesh in the MED file.
9719 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9720 * \throw If no field values of the required parameters are available.
9722 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
9724 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9725 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9727 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting FLOAT64 !");
9728 MCAuto<DataArray> arrOut;
9729 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9730 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9735 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9736 * the top level cells of the first mesh in MED file.
9737 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9738 * \param [in] type - a spatial discretization of interest.
9739 * \param [in] iteration - the iteration number of a required time step.
9740 * \param [in] order - the iteration order number of required time step.
9741 * \param [in] renumPol - specifies how to permute values of the result field according to
9742 * the optional numbers of cells and nodes, if any. The valid values are
9743 * - 0 - do not permute.
9744 * - 1 - permute cells.
9745 * - 2 - permute nodes.
9746 * - 3 - permute cells and nodes.
9748 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9749 * caller is to delete this field using decrRef() as it is no more needed.
9750 * \throw If the MED file is not readable.
9751 * \throw If there is no mesh in the MED file.
9752 * \throw If no field values of the required parameters are available.
9754 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
9756 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9757 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9759 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtTopLevel : mismatch of type of field !");
9760 MCAuto<DataArray> arrOut;
9761 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arrOut,*contentNotNullBase());
9762 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9767 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
9768 * method should be called (getFieldOnMeshAtLevel for example).
9769 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
9771 * \param [in] iteration - the iteration number of a required time step.
9772 * \param [in] order - the iteration order number of required time step.
9773 * \param [in] mesh - the mesh the field is lying on
9774 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9775 * caller is to delete this field using decrRef() as it is no more needed.
9777 MEDCouplingFieldDouble *MEDFileFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
9779 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9780 MCAuto<DataArray> arrOut;
9781 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
9782 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9787 * Returns a new MEDCouplingFieldDouble of a given type, of a given time step, lying on
9789 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9790 * \param [in] type - a spatial discretization of interest.
9791 * \param [in] iteration - the iteration number of a required time step.
9792 * \param [in] order - the iteration order number of required time step.
9793 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9794 * \param [in] mesh - the supporting mesh.
9795 * \param [in] renumPol - specifies how to permute values of the result field according to
9796 * the optional numbers of cells and nodes, if any. The valid values are
9797 * - 0 - do not permute.
9798 * - 1 - permute cells.
9799 * - 2 - permute nodes.
9800 * - 3 - permute cells and nodes.
9802 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9803 * caller is to delete this field using decrRef() as it is no more needed.
9804 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
9805 * \throw If no field of \a this is lying on \a mesh.
9806 * \throw If no field values of the required parameters are available.
9808 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
9810 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
9811 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9813 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9814 MCAuto<DataArray> arrOut;
9815 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arrOut,*contentNotNullBase());
9816 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9821 * Returns a new MEDCouplingFieldDouble of given type, of a given time step, lying on a
9823 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9824 * \param [in] type - a spatial discretization of the new field.
9825 * \param [in] iteration - the iteration number of a required time step.
9826 * \param [in] order - the iteration order number of required time step.
9827 * \param [in] mesh - the supporting mesh.
9828 * \param [in] renumPol - specifies how to permute values of the result field according to
9829 * the optional numbers of cells and nodes, if any. The valid values are
9830 * - 0 - do not permute.
9831 * - 1 - permute cells.
9832 * - 2 - permute nodes.
9833 * - 3 - permute cells and nodes.
9835 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
9836 * caller is to delete this field using decrRef() as it is no more needed.
9837 * \throw If no field of \a this is lying on \a mesh.
9838 * \throw If no field values of the required parameters are available.
9840 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
9842 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9843 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9845 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field !");
9846 MCAuto<DataArray> arrOut;
9847 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arrOut,*contentNotNullBase());
9848 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9853 * This method has a close behaviour than MEDFileFieldMultiTS::getFieldAtLevel.
9854 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
9855 * This method is useful for MED2 file format when field on different mesh was autorized.
9857 MEDCouplingFieldDouble *MEDFileFieldMultiTS::getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol) const
9859 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9860 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9862 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldAtLevelOld : mismatch of type of field !");
9863 MCAuto<DataArray> arrOut;
9864 MCAuto<MEDCouplingFieldDouble> ret=myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arrOut,*contentNotNullBase());
9865 MEDFileField1TS::SetDataArrayDoubleInField(ret,arrOut);
9870 * Returns values and a profile of the field of a given type, of a given time step,
9871 * lying on a given support.
9872 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9873 * \param [in] type - a spatial discretization of the field.
9874 * \param [in] iteration - the iteration number of a required time step.
9875 * \param [in] order - the iteration order number of required time step.
9876 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
9877 * \param [in] mesh - the supporting mesh.
9878 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
9879 * field of interest lies on. If the field lies on all entities of the given
9880 * dimension, all ids in \a pfl are zero. The caller is to delete this array
9881 * using decrRef() as it is no more needed.
9882 * \param [in] glob - the global data storing profiles and localization.
9883 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
9884 * field. The caller is to delete this array using decrRef() as it is no more needed.
9885 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9886 * \throw If no field of \a this is lying on \a mesh.
9887 * \throw If no field values of the required parameters are available.
9889 DataArrayDouble *MEDFileFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
9891 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
9892 const MEDFileField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileField1TSWithoutSDA *>(&myF1TS);
9894 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldWithProfile : mismatch of type of field !");
9895 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
9896 return MEDFileField1TS::ReturnSafelyDataArrayDouble(ret);
9899 const MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull() const
9901 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9903 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the content pointer is null !");
9904 const MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(pt);
9906 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 !");
9910 MEDFileFieldMultiTSWithoutSDA *MEDFileFieldMultiTS::contentNotNull()
9912 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
9914 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::contentNotNull : the non const content pointer is null !");
9915 MEDFileFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileFieldMultiTSWithoutSDA *>(pt);
9917 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 !");
9922 * Adds a MEDCouplingFieldDouble to \a this as another time step. The underlying mesh of
9923 * the given field is checked if its elements are sorted suitable for writing to MED file
9924 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
9925 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9926 * \param [in] field - the field to add to \a this.
9927 * \throw If the name of \a field is empty.
9928 * \throw If the data array of \a field is not set.
9929 * \throw If existing time steps have different name or number of components than \a field.
9930 * \throw If the underlying mesh of \a field has no name.
9931 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
9933 void MEDFileFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field)
9935 const DataArrayDouble *arr=0;
9937 arr=field->getArray();
9938 contentNotNull()->appendFieldNoProfileSBT(field,arr,*this);
9942 * Adds a MEDCouplingFieldDouble to \a this as another time step.
9943 * The mesh support of input parameter \a field is ignored here, it can be NULL.
9944 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
9947 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
9948 * A new profile is added only if no equal profile is missing.
9949 * For more info, see \ref AdvMEDLoaderAPIFieldRW
9950 * \param [in] field - the field to add to \a this. The mesh support of field is ignored.
9951 * \param [in] mesh - the supporting mesh of \a field.
9952 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
9953 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
9954 * \throw If either \a field or \a mesh or \a profile has an empty name.
9955 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
9956 * \throw If the data array of \a field is not set.
9957 * \throw If the data array of \a this is already allocated but has different number of
9958 * components than \a field.
9959 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
9960 * \sa setFieldNoProfileSBT()
9962 void MEDFileFieldMultiTS::appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
9964 const DataArrayDouble *arr=0;
9966 arr=field->getArray();
9967 contentNotNull()->appendFieldProfile(field,arr,mesh,meshDimRelToMax,profile,*this);
9970 MEDFileFieldMultiTS::MEDFileFieldMultiTS()
9972 _content=new MEDFileFieldMultiTSWithoutSDA;
9975 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
9976 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
9979 catch(INTERP_KERNEL::Exception& e)
9982 MEDFileFieldMultiTS::MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
9983 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
9986 catch(INTERP_KERNEL::Exception& e)
9989 MEDFileFieldMultiTS::MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
9993 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
9995 return contentNotNull()->getFieldSplitedByType2(iteration,order,mname,types,typesF,pfls,locs);
9998 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10000 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10003 DataArrayDouble *MEDFileFieldMultiTS::getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
10005 return static_cast<DataArrayDouble *>(contentNotNull()->getUndergroundDataArrayExt(iteration,order,entries));
10008 MEDFileFieldMultiTS *MEDFileFieldMultiTS::buildNewEmpty() const
10010 return MEDFileFieldMultiTS::New();
10013 //= MEDFileAnyTypeFieldMultiTSIterator
10015 MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts):_fmts(fmts),_iter_id(0),_nb_iter(0)
10020 _nb_iter=fmts->getNumberOfTS();
10024 MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
10028 MEDFileAnyTypeField1TS *MEDFileAnyTypeFieldMultiTSIterator::nextt()
10030 if(_iter_id<_nb_iter)
10032 MEDFileAnyTypeFieldMultiTS *fmts(_fmts);
10034 return fmts->getTimeStepAtPos(_iter_id++);
10042 //= MEDFileIntFieldMultiTS
10045 * Returns a new empty instance of MEDFileFieldMultiTS.
10046 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10047 * is to delete this field using decrRef() as it is no more needed.
10049 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New()
10051 return new MEDFileIntFieldMultiTS;
10055 * Returns a new instance of MEDFileIntFieldMultiTS holding data of the first field
10056 * that has been read from a specified MED file.
10057 * \param [in] fileName - the name of the MED file to read.
10058 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10059 * is to delete this field using decrRef() as it is no more needed.
10060 * \throw If reading the file fails.
10062 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, bool loadAll)
10064 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10065 return New(fid,loadAll);
10068 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, bool loadAll)
10070 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,loadAll,0));
10071 ret->contentNotNull();//to check that content type matches with \a this type.
10076 * Returns a new instance of MEDFileIntFieldMultiTS holding data of a given field
10077 * that has been read from a specified MED file.
10078 * \param [in] fileName - the name of the MED file to read.
10079 * \param [in] fieldName - the name of the field to read.
10080 * \return MEDFileFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10081 * is to delete this field using decrRef() as it is no more needed.
10082 * \throw If reading the file fails.
10083 * \throw If there is no field named \a fieldName in the file.
10085 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
10087 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10088 return New(fid,fieldName,loadAll);
10091 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(med_idt fid, const std::string& fieldName, bool loadAll)
10093 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0));
10094 ret->contentNotNull();//to check that content type matches with \a this type.
10099 * Returns a new instance of MEDFileIntFieldMultiTS. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
10100 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
10102 * Returns a new instance of MEDFileIntFieldMultiTS holding either a shallow copy
10103 * of a given MEDFileIntFieldMultiTSWithoutSDA ( \a other ) or \a other itself.
10104 * \warning this is a shallow copy constructor
10105 * \param [in] other - a MEDFileIntField1TSWithoutSDA to copy.
10106 * \param [in] shallowCopyOfContent - if \c true, a shallow copy of \a other is created.
10107 * \return MEDFileIntFieldMultiTS * - a new instance of MEDFileIntFieldMultiTS. The caller
10108 * is to delete this field using decrRef() as it is no more needed.
10110 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent)
10112 return new MEDFileIntFieldMultiTS(other,shallowCopyOfContent);
10115 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10117 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10118 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10119 MCAuto<MEDFileIntFieldMultiTS> ret(new MEDFileIntFieldMultiTS(fid,fieldName,loadAll,0,ent));
10120 ret->contentNotNull();//to check that content type matches with \a this type.
10125 * This method performs a copy with datatype modification ( int32->float64 ) of \a this. The globals information are copied
10126 * following the given input policy.
10128 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
10129 * By default (true) the globals are deeply copied.
10130 * \return MEDFileFieldMultiTS * - a new object that is the result of the conversion of \a this to float64 field.
10132 MEDFileFieldMultiTS *MEDFileIntFieldMultiTS::convertToDouble(bool isDeepCpyGlobs) const
10134 MCAuto<MEDFileFieldMultiTS> ret;
10135 const MEDFileAnyTypeFieldMultiTSWithoutSDA *content(_content);
10138 const MEDFileIntFieldMultiTSWithoutSDA *contc=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(content);
10140 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::convertToInt : the content inside this is not INT32 ! This is incoherent !");
10141 MCAuto<MEDFileFieldMultiTSWithoutSDA> newc(contc->convertToDouble());
10142 ret=static_cast<MEDFileFieldMultiTS *>(MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent((MEDFileFieldMultiTSWithoutSDA *)newc));
10145 ret=MEDFileFieldMultiTS::New();
10147 ret->deepCpyGlobs(*this);
10149 ret->shallowCpyGlobs(*this);
10153 MEDFileAnyTypeFieldMultiTS *MEDFileIntFieldMultiTS::shallowCpy() const
10155 return new MEDFileIntFieldMultiTS(*this);
10158 void MEDFileIntFieldMultiTS::checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const
10161 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : input field1TS is NULL ! Impossible to check !");
10162 const MEDFileIntField1TS *f1tsC=dynamic_cast<const MEDFileIntField1TS *>(f1ts);
10164 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::checkCoherencyOfType : the input field1TS is not a INT32 type !");
10168 * This is the simplest version to fetch a field for MED structure. One drawback : if \a this is a complex field (multi spatial discretization inside a same field) this method will throw exception and more advance
10169 * method should be called (getFieldOnMeshAtLevel for example).
10170 * But for normal usage of field in MED file world this method is the most efficient to fetch data.
10172 * \param [in] iteration - the iteration number of a required time step.
10173 * \param [in] order - the iteration order number of required time step.
10174 * \param [in] mesh - the mesh the field is lying on
10175 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldInt. The
10176 * caller is to delete this field using decrRef() as it is no more needed.
10178 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::field(int iteration, int order, const MEDFileMesh *mesh) const
10180 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10181 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10183 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::field : mismatch of type of field expecting INT32 !");
10184 MCAuto<DataArray> arrOut;
10185 MCAuto<MEDCouplingFieldDouble> ret(myF1TS.fieldOnMesh(this,mesh,arrOut,*contentNotNullBase()));
10186 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arrOut));
10187 return ret2.retn();
10191 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10192 * mesh entities of a given dimension of the first mesh in MED file.
10193 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10194 * \param [in] type - a spatial discretization of interest.
10195 * \param [in] iteration - the iteration number of a required time step.
10196 * \param [in] order - the iteration order number of required time step.
10197 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10198 * \param [in] renumPol - specifies how to permute values of the result field according to
10199 * the optional numbers of cells and nodes, if any. The valid values are
10200 * - 0 - do not permute.
10201 * - 1 - permute cells.
10202 * - 2 - permute nodes.
10203 * - 3 - permute cells and nodes.
10205 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10206 * caller is to delete this field using decrRef() as it is no more needed.
10207 * \throw If the MED file is not readable.
10208 * \throw If there is no mesh in the MED file.
10209 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10210 * \throw If no field values of the required parameters are available.
10212 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol) const
10214 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10215 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10217 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtLevel : mismatch of type of field expecting INT32 !");
10218 MCAuto<DataArray> arr;
10219 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,std::string(),renumPol,this,arr,*contentNotNullBase()));
10220 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10221 return ret2.retn();
10225 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10226 * the top level cells of the first mesh in MED file.
10227 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10228 * \param [in] type - a spatial discretization of interest.
10229 * \param [in] iteration - the iteration number of a required time step.
10230 * \param [in] order - the iteration order number of required time step.
10231 * \param [in] renumPol - specifies how to permute values of the result field according to
10232 * the optional numbers of cells and nodes, if any. The valid values are
10233 * - 0 - do not permute.
10234 * - 1 - permute cells.
10235 * - 2 - permute nodes.
10236 * - 3 - permute cells and nodes.
10238 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10239 * caller is to delete this field using decrRef() as it is no more needed.
10240 * \throw If the MED file is not readable.
10241 * \throw If there is no mesh in the MED file.
10242 * \throw If no field values of the required parameters are available.
10244 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol) const
10246 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10247 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10249 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldAtTopLevel : mismatch of type of field ! INT32 expected !");
10250 MCAuto<DataArray> arr;
10251 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtTopLevel(type,std::string(),renumPol,this,arr,*contentNotNullBase()));
10252 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10253 return ret2.retn();
10257 * Returns a new MEDCouplingFieldInt of a given type, of a given time step, lying on
10259 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10260 * \param [in] type - a spatial discretization of interest.
10261 * \param [in] iteration - the iteration number of a required time step.
10262 * \param [in] order - the iteration order number of required time step.
10263 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10264 * \param [in] mesh - the supporting mesh.
10265 * \param [in] renumPol - specifies how to permute values of the result field according to
10266 * the optional numbers of cells and nodes, if any. The valid values are
10267 * - 0 - do not permute.
10268 * - 1 - permute cells.
10269 * - 2 - permute nodes.
10270 * - 3 - permute cells and nodes.
10272 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10273 * caller is to delete this field using decrRef() as it is no more needed.
10274 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
10275 * \throw If no field of \a this is lying on \a mesh.
10276 * \throw If no field values of the required parameters are available.
10278 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol) const
10280 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10281 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10283 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10284 MCAuto<DataArray> arr;
10285 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,this,mesh,arr,*contentNotNullBase()));
10286 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10287 return ret2.retn();
10291 * Returns a new MEDCouplingFieldInt of given type, of a given time step, lying on a
10293 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10294 * \param [in] type - a spatial discretization of the new field.
10295 * \param [in] iteration - the iteration number of a required time step.
10296 * \param [in] order - the iteration order number of required time step.
10297 * \param [in] mesh - the supporting mesh.
10298 * \param [out] arrOut - the DataArrayInt containing values of field.
10299 * \param [in] renumPol - specifies how to permute values of the result field according to
10300 * the optional numbers of cells and nodes, if any. The valid values are
10301 * - 0 - do not permute.
10302 * - 1 - permute cells.
10303 * - 2 - permute nodes.
10304 * - 3 - permute cells and nodes.
10306 * \return MEDCouplingFieldInt * - a new instance of MEDCouplingFieldDouble. The
10307 * caller is to delete this field using decrRef() as it is no more needed.
10308 * \throw If no field of \a this is lying on \a mesh.
10309 * \throw If no field values of the required parameters are available.
10311 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol) const
10313 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10314 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10316 throw INTERP_KERNEL::Exception("MEDFileFieldIntMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10317 MCAuto<DataArray> arr;
10318 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldOnMeshAtLevel(type,renumPol,this,mesh,0,0,arr,*contentNotNullBase()));
10319 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10320 return ret2.retn();
10324 * This method has a close behaviour than MEDFileIntFieldMultiTS::getFieldAtLevel.
10325 * This method is called 'old' because the user should give the mesh name he wants to use for it's field.
10326 * This method is useful for MED2 file format when field on different mesh was autorized.
10328 MEDCouplingFieldInt *MEDFileIntFieldMultiTS::getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol) const
10330 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS(contentNotNullBase()->getTimeStepEntry(iteration,order));
10331 const MEDFileIntField1TSWithoutSDA *myF1TSC(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS));
10333 throw INTERP_KERNEL::Exception("MEDFileFieldMultiTS::getFieldOnMeshAtLevel : mismatch of type of field ! INT32 expected !");
10334 MCAuto<DataArray> arr;
10335 MCAuto<MEDCouplingFieldDouble> ret(myF1TSC->getFieldAtLevel(type,meshDimRelToMax,mname,renumPol,this,arr,*contentNotNullBase()));
10336 MCAuto<MEDCouplingFieldInt> ret2(MEDFileIntField1TS::SetDataArrayDoubleInIntField(ret,arr));
10337 return ret2.retn();
10341 * Returns values and a profile of the field of a given type, of a given time step,
10342 * lying on a given support.
10343 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10344 * \param [in] type - a spatial discretization of the field.
10345 * \param [in] iteration - the iteration number of a required time step.
10346 * \param [in] order - the iteration order number of required time step.
10347 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
10348 * \param [in] mesh - the supporting mesh.
10349 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
10350 * field of interest lies on. If the field lies on all entities of the given
10351 * dimension, all ids in \a pfl are zero. The caller is to delete this array
10352 * using decrRef() as it is no more needed.
10353 * \param [in] glob - the global data storing profiles and localization.
10354 * \return DataArrayInt * - a new instance of DataArrayInt holding values of the
10355 * field. The caller is to delete this array using decrRef() as it is no more needed.
10356 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10357 * \throw If no field of \a this is lying on \a mesh.
10358 * \throw If no field values of the required parameters are available.
10360 DataArrayInt *MEDFileIntFieldMultiTS::getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const
10362 const MEDFileAnyTypeField1TSWithoutSDA& myF1TS=contentNotNullBase()->getTimeStepEntry(iteration,order);
10363 const MEDFileIntField1TSWithoutSDA *myF1TSC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(&myF1TS);
10365 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::getFieldWithProfile : mismatch of type of field ! INT32 expected !");
10366 MCAuto<DataArray> ret=myF1TSC->getFieldWithProfile(type,meshDimRelToMax,mesh,pfl,this,*contentNotNullBase());
10367 return MEDFileIntField1TS::ReturnSafelyDataArrayInt(ret);
10371 * Returns a new MEDFileIntField1TS holding data of a given time step of \a this field.
10372 * \param [in] pos - a time step id.
10373 * \return MEDFileIntField1TS * - a new instance of MEDFileIntField1TS. The caller is to
10374 * delete this field using decrRef() as it is no more needed.
10375 * \throw If \a pos is not a valid time step id.
10377 MEDFileIntField1TS *MEDFileIntFieldMultiTS::getTimeStepAtPos(int pos) const
10379 const MEDFileAnyTypeField1TSWithoutSDA *item=contentNotNullBase()->getTimeStepAtPos2(pos);
10382 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : field at pos #" << pos << " is null !";
10383 throw INTERP_KERNEL::Exception(oss.str());
10385 const MEDFileIntField1TSWithoutSDA *itemC=dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(item);
10388 MCAuto<MEDFileIntField1TS> ret=MEDFileIntField1TS::New(*itemC,false);
10389 ret->shallowCpyGlobs(*this);
10392 std::ostringstream oss; oss << "MEDFileIntFieldMultiTS::getTimeStepAtPos : type of field at pos #" << pos << " is not INT32 !";
10393 throw INTERP_KERNEL::Exception(oss.str());
10397 * Adds a MEDCouplingFieldInt to \a this as another time step. The underlying mesh of
10398 * the given field is checked if its elements are sorted suitable for writing to MED file
10399 * ("STB" stands for "Sort By Type"), if not, an exception is thrown.
10400 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10401 * \param [in] field - the field to add to \a this.
10402 * \throw If the name of \a field is empty.
10403 * \throw If the data array of \a field is not set.
10404 * \throw If existing time steps have different name or number of components than \a field.
10405 * \throw If the underlying mesh of \a field has no name.
10406 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
10408 void MEDFileIntFieldMultiTS::appendFieldNoProfileSBT(const MEDCouplingFieldInt *field)
10410 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10411 contentNotNull()->appendFieldNoProfileSBT(field2,field->getArray(),*this);
10415 * Adds a MEDCouplingFieldDouble to \a this as another time step.
10416 * The mesh support of input parameter \a field is ignored here, it can be NULL.
10417 * The support of field \a field is expected to be those computed with the input parameter \a mesh, \a meshDimRelToMax,
10420 * This method will check that the field based on the computed support is coherent. If not an exception will be thrown.
10421 * A new profile is added only if no equal profile is missing.
10422 * For more info, see \ref AdvMEDLoaderAPIFieldRW
10423 * \param [in] field - the field to add to \a this. The field double values and mesh support are ignored.
10424 * \param [in] arrOfVals - the values of the field \a field used.
10425 * \param [in] mesh - the supporting mesh of \a field.
10426 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on (useless if field spatial discretization is ON_NODES).
10427 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
10428 * \throw If either \a field or \a mesh or \a profile has an empty name.
10429 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
10430 * \throw If the data array of \a field is not set.
10431 * \throw If the data array of \a this is already allocated but has different number of
10432 * components than \a field.
10433 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
10434 * \sa setFieldNoProfileSBT()
10436 void MEDFileIntFieldMultiTS::appendFieldProfile(const MEDCouplingFieldInt *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
10438 MCAuto<MEDCouplingFieldDouble> field2(MEDFileIntField1TS::ConvertFieldIntToFieldDouble(field));
10439 contentNotNull()->appendFieldProfile(field2,field->getArray(),mesh,meshDimRelToMax,profile,*this);
10442 const MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull() const
10444 const MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10446 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the content pointer is null !");
10447 const MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10449 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 !");
10453 MEDFileIntFieldMultiTSWithoutSDA *MEDFileIntFieldMultiTS::contentNotNull()
10455 MEDFileAnyTypeFieldMultiTSWithoutSDA *pt(_content);
10457 throw INTERP_KERNEL::Exception("MEDFileIntFieldMultiTS::contentNotNull : the non const content pointer is null !");
10458 MEDFileIntFieldMultiTSWithoutSDA *ret=dynamic_cast<MEDFileIntFieldMultiTSWithoutSDA *>(pt);
10460 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 !");
10464 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS()
10466 _content=new MEDFileIntFieldMultiTSWithoutSDA;
10469 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileAnyTypeFieldMultiTS(other,shallowCopyOfContent)
10473 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
10474 try:MEDFileAnyTypeFieldMultiTS(fid,loadAll,ms)
10477 catch(INTERP_KERNEL::Exception& e)
10480 MEDFileIntFieldMultiTS::MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10481 try:MEDFileAnyTypeFieldMultiTS(fid,fieldName,loadAll,ms,entities)
10484 catch(INTERP_KERNEL::Exception& e)
10487 DataArrayInt *MEDFileIntFieldMultiTS::getUndergroundDataArray(int iteration, int order) const
10489 return static_cast<DataArrayInt *>(contentNotNull()->getUndergroundDataArray(iteration,order));
10492 MEDFileIntFieldMultiTS *MEDFileIntFieldMultiTS::buildNewEmpty() const
10494 return MEDFileIntFieldMultiTS::New();
10499 MEDFileFields *MEDFileFields::New()
10501 return new MEDFileFields;
10504 MEDFileFields *MEDFileFields::New(const std::string& fileName, bool loadAll)
10506 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10507 return New(fid,loadAll);
10510 MEDFileFields *MEDFileFields::NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll)
10512 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10513 return NewWithDynGT(fid,se,loadAll);
10516 MEDFileFields *MEDFileFields::NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll)
10519 throw INTERP_KERNEL::Exception("MEDFileFields::NewWithDynGT : null struct element pointer !");
10520 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entities(MEDFileEntities::BuildFrom(*se));
10521 return new MEDFileFields(fid,loadAll,0,entities);
10524 MEDFileFields *MEDFileFields::New(med_idt fid, bool loadAll)
10526 return new MEDFileFields(fid,loadAll,0,0);
10529 MEDFileFields *MEDFileFields::LoadPartOf(const std::string& fileName, bool loadAll, const MEDFileMeshes *ms)
10531 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10532 return new MEDFileFields(fid,loadAll,ms,0);
10535 MEDFileFields *MEDFileFields::LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll)
10537 MEDFileUtilities::CheckFileForRead(fileName);
10538 INTERP_KERNEL::AutoCppPtr<MEDFileEntities> ent(new MEDFileStaticEntities(entities));
10539 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
10540 return new MEDFileFields(fid,loadAll,0,ent);
10543 std::size_t MEDFileFields::getHeapMemorySizeWithoutChildren() const
10545 std::size_t ret(MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren());
10546 ret+=_fields.capacity()*sizeof(MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA>);
10550 std::vector<const BigMemoryObject *> MEDFileFields::getDirectChildrenWithNull() const
10552 std::vector<const BigMemoryObject *> ret;
10553 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10554 ret.push_back((const MEDFileAnyTypeFieldMultiTSWithoutSDA *)*it);
10558 MEDFileFields *MEDFileFields::deepCopy() const
10560 MCAuto<MEDFileFields> ret(shallowCpy());
10562 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10564 if((const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10565 ret->_fields[i]=(*it)->deepCopy();
10567 ret->deepCpyGlobs(*this);
10571 MEDFileFields *MEDFileFields::shallowCpy() const
10573 return new MEDFileFields(*this);
10577 * 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
10578 * 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.
10579 * If \a areThereSomeForgottenTS is set to true, only the sorted intersection of time steps present for all fields in \a this will be returned.
10581 * \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.
10582 * \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.
10584 * \sa MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
10586 std::vector< std::pair<int,int> > MEDFileFields::getCommonIterations(bool& areThereSomeForgottenTS) const
10588 std::set< std::pair<int,int> > s;
10589 bool firstShot=true;
10590 areThereSomeForgottenTS=false;
10591 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10593 if(!(const MEDFileAnyTypeFieldMultiTSWithoutSDA*)*it)
10595 std::vector< std::pair<int,int> > v=(*it)->getIterations();
10596 std::set< std::pair<int,int> > s1; std::copy(v.begin(),v.end(),std::inserter(s1,s1.end()));
10598 { s=s1; firstShot=false; }
10601 std::set< std::pair<int,int> > s2; std::set_intersection(s.begin(),s.end(),s1.begin(),s1.end(),std::inserter(s2,s2.end()));
10603 areThereSomeForgottenTS=true;
10607 std::vector< std::pair<int,int> > ret;
10608 std::copy(s.begin(),s.end(),std::back_insert_iterator< std::vector< std::pair<int,int> > >(ret));
10612 int MEDFileFields::getNumberOfFields() const
10614 return _fields.size();
10617 std::vector<std::string> MEDFileFields::getFieldsNames() const
10619 std::vector<std::string> ret(_fields.size());
10621 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10623 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f=(*it);
10626 ret[i]=f->getName();
10630 std::ostringstream oss; oss << "MEDFileFields::getFieldsNames : At rank #" << i << " field is not defined !";
10631 throw INTERP_KERNEL::Exception(oss.str());
10637 std::vector<std::string> MEDFileFields::getMeshesNames() const
10639 std::vector<std::string> ret;
10640 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10642 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10644 ret.push_back(cur->getMeshName());
10649 std::string MEDFileFields::simpleRepr() const
10651 std::ostringstream oss;
10652 oss << "(*****************)\n(* MEDFileFields *)\n(*****************)\n\n";
10657 void MEDFileFields::simpleRepr(int bkOffset, std::ostream& oss) const
10659 int nbOfFields(getNumberOfFields());
10660 std::string startLine(bkOffset,' ');
10661 oss << startLine << "There are " << nbOfFields << " fields in this :" << std::endl;
10663 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10665 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10668 oss << startLine << " - # "<< i << " has the following name : \"" << cur->getName() << "\"." << std::endl;
10672 oss << startLine << " - not defined !" << std::endl;
10676 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10678 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur=(*it);
10679 std::string chapter(17,'0'+i);
10680 oss << startLine << chapter << std::endl;
10683 cur->simpleRepr(bkOffset+2,oss,i);
10687 oss << startLine << " - not defined !" << std::endl;
10689 oss << startLine << chapter << std::endl;
10691 simpleReprGlobs(oss);
10694 MEDFileFields::MEDFileFields()
10698 MEDFileFields::MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
10699 try:MEDFileFieldGlobsReal(fid)
10701 int nbFields(MEDnField(fid));
10702 _fields.resize(nbFields);
10703 med_field_type typcha;
10704 for(int i=0;i<nbFields;i++)
10706 std::vector<std::string> infos;
10707 std::string fieldName,dtunit;
10708 int nbOfStep(MEDFileAnyTypeField1TS::LocateField2(fid,i,false,fieldName,typcha,infos,dtunit));
10713 _fields[i]=MEDFileFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10718 _fields[i]=MEDFileIntFieldMultiTSWithoutSDA::New(fid,fieldName.c_str(),typcha,infos,nbOfStep,dtunit,loadAll,ms,entities);
10723 std::ostringstream oss; oss << "constructor MEDFileFields(fileName) : file \'" << FileNameFromFID(fid) << "\' at pos #" << i << " field has name \'" << fieldName << "\' but the type of field is not in [MED_FLOAT64, MED_INT32] !";
10724 throw INTERP_KERNEL::Exception(oss.str());
10728 loadAllGlobals(fid);
10730 catch(INTERP_KERNEL::Exception& e)
10735 void MEDFileFields::writeLL(med_idt fid) const
10738 writeGlobals(fid,*this);
10739 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++,i++)
10741 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt=*it;
10744 std::ostringstream oss; oss << "MEDFileFields::write : at rank #" << i << "/" << _fields.size() << " field is empty !";
10745 throw INTERP_KERNEL::Exception(oss.str());
10747 elt->writeLL(fid,*this);
10752 * This method alloc the arrays and load potentially huge arrays contained in this field.
10753 * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
10754 * This method can be also called to refresh or reinit values from a file.
10756 * \throw If the fileName is not set or points to a non readable MED file.
10758 void MEDFileFields::loadArrays()
10760 if(getFileName().empty())
10761 throw INTERP_KERNEL::Exception("MEDFileFields::loadArrays : the structure does not come from a file !");
10762 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10763 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10765 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10767 elt->loadBigArraysRecursively(fid,*elt);
10772 * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
10773 * But once data loaded once, this method does nothing.
10775 * \throw If the fileName is not set or points to a non readable MED file.
10776 * \sa MEDFileFields::loadArrays, MEDFileFields::unloadArrays
10778 void MEDFileFields::loadArraysIfNecessary()
10780 if(!getFileName().empty())
10782 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
10783 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10785 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10787 elt->loadBigArraysRecursivelyIfNecessary(fid,*elt);
10793 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
10794 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
10795 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileFields::unloadArraysWithoutDataLoss instead.
10797 * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary, MEDFileFields::unloadArraysWithoutDataLoss
10799 void MEDFileFields::unloadArrays()
10801 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10803 MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
10805 elt->unloadArrays();
10810 * 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.
10811 * This method is the symetrical method of MEDFileFields::loadArraysIfNecessary.
10812 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
10814 * \sa MEDFileFields::loadArraysIfNecessary
10816 void MEDFileFields::unloadArraysWithoutDataLoss()
10818 if(!getFileName().empty())
10822 std::vector<std::string> MEDFileFields::getPflsReallyUsed() const
10824 std::vector<std::string> ret;
10825 std::set<std::string> ret2;
10826 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10828 std::vector<std::string> tmp=(*it)->getPflsReallyUsed2();
10829 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10830 if(ret2.find(*it2)==ret2.end())
10832 ret.push_back(*it2);
10839 std::vector<std::string> MEDFileFields::getLocsReallyUsed() const
10841 std::vector<std::string> ret;
10842 std::set<std::string> ret2;
10843 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10845 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10846 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
10847 if(ret2.find(*it2)==ret2.end())
10849 ret.push_back(*it2);
10856 std::vector<std::string> MEDFileFields::getPflsReallyUsedMulti() const
10858 std::vector<std::string> ret;
10859 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10861 std::vector<std::string> tmp((*it)->getPflsReallyUsedMulti2());
10862 ret.insert(ret.end(),tmp.begin(),tmp.end());
10867 std::vector<std::string> MEDFileFields::getLocsReallyUsedMulti() const
10869 std::vector<std::string> ret;
10870 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::const_iterator it=_fields.begin();it!=_fields.end();it++)
10872 std::vector<std::string> tmp((*it)->getLocsReallyUsed2());
10873 ret.insert(ret.end(),tmp.begin(),tmp.end());
10878 void MEDFileFields::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10880 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10881 (*it)->changePflsRefsNamesGen2(mapOfModif);
10884 void MEDFileFields::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
10886 for(std::vector< MCAuto< MEDFileAnyTypeFieldMultiTSWithoutSDA > >::iterator it=_fields.begin();it!=_fields.end();it++)
10887 (*it)->changeLocsRefsNamesGen2(mapOfModif);
10890 void MEDFileFields::resize(int newSize)
10892 _fields.resize(newSize);
10895 void MEDFileFields::pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields)
10897 for(std::vector<MEDFileAnyTypeFieldMultiTS *>::const_iterator it=fields.begin();it!=fields.end();it++)
10901 void MEDFileFields::pushField(MEDFileAnyTypeFieldMultiTS *field)
10904 throw INTERP_KERNEL::Exception("MEDFileFields::pushMesh : invalid input pointer ! should be different from 0 !");
10905 _fields.push_back(field->getContent());
10906 appendGlobs(*field,1e-12);
10909 void MEDFileFields::setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field)
10912 throw INTERP_KERNEL::Exception("MEDFileFields::setFieldAtPos : invalid input pointer ! should be different from 0 !");
10913 if(i>=(int)_fields.size())
10914 _fields.resize(i+1);
10915 _fields[i]=field->getContent();
10916 appendGlobs(*field,1e-12);
10919 void MEDFileFields::destroyFieldAtPos(int i)
10921 destroyFieldsAtPos(&i,&i+1);
10924 void MEDFileFields::destroyFieldsAtPos(const int *startIds, const int *endIds)
10926 std::vector<bool> b(_fields.size(),true);
10927 for(const int *i=startIds;i!=endIds;i++)
10929 if(*i<0 || *i>=(int)_fields.size())
10931 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
10932 throw INTERP_KERNEL::Exception(oss.str());
10936 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10938 for(std::size_t i=0;i<_fields.size();i++)
10940 fields[j++]=_fields[i];
10944 void MEDFileFields::destroyFieldsAtPos2(int bg, int end, int step)
10946 static const char msg[]="MEDFileFields::destroyFieldsAtPos2";
10947 int nbOfEntriesToKill(DataArrayInt::GetNumberOfItemGivenBESRelative(bg,end,step,msg));
10948 std::vector<bool> b(_fields.size(),true);
10950 for(int i=0;i<nbOfEntriesToKill;i++,k+=step)
10952 if(k<0 || k>=(int)_fields.size())
10954 std::ostringstream oss; oss << "MEDFileFields::destroyFieldsAtPos2 : Invalid given id in input (" << k << ") should be in [0," << _fields.size() << ") !";
10955 throw INTERP_KERNEL::Exception(oss.str());
10959 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(std::count(b.begin(),b.end(),true));
10961 for(std::size_t i=0;i<_fields.size();i++)
10963 fields[j++]=_fields[i];
10967 bool MEDFileFields::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
10970 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10972 MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
10974 ret=cur->changeMeshNames(modifTab) || ret;
10980 * \param [in] meshName the name of the mesh that will be renumbered.
10981 * \param [in] oldCode is of format returned by MEDCouplingUMesh::getDistributionOfTypes. And for each *i* oldCode[3*i+2] gives the position (MEDFileUMesh::PutInThirdComponentOfCodeOffset).
10982 * This code corresponds to the distribution of types in the corresponding mesh.
10983 * \param [in] newCode idem to param \a oldCode except that here the new distribution is given.
10984 * \param [in] renumO2N the old to new renumber array.
10985 * \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
10986 * field in \a this.
10988 bool MEDFileFields::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N)
10991 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
10993 MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts(*it);
10996 ret=fmts->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,*this) || ret;
11003 * Return an extraction of \a this using \a extractDef map to specify the extraction.
11004 * The keys of \a extractDef is level relative to max ext of \a mm mesh.
11006 * \return A new object that the caller is responsible to deallocate.
11008 MEDFileFields *MEDFileFields::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
11011 throw INTERP_KERNEL::Exception("MEDFileFields::extractPart : input mesh is NULL !");
11012 MCAuto<MEDFileFields> fsOut(MEDFileFields::New());
11013 int nbFields(getNumberOfFields());
11014 for(int i=0;i<nbFields;i++)
11016 MCAuto<MEDFileAnyTypeFieldMultiTS> fmts(getFieldAtPos(i));
11019 std::ostringstream oss; oss << "MEDFileFields::extractPart : at pos #" << i << " field is null !";
11020 throw INTERP_KERNEL::Exception(oss.str());
11022 MCAuto<MEDFileAnyTypeFieldMultiTS> fmtsOut(fmts->extractPart(extractDef,mm));
11023 fsOut->pushField(fmtsOut);
11025 return fsOut.retn();
11028 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldAtPos(int i) const
11030 if(i<0 || i>=(int)_fields.size())
11032 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : Invalid given id in input (" << i << ") should be in [0," << _fields.size() << ") !";
11033 throw INTERP_KERNEL::Exception(oss.str());
11035 const MEDFileAnyTypeFieldMultiTSWithoutSDA *fmts=_fields[i];
11038 MCAuto<MEDFileAnyTypeFieldMultiTS> ret;
11039 const MEDFileFieldMultiTSWithoutSDA *fmtsC(dynamic_cast<const MEDFileFieldMultiTSWithoutSDA *>(fmts));
11040 const MEDFileIntFieldMultiTSWithoutSDA *fmtsC2(dynamic_cast<const MEDFileIntFieldMultiTSWithoutSDA *>(fmts));
11042 ret=MEDFileFieldMultiTS::New(*fmtsC,false);
11044 ret=MEDFileIntFieldMultiTS::New(*fmtsC2,false);
11047 std::ostringstream oss; oss << "MEDFileFields::getFieldAtPos : At pos #" << i << " field is neither double (FLOAT64) nor integer (INT32) !";
11048 throw INTERP_KERNEL::Exception(oss.str());
11050 ret->shallowCpyGlobs(*this);
11055 * Return a shallow copy of \a this reduced to the fields ids defined in [ \a startIds , endIds ).
11056 * This method is accessible in python using __getitem__ with a list in input.
11057 * \return a new object that the caller should deal with.
11059 MEDFileFields *MEDFileFields::buildSubPart(const int *startIds, const int *endIds) const
11061 MCAuto<MEDFileFields> ret=shallowCpy();
11062 std::size_t sz=std::distance(startIds,endIds);
11063 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > fields(sz);
11065 for(const int *i=startIds;i!=endIds;i++,j++)
11067 if(*i<0 || *i>=(int)_fields.size())
11069 std::ostringstream oss; oss << "MEDFileFields::buildSubPart : Invalid given id in input (" << *i << ") should be in [0," << _fields.size() << ") !";
11070 throw INTERP_KERNEL::Exception(oss.str());
11072 fields[j]=_fields[*i];
11074 ret->_fields=fields;
11078 MEDFileAnyTypeFieldMultiTS *MEDFileFields::getFieldWithName(const std::string& fieldName) const
11080 return getFieldAtPos(getPosFromFieldName(fieldName));
11084 * This method removes, if any, fields in \a this having no time steps.
11085 * 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.
11087 * If false is returned \a this does not contain such fields. If false is returned this method can be considered as const.
11089 bool MEDFileFields::removeFieldsWithoutAnyTimeStep()
11091 std::vector<MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > newFields;
11092 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11094 const MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it);
11097 if(elt->getNumberOfTS()>0)
11098 newFields.push_back(*it);
11101 if(_fields.size()==newFields.size())
11108 * This method returns a new object containing part of \a this fields lying on mesh name specified by the input parameter \a meshName.
11109 * This method can be seen as a filter applied on \a this, that returns an object containing
11110 * 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
11111 * shallow copied from \a this.
11113 * \param [in] meshName - the name of the mesh on w
11114 * \return a new object that the caller should deal with.
11116 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const
11118 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11119 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11121 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11124 if(cur->getMeshName()==meshName)
11127 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> cur2(const_cast<MEDFileAnyTypeFieldMultiTSWithoutSDA *>(cur));
11128 ret->_fields.push_back(cur2);
11131 ret->shallowCpyOnlyUsedGlobs(*this);
11136 * This method returns a new object containing part of \a this fields lying ** exactly ** on the time steps specified by input parameter \a timeSteps.
11137 * Input time steps are specified using a pair of integer (iteration, order).
11138 * 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,
11139 * but for each multitimestep only the time steps in \a timeSteps are kept.
11140 * Typically the input parameter \a timeSteps comes from the call of MEDFileFields::getCommonIterations.
11142 * The returned object points to shallow copy of elements in \a this.
11144 * \param [in] timeSteps - the time steps given by a vector of pair of integers (iteration,order)
11145 * \throw If there is a field in \a this that is \b not defined on a time step in the input \a timeSteps.
11146 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps
11148 MEDFileFields *MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11150 MCAuto<MEDFileFields> ret(MEDFileFields::New());
11151 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11153 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11156 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisLyingOnSpecifiedTimeSteps(timeSteps);
11157 ret->_fields.push_back(elt);
11159 ret->shallowCpyOnlyUsedGlobs(*this);
11164 * \sa MEDFileFields::getCommonIterations, MEDFileFields::partOfThisLyingOnSpecifiedTimeSteps
11166 MEDFileFields *MEDFileFields::partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const
11168 MCAuto<MEDFileFields> ret=MEDFileFields::New();
11169 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11171 const MEDFileAnyTypeFieldMultiTSWithoutSDA *cur(*it);
11174 MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> elt=cur->partOfThisNotLyingOnSpecifiedTimeSteps(timeSteps);
11175 if(elt->getNumberOfTS()!=0)
11176 ret->_fields.push_back(elt);
11178 ret->shallowCpyOnlyUsedGlobs(*this);
11182 bool MEDFileFields::presenceOfStructureElements() const
11184 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11185 if((*it).isNotNull())
11186 if((*it)->presenceOfStructureElements())
11191 void MEDFileFields::killStructureElements()
11193 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11194 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11195 if((*it).isNotNull())
11197 if((*it)->presenceOfStructureElements())
11199 if(!(*it)->onlyStructureElements())
11201 (*it)->killStructureElements();
11202 ret.push_back(*it);
11207 ret.push_back(*it);
11213 void MEDFileFields::keepOnlyStructureElements()
11215 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11216 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11217 if((*it).isNotNull())
11219 if((*it)->presenceOfStructureElements())
11221 if(!(*it)->onlyStructureElements())
11222 (*it)->keepOnlyStructureElements();
11223 ret.push_back(*it);
11229 void MEDFileFields::keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName)
11231 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
11232 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::iterator it=_fields.begin();it!=_fields.end();it++)
11233 if((*it).isNotNull())
11235 if((*it)->getMeshName()!=meshName)
11237 std::vector< std::pair<std::string,std::string> > ps;
11238 (*it)->getMeshSENames(ps);
11239 std::pair<std::string,std::string> p(meshName,seName);
11240 if(std::find(ps.begin(),ps.end(),p)!=ps.end())
11241 (*it)->keepOnlyOnSE(seName);
11242 ret.push_back(*it);
11247 void MEDFileFields::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
11249 for(std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> >::const_iterator it=_fields.begin();it!=_fields.end();it++)
11250 if((*it).isNotNull())
11251 (*it)->getMeshSENames(ps);
11254 MCAuto<MEDFileFields> MEDFileFields::partOfThisOnStructureElements() const
11256 MCAuto<MEDFileFields> ret(deepCopy());
11257 ret->keepOnlyStructureElements();
11261 MCAuto<MEDFileFields> MEDFileFields::partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const
11263 MCAuto<MEDFileFields> ret(deepCopy());
11264 ret->keepOnlyOnMeshSE(meshName,seName);
11268 void MEDFileFields::aggregate(const MEDFileFields& other)
11270 int nbFieldsToAdd(other.getNumberOfFields());
11271 std::vector<std::string> fsn(getFieldsNames());
11272 for(int i=0;i<nbFieldsToAdd;i++)
11274 MCAuto<MEDFileAnyTypeFieldMultiTS> elt(other.getFieldAtPos(i));
11275 std::string name(elt->getName());
11276 if(std::find(fsn.begin(),fsn.end(),name)!=fsn.end())
11278 std::ostringstream oss; oss << "MEDFileFields::aggregate : name \"" << name << "\" already appears !";
11279 throw INTERP_KERNEL::Exception(oss.str());
11285 MEDFileFieldsIterator *MEDFileFields::iterator()
11287 return new MEDFileFieldsIterator(this);
11290 int MEDFileFields::getPosFromFieldName(const std::string& fieldName) const
11292 std::string tmp(fieldName);
11293 std::vector<std::string> poss;
11294 for(std::size_t i=0;i<_fields.size();i++)
11296 const MEDFileAnyTypeFieldMultiTSWithoutSDA *f(_fields[i]);
11299 std::string fname(f->getName());
11303 poss.push_back(fname);
11306 std::ostringstream oss; oss << "MEDFileFields::getPosFromFieldName : impossible to find field '" << tmp << "' in this ! Possibilities are : ";
11307 std::copy(poss.begin(),poss.end(),std::ostream_iterator<std::string>(oss,", "));
11309 throw INTERP_KERNEL::Exception(oss.str());
11312 MEDFileFieldsIterator::MEDFileFieldsIterator(MEDFileFields *fs):_fs(fs),_iter_id(0),_nb_iter(0)
11317 _nb_iter=fs->getNumberOfFields();
11321 MEDFileFieldsIterator::~MEDFileFieldsIterator()
11325 MEDFileAnyTypeFieldMultiTS *MEDFileFieldsIterator::nextt()
11327 if(_iter_id<_nb_iter)
11329 MEDFileFields *fs(_fs);
11331 return fs->getFieldAtPos(_iter_id++);