1 // Copyright (C) 2017-2019 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 (EDF R&D)
21 #include "MEDFileField1TS.hxx"
22 #include "MEDFileFieldVisitor.hxx"
23 #include "MEDFileSafeCaller.txx"
24 #include "MEDLoaderBase.hxx"
25 #include "MEDFileField.txx"
27 #include "MEDCouplingFieldTemplate.hxx"
28 #include "MEDCouplingFieldDouble.hxx"
30 using namespace MEDCoupling;
32 extern INTERP_KERNEL::NormalizedCellType typmai2[MED_N_CELL_FIXED_GEO];
34 template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA<int>;
35 template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA<float>;
36 template class MEDCoupling::MEDFileField1TSTemplateWithoutSDA<double>;
37 template class MEDCoupling::MEDFileField1TSNDTemplateWithoutSDA<int>;
38 template class MEDCoupling::MEDFileField1TSNDTemplateWithoutSDA<float>;
39 template class MEDCoupling::MEDFileTemplateField1TS<int>;
40 template class MEDCoupling::MEDFileTemplateField1TS<float>;
41 template class MEDCoupling::MEDFileTemplateField1TS<double>;
42 template class MEDCoupling::MEDFileNDTemplateField1TS<int>;
43 template class MEDCoupling::MEDFileNDTemplateField1TS<float>;
45 const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
46 const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
47 const char MEDFileFloatField1TSWithoutSDA::TYPE_STR[]="FLOAT32";
49 //= MEDFileAnyTypeField1TSWithoutSDA
51 void MEDFileAnyTypeField1TSWithoutSDA::deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other)
53 _field_per_mesh.resize(other._field_per_mesh.size());
55 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=other._field_per_mesh.begin();it!=other._field_per_mesh.end();it++,i++)
57 if((const MEDFileFieldPerMesh *)*it)
58 _field_per_mesh[i]=(*it)->deepCopy(this);
62 void MEDFileAnyTypeField1TSWithoutSDA::accept(MEDFileFieldVisitor& visitor) const
64 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
67 visitor.newMeshEntry(*it);
68 (*it)->accept(visitor);
69 visitor.endMeshEntry(*it);
74 * Prints a string describing \a this field into a stream. This string is outputted
75 * by \c print Python command.
76 * \param [in] bkOffset - number of white spaces printed at the beginning of each line.
77 * \param [in,out] oss - the out stream.
78 * \param [in] f1tsId - the field index within a MED file. If \a f1tsId < 0, the tiny
79 * info id printed, else, not.
81 void MEDFileAnyTypeField1TSWithoutSDA::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
83 std::string startOfLine(bkOffset,' ');
84 oss << startOfLine << "Field ";
86 oss << "[Type=" << getTypeStr() << "] with name \"" << getName() << "\" ";
87 oss << "on one time Step ";
89 oss << "(" << f1tsId << ") ";
90 oss << "on iteration=" << _iteration << " order=" << _order << "." << std::endl;
91 oss << startOfLine << "Time attached is : " << _dt << " [" << _dt_unit << "]." << std::endl;
92 const DataArray *arr=getUndergroundDataArray();
95 const std::vector<std::string> &comps=arr->getInfoOnComponents();
98 oss << startOfLine << "Field has " << comps.size() << " components with the following infos :" << std::endl;
99 for(std::vector<std::string>::const_iterator it=comps.begin();it!=comps.end();it++)
100 oss << startOfLine << " - \"" << (*it) << "\"" << std::endl;
102 if(arr->isAllocated())
104 oss << startOfLine << "Whole field contains " << arr->getNumberOfTuples() << " tuples." << std::endl;
107 oss << startOfLine << "The array of the current field has not allocated yet !" << std::endl;
111 oss << startOfLine << "Field infos are empty ! Not defined yet !" << std::endl;
113 oss << startOfLine << "----------------------" << std::endl;
114 if(!_field_per_mesh.empty())
117 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it2=_field_per_mesh.begin();it2!=_field_per_mesh.end();it2++,i++)
119 const MEDFileFieldPerMesh *cur=(*it2);
121 cur->simpleRepr(bkOffset,oss,i);
123 oss << startOfLine << "Field per mesh #" << i << " is not defined !" << std::endl;
128 oss << startOfLine << "Field is not defined on any meshes !" << std::endl;
130 oss << startOfLine << "----------------------" << std::endl;
133 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitComponents() const
135 const DataArray *arr(getUndergroundDataArray());
137 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitComponents : no array defined !");
138 int nbOfCompo=arr->getNumberOfComponents();
139 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfCompo);
140 for(int i=0;i<nbOfCompo;i++)
143 std::vector<int> v(1,i);
144 MCAuto<DataArray> arr2=arr->keepSelectedComponents(v);
145 ret[i]->setArray(arr2);
150 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order):MEDFileFieldNameScope(fieldName,meshName),_iteration(iteration),_order(order),_csit(csit),_nb_of_tuples_to_be_allocated(-2)
154 MEDFileAnyTypeField1TSWithoutSDA::MEDFileAnyTypeField1TSWithoutSDA():_iteration(-1),_order(-1),_dt(0.),_csit(-1),_nb_of_tuples_to_be_allocated(-1)
159 * Returns the maximal dimension of supporting elements. Returns -2 if \a this is
160 * empty. Returns -1 if this in on nodes.
161 * \return int - the dimension of \a this.
163 int MEDFileAnyTypeField1TSWithoutSDA::getDimension() const
166 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
167 (*it)->getDimension(ret);
171 bool MEDFileAnyTypeField1TSWithoutSDA::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
174 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
176 MEDFileFieldPerMesh *cur(*it);
178 ret=cur->changeMeshNames(modifTab) || ret;
184 * Returns the number of iteration of the state of underlying mesh.
185 * \return int - the iteration number.
186 * \throw If \c _field_per_mesh.empty()
188 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIteration() const
190 if(_field_per_mesh.empty())
191 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshIteration : No field set !");
192 return _field_per_mesh[0]->getMeshIteration();
196 * Returns the order number of iteration of the state of underlying mesh.
197 * \return int - the order number.
198 * \throw If \c _field_per_mesh.empty()
200 int MEDFileAnyTypeField1TSWithoutSDA::getMeshOrder() const
202 if(_field_per_mesh.empty())
203 throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::getMeshOrder : No field set !");
204 return _field_per_mesh[0]->getMeshOrder();
208 * Checks if \a this field is tagged by a given iteration number and a given
209 * iteration order number.
210 * \param [in] iteration - the iteration number of interest.
211 * \param [in] order - the iteration order number of interest.
212 * \return bool - \c true if \a this->getIteration() == \a iteration &&
213 * \a this->getOrder() == \a order.
215 bool MEDFileAnyTypeField1TSWithoutSDA::isDealingTS(int iteration, int order) const
217 return iteration==_iteration && order==_order;
221 * Returns number of iteration and order number of iteration when
222 * \a this field has been calculated.
223 * \return std::pair<int,int> - a pair of the iteration number and the iteration
226 std::pair<int,int> MEDFileAnyTypeField1TSWithoutSDA::getDtIt() const
228 std::pair<int,int> p;
234 * Returns number of iteration and order number of iteration when
235 * \a this field has been calculated.
236 * \param [in,out] p - a pair returning the iteration number and the iteration
239 void MEDFileAnyTypeField1TSWithoutSDA::fillIteration(std::pair<int,int>& p) const
246 * Returns all types of spatial discretization of \a this field.
247 * \param [in,out] types - a sequence of types of \a this field.
249 void MEDFileAnyTypeField1TSWithoutSDA::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
251 std::set<TypeOfField> types2;
252 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
254 (*it)->fillTypesOfFieldAvailable(types2);
256 std::back_insert_iterator< std::vector<TypeOfField> > bi(types);
257 std::copy(types2.begin(),types2.end(),bi);
261 * Returns all types of spatial discretization of \a this field.
262 * \return std::vector<TypeOfField> - a sequence of types of spatial discretization
265 std::vector<TypeOfField> MEDFileAnyTypeField1TSWithoutSDA::getTypesOfFieldAvailable() const
267 std::vector<TypeOfField> ret;
268 fillTypesOfFieldAvailable(ret);
272 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsed2() const
274 std::vector<std::string> ret;
275 std::set<std::string> ret2;
276 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
278 std::vector<std::string> tmp=(*it)->getPflsReallyUsed();
279 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
280 if(ret2.find(*it2)==ret2.end())
289 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsed2() const
291 std::vector<std::string> ret;
292 std::set<std::string> ret2;
293 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
295 std::vector<std::string> tmp=(*it)->getLocsReallyUsed();
296 for(std::vector<std::string>::const_iterator it2=tmp.begin();it2!=tmp.end();it2++)
297 if(ret2.find(*it2)==ret2.end())
306 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getPflsReallyUsedMulti2() const
308 std::vector<std::string> ret;
309 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
311 std::vector<std::string> tmp=(*it)->getPflsReallyUsedMulti();
312 ret.insert(ret.end(),tmp.begin(),tmp.end());
317 std::vector<std::string> MEDFileAnyTypeField1TSWithoutSDA::getLocsReallyUsedMulti2() const
319 std::vector<std::string> ret;
320 std::set<std::string> ret2;
321 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
323 std::vector<std::string> tmp=(*it)->getLocsReallyUsedMulti();
324 ret.insert(ret.end(),tmp.begin(),tmp.end());
329 void MEDFileAnyTypeField1TSWithoutSDA::changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
331 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
332 (*it)->changePflsRefsNamesGen(mapOfModif);
335 void MEDFileAnyTypeField1TSWithoutSDA::changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
337 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
338 (*it)->changeLocsRefsNamesGen(mapOfModif);
342 * Returns all attributes of parts of \a this field lying on a given mesh.
343 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
344 * item of every of returned sequences refers to the _i_-th part of \a this field.
345 * Thus all sequences returned by this method are of the same length equal to number
346 * of different types of supporting entities.<br>
347 * A field part can include sub-parts with several different spatial discretizations,
348 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
349 * for example. Hence, some of the returned sequences contains nested sequences, and an item
350 * of a nested sequence corresponds to a type of spatial discretization.<br>
351 * This method allows for iteration over MEDFile DataStructure without any overhead.
352 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
353 * for the case with only one underlying mesh. (Actually, the number of meshes is
354 * not checked if \a mname == \c NULL).
355 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
356 * a field part is returned.
357 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
358 * This sequence is of the same length as \a types.
359 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
360 * discretization. A profile name can be empty.
361 * Length of this and of nested sequences is the same as that of \a typesF.
362 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
363 * discretization. A localization name can be empty.
364 * Length of this and of nested sequences is the same as that of \a typesF.
365 * \return std::vector< std::vector< std::pair<int,int> > > - a sequence holding a range
366 * of ids of tuples within the data array, per each type of spatial
367 * discretization within one mesh entity type.
368 * Length of this and of nested sequences is the same as that of \a typesF.
369 * \throw If no field is lying on \a mname.
371 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
373 if(_field_per_mesh.empty())
374 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
375 return _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
379 * Returns dimensions of mesh elements \a this field lies on. The returned value is a
380 * maximal absolute dimension and values returned via the out parameter \a levs are
381 * dimensions relative to the maximal absolute dimension. <br>
382 * This method is designed for MEDFileField1TS instances that have a discretization
383 * \ref MEDCoupling::ON_CELLS "ON_CELLS",
384 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT",
385 * \ref MEDCoupling::ON_GAUSS_NE "ON_GAUSS_NE".
386 * Only these 3 discretizations will be taken into account here. If \a this is
387 * \ref MEDCoupling::ON_NODES "ON_NODES", -1 is returned and \a levs are empty.<br>
388 * This method is useful to make the link between the dimension of the underlying mesh
389 * and the levels of \a this, because it is possible that the highest dimension of \a this
390 * field is not equal to the dimension of the underlying mesh.
392 * Let's consider the following case:
393 * - mesh \a m1 has a meshDimension 3 and has non empty levels [0,-1,-2] with elements
394 * TETRA4, HEXA8, TRI3 and SEG2.
395 * - field \a f1 lies on \a m1 and is defined on 3D and 1D elements TETRA4 and SEG2.
396 * - field \a f2 lies on \a m1 and is defined on 2D and 1D elements TRI3 and SEG2.
398 * In this case \a f1->getNonEmptyLevels() returns (3,[0,-2]) and \a
399 * f2->getNonEmptyLevels() returns (2,[0,-1]). <br>
400 * The returned values can be used for example to retrieve a MEDCouplingFieldDouble lying
401 * on elements of a certain relative level by calling getFieldAtLevel(). \a meshDimRelToMax
402 * parameter of getFieldAtLevel() is computed basing on the returned values as this:
403 * <em> meshDimRelToMax = absDim - meshDim + relativeLev </em>.
405 * to retrieve the highest level of
406 * \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+0 ); // absDim - meshDim + relativeLev</em><br>
407 * to retrieve the lowest level of \a f1: <em>f1->getFieldAtLevel( ON_CELLS, 3-3+(-2) );</em><br>
408 * to retrieve the highest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+0 );</em><br>
409 * to retrieve the lowest level of \a f2: <em>f2->getFieldAtLevel( ON_CELLS, 2-3+(-1) )</em>.
410 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
411 * for the case with only one underlying mesh. (Actually, the number of meshes is
412 * not checked if \a mname == \c NULL).
413 * \param [in,out] levs - a sequence returning the dimensions relative to the maximal
414 * absolute one. They are in decreasing order. This sequence is cleared before
416 * \return int - the maximal absolute dimension of elements \a this fields lies on.
417 * \throw If no field is lying on \a mname.
419 int MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
422 std::vector<INTERP_KERNEL::NormalizedCellType> types;
423 std::vector< std::vector<TypeOfField> > typesF;
424 std::vector< std::vector<std::string> > pfls, locs;
425 if(_field_per_mesh.empty())
426 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getNonEmptyLevels : This is empty !");
427 _field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
429 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getNonEmptyLevels : 'this' is empty !");
430 std::set<INTERP_KERNEL::NormalizedCellType> st(types.begin(),types.end());
431 if(st.size()==1 && (*st.begin())==INTERP_KERNEL::NORM_ERROR)
433 st.erase(INTERP_KERNEL::NORM_ERROR);
435 for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=st.begin();it!=st.end();it++)
437 const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(*it);
438 ret1.insert((int)cm.getDimension());
440 int ret=*std::max_element(ret1.begin(),ret1.end());
441 std::copy(ret1.rbegin(),ret1.rend(),std::back_insert_iterator<std::vector<int> >(levs));
442 std::transform(levs.begin(),levs.end(),levs.begin(),std::bind2nd(std::plus<int>(),-ret));
446 void MEDFileAnyTypeField1TSWithoutSDA::convertMedBallIntoClassic()
448 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it<_field_per_mesh.end();it++)
449 if((*it).isNotNull())
450 (*it)->convertMedBallIntoClassic();
453 void MEDFileAnyTypeField1TSWithoutSDA::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
456 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : null pfl !");
457 std::string name(pfl->getName());
458 pfl->checkAllocated();
459 if(pfl->getNumberOfComponents()!=1)
460 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : non mono compo array !");
462 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : empty pfl name !");
463 if(_field_per_mesh.size()!=1)
464 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single mesh supported !");
465 MCAuto<MEDFileFieldPerMesh> fpm(_field_per_mesh[0]);
467 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : only single not null mesh supported !");
468 MEDFileFieldPerMeshPerTypePerDisc *disc(fpm->getLeafGivenTypeAndLocId(ct,0));
469 if(disc->getType()!=tof)
470 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : error !");
471 int s(disc->getStart()),e(disc->getEnd()),nt(pfl->getNumberOfTuples());
472 DataArray *arr(getUndergroundDataArray());
473 int nt2(arr->getNumberOfTuples()),delta((e-s)-nt);
475 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::makeReduction : internal error !");
476 MCAuto<DataArray> arr0(arr->selectByTupleIdSafeSlice(0,s,1)),arr1(arr->selectByTupleIdSafeSlice(s,e,1)),arr2(arr->selectByTupleIdSafeSlice(e,nt2,1));
477 MCAuto<DataArray> arr11(arr1->selectByTupleIdSafe(pfl->begin(),pfl->end()));
478 MCAuto<DataArray> arrOut(arr->buildNewEmptyInstance());
479 arrOut->alloc(nt2-delta,arr->getNumberOfComponents());
480 arrOut->copyStringInfoFrom(*arr);
481 arrOut->setContigPartOfSelectedValuesSlice(0,arr0,0,s,1);
482 arrOut->setContigPartOfSelectedValuesSlice(s,arr11,0,nt,1);
483 arrOut->setContigPartOfSelectedValuesSlice(e-delta,arr2,0,nt2-e,1);
485 disc->setEnd(e-delta);
486 disc->setProfile(name);
490 * \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.
491 * \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.
492 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
493 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
495 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
497 if(_field_per_mesh.empty())
498 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
499 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
503 * \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.
504 * \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.
505 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
506 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
508 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
510 if(_field_per_mesh.empty())
511 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getLeafGivenMeshAndTypeAndLocId : This is empty !");
512 return _field_per_mesh[0]->getLeafGivenTypeAndLocId(typ,locId);
516 * \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.
518 int MEDFileAnyTypeField1TSWithoutSDA::getMeshIdFromMeshName(const std::string& mName) const
520 if(_field_per_mesh.empty())
521 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No field set !");
524 std::string mName2(mName);
526 std::vector<std::string> msg;
527 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++,ret++)
528 if(mName2==(*it)->getMeshName())
531 msg.push_back((*it)->getMeshName());
532 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getMeshIdFromMeshName : No such mesh \"" << mName2 << "\" as underlying mesh of field \"" << getName() << "\" !\n";
533 oss << "Possible meshes are : ";
534 for(std::vector<std::string>::const_iterator it2=msg.begin();it2!=msg.end();it2++)
535 oss << "\"" << (*it2) << "\" ";
536 throw INTERP_KERNEL::Exception(oss.str());
539 int MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary(const MEDCouplingMesh *mesh)
542 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::addNewEntryIfNecessary : input mesh is NULL !");
543 std::string tmp(mesh->getName());
545 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::addNewEntryIfNecessary : empty mesh name ! unsupported by MED file !");
547 std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();
549 for(;it!=_field_per_mesh.end();it++,i++)
551 if((*it)->getMeshName()==tmp)
554 int sz=_field_per_mesh.size();
555 _field_per_mesh.resize(sz+1);
556 _field_per_mesh[sz]=MEDFileFieldPerMesh::New(this,mesh);
560 bool MEDFileAnyTypeField1TSWithoutSDA::renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N,
561 MEDFileFieldGlobsReal& glob)
564 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
566 MEDFileFieldPerMesh *fpm(*it);
568 ret=fpm->renumberEntitiesLyingOnMesh(meshName,oldCode,newCode,renumO2N,glob) || ret;
574 * This method splits \a this into several sub-parts so that each sub parts have exactly one spatial discretization. This method implements the minimal
575 * splitting that leads to single spatial discretization of this.
577 * \sa splitMultiDiscrPerGeoTypes
579 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitDiscretizations() const
581 std::vector<INTERP_KERNEL::NormalizedCellType> types;
582 std::vector< std::vector<TypeOfField> > typesF;
583 std::vector< std::vector<std::string> > pfls,locs;
584 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
585 std::set<TypeOfField> allEnt;
586 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++)
587 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
589 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(allEnt.size());
590 std::set<TypeOfField>::const_iterator it3(allEnt.begin());
591 for(std::size_t i=0;i<allEnt.size();i++,it3++)
593 std::vector< std::pair<int,int> > its;
595 int newLgth(ret[i]->keepOnlySpatialDiscretization(*it3,its));
596 ret[i]->updateData(newLgth,its);
602 * This method performs a sub splitting as splitDiscretizations does but finer. This is the finest splitting level that can be done.
603 * This method implements the minimal splitting so that each returned elements are mono Gauss discretization per geometric type.
605 * \sa splitDiscretizations
607 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes() const
609 std::vector<INTERP_KERNEL::NormalizedCellType> types;
610 std::vector< std::vector<TypeOfField> > typesF;
611 std::vector< std::vector<std::string> > pfls,locs;
612 std::vector< std::vector<std::pair<int,int> > > bgEnd(getFieldSplitedByType(getMeshName().c_str(),types,typesF,pfls,locs));
613 std::set<TypeOfField> allEnt;
614 std::size_t nbOfMDPGT(0),ii(0);
615 for(std::vector< std::vector<TypeOfField> >::const_iterator it1=typesF.begin();it1!=typesF.end();it1++,ii++)
617 nbOfMDPGT=std::max(nbOfMDPGT,locs[ii].size());
618 for(std::vector<TypeOfField>::const_iterator it2=(*it1).begin();it2!=(*it1).end();it2++)
622 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : this field is expected to be defined only on one spatial discretization !");
624 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::splitMultiDiscrPerGeoTypes : empty field !");
627 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret0(1);
628 ret0[0]=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(this); this->incrRef();
631 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > ret(nbOfMDPGT);
632 for(std::size_t i=0;i<nbOfMDPGT;i++)
634 std::vector< std::pair<int,int> > its;
636 int newLgth(ret[i]->keepOnlyGaussDiscretization(i,its));
637 ret[i]->updateData(newLgth,its);
642 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its)
644 int globalCounter(0);
645 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
646 (*it)->keepOnlySpatialDiscretization(tof,globalCounter,its);
647 return globalCounter;
650 int MEDFileAnyTypeField1TSWithoutSDA::keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its)
652 int globalCounter(0);
653 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
654 (*it)->keepOnlyGaussDiscretization(idOfDisc,globalCounter,its);
655 return globalCounter;
658 void MEDFileAnyTypeField1TSWithoutSDA::updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops)
660 if(_nb_of_tuples_to_be_allocated>=0)
662 _nb_of_tuples_to_be_allocated=newLgth;
663 const DataArray *oldArr(getUndergroundDataArray());
666 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
667 newArr->setInfoAndChangeNbOfCompo(oldArr->getInfoOnComponents());
669 _nb_of_tuples_to_be_allocated=newLgth;//force the _nb_of_tuples_to_be_allocated because setArray has been used specialy
673 if(_nb_of_tuples_to_be_allocated==-1)
675 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
677 const DataArray *oldArr(getUndergroundDataArray());
678 if(!oldArr || !oldArr->isAllocated())
679 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 1 !");
680 MCAuto<DataArray> newArr(createNewEmptyDataArrayInstance());
681 newArr->alloc(newLgth,getNumberOfComponents());
683 newArr->copyStringInfoFrom(*oldArr);
685 for(std::vector< std::pair<int,int> >::const_iterator it=oldStartStops.begin();it!=oldStartStops.end();it++)
687 if((*it).second<(*it).first)
688 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : the range in the leaves was invalid !");
689 newArr->setContigPartOfSelectedValuesSlice(pos,oldArr,(*it).first,(*it).second,1);
690 pos+=(*it).second-(*it).first;
695 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::updateData : internal error 2 !");
698 void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const
700 if(_field_per_mesh.empty())
701 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : empty field !");
702 if(_field_per_mesh.size()>1)
703 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::writeLL : In MED3.0 mode in writing mode only ONE underlying mesh supported !");
704 _field_per_mesh[0]->copyOptionsFrom(opts);
705 _field_per_mesh[0]->writeLL(fid,nasc);
709 * MED file does not support ' ' at the end of the field name. This method corrects the possibly invalid input \a nonCorrectFieldName to a correct one by right stripping input.
711 std::string MEDFileAnyTypeField1TSWithoutSDA::FieldNameToMEDFileConvention(const std::string& nonCorrectFieldName)
713 std::string::size_type pos0(nonCorrectFieldName.find_last_not_of(' '));
714 if(pos0==std::string::npos)
715 return nonCorrectFieldName;
716 if(pos0+1==nonCorrectFieldName.length())
717 return nonCorrectFieldName;
718 return nonCorrectFieldName.substr(0,pos0+1);
722 * 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.
723 * If false is returned the memory allocation is not required.
725 bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile()
727 if(_nb_of_tuples_to_be_allocated>=0)
729 getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents());
730 _nb_of_tuples_to_be_allocated=-2;
733 if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3)
735 if(_nb_of_tuples_to_be_allocated==-1)
736 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !");
737 if(_nb_of_tuples_to_be_allocated<-3)
738 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
739 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
742 void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
746 med_int meshnumdt,meshnumit;
747 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
751 INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
752 MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit)); // to check with Adrien for legacy MED files
754 //MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt,&meshnumdt,&meshnumit));
755 if(_iteration!=numdt || _order!=numit)
756 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
757 _field_per_mesh.resize(1);
762 mm=ms->getMeshWithName(getMeshName());
765 _field_per_mesh[0]=MEDFileFieldPerMesh::NewOnRead(fid,this,0,meshnumdt,meshnumit,nasc,mm,entities);
766 _nb_of_tuples_to_be_allocated=0;
767 _field_per_mesh[0]->loadOnlyStructureOfDataRecursively(fid,_nb_of_tuples_to_be_allocated,nasc);
770 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc)
772 allocIfNecessaryTheArrayToReceiveDataFromFile();
773 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
774 (*it)->loadBigArraysRecursively(fid,nasc);
777 void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc)
779 if(allocIfNecessaryTheArrayToReceiveDataFromFile())
780 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
781 (*it)->loadBigArraysRecursively(fid,nasc);
784 void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
786 loadOnlyStructureOfDataRecursively(fid,nasc,ms,entities);
787 loadBigArraysRecursively(fid,nasc);
790 void MEDFileAnyTypeField1TSWithoutSDA::unloadArrays()
792 DataArray *thisArr(getUndergroundDataArray());
793 if(thisArr && thisArr->isAllocated())
795 _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples();
796 thisArr->desallocate();
800 std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySizeWithoutChildren() const
802 return _mesh_name.capacity()+_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MCAuto< MEDFileFieldPerMesh >);
805 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TSWithoutSDA::getDirectChildrenWithNull() const
807 std::vector<const BigMemoryObject *> ret;
808 if(getUndergroundDataArray())
809 ret.push_back(getUndergroundDataArray());
810 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
811 ret.push_back((const MEDFileFieldPerMesh *)*it);
816 * Adds a MEDCouplingFieldDouble to \a this. The underlying mesh of the given field is
817 * checked if its elements are sorted suitable for writing to MED file ("STB" stands for
818 * "Sort By Type"), if not, an exception is thrown.
819 * \param [in] field - the field to add to \a this. The array of field \a field is ignored
820 * \param [in] arr - the array of values.
821 * \param [in,out] glob - the global data where profiles and localization present in
822 * \a field, if any, are added.
823 * \throw If the name of \a field is empty.
824 * \throw If the data array of \a field is not set.
825 * \throw If \a this->_arr is already allocated but has different number of components
827 * \throw If the underlying mesh of \a field has no name.
828 * \throw If elements in the mesh are not in the order suitable for writing to the MED file.
830 void MEDFileAnyTypeField1TSWithoutSDA::setFieldNoProfileSBT(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc)
832 const MEDCouplingMesh *mesh(field->getMesh());
834 TypeOfField type(field->getTypeOfField());
835 std::vector<DataArrayInt *> dummy;
837 setMeshName(mesh->getName());
838 int start(copyTinyInfoFrom(th,field,arr));
839 int pos(addNewEntryIfNecessary(mesh));
842 std::vector<int> code=MEDFileField1TSWithoutSDA::CheckSBTMesh(mesh);
843 _field_per_mesh[pos]->assignFieldNoProfileNoRenum(start,code,field,arr,glob,nasc);
846 _field_per_mesh[pos]->assignNodeFieldNoProfile(start,field,arr,glob);
850 * Adds a MEDCouplingFieldDouble to \a this. Specified entities of a given dimension
851 * of a given mesh are used as the support of the given field (a real support is not used).
852 * Elements of the given mesh must be sorted suitable for writing to MED file.
853 * Order of underlying mesh entities of the given field specified by \a profile parameter
854 * is not prescribed; this method permutes field values to have them sorted by element
855 * type as required for writing to MED file. A new profile is added only if no equal
856 * profile is missing.
857 * \param [in] field - the field to add to \a this. The field double values are ignored.
858 * \param [in] arrOfVals - the values of the field \a field used.
859 * \param [in] mesh - the supporting mesh of \a field.
860 * \param [in] meshDimRelToMax - a relative dimension of mesh entities \a field lies on.
861 * \param [in] profile - ids of mesh entities on which corresponding field values lie.
862 * \param [in,out] glob - the global data where profiles and localization present in
863 * \a field, if any, are added.
864 * \param [in] nasc - the name scope used to assign names. Depends on the caller on the top call stack
865 * \param [in] smartPflKiller - specifies if this method tries at most to avoid profiles
866 * \throw If either \a field or \a mesh or \a profile has an empty name.
867 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
868 * \throw If the data array of \a field is not set.
869 * \throw If \a this->_arr is already allocated but has different number of components
871 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
872 * \sa setFieldNoProfileSBT()
874 void MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc, bool smartPflKiller)
877 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
878 if(!arrOfVals || !arrOfVals->isAllocated())
879 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
880 TypeOfField type=field->getTypeOfField();
881 std::vector<DataArrayInt *> idsInPflPerType;
882 std::vector<DataArrayInt *> idsPerType;
883 std::vector<int> code,code2;
884 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
887 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType,smartPflKiller);
888 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
889 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
890 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
892 MCAuto<MEDCouplingFieldTemplate> field2=field->clone(false);
893 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
894 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
896 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
897 throw INTERP_KERNEL::Exception(oss.str());
900 int start(copyTinyInfoFrom(th,field,arrOfVals));
901 code2=m->getDistributionOfTypes();
903 int pos=addNewEntryIfNecessary(m);
904 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
908 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
909 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
910 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
911 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
912 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
913 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
915 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
916 throw INTERP_KERNEL::Exception(oss.str());
918 int start(copyTinyInfoFrom(th,field,arrOfVals));
919 int pos(addNewEntryIfNecessary(m));
920 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
925 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
927 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
929 if(_nb_of_tuples_to_be_allocated>=0)
930 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 !");
931 DataArray *arr(getOrCreateAndGetArray());
932 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
933 _nb_of_tuples_to_be_allocated=-3;
937 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
938 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
939 * larger by the size of \a field. Returns an id of the first not filled
940 * tuple of \a this->_arr.
941 * \param [in] field - the field to copy the info on components and the name from.
942 * \return int - the id of first not initialized tuple of \a this->_arr.
943 * \throw If the name of \a field is empty.
944 * \throw If the data array of \a field is not set.
945 * \throw If \a this->_arr is already allocated but has different number of components
948 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
951 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
952 std::string name(field->getName());
953 setName(name.c_str());
955 setMeshName(field->getMesh()->getName());
956 setDtUnit(th->getTimeUnit());
958 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
960 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
961 if(!arr->isAllocated())
962 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
963 _dt=th->getTime(_iteration,_order);
964 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
965 if(!getOrCreateAndGetArray()->isAllocated())
967 allocNotFromFile(arr->getNumberOfTuples());
972 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
973 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
974 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
975 _nb_of_tuples_to_be_allocated=-3;
976 return oldNbOfTuples;
981 * Returns number of components in \a this field
982 * \return int - the number of components.
984 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
986 return getOrCreateAndGetArray()->getNumberOfComponents();
990 * Change info on components in \a this.
991 * \throw If size of \a infos is not equal to the number of components already in \a this.
993 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
995 DataArray *arr=getOrCreateAndGetArray();
996 arr->setInfoOnComponents(infos);//will throw an exception if number of components mismatches
1000 * Returns info on components of \a this field.
1001 * \return const std::vector<std::string>& - a sequence of strings each being an
1002 * information on _i_-th component.
1004 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
1006 const DataArray *arr=getOrCreateAndGetArray();
1007 return arr->getInfoOnComponents();
1011 * Returns a mutable info on components of \a this field.
1012 * \return std::vector<std::string>& - a sequence of strings each being an
1013 * information on _i_-th component.
1015 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
1017 DataArray *arr=getOrCreateAndGetArray();
1018 return arr->getInfoOnComponents();
1021 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
1023 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1025 const MEDFileFieldPerMesh *fpm(*it);
1028 if(fpm->presenceOfMultiDiscPerGeoType())
1034 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
1036 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1037 if((*it).isNotNull())
1038 if((*it)->presenceOfStructureElements())
1043 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
1045 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1046 if((*it).isNotNull())
1047 if(!(*it)->onlyStructureElements())
1052 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
1054 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1055 if((*it).isNotNull())
1056 (*it)->killStructureElements();
1059 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
1061 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1062 if((*it).isNotNull())
1063 (*it)->keepOnlyStructureElements();
1066 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
1068 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1069 if((*it).isNotNull())
1070 (*it)->keepOnlyOnSE(seName);
1073 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
1075 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1076 if((*it).isNotNull())
1077 (*it)->getMeshSENames(ps);
1080 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1082 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 !";
1083 if(_field_per_mesh.empty())
1084 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
1085 if(_field_per_mesh.size()>1)
1086 throw INTERP_KERNEL::Exception(MSG0);
1087 if(_field_per_mesh[0].isNull())
1088 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
1089 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
1090 std::set<TypeOfField> types;
1091 pm->fillTypesOfFieldAvailable(types);
1093 throw INTERP_KERNEL::Exception(MSG0);
1094 TypeOfField type(*types.begin());
1095 int meshDimRelToMax(0);
1100 int myDim(std::numeric_limits<int>::max());
1101 bool isUnique(pm->isUniqueLevel(myDim));
1103 throw INTERP_KERNEL::Exception(MSG0);
1104 meshDimRelToMax=myDim-mesh->getMeshDimension();
1105 if(meshDimRelToMax>0)
1106 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
1108 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
1112 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1113 * \param [in] type - a spatial discretization of the new field.
1114 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1115 * \param [in] mName - a name of the supporting mesh.
1116 * \param [in] renumPol - specifies how to permute values of the result field according to
1117 * the optional numbers of cells and nodes, if any. The valid values are
1118 * - 0 - do not permute.
1119 * - 1 - permute cells.
1120 * - 2 - permute nodes.
1121 * - 3 - permute cells and nodes.
1123 * \param [in] glob - the global data storing profiles and localization.
1124 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1125 * caller is to delete this field using decrRef() as it is no more needed.
1126 * \throw If the MED file is not readable.
1127 * \throw If there is no mesh named \a mName in the MED file.
1128 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1129 * \throw If no field of \a this is lying on the mesh \a mName.
1130 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1132 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1134 MCAuto<MEDFileMesh> mm;
1136 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
1138 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
1139 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
1143 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1144 * \param [in] type - a spatial discretization of the new field.
1145 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1146 * \param [in] renumPol - specifies how to permute values of the result field according to
1147 * the optional numbers of cells and nodes, if any. The valid values are
1148 * - 0 - do not permute.
1149 * - 1 - permute cells.
1150 * - 2 - permute nodes.
1151 * - 3 - permute cells and nodes.
1153 * \param [in] glob - the global data storing profiles and localization.
1154 * \param [in] mesh - the supporting mesh.
1155 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1156 * caller is to delete this field using decrRef() as it is no more needed.
1157 * \throw If the MED file is not readable.
1158 * \throw If no field of \a this is lying on \a mesh.
1159 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1160 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1162 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1164 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
1165 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
1166 if(meshDimRelToMax==1)
1167 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
1168 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
1172 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
1174 * \param [in] type - a spatial discretization of the new field.
1175 * \param [in] mName - a name of the supporting mesh.
1176 * \param [in] renumPol - specifies how to permute values of the result field according to
1177 * the optional numbers of cells and nodes, if any. The valid values are
1178 * - 0 - do not permute.
1179 * - 1 - permute cells.
1180 * - 2 - permute nodes.
1181 * - 3 - permute cells and nodes.
1183 * \param [in] glob - the global data storing profiles and localization.
1184 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1185 * caller is to delete this field using decrRef() as it is no more needed.
1186 * \throw If the MED file is not readable.
1187 * \throw If there is no mesh named \a mName in the MED file.
1188 * \throw If there are no mesh entities in the mesh.
1189 * \throw If no field values of the given \a type are available.
1191 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1193 MCAuto<MEDFileMesh> mm;
1195 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
1197 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
1198 int absDim=getDimension();
1199 int meshDimRelToMax=absDim-mm->getMeshDimension();
1200 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
1204 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1205 * \param [in] type - a spatial discretization of the new field.
1206 * \param [in] renumPol - specifies how to permute values of the result field according to
1207 * the optional numbers of cells and nodes, if any. The valid values are
1208 * - 0 - do not permute.
1209 * - 1 - permute cells.
1210 * - 2 - permute nodes.
1211 * - 3 - permute cells and nodes.
1213 * \param [in] glob - the global data storing profiles and localization.
1214 * \param [in] mesh - the supporting mesh.
1215 * \param [in] cellRenum - the cell numbers array used for permutation of the result
1216 * field according to \a renumPol.
1217 * \param [in] nodeRenum - the node numbers array used for permutation of the result
1218 * field according to \a renumPol.
1219 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1220 * caller is to delete this field using decrRef() as it is no more needed.
1221 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1222 * \throw If no field of \a this is lying on \a mesh.
1223 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1225 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
1227 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
1229 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[0]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
1234 //no need to test _field_per_mesh.empty() because geMeshName has already done it
1241 throw INTERP_KERNEL::Exception(msg1);
1242 //no need to test _field_per_mesh.empty() because geMeshName has already done it
1245 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
1247 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
1248 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
1249 throw INTERP_KERNEL::Exception(oss.str());
1251 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
1252 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
1253 std::vector<DataArray *> arrOut2(1,arrOut);
1254 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
1255 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
1256 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
1263 //no need to test _field_per_mesh.empty() because geMeshName has already done it
1265 throw INTERP_KERNEL::Exception(msg1);
1268 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
1270 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
1271 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
1272 throw INTERP_KERNEL::Exception(oss.str());
1274 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
1275 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
1276 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
1277 ret->renumberNodes(nodeRenumSafe->getConstPointer());
1282 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
1287 * Returns values and a profile of the field of a given type lying on a given support.
1288 * \param [in] type - a spatial discretization of the field.
1289 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1290 * \param [in] mesh - the supporting mesh.
1291 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
1292 * field of interest lies on. If the field lies on all entities of the given
1293 * dimension, all ids in \a pfl are zero. The caller is to delete this array
1294 * using decrRef() as it is no more needed.
1295 * \param [in] glob - the global data storing profiles and localization.
1296 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
1297 * field. The caller is to delete this array using decrRef() as it is no more needed.
1298 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
1299 * \throw If no field of \a this is lying on \a mesh.
1300 * \throw If no field values of the given \a type are available.
1302 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
1304 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
1305 MCAuto<DataArray> ret=_field_per_mesh[0]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
1306 ret->setName(nasc.getName().c_str());
1310 //= MEDFileField1TSWithoutSDA
1313 * Throws if a given value is not a valid (non-extended) relative dimension.
1314 * \param [in] meshDimRelToMax - the relative dimension value.
1315 * \throw If \a meshDimRelToMax > 0.
1317 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
1319 if(meshDimRelToMax>0)
1320 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
1324 * Checks if elements of a given mesh are in the order suitable for writing
1325 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
1326 * vector describing types of elements and their number.
1327 * \param [in] mesh - the mesh to check.
1328 * \return std::vector<int> - a vector holding for each element type (1) item of
1329 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
1330 * These values are in full-interlace mode.
1331 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
1333 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
1336 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
1337 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
1338 int nbOfTypes=geoTypes.size();
1339 std::vector<int> code(3*nbOfTypes);
1340 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
1341 arr1->alloc(nbOfTypes,1);
1342 int *arrPtr=arr1->getPointer();
1343 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
1344 for(int i=0;i<nbOfTypes;i++,it++)
1345 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
1346 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
1347 const int *arrPtr2=arr2->getConstPointer();
1349 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
1352 int nbCells=mesh->getNumberOfCellsWithType(*it);
1353 code[3*pos]=(int)(*it);
1354 code[3*pos+1]=nbCells;
1355 code[3*pos+2]=-1;//no profiles
1357 std::vector<const DataArrayInt *> idsPerType;//no profiles
1358 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
1362 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
1367 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1369 return new MEDFileField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1373 * Returns all attributes and values of parts of \a this field lying on a given mesh.
1374 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
1375 * item of every of returned sequences refers to the _i_-th part of \a this field.
1376 * Thus all sequences returned by this method are of the same length equal to number
1377 * of different types of supporting entities.<br>
1378 * A field part can include sub-parts with several different spatial discretizations,
1379 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
1380 * for example. Hence, some of the returned sequences contains nested sequences, and an item
1381 * of a nested sequence corresponds to a type of spatial discretization.<br>
1382 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
1383 * The overhead is due to selecting values into new instances of DataArrayDouble.
1384 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
1385 * for the case with only one underlying mesh. (Actually, the number of meshes is
1386 * not checked if \a mname == \c NULL).
1387 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
1388 * a field part is returned.
1389 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
1390 * A field part can include sub-parts with several different spatial discretizations,
1391 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
1392 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
1393 * This sequence is of the same length as \a types.
1394 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
1395 * discretization. A profile name can be empty.
1396 * Length of this and of nested sequences is the same as that of \a typesF.
1397 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
1398 * discretization. A localization name can be empty.
1399 * Length of this and of nested sequences is the same as that of \a typesF.
1400 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
1401 * per each type of spatial discretization within one mesh entity type.
1402 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
1403 * Length of this and of nested sequences is the same as that of \a typesF.
1404 * \throw If no field is lying on \a mname.
1406 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
1409 if(_field_per_mesh.empty())
1410 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
1411 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
1412 int nbOfRet=ret0.size();
1413 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
1414 for(int i=0;i<nbOfRet;i++)
1416 const std::vector< std::pair<int,int> >& p=ret0[i];
1417 int nbOfRet1=p.size();
1418 ret[i].resize(nbOfRet1);
1419 for(int j=0;j<nbOfRet1;j++)
1421 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
1428 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
1433 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
1435 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
1436 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
1437 ret->deepCpyLeavesFrom(*this);
1438 const DataArrayDouble *arr(_arr);
1441 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
1442 ret->setArray(arr2);
1448 * Returns a pointer to the underground DataArrayDouble instance and a
1449 * sequence describing parameters of a support of each part of \a this field. The
1450 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
1451 * direct access to the field values. This method is intended for the field lying on one
1453 * \param [in,out] entries - the sequence describing parameters of a support of each
1454 * part of \a this field. Each item of this sequence consists of two parts. The
1455 * first part describes a type of mesh entity and an id of discretization of a
1456 * current field part. The second part describes a range of values [begin,end)
1457 * within the returned array relating to the current field part.
1458 * \return DataArrayDouble * - the pointer to the field values array.
1459 * \throw If the number of underlying meshes is not equal to 1.
1460 * \throw If no field values are available.
1461 * \sa getUndergroundDataArray()
1463 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1465 return getUndergroundDataArrayTemplateExt(entries);
1468 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,meshName,csit,iteration,order)
1470 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
1471 arr->setInfoAndChangeNbOfCompo(infos);
1474 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
1478 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
1480 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
1481 ret->deepCpyLeavesFrom(*this);
1485 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
1487 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
1488 if(_arr.isNotNull())
1489 ret->_arr=_arr->deepCopy();
1493 //= MEDFileIntField1TSWithoutSDA
1495 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1497 return new MEDFileIntField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1500 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA()
1504 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
1505 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<int>(fieldName,meshName,csit,iteration,order,infos)
1507 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
1508 arr->setInfoAndChangeNbOfCompo(infos);
1511 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
1517 * Returns a pointer to the underground DataArrayInt instance and a
1518 * sequence describing parameters of a support of each part of \a this field. The
1519 * caller should not decrRef() the returned DataArrayInt. This method allows for a
1520 * direct access to the field values. This method is intended for the field lying on one
1522 * \param [in,out] entries - the sequence describing parameters of a support of each
1523 * part of \a this field. Each item of this sequence consists of two parts. The
1524 * first part describes a type of mesh entity and an id of discretization of a
1525 * current field part. The second part describes a range of values [begin,end)
1526 * within the returned array relating to the current field part.
1527 * \return DataArrayInt * - the pointer to the field values array.
1528 * \throw If the number of underlying meshes is not equal to 1.
1529 * \throw If no field values are available.
1530 * \sa getUndergroundDataArray()
1532 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1534 return getUndergroundDataArrayIntExt(entries);
1538 * Returns a pointer to the underground DataArrayInt instance and a
1539 * sequence describing parameters of a support of each part of \a this field. The
1540 * caller should not decrRef() the returned DataArrayInt. This method allows for a
1541 * direct access to the field values. This method is intended for the field lying on one
1543 * \param [in,out] entries - the sequence describing parameters of a support of each
1544 * part of \a this field. Each item of this sequence consists of two parts. The
1545 * first part describes a type of mesh entity and an id of discretization of a
1546 * current field part. The second part describes a range of values [begin,end)
1547 * within the returned array relating to the current field part.
1548 * \return DataArrayInt * - the pointer to the field values array.
1549 * \throw If the number of underlying meshes is not equal to 1.
1550 * \throw If no field values are available.
1551 * \sa getUndergroundDataArray()
1553 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1555 if(_field_per_mesh.size()!=1)
1556 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
1557 if(_field_per_mesh[0]==0)
1558 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
1559 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
1560 return getUndergroundDataArrayTemplate();
1563 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
1565 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
1566 ret->deepCpyLeavesFrom(*this);
1570 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
1572 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
1573 if(_arr.isNotNull())
1574 ret->_arr=_arr->deepCopy();
1578 //= MEDFileFloatField1TSWithoutSDA
1580 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1582 return new MEDFileFloatField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1585 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA()
1589 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
1590 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<float>(fieldName,meshName,csit,iteration,order,infos)
1592 DataArrayFloat *arr(getOrCreateAndGetArrayTemplate());
1593 arr->setInfoAndChangeNbOfCompo(infos);
1596 const char *MEDFileFloatField1TSWithoutSDA::getTypeStr() const
1602 * Returns a pointer to the underground DataArrayFloat instance and a
1603 * sequence describing parameters of a support of each part of \a this field. The
1604 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
1605 * direct access to the field values. This method is intended for the field lying on one
1607 * \param [in,out] entries - the sequence describing parameters of a support of each
1608 * part of \a this field. Each item of this sequence consists of two parts. The
1609 * first part describes a type of mesh entity and an id of discretization of a
1610 * current field part. The second part describes a range of values [begin,end)
1611 * within the returned array relating to the current field part.
1612 * \return DataArrayFloat * - the pointer to the field values array.
1613 * \throw If the number of underlying meshes is not equal to 1.
1614 * \throw If no field values are available.
1615 * \sa getUndergroundDataArray()
1617 DataArray *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1619 return getUndergroundDataArrayFloatExt(entries);
1623 * Returns a pointer to the underground DataArrayFloat instance and a
1624 * sequence describing parameters of a support of each part of \a this field. The
1625 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
1626 * direct access to the field values. This method is intended for the field lying on one
1628 * \param [in,out] entries - the sequence describing parameters of a support of each
1629 * part of \a this field. Each item of this sequence consists of two parts. The
1630 * first part describes a type of mesh entity and an id of discretization of a
1631 * current field part. The second part describes a range of values [begin,end)
1632 * within the returned array relating to the current field part.
1633 * \return DataArrayFloat * - the pointer to the field values array.
1634 * \throw If the number of underlying meshes is not equal to 1.
1635 * \throw If no field values are available.
1636 * \sa getUndergroundDataArray()
1638 DataArrayFloat *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayFloatExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1640 if(_field_per_mesh.size()!=1)
1641 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
1642 if(_field_per_mesh[0]==0)
1643 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
1644 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
1645 return getUndergroundDataArrayTemplate();
1648 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::shallowCpy() const
1650 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(new MEDFileFloatField1TSWithoutSDA(*this));
1651 ret->deepCpyLeavesFrom(*this);
1655 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::deepCopy() const
1657 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(shallowCpy());
1658 if(_arr.isNotNull())
1659 ret->_arr=_arr->deepCopy();
1663 //= MEDFileAnyTypeField1TS
1665 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
1669 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1671 med_field_type typcha;
1673 std::vector<std::string> infos;
1674 std::string dtunit,fieldName,meshName;
1675 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
1676 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
1681 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1686 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1691 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1696 if(sizeof(med_int)==sizeof(int))
1698 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1704 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] !";
1705 throw INTERP_KERNEL::Exception(oss.str());
1708 ret->setDtUnit(dtunit.c_str());
1709 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
1711 med_int numdt,numit;
1713 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
1714 ret->setTime(numdt,numit,dt);
1717 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1719 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1723 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1724 try:MEDFileFieldGlobsReal(fid)
1726 _content=BuildContentFrom(fid,loadAll,ms,entities);
1729 catch(INTERP_KERNEL::Exception& e)
1734 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1736 med_field_type typcha;
1737 std::vector<std::string> infos;
1738 std::string dtunit,meshName;
1742 nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName);
1744 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
1749 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1754 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1759 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1764 if(sizeof(med_int)==sizeof(int))
1766 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1772 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, MED_FLOAT32] !";
1773 throw INTERP_KERNEL::Exception(oss.str());
1776 ret->setMeshName(meshName);
1777 ret->setDtUnit(dtunit.c_str());
1778 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
1782 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
1783 throw INTERP_KERNEL::Exception(oss.str());
1786 med_int numdt,numit;
1788 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
1789 ret->setTime(numdt,numit,dt);
1792 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1794 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1798 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1799 try:MEDFileFieldGlobsReal(fid)
1801 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
1804 catch(INTERP_KERNEL::Exception& e)
1809 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
1812 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
1813 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
1815 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
1816 ret->_content=c; c->incrRef();
1819 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
1821 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
1822 ret->_content=c; c->incrRef();
1825 if(dynamic_cast<const MEDFileFloatField1TSWithoutSDA *>(c))
1827 MCAuto<MEDFileFloatField1TS> ret(MEDFileFloatField1TS::New());
1828 ret->_content=c; c->incrRef();
1831 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
1834 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
1836 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
1837 ret->setFileName(FileNameFromFID(fid));
1841 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
1843 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1844 return New(fid,loadAll);
1847 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
1849 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0,0));
1850 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1851 ret->loadGlobals(fid);
1855 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
1857 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1858 return New(fid,fieldName,loadAll);
1861 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
1863 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
1864 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1865 ret->loadGlobals(fid);
1869 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
1871 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1872 return New(fid,fieldName,iteration,order,loadAll);
1875 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
1877 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0));
1878 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1879 ret->loadGlobals(fid);
1883 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
1885 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1886 return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
1889 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
1891 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
1892 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1893 ret->loadGlobals(fid);
1897 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1899 med_field_type typcha;
1900 std::vector<std::string> infos;
1901 std::string dtunit,meshName;
1903 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName));
1904 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
1909 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1914 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1919 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1924 if(sizeof(med_int)==sizeof(int))
1926 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1932 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, MED_FLOAT32] !";
1933 throw INTERP_KERNEL::Exception(oss.str());
1936 ret->setDtUnit(dtunit.c_str());
1937 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
1940 std::vector< std::pair<int,int> > dtits(nbOfStep2);
1941 for(int i=0;i<nbOfStep2 && !found;i++)
1943 med_int numdt,numit;
1945 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
1946 if(numdt==iteration && numit==order)
1952 dtits[i]=std::pair<int,int>(numdt,numit);
1956 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
1957 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
1958 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
1959 throw INTERP_KERNEL::Exception(oss.str());
1962 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1964 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1968 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1969 try:MEDFileFieldGlobsReal(fid)
1971 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
1974 catch(INTERP_KERNEL::Exception& e)
1980 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
1981 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
1983 * \warning this is a shallow copy constructor
1985 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
1987 if(!shallowCopyOfContent)
1989 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
1990 otherPtr->incrRef();
1991 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
1995 _content=other.shallowCpy();
1999 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, std::string& meshName)
2003 int nbFields=MEDnField(fid);
2004 if(fieldIdCFormat>=nbFields)
2006 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
2007 throw INTERP_KERNEL::Exception(oss.str());
2010 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
2011 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
2012 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
2013 INTERP_KERNEL::AutoPtr<char> dtunit(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE));
2014 INTERP_KERNEL::AutoPtr<char> nomcha(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2015 INTERP_KERNEL::AutoPtr<char> nomMaa(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2018 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
2019 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
2020 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
2021 meshName=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
2022 infos.clear(); infos.resize(ncomp);
2023 for(int j=0;j<ncomp;j++)
2024 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
2029 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
2032 * \return in case of success the number of time steps available for the field with name \a fieldName.
2034 int MEDFileAnyTypeField1TS::LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut, std::string& meshName)
2036 int nbFields=MEDnField(fid);
2038 std::vector<std::string> fns(nbFields);
2040 for(int i=0;i<nbFields && !found;i++)
2042 std::string tmp,tmp2;
2043 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut,tmp2);
2045 found=(tmp==fieldName);
2054 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
2055 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
2056 oss << "\"" << *it << "\" ";
2057 throw INTERP_KERNEL::Exception(oss.str());
2063 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
2064 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
2065 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
2066 * It is the responsibility of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
2067 * to keep a valid instance.
2068 * 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.
2069 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
2070 * 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.
2072 * \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.
2073 * \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.
2074 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
2075 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
2076 * \param [in] newLocName is the new localization name.
2077 * \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.
2078 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
2080 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
2082 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2083 std::string oldPflName=disc->getProfile();
2084 std::vector<std::string> vv=getPflsReallyUsedMulti();
2085 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
2086 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
2088 disc->setProfile(newPflName);
2089 DataArrayInt *pfl=getProfile(oldPflName.c_str());
2090 pfl->setName(newPflName);
2094 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
2095 throw INTERP_KERNEL::Exception(oss.str());
2100 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
2101 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
2102 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
2103 * It is the responsibility of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
2104 * to keep a valid instance.
2105 * 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.
2106 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
2107 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
2108 * 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.
2110 * \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.
2111 * \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.
2112 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
2113 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
2114 * \param [in] newLocName is the new localization name.
2115 * \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.
2116 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
2118 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
2120 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2121 std::string oldLocName=disc->getLocalization();
2122 std::vector<std::string> vv=getLocsReallyUsedMulti();
2123 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
2124 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
2126 disc->setLocalization(newLocName);
2127 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
2128 loc.setName(newLocName);
2132 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
2133 throw INTERP_KERNEL::Exception(oss.str());
2137 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
2139 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
2141 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
2145 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
2147 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
2149 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
2154 * This method alloc the arrays and load potentially huge arrays contained in this field.
2155 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
2156 * This method can be also called to refresh or reinit values from a file.
2158 * \throw If the fileName is not set or points to a non readable MED file.
2159 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
2161 void MEDFileAnyTypeField1TS::loadArrays()
2163 if(getFileName().empty())
2164 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
2165 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
2166 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
2170 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
2171 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
2172 * this method does not throw if \a this does not come from file read.
2174 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
2176 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
2178 if(!getFileName().empty())
2180 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
2181 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
2186 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
2187 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
2188 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
2190 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
2192 void MEDFileAnyTypeField1TS::unloadArrays()
2194 contentNotNullBase()->unloadArrays();
2198 * 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.
2199 * This method is the symmetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
2200 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
2202 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
2204 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
2206 if(!getFileName().empty())
2207 contentNotNullBase()->unloadArrays();
2210 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
2212 int nbComp(getNumberOfComponents());
2213 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
2214 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
2215 for(int i=0;i<nbComp;i++)
2217 std::string info=getInfo()[i];
2219 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
2220 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
2221 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
2223 if(getName().empty())
2224 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
2225 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
2226 writeGlobals(fid,*this);
2227 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
2230 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
2232 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
2235 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
2237 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
2238 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
2243 * Returns a string describing \a this field. This string is outputted
2244 * by \c print Python command.
2246 std::string MEDFileAnyTypeField1TS::simpleRepr() const
2248 std::ostringstream oss;
2249 contentNotNullBase()->simpleRepr(0,oss,-1);
2250 simpleReprGlobs(oss);
2255 * This method returns all profiles whose name is non empty used.
2256 * \b WARNING If profile is used several times it will be reported \b only \b once.
2257 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
2259 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
2261 return contentNotNullBase()->getPflsReallyUsed2();
2265 * This method returns all localizations whose name is non empty used.
2266 * \b WARNING If localization is used several times it will be reported \b only \b once.
2268 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
2270 return contentNotNullBase()->getLocsReallyUsed2();
2274 * This method returns all profiles whose name is non empty used.
2275 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
2277 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
2279 return contentNotNullBase()->getPflsReallyUsedMulti2();
2283 * This method returns all localizations whose name is non empty used.
2284 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
2286 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
2288 return contentNotNullBase()->getLocsReallyUsedMulti2();
2291 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2293 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
2296 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2298 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
2301 int MEDFileAnyTypeField1TS::getDimension() const
2303 return contentNotNullBase()->getDimension();
2306 int MEDFileAnyTypeField1TS::getIteration() const
2308 return contentNotNullBase()->getIteration();
2311 int MEDFileAnyTypeField1TS::getOrder() const
2313 return contentNotNullBase()->getOrder();
2316 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
2318 return contentNotNullBase()->getTime(iteration,order);
2321 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
2323 contentNotNullBase()->setTime(iteration,order,val);
2326 std::string MEDFileAnyTypeField1TS::getName() const
2328 return contentNotNullBase()->getName();
2331 void MEDFileAnyTypeField1TS::setName(const std::string& name)
2333 contentNotNullBase()->setName(name);
2336 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
2338 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
2341 std::string MEDFileAnyTypeField1TS::getDtUnit() const
2343 return contentNotNullBase()->getDtUnit();
2346 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
2348 contentNotNullBase()->setDtUnit(dtUnit);
2351 std::string MEDFileAnyTypeField1TS::getMeshName() const
2353 return contentNotNullBase()->getMeshName();
2356 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
2358 contentNotNullBase()->setMeshName(newMeshName);
2361 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2363 return contentNotNullBase()->changeMeshNames(modifTab);
2366 int MEDFileAnyTypeField1TS::getMeshIteration() const
2368 return contentNotNullBase()->getMeshIteration();
2371 int MEDFileAnyTypeField1TS::getMeshOrder() const
2373 return contentNotNullBase()->getMeshOrder();
2376 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
2378 return contentNotNullBase()->getNumberOfComponents();
2381 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
2383 return contentNotNullBase()->isDealingTS(iteration,order);
2386 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
2388 return contentNotNullBase()->getDtIt();
2391 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
2393 contentNotNullBase()->fillIteration(p);
2396 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
2398 contentNotNullBase()->fillTypesOfFieldAvailable(types);
2401 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
2403 contentNotNullBase()->setInfo(infos);
2406 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
2408 return contentNotNullBase()->getInfo();
2410 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
2412 return contentNotNullBase()->getInfo();
2415 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
2417 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
2420 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
2422 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2425 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
2427 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2430 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
2432 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
2435 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
2437 return contentNotNullBase()->convertMedBallIntoClassic();
2440 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
2442 return contentNotNullBase()->makeReduction(ct,tof,pfl);
2445 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
2447 return contentNotNullBase()->getTypesOfFieldAvailable();
2450 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,
2451 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
2453 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
2457 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
2458 * The returned instances are deep copy of \a this except that for globals that are shared with those contained in \a this.
2459 * ** WARNING ** do no forget to rename the output instances to avoid to write n-times in the same MED file field !
2461 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
2463 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2465 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
2466 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
2467 std::size_t sz(contentsSplit.size());
2468 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2469 for(std::size_t i=0;i<sz;i++)
2471 ret[i]=shallowCpy();
2472 ret[i]->_content=contentsSplit[i];
2478 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
2479 * The returned instances are shallowed copied of \a this except that for globals that are shared with those contained in \a this.
2481 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
2483 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2485 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
2486 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
2487 std::size_t sz(contentsSplit.size());
2488 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2489 for(std::size_t i=0;i<sz;i++)
2491 ret[i]=shallowCpy();
2492 ret[i]->_content=contentsSplit[i];
2498 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
2499 * The returned instances are shallowed copied of \a this except that for globals that are shared with those contained in \a this.
2501 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
2503 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2505 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
2506 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
2507 std::size_t sz(contentsSplit.size());
2508 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2509 for(std::size_t i=0;i<sz;i++)
2511 ret[i]=shallowCpy();
2512 ret[i]->_content=contentsSplit[i];
2517 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
2519 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
2520 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
2521 ret->_content=_content->deepCopy();
2522 ret->deepCpyGlobs(*this);
2526 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
2528 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
2529 return copyTinyInfoFrom(field->timeDiscrSafe(),ft,arr);
2532 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
2534 return contentNotNullBase()->copyTinyInfoFrom(th,field,arr);
2540 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
2541 * following the given input policy.
2543 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
2544 * By default (true) the globals are deeply copied.
2545 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
2547 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
2549 MCAuto<MEDFileIntField1TS> ret;
2550 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2553 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
2555 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
2556 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
2557 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
2560 ret=MEDFileIntField1TS::New();
2562 ret->deepCpyGlobs(*this);
2564 ret->shallowCpyGlobs(*this);
2568 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
2569 try:MEDFileTemplateField1TS<double>(fid,loadAll,ms)
2572 catch(INTERP_KERNEL::Exception& e)
2575 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
2576 try:MEDFileTemplateField1TS<double>(fid,fieldName,loadAll,ms)
2579 catch(INTERP_KERNEL::Exception& e)
2582 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
2583 try:MEDFileTemplateField1TS<double>(fid,fieldName,iteration,order,loadAll,ms)
2586 catch(INTERP_KERNEL::Exception& e)
2590 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
2591 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
2593 * \warning this is a shallow copy constructor
2595 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
2596 try:MEDFileTemplateField1TS<double>(other,shallowCopyOfContent)
2599 catch(INTERP_KERNEL::Exception& e)
2602 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
2604 return new MEDFileField1TS(*this);
2607 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
2608 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
2610 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
2613 //= MEDFileIntField1TS
2615 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
2618 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
2620 double t0(f->getTime(t1,t2));
2621 std::string tu(f->getTimeUnit());
2622 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
2623 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
2624 ret->setTime(t0,t1,t2); ret->setTimeUnit(tu);
2628 //= MEDFileFloatField1TS
2630 //= MEDFileFloatField1TS