1 // Copyright (C) 2017 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 spliting 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 writting 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 * \throw If either \a field or \a mesh or \a profile has an empty name.
865 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
866 * \throw If the data array of \a field is not set.
867 * \throw If \a this->_arr is already allocated but has different number of components
869 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
870 * \sa setFieldNoProfileSBT()
872 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)
875 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input field is null !");
876 if(!arrOfVals || !arrOfVals->isAllocated())
877 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input array is null or not allocated !");
878 TypeOfField type=field->getTypeOfField();
879 std::vector<DataArrayInt *> idsInPflPerType;
880 std::vector<DataArrayInt *> idsPerType;
881 std::vector<int> code,code2;
882 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
885 m->splitProfilePerType(profile,code,idsInPflPerType,idsPerType);
886 std::vector< MCAuto<DataArrayInt> > idsInPflPerType2(idsInPflPerType.size()); std::copy(idsInPflPerType.begin(),idsInPflPerType.end(),idsInPflPerType2.begin());
887 std::vector< MCAuto<DataArrayInt> > idsPerType2(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType2.begin());
888 std::vector<const DataArrayInt *> idsPerType3(idsPerType.size()); std::copy(idsPerType.begin(),idsPerType.end(),idsPerType3.begin());
890 MCAuto<MEDCouplingFieldTemplate> field2=field->clone(false);
891 int nbOfTuplesExp=field2->getNumberOfTuplesExpectedRegardingCode(code,idsPerType3);
892 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
894 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : The array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
895 throw INTERP_KERNEL::Exception(oss.str());
898 int start(copyTinyInfoFrom(th,field,arrOfVals));
899 code2=m->getDistributionOfTypes();
901 int pos=addNewEntryIfNecessary(m);
902 _field_per_mesh[pos]->assignFieldProfile(start,profile,code,code2,idsInPflPerType,idsPerType,field,arrOfVals,m,glob,nasc);
906 if(!profile || !profile->isAllocated() || profile->getNumberOfComponents()!=1)
907 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : input profile is null, not allocated or with number of components != 1 !");
908 std::vector<int> v(3); v[0]=-1; v[1]=profile->getNumberOfTuples(); v[2]=0;
909 std::vector<const DataArrayInt *> idsPerType3(1); idsPerType3[0]=profile;
910 int nbOfTuplesExp=field->getNumberOfTuplesExpectedRegardingCode(v,idsPerType3);
911 if(nbOfTuplesExp!=arrOfVals->getNumberOfTuples())
913 std::ostringstream oss; oss << "MEDFileAnyTypeField1TSWithoutSDA::setFieldProfile : For node field, the array is expected to have " << nbOfTuplesExp << " tuples ! It has " << arrOfVals->getNumberOfTuples() << " !";
914 throw INTERP_KERNEL::Exception(oss.str());
916 int start(copyTinyInfoFrom(th,field,arrOfVals));
917 int pos(addNewEntryIfNecessary(m));
918 _field_per_mesh[pos]->assignNodeFieldProfile(start,profile,field,arrOfVals,glob,nasc);
923 * \param [in] newNbOfTuples - The new nb of tuples to be allocated.
925 void MEDFileAnyTypeField1TSWithoutSDA::allocNotFromFile(int newNbOfTuples)
927 if(_nb_of_tuples_to_be_allocated>=0)
928 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 !");
929 DataArray *arr(getOrCreateAndGetArray());
930 arr->alloc(newNbOfTuples,arr->getNumberOfComponents());
931 _nb_of_tuples_to_be_allocated=-3;
935 * Copies tiny info and allocates \a this->_arr instance of DataArrayDouble to
936 * append data of a given MEDCouplingFieldDouble. So that the size of \a this->_arr becomes
937 * larger by the size of \a field. Returns an id of the first not filled
938 * tuple of \a this->_arr.
939 * \param [in] field - the field to copy the info on components and the name from.
940 * \return int - the id of first not initialized tuple of \a this->_arr.
941 * \throw If the name of \a field is empty.
942 * \throw If the data array of \a field is not set.
943 * \throw If \a this->_arr is already allocated but has different number of components
946 int MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
949 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::copyTinyInfoFrom : input field is NULL !");
950 std::string name(field->getName());
951 setName(name.c_str());
953 setMeshName(field->getMesh()->getName());
954 setDtUnit(th->getTimeUnit());
956 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : unsupported fields with no name in MED file !");
958 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : no array set !");
959 if(!arr->isAllocated())
960 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::copyTinyInfoFrom : array is not allocated !");
961 _dt=th->getTime(_iteration,_order);
962 getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(arr->getInfoOnComponents());
963 if(!getOrCreateAndGetArray()->isAllocated())
965 allocNotFromFile(arr->getNumberOfTuples());
970 int oldNbOfTuples=getOrCreateAndGetArray()->getNumberOfTuples();
971 int newNbOfTuples=oldNbOfTuples+arr->getNumberOfTuples();
972 getOrCreateAndGetArray()->reAlloc(newNbOfTuples);
973 _nb_of_tuples_to_be_allocated=-3;
974 return oldNbOfTuples;
979 * Returns number of components in \a this field
980 * \return int - the number of components.
982 int MEDFileAnyTypeField1TSWithoutSDA::getNumberOfComponents() const
984 return getOrCreateAndGetArray()->getNumberOfComponents();
988 * Change info on components in \a this.
989 * \throw If size of \a infos is not equal to the number of components already in \a this.
991 void MEDFileAnyTypeField1TSWithoutSDA::setInfo(const std::vector<std::string>& infos)
993 DataArray *arr=getOrCreateAndGetArray();
994 arr->setInfoOnComponents(infos);//will throw an exception if number of components mimatches
998 * Returns info on components of \a this field.
999 * \return const std::vector<std::string>& - a sequence of strings each being an
1000 * information on _i_-th component.
1002 const std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo() const
1004 const DataArray *arr=getOrCreateAndGetArray();
1005 return arr->getInfoOnComponents();
1009 * Returns a mutable info on components of \a this field.
1010 * \return std::vector<std::string>& - a sequence of strings each being an
1011 * information on _i_-th component.
1013 std::vector<std::string>& MEDFileAnyTypeField1TSWithoutSDA::getInfo()
1015 DataArray *arr=getOrCreateAndGetArray();
1016 return arr->getInfoOnComponents();
1019 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfMultiDiscPerGeoType() const
1021 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1023 const MEDFileFieldPerMesh *fpm(*it);
1026 if(fpm->presenceOfMultiDiscPerGeoType())
1032 bool MEDFileAnyTypeField1TSWithoutSDA::presenceOfStructureElements() const
1034 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1035 if((*it).isNotNull())
1036 if((*it)->presenceOfStructureElements())
1041 bool MEDFileAnyTypeField1TSWithoutSDA::onlyStructureElements() const
1043 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1044 if((*it).isNotNull())
1045 if(!(*it)->onlyStructureElements())
1050 void MEDFileAnyTypeField1TSWithoutSDA::killStructureElements()
1052 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1053 if((*it).isNotNull())
1054 (*it)->killStructureElements();
1057 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyStructureElements()
1059 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1060 if((*it).isNotNull())
1061 (*it)->keepOnlyStructureElements();
1064 void MEDFileAnyTypeField1TSWithoutSDA::keepOnlyOnSE(const std::string& seName)
1066 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1067 if((*it).isNotNull())
1068 (*it)->keepOnlyOnSE(seName);
1071 void MEDFileAnyTypeField1TSWithoutSDA::getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const
1073 for(std::vector< MCAuto< MEDFileFieldPerMesh > >::const_iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++)
1074 if((*it).isNotNull())
1075 (*it)->getMeshSENames(ps);
1078 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1080 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 !";
1081 if(_field_per_mesh.empty())
1082 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is empty ! Nothing to extract !");
1083 if(_field_per_mesh.size()>1)
1084 throw INTERP_KERNEL::Exception(MSG0);
1085 if(_field_per_mesh[0].isNull())
1086 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the field is inconsistent !");
1087 const MEDFileFieldPerMesh *pm(_field_per_mesh[0]);
1088 std::set<TypeOfField> types;
1089 pm->fillTypesOfFieldAvailable(types);
1091 throw INTERP_KERNEL::Exception(MSG0);
1092 TypeOfField type(*types.begin());
1093 int meshDimRelToMax(0);
1098 int myDim(std::numeric_limits<int>::max());
1099 bool isUnique(pm->isUniqueLevel(myDim));
1101 throw INTERP_KERNEL::Exception(MSG0);
1102 meshDimRelToMax=myDim-mesh->getMeshDimension();
1103 if(meshDimRelToMax>0)
1104 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::fieldOnMesh : the mesh attached to field is not compatible with the field !");
1106 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,0/*renumPol*/,glob,mesh,arrOut,nasc);
1110 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1111 * \param [in] type - a spatial discretization of the new field.
1112 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1113 * \param [in] mName - a name of the supporting mesh.
1114 * \param [in] renumPol - specifies how to permute values of the result field according to
1115 * the optional numbers of cells and nodes, if any. The valid values are
1116 * - 0 - do not permute.
1117 * - 1 - permute cells.
1118 * - 2 - permute nodes.
1119 * - 3 - permute cells and nodes.
1121 * \param [in] glob - the global data storing profiles and localization.
1122 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1123 * caller is to delete this field using decrRef() as it is no more needed.
1124 * \throw If the MED file is not readable.
1125 * \throw If there is no mesh named \a mName in the MED file.
1126 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1127 * \throw If no field of \a this is lying on the mesh \a mName.
1128 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1130 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1132 MCAuto<MEDFileMesh> mm;
1134 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
1136 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
1137 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
1141 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1142 * \param [in] type - a spatial discretization of the new field.
1143 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1144 * \param [in] renumPol - specifies how to permute values of the result field according to
1145 * the optional numbers of cells and nodes, if any. The valid values are
1146 * - 0 - do not permute.
1147 * - 1 - permute cells.
1148 * - 2 - permute nodes.
1149 * - 3 - permute cells and nodes.
1151 * \param [in] glob - the global data storing profiles and localization.
1152 * \param [in] mesh - the supporting mesh.
1153 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1154 * caller is to delete this field using decrRef() as it is no more needed.
1155 * \throw If the MED file is not readable.
1156 * \throw If no field of \a this is lying on \a mesh.
1157 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1158 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1160 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1162 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax,false));
1163 const DataArrayInt *d(mesh->getNumberFieldAtLevel(meshDimRelToMax)),*e(mesh->getNumberFieldAtLevel(1));
1164 if(meshDimRelToMax==1)
1165 (static_cast<MEDCouplingUMesh *>((MEDCouplingMesh *)m))->setMeshDimension(0);
1166 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,renumPol,glob,m,d,e,arrOut,nasc);
1170 * Returns a new MEDCouplingFieldDouble of a given type lying on the top level cells of a
1172 * \param [in] type - a spatial discretization of the new field.
1173 * \param [in] mName - a name of the supporting mesh.
1174 * \param [in] renumPol - specifies how to permute values of the result field according to
1175 * the optional numbers of cells and nodes, if any. The valid values are
1176 * - 0 - do not permute.
1177 * - 1 - permute cells.
1178 * - 2 - permute nodes.
1179 * - 3 - permute cells and nodes.
1181 * \param [in] glob - the global data storing profiles and localization.
1182 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1183 * caller is to delete this field using decrRef() as it is no more needed.
1184 * \throw If the MED file is not readable.
1185 * \throw If there is no mesh named \a mName in the MED file.
1186 * \throw If there are no mesh entities in the mesh.
1187 * \throw If no field values of the given \a type are available.
1189 MEDCouplingFieldDouble *MEDFileAnyTypeField1TSWithoutSDA::getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const
1191 MCAuto<MEDFileMesh> mm;
1193 mm=MEDFileMesh::New(glob->getFileName(),getMeshName().c_str(),getMeshIteration(),getMeshOrder());
1195 mm=MEDFileMesh::New(glob->getFileName(),mName,getMeshIteration(),getMeshOrder());
1196 int absDim=getDimension();
1197 int meshDimRelToMax=absDim-mm->getMeshDimension();
1198 return MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel(type,meshDimRelToMax,renumPol,glob,mm,arrOut,nasc);
1202 * Returns a new MEDCouplingFieldDouble of given type lying on a given support.
1203 * \param [in] type - a spatial discretization of the new field.
1204 * \param [in] renumPol - specifies how to permute values of the result field according to
1205 * the optional numbers of cells and nodes, if any. The valid values are
1206 * - 0 - do not permute.
1207 * - 1 - permute cells.
1208 * - 2 - permute nodes.
1209 * - 3 - permute cells and nodes.
1211 * \param [in] glob - the global data storing profiles and localization.
1212 * \param [in] mesh - the supporting mesh.
1213 * \param [in] cellRenum - the cell numbers array used for permutation of the result
1214 * field according to \a renumPol.
1215 * \param [in] nodeRenum - the node numbers array used for permutation of the result
1216 * field according to \a renumPol.
1217 * \return MEDCouplingFieldDouble * - a new instance of MEDCouplingFieldDouble. The
1218 * caller is to delete this field using decrRef() as it is no more needed.
1219 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in the mesh.
1220 * \throw If no field of \a this is lying on \a mesh.
1221 * \throw If no field values of the given \a type or given \a meshDimRelToMax are available.
1223 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
1225 static const char msg1[]="MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : request for a renumbered field following mesh numbering whereas it is a profile field !";
1227 MCAuto<MEDCouplingFieldDouble> ret=_field_per_mesh[0]->getFieldOnMeshAtLevel(type,glob,mesh,isPfl,arrOut,nasc);
1232 //no need to test _field_per_mesh.empty() because geMeshName has already done it
1239 throw INTERP_KERNEL::Exception(msg1);
1240 //no need to test _field_per_mesh.empty() because geMeshName has already done it
1243 if((int)cellRenum->getNbOfElems()!=mesh->getNumberOfCells())
1245 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
1246 oss << "\"" << getName() << "\" has partial renumbering (some geotype has no renumber) !";
1247 throw INTERP_KERNEL::Exception(oss.str());
1249 MEDCouplingFieldDiscretization *disc=ret->getDiscretization();
1250 if(!disc) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::getFieldOnMeshAtLevel : internal error, no discretization on field !");
1251 std::vector<DataArray *> arrOut2(1,arrOut);
1252 // 2 following lines replace ret->renumberCells(cellRenum->getConstPointer()) if not DataArrayDouble
1253 disc->renumberArraysForCell(ret->getMesh(),arrOut2,cellRenum->getConstPointer(),true);
1254 (const_cast<MEDCouplingMesh*>(ret->getMesh()))->renumberCells(cellRenum->getConstPointer(),true);
1261 //no need to test _field_per_mesh.empty() because geMeshName has already done it
1263 throw INTERP_KERNEL::Exception(msg1);
1266 if((int)nodeRenum->getNbOfElems()!=mesh->getNumberOfNodes())
1268 std::ostringstream oss; oss << "MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : Request of simple renumbering but it seems that underlying mesh \"" << mesh->getName() << "\" of requested field ";
1269 oss << "\"" << nasc.getName() << "\" not defined on all nodes !";
1270 throw INTERP_KERNEL::Exception(oss.str());
1272 MCAuto<DataArrayInt> nodeRenumSafe=nodeRenum->checkAndPreparePermutation();
1273 if(!dynamic_cast<DataArrayDouble *>((DataArray *)arrOut))
1274 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : node renumbering not implemented for not double DataArrays !");
1275 ret->renumberNodes(nodeRenumSafe->getConstPointer());
1280 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldOnMeshAtLevel : unsupported renum policy ! Dealing with policy 0 1 2 and 3 !");
1285 * Returns values and a profile of the field of a given type lying on a given support.
1286 * \param [in] type - a spatial discretization of the field.
1287 * \param [in] meshDimRelToMax - a relative dimension of the supporting mesh entities.
1288 * \param [in] mesh - the supporting mesh.
1289 * \param [out] pfl - a new instance of DataArrayInt holding ids of mesh entities the
1290 * field of interest lies on. If the field lies on all entities of the given
1291 * dimension, all ids in \a pfl are zero. The caller is to delete this array
1292 * using decrRef() as it is no more needed.
1293 * \param [in] glob - the global data storing profiles and localization.
1294 * \return DataArrayDouble * - a new instance of DataArrayDouble holding values of the
1295 * field. The caller is to delete this array using decrRef() as it is no more needed.
1296 * \throw If there are no mesh entities of \a meshDimRelToMax dimension in \a mesh.
1297 * \throw If no field of \a this is lying on \a mesh.
1298 * \throw If no field values of the given \a type are available.
1300 DataArray *MEDFileAnyTypeField1TSWithoutSDA::getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const
1302 MCAuto<MEDCouplingMesh> m(mesh->getMeshAtLevel(meshDimRelToMax));
1303 MCAuto<DataArray> ret=_field_per_mesh[0]->getFieldOnMeshAtLevelWithPfl(type,m,pfl,glob,nasc);
1304 ret->setName(nasc.getName().c_str());
1308 //= MEDFileField1TSWithoutSDA
1311 * Throws if a given value is not a valid (non-extended) relative dimension.
1312 * \param [in] meshDimRelToMax - the relative dimension value.
1313 * \throw If \a meshDimRelToMax > 0.
1315 void MEDFileField1TSWithoutSDA::CheckMeshDimRel(int meshDimRelToMax)
1317 if(meshDimRelToMax>0)
1318 throw INTERP_KERNEL::Exception("CheckMeshDimRel : This is a meshDimRel not a meshDimRelExt ! So value should be <=0 !");
1322 * Checks if elements of a given mesh are in the order suitable for writing
1323 * to the MED file. If this is not so, an exception is thrown. In a case of success, returns a
1324 * vector describing types of elements and their number.
1325 * \param [in] mesh - the mesh to check.
1326 * \return std::vector<int> - a vector holding for each element type (1) item of
1327 * INTERP_KERNEL::NormalizedCellType, (2) number of elements, (3) -1.
1328 * These values are in full-interlace mode.
1329 * \throw If elements in \a mesh are not in the order suitable for writing to the MED file.
1331 std::vector<int> MEDFileField1TSWithoutSDA::CheckSBTMesh(const MEDCouplingMesh *mesh)
1334 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : input mesh is NULL !");
1335 std::set<INTERP_KERNEL::NormalizedCellType> geoTypes=mesh->getAllGeoTypes();
1336 int nbOfTypes=geoTypes.size();
1337 std::vector<int> code(3*nbOfTypes);
1338 MCAuto<DataArrayInt> arr1=DataArrayInt::New();
1339 arr1->alloc(nbOfTypes,1);
1340 int *arrPtr=arr1->getPointer();
1341 std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator it=geoTypes.begin();
1342 for(int i=0;i<nbOfTypes;i++,it++)
1343 arrPtr[i]=std::distance(typmai2,std::find(typmai2,typmai2+MED_N_CELL_FIXED_GEO,*it));
1344 MCAuto<DataArrayInt> arr2=arr1->checkAndPreparePermutation();
1345 const int *arrPtr2=arr2->getConstPointer();
1347 for(it=geoTypes.begin();it!=geoTypes.end();it++,i++)
1350 int nbCells=mesh->getNumberOfCellsWithType(*it);
1351 code[3*pos]=(int)(*it);
1352 code[3*pos+1]=nbCells;
1353 code[3*pos+2]=-1;//no profiles
1355 std::vector<const DataArrayInt *> idsPerType;//no profiles
1356 DataArrayInt *da=mesh->checkTypeConsistencyAndContig(code,idsPerType);
1360 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::CheckSBTMesh : underlying mesh is not sorted by type as MED file expects !");
1365 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1367 return new MEDFileField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1371 * Returns all attributes and values of parts of \a this field lying on a given mesh.
1372 * Each part differs from other ones by a type of supporting mesh entity. The _i_-th
1373 * item of every of returned sequences refers to the _i_-th part of \a this field.
1374 * Thus all sequences returned by this method are of the same length equal to number
1375 * of different types of supporting entities.<br>
1376 * A field part can include sub-parts with several different spatial discretizations,
1377 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT"
1378 * for example. Hence, some of the returned sequences contains nested sequences, and an item
1379 * of a nested sequence corresponds to a type of spatial discretization.<br>
1380 * This method allows for iteration over MEDFile DataStructure with a reduced overhead.
1381 * The overhead is due to selecting values into new instances of DataArrayDouble.
1382 * \param [in] mname - a name of a mesh of interest. It can be \c NULL, which is valid
1383 * for the case with only one underlying mesh. (Actually, the number of meshes is
1384 * not checked if \a mname == \c NULL).
1385 * \param [in,out] types - a sequence of types of underlying mesh entities. A type per
1386 * a field part is returned.
1387 * \param [in,out] typesF - a sequence of sequences of types of spatial discretizations.
1388 * A field part can include sub-parts with several different spatial discretizations,
1389 * \ref MEDCoupling::ON_CELLS "ON_CELLS" and
1390 * \ref MEDCoupling::ON_GAUSS_PT "ON_GAUSS_PT" for example.
1391 * This sequence is of the same length as \a types.
1392 * \param [in,out] pfls - a sequence returning a profile name per each type of spatial
1393 * discretization. A profile name can be empty.
1394 * Length of this and of nested sequences is the same as that of \a typesF.
1395 * \param [in,out] locs - a sequence returning a localization name per each type of spatial
1396 * discretization. A localization name can be empty.
1397 * Length of this and of nested sequences is the same as that of \a typesF.
1398 * \return std::vector< std::vector<DataArrayDouble *> > - a sequence holding arrays of values
1399 * per each type of spatial discretization within one mesh entity type.
1400 * The caller is to delete each DataArrayDouble using decrRef() as it is no more needed.
1401 * Length of this and of nested sequences is the same as that of \a typesF.
1402 * \throw If no field is lying on \a mname.
1404 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
1407 if(_field_per_mesh.empty())
1408 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getFieldSplitedByType : This is empty !");
1409 std::vector< std::vector< std::pair<int,int> > > ret0=_field_per_mesh[0]->getFieldSplitedByType(types,typesF,pfls,locs);
1410 int nbOfRet=ret0.size();
1411 std::vector< std::vector<DataArrayDouble *> > ret(nbOfRet);
1412 for(int i=0;i<nbOfRet;i++)
1414 const std::vector< std::pair<int,int> >& p=ret0[i];
1415 int nbOfRet1=p.size();
1416 ret[i].resize(nbOfRet1);
1417 for(int j=0;j<nbOfRet1;j++)
1419 DataArrayDouble *tmp=_arr->selectByTupleIdSafeSlice(p[j].first,p[j].second,1);
1426 const char *MEDFileField1TSWithoutSDA::getTypeStr() const
1431 MEDFileIntField1TSWithoutSDA *MEDFileField1TSWithoutSDA::convertToInt() const
1433 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA);
1434 ret->MEDFileAnyTypeField1TSWithoutSDA::operator =(*this);
1435 ret->deepCpyLeavesFrom(*this);
1436 const DataArrayDouble *arr(_arr);
1439 MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
1440 ret->setArray(arr2);
1446 * Returns a pointer to the underground DataArrayDouble instance and a
1447 * sequence describing parameters of a support of each part of \a this field. The
1448 * caller should not decrRef() the returned DataArrayDouble. This method allows for a
1449 * direct access to the field values. This method is intended for the field lying on one
1451 * \param [in,out] entries - the sequence describing parameters of a support of each
1452 * part of \a this field. Each item of this sequence consists of two parts. The
1453 * first part describes a type of mesh entity and an id of discretization of a
1454 * current field part. The second part describes a range of values [begin,end)
1455 * within the returned array relating to the current field part.
1456 * \return DataArrayDouble * - the pointer to the field values array.
1457 * \throw If the number of underlying meshes is not equal to 1.
1458 * \throw If no field values are available.
1459 * \sa getUndergroundDataArray()
1461 DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1463 return getUndergroundDataArrayTemplateExt(entries);
1466 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)
1468 DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
1469 arr->setInfoAndChangeNbOfCompo(infos);
1472 MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
1476 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::shallowCpy() const
1478 MCAuto<MEDFileField1TSWithoutSDA> ret(new MEDFileField1TSWithoutSDA(*this));
1479 ret->deepCpyLeavesFrom(*this);
1483 MEDFileField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCopy() const
1485 MCAuto<MEDFileField1TSWithoutSDA> ret(shallowCpy());
1486 if(_arr.isNotNull())
1487 ret->_arr=_arr->deepCopy();
1491 //= MEDFileIntField1TSWithoutSDA
1493 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1495 return new MEDFileIntField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1498 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA()
1502 MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
1503 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<int>(fieldName,meshName,csit,iteration,order,infos)
1505 DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
1506 arr->setInfoAndChangeNbOfCompo(infos);
1509 const char *MEDFileIntField1TSWithoutSDA::getTypeStr() const
1515 * Returns a pointer to the underground DataArrayInt instance and a
1516 * sequence describing parameters of a support of each part of \a this field. The
1517 * caller should not decrRef() the returned DataArrayInt. This method allows for a
1518 * direct access to the field values. This method is intended for the field lying on one
1520 * \param [in,out] entries - the sequence describing parameters of a support of each
1521 * part of \a this field. Each item of this sequence consists of two parts. The
1522 * first part describes a type of mesh entity and an id of discretization of a
1523 * current field part. The second part describes a range of values [begin,end)
1524 * within the returned array relating to the current field part.
1525 * \return DataArrayInt * - the pointer to the field values array.
1526 * \throw If the number of underlying meshes is not equal to 1.
1527 * \throw If no field values are available.
1528 * \sa getUndergroundDataArray()
1530 DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1532 return getUndergroundDataArrayIntExt(entries);
1536 * Returns a pointer to the underground DataArrayInt instance and a
1537 * sequence describing parameters of a support of each part of \a this field. The
1538 * caller should not decrRef() the returned DataArrayInt. This method allows for a
1539 * direct access to the field values. This method is intended for the field lying on one
1541 * \param [in,out] entries - the sequence describing parameters of a support of each
1542 * part of \a this field. Each item of this sequence consists of two parts. The
1543 * first part describes a type of mesh entity and an id of discretization of a
1544 * current field part. The second part describes a range of values [begin,end)
1545 * within the returned array relating to the current field part.
1546 * \return DataArrayInt * - the pointer to the field values array.
1547 * \throw If the number of underlying meshes is not equal to 1.
1548 * \throw If no field values are available.
1549 * \sa getUndergroundDataArray()
1551 DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1553 if(_field_per_mesh.size()!=1)
1554 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
1555 if(_field_per_mesh[0]==0)
1556 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
1557 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
1558 return getUndergroundDataArrayTemplate();
1561 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
1563 MCAuto<MEDFileIntField1TSWithoutSDA> ret(new MEDFileIntField1TSWithoutSDA(*this));
1564 ret->deepCpyLeavesFrom(*this);
1568 MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCopy() const
1570 MCAuto<MEDFileIntField1TSWithoutSDA> ret(shallowCpy());
1571 if(_arr.isNotNull())
1572 ret->_arr=_arr->deepCopy();
1576 //= MEDFileFloatField1TSWithoutSDA
1578 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos)
1580 return new MEDFileFloatField1TSWithoutSDA(fieldName,meshName,csit,iteration,order,infos);
1583 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA()
1587 MEDFileFloatField1TSWithoutSDA::MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order,
1588 const std::vector<std::string>& infos):MEDFileField1TSNDTemplateWithoutSDA<float>(fieldName,meshName,csit,iteration,order,infos)
1590 DataArrayFloat *arr(getOrCreateAndGetArrayTemplate());
1591 arr->setInfoAndChangeNbOfCompo(infos);
1594 const char *MEDFileFloatField1TSWithoutSDA::getTypeStr() const
1600 * Returns a pointer to the underground DataArrayFloat instance and a
1601 * sequence describing parameters of a support of each part of \a this field. The
1602 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
1603 * direct access to the field values. This method is intended for the field lying on one
1605 * \param [in,out] entries - the sequence describing parameters of a support of each
1606 * part of \a this field. Each item of this sequence consists of two parts. The
1607 * first part describes a type of mesh entity and an id of discretization of a
1608 * current field part. The second part describes a range of values [begin,end)
1609 * within the returned array relating to the current field part.
1610 * \return DataArrayFloat * - the pointer to the field values array.
1611 * \throw If the number of underlying meshes is not equal to 1.
1612 * \throw If no field values are available.
1613 * \sa getUndergroundDataArray()
1615 DataArray *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1617 return getUndergroundDataArrayFloatExt(entries);
1621 * Returns a pointer to the underground DataArrayFloat instance and a
1622 * sequence describing parameters of a support of each part of \a this field. The
1623 * caller should not decrRef() the returned DataArrayFloat. This method allows for a
1624 * direct access to the field values. This method is intended for the field lying on one
1626 * \param [in,out] entries - the sequence describing parameters of a support of each
1627 * part of \a this field. Each item of this sequence consists of two parts. The
1628 * first part describes a type of mesh entity and an id of discretization of a
1629 * current field part. The second part describes a range of values [begin,end)
1630 * within the returned array relating to the current field part.
1631 * \return DataArrayFloat * - the pointer to the field values array.
1632 * \throw If the number of underlying meshes is not equal to 1.
1633 * \throw If no field values are available.
1634 * \sa getUndergroundDataArray()
1636 DataArrayFloat *MEDFileFloatField1TSWithoutSDA::getUndergroundDataArrayFloatExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
1638 if(_field_per_mesh.size()!=1)
1639 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : field lies on several meshes, this method has no sense !");
1640 if(_field_per_mesh[0]==0)
1641 throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
1642 _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
1643 return getUndergroundDataArrayTemplate();
1646 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::shallowCpy() const
1648 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(new MEDFileFloatField1TSWithoutSDA(*this));
1649 ret->deepCpyLeavesFrom(*this);
1653 MEDFileFloatField1TSWithoutSDA *MEDFileFloatField1TSWithoutSDA::deepCopy() const
1655 MCAuto<MEDFileFloatField1TSWithoutSDA> ret(shallowCpy());
1656 if(_arr.isNotNull())
1657 ret->_arr=_arr->deepCopy();
1661 //= MEDFileAnyTypeField1TS
1663 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
1667 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1669 med_field_type typcha;
1671 std::vector<std::string> infos;
1672 std::string dtunit,fieldName,meshName;
1673 LocateField2(fid,0,true,fieldName,typcha,infos,dtunit,meshName);
1674 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
1679 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1684 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1689 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1694 if(sizeof(med_int)==sizeof(int))
1696 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1702 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] !";
1703 throw INTERP_KERNEL::Exception(oss.str());
1706 ret->setDtUnit(dtunit.c_str());
1707 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
1709 med_int numdt,numit;
1711 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
1712 ret->setTime(numdt,numit,dt);
1715 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1717 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1721 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1722 try:MEDFileFieldGlobsReal(fid)
1724 _content=BuildContentFrom(fid,loadAll,ms,entities);
1727 catch(INTERP_KERNEL::Exception& e)
1732 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1734 med_field_type typcha;
1735 std::vector<std::string> infos;
1736 std::string dtunit,meshName;
1740 nbSteps=LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName);
1742 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
1747 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1752 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1757 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1762 if(sizeof(med_int)==sizeof(int))
1764 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,-1/*iteration*/,-1/*order*/,std::vector<std::string>());
1770 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] !";
1771 throw INTERP_KERNEL::Exception(oss.str());
1774 ret->setMeshName(meshName);
1775 ret->setDtUnit(dtunit.c_str());
1776 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
1780 std::ostringstream oss; oss << "MEDFileField1TS(fid,fieldName) : file \'" << FileNameFromFID(fid) << "\' contains field with name \'" << fieldName << "\' but there is no time steps on it !";
1781 throw INTERP_KERNEL::Exception(oss.str());
1784 med_int numdt,numit;
1786 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),1,&numdt,&numit,&dt));
1787 ret->setTime(numdt,numit,dt);
1790 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1792 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1796 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1797 try:MEDFileFieldGlobsReal(fid)
1799 _content=BuildContentFrom(fid,fieldName,loadAll,ms,entities);
1802 catch(INTERP_KERNEL::Exception& e)
1807 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c)
1810 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : empty content in input : unable to build a new instance !");
1811 if(dynamic_cast<const MEDFileField1TSWithoutSDA *>(c))
1813 MCAuto<MEDFileField1TS> ret(MEDFileField1TS::New());
1814 ret->_content=c; c->incrRef();
1817 if(dynamic_cast<const MEDFileIntField1TSWithoutSDA *>(c))
1819 MCAuto<MEDFileIntField1TS> ret(MEDFileIntField1TS::New());
1820 ret->_content=c; c->incrRef();
1823 if(dynamic_cast<const MEDFileFloatField1TSWithoutSDA *>(c))
1825 MCAuto<MEDFileFloatField1TS> ret(MEDFileFloatField1TS::New());
1826 ret->_content=c; c->incrRef();
1829 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
1832 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid)
1834 MEDFileAnyTypeField1TS *ret(BuildNewInstanceFromContent(c));
1835 ret->setFileName(FileNameFromFID(fid));
1839 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, bool loadAll)
1841 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1842 return New(fid,loadAll);
1845 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, bool loadAll)
1847 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,loadAll,0,0));
1848 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1849 ret->loadGlobals(fid);
1853 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, bool loadAll)
1855 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1856 return New(fid,fieldName,loadAll);
1859 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, bool loadAll)
1861 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,loadAll,0,0));
1862 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1863 ret->loadGlobals(fid);
1867 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll)
1869 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1870 return New(fid,fieldName,iteration,order,loadAll);
1873 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll)
1875 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,0));
1876 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1877 ret->loadGlobals(fid);
1881 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
1883 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(fileName));
1884 return NewAdv(fid,fieldName,iteration,order,loadAll,entities);
1887 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities)
1889 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> c(BuildContentFrom(fid,fieldName,iteration,order,loadAll,0,entities));
1890 MCAuto<MEDFileAnyTypeField1TS> ret(BuildNewInstanceFromContent(c,fid));
1891 ret->loadGlobals(fid);
1895 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1897 med_field_type typcha;
1898 std::vector<std::string> infos;
1899 std::string dtunit,meshName;
1901 int nbOfStep2(LocateField(fid,fieldName,iii,typcha,infos,dtunit,meshName));
1902 MCAuto<MEDFileAnyTypeField1TSWithoutSDA> ret;
1907 ret=MEDFileField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1912 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1917 ret=MEDFileFloatField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1922 if(sizeof(med_int)==sizeof(int))
1924 ret=MEDFileIntField1TSWithoutSDA::New(fieldName,meshName,-1,iteration,order,std::vector<std::string>());
1930 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] !";
1931 throw INTERP_KERNEL::Exception(oss.str());
1934 ret->setDtUnit(dtunit.c_str());
1935 ret->getOrCreateAndGetArray()->setInfoAndChangeNbOfCompo(infos);
1938 std::vector< std::pair<int,int> > dtits(nbOfStep2);
1939 for(int i=0;i<nbOfStep2 && !found;i++)
1941 med_int numdt,numit;
1943 MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,fieldName.c_str(),i+1,&numdt,&numit,&dt));
1944 if(numdt==iteration && numit==order)
1950 dtits[i]=std::pair<int,int>(numdt,numit);
1954 std::ostringstream oss; oss << "No such iteration (" << iteration << "," << order << ") in existing field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available iterations are : ";
1955 for(std::vector< std::pair<int,int> >::const_iterator iter=dtits.begin();iter!=dtits.end();iter++)
1956 oss << "(" << (*iter).first << "," << (*iter).second << "), ";
1957 throw INTERP_KERNEL::Exception(oss.str());
1960 ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1962 ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret),ms,entities);
1966 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
1967 try:MEDFileFieldGlobsReal(fid)
1969 _content=BuildContentFrom(fid,fieldName,iteration,order,loadAll,ms,entities);
1972 catch(INTERP_KERNEL::Exception& e)
1978 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
1979 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
1981 * \warning this is a shallow copy constructor
1983 MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent)
1985 if(!shallowCopyOfContent)
1987 const MEDFileAnyTypeField1TSWithoutSDA *otherPtr(&other);
1988 otherPtr->incrRef();
1989 _content=const_cast<MEDFileAnyTypeField1TSWithoutSDA *>(otherPtr);
1993 _content=other.shallowCpy();
1997 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)
2001 int nbFields=MEDnField(fid);
2002 if(fieldIdCFormat>=nbFields)
2004 std::ostringstream oss; oss << "MEDFileAnyTypeField1TS::LocateField2(fileName) : in file \'" << FileNameFromFID(fid) << "\' number of fields is " << nbFields << " ! Trying to request for id " << fieldIdCFormat << " !";
2005 throw INTERP_KERNEL::Exception(oss.str());
2008 int ncomp(MEDfieldnComponent(fid,fieldIdCFormat+1));
2009 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
2010 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(ncomp*MED_SNAME_SIZE));
2011 INTERP_KERNEL::AutoPtr<char> dtunit(MEDLoaderBase::buildEmptyString(MED_LNAME_SIZE));
2012 INTERP_KERNEL::AutoPtr<char> nomcha(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2013 INTERP_KERNEL::AutoPtr<char> nomMaa(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
2016 MEDFILESAFECALLERRD0(MEDfieldInfo,(fid,fieldIdCFormat+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep));
2017 fieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE);
2018 dtunitOut=MEDLoaderBase::buildStringFromFortran(dtunit,MED_LNAME_SIZE);
2019 meshName=MEDLoaderBase::buildStringFromFortran(nomMaa,MED_NAME_SIZE);
2020 infos.clear(); infos.resize(ncomp);
2021 for(int j=0;j<ncomp;j++)
2022 infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
2027 * This method throws an INTERP_KERNEL::Exception if \a fieldName field is not in file pointed by \a fid and with name \a fileName.
2030 * \return in case of success the number of time steps available for the field with name \a fieldName.
2032 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)
2034 int nbFields=MEDnField(fid);
2036 std::vector<std::string> fns(nbFields);
2038 for(int i=0;i<nbFields && !found;i++)
2040 std::string tmp,tmp2;
2041 nbOfStep2=LocateField2(fid,i,false,tmp,typcha,infos,dtunitOut,tmp2);
2043 found=(tmp==fieldName);
2052 std::ostringstream oss; oss << "No such field '" << fieldName << "' in file '" << FileNameFromFID(fid) << "' ! Available fields are : ";
2053 for(std::vector<std::string>::const_iterator it=fns.begin();it!=fns.end();it++)
2054 oss << "\"" << *it << "\" ";
2055 throw INTERP_KERNEL::Exception(oss.str());
2061 * This method as MEDFileField1TSW::setLocNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
2062 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
2063 * This method changes the attribute (here it's profile name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
2064 * It is the responsibility of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
2065 * to keep a valid instance.
2066 * 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.
2067 * If \b newPflName profile name does not already exist the profile with old name will be renamed with name \b newPflName.
2068 * 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.
2070 * \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.
2071 * \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.
2072 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
2073 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
2074 * \param [in] newLocName is the new localization name.
2075 * \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.
2076 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newPflName
2078 void MEDFileAnyTypeField1TS::setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob)
2080 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2081 std::string oldPflName=disc->getProfile();
2082 std::vector<std::string> vv=getPflsReallyUsedMulti();
2083 int nbOfOcc=std::count(vv.begin(),vv.end(),oldPflName);
2084 if(forceRenameOnGlob || (!existsPfl(newPflName) && nbOfOcc==1))
2086 disc->setProfile(newPflName);
2087 DataArrayInt *pfl=getProfile(oldPflName.c_str());
2088 pfl->setName(newPflName);
2092 std::ostringstream oss; oss << "MEDFileField1TS::setProfileNameOnLeaf : Profile \"" << newPflName << "\" already exists or referenced more than one !";
2093 throw INTERP_KERNEL::Exception(oss.str());
2098 * This method as MEDFileField1TSW::setProfileNameOnLeaf, is dedicated for advanced user that a want a very fine control on their data structure
2099 * without overhead. This method can be called only regarding information returned by MEDFileField1TSWithoutSDA::getFieldSplitedByType or MEDFileField1TSWithoutSDA::getFieldSplitedByType2.
2100 * This method changes the attribute (here it's localization name) of the leaf datastructure (MEDFileFieldPerMeshPerTypePerDisc instance).
2101 * It is the responsibility of the caller to invoke MEDFileFieldGlobs::appendProfile or MEDFileFieldGlobs::getProfile
2102 * to keep a valid instance.
2103 * 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.
2104 * This method is an extension of MEDFileField1TSWithoutSDA::setProfileNameOnLeafExt method because it performs a modification of global info.
2105 * If \b newLocName profile name does not already exist the localization with old name will be renamed with name \b newLocName.
2106 * 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.
2108 * \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.
2109 * \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.
2110 * \param [in] locId is the localization id to find the right MEDFileFieldPerMeshPerTypePerDisc instance to set. It corresponds to the position of
2111 * \c pfls[std::distance(types.begin(),std::find(types.begin(),typ)] vector in MEDFileField1TSWithoutSDA::getFieldSplitedByType. For non gausspoints field users, the value is 0.
2112 * \param [in] newLocName is the new localization name.
2113 * \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.
2114 * If false, an exception will be thrown to force user to change previously the name of the profile with name \b newLocName
2116 void MEDFileAnyTypeField1TS::setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob)
2118 MEDFileFieldPerMeshPerTypePerDisc *disc=getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2119 std::string oldLocName=disc->getLocalization();
2120 std::vector<std::string> vv=getLocsReallyUsedMulti();
2121 int nbOfOcc=std::count(vv.begin(),vv.end(),oldLocName);
2122 if(forceRenameOnGlob || (!existsLoc(newLocName) && nbOfOcc==1))
2124 disc->setLocalization(newLocName);
2125 MEDFileFieldLoc& loc=getLocalization(oldLocName.c_str());
2126 loc.setName(newLocName);
2130 std::ostringstream oss; oss << "MEDFileField1TS::setLocNameOnLeaf : Localization \"" << newLocName << "\" already exists or referenced more than one !";
2131 throw INTERP_KERNEL::Exception(oss.str());
2135 MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase()
2137 MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
2139 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : content is expected to be not null !");
2143 const MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::contentNotNullBase() const
2145 const MEDFileAnyTypeField1TSWithoutSDA *ret=_content;
2147 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS : const content is expected to be not null !");
2152 * This method alloc the arrays and load potentially huge arrays contained in this field.
2153 * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter.
2154 * This method can be also called to refresh or reinit values from a file.
2156 * \throw If the fileName is not set or points to a non readable MED file.
2157 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
2159 void MEDFileAnyTypeField1TS::loadArrays()
2161 if(getFileName().empty())
2162 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::loadArrays : the structure does not come from a file !");
2163 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
2164 contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase());
2168 * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
2169 * But once data loaded once, this method does nothing. Contrary to MEDFileAnyTypeField1TS::loadArrays and MEDFileAnyTypeField1TS::unloadArrays
2170 * this method does not throw if \a this does not come from file read.
2172 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::unloadArrays
2174 void MEDFileAnyTypeField1TS::loadArraysIfNecessary()
2176 if(!getFileName().empty())
2178 MEDFileUtilities::AutoFid fid(OpenMEDFileForRead(getFileName()));
2179 contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase());
2184 * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
2185 * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
2186 * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss instead.
2188 * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary, MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss
2190 void MEDFileAnyTypeField1TS::unloadArrays()
2192 contentNotNullBase()->unloadArrays();
2196 * 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.
2197 * This method is the symmetrical method of MEDFileAnyTypeField1TS::loadArraysIfNecessary.
2198 * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
2200 * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary
2202 void MEDFileAnyTypeField1TS::unloadArraysWithoutDataLoss()
2204 if(!getFileName().empty())
2205 contentNotNullBase()->unloadArrays();
2208 void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const
2210 int nbComp(getNumberOfComponents());
2211 INTERP_KERNEL::AutoPtr<char> comp(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
2212 INTERP_KERNEL::AutoPtr<char> unit(MEDLoaderBase::buildEmptyString(nbComp*MED_SNAME_SIZE));
2213 for(int i=0;i<nbComp;i++)
2215 std::string info=getInfo()[i];
2217 MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
2218 MEDLoaderBase::safeStrCpy2(c.c_str(),MED_SNAME_SIZE,comp+i*MED_SNAME_SIZE,_too_long_str);
2219 MEDLoaderBase::safeStrCpy2(u.c_str(),MED_SNAME_SIZE,unit+i*MED_SNAME_SIZE,_too_long_str);
2221 if(getName().empty())
2222 throw INTERP_KERNEL::Exception("MEDFileField1TS::write : MED file does not accept field with empty name !");
2223 MEDFILESAFECALLERWR0(MEDfieldCr,(fid,getName().c_str(),getMEDFileFieldType(),nbComp,comp,unit,getDtUnit().c_str(),getMeshName().c_str()));
2224 writeGlobals(fid,*this);
2225 contentNotNullBase()->writeLL(fid,*this,*contentNotNullBase());
2228 std::size_t MEDFileAnyTypeField1TS::getHeapMemorySizeWithoutChildren() const
2230 return MEDFileFieldGlobsReal::getHeapMemorySizeWithoutChildren();
2233 std::vector<const BigMemoryObject *> MEDFileAnyTypeField1TS::getDirectChildrenWithNull() const
2235 std::vector<const BigMemoryObject *> ret(MEDFileFieldGlobsReal::getDirectChildrenWithNull());
2236 ret.push_back((const MEDFileAnyTypeField1TSWithoutSDA *)_content);
2241 * Returns a string describing \a this field. This string is outputted
2242 * by \c print Python command.
2244 std::string MEDFileAnyTypeField1TS::simpleRepr() const
2246 std::ostringstream oss;
2247 contentNotNullBase()->simpleRepr(0,oss,-1);
2248 simpleReprGlobs(oss);
2253 * This method returns all profiles whose name is non empty used.
2254 * \b WARNING If profile is used several times it will be reported \b only \b once.
2255 * To get non empty name profiles as time as they appear in \b this call MEDFileField1TS::getPflsReallyUsedMulti instead.
2257 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsed() const
2259 return contentNotNullBase()->getPflsReallyUsed2();
2263 * This method returns all localizations whose name is non empty used.
2264 * \b WARNING If localization is used several times it will be reported \b only \b once.
2266 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsed() const
2268 return contentNotNullBase()->getLocsReallyUsed2();
2272 * This method returns all profiles whose name is non empty used.
2273 * \b WARNING contrary to MEDFileField1TS::getPflsReallyUsed, if profile is used several times it will be reported as time as it appears.
2275 std::vector<std::string> MEDFileAnyTypeField1TS::getPflsReallyUsedMulti() const
2277 return contentNotNullBase()->getPflsReallyUsedMulti2();
2281 * This method returns all localizations whose name is non empty used.
2282 * \b WARNING contrary to MEDFileField1TS::getLocsReallyUsed if localization is used several times it will be reported as time as it appears.
2284 std::vector<std::string> MEDFileAnyTypeField1TS::getLocsReallyUsedMulti() const
2286 return contentNotNullBase()->getLocsReallyUsedMulti2();
2289 void MEDFileAnyTypeField1TS::changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2291 contentNotNullBase()->changePflsRefsNamesGen2(mapOfModif);
2294 void MEDFileAnyTypeField1TS::changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif)
2296 contentNotNullBase()->changeLocsRefsNamesGen2(mapOfModif);
2299 int MEDFileAnyTypeField1TS::getDimension() const
2301 return contentNotNullBase()->getDimension();
2304 int MEDFileAnyTypeField1TS::getIteration() const
2306 return contentNotNullBase()->getIteration();
2309 int MEDFileAnyTypeField1TS::getOrder() const
2311 return contentNotNullBase()->getOrder();
2314 double MEDFileAnyTypeField1TS::getTime(int& iteration, int& order) const
2316 return contentNotNullBase()->getTime(iteration,order);
2319 void MEDFileAnyTypeField1TS::setTime(int iteration, int order, double val)
2321 contentNotNullBase()->setTime(iteration,order,val);
2324 std::string MEDFileAnyTypeField1TS::getName() const
2326 return contentNotNullBase()->getName();
2329 void MEDFileAnyTypeField1TS::setName(const std::string& name)
2331 contentNotNullBase()->setName(name);
2334 void MEDFileAnyTypeField1TS::simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const
2336 contentNotNullBase()->simpleRepr(bkOffset,oss,f1tsId);
2339 std::string MEDFileAnyTypeField1TS::getDtUnit() const
2341 return contentNotNullBase()->getDtUnit();
2344 void MEDFileAnyTypeField1TS::setDtUnit(const std::string& dtUnit)
2346 contentNotNullBase()->setDtUnit(dtUnit);
2349 std::string MEDFileAnyTypeField1TS::getMeshName() const
2351 return contentNotNullBase()->getMeshName();
2354 void MEDFileAnyTypeField1TS::setMeshName(const std::string& newMeshName)
2356 contentNotNullBase()->setMeshName(newMeshName);
2359 bool MEDFileAnyTypeField1TS::changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab)
2361 return contentNotNullBase()->changeMeshNames(modifTab);
2364 int MEDFileAnyTypeField1TS::getMeshIteration() const
2366 return contentNotNullBase()->getMeshIteration();
2369 int MEDFileAnyTypeField1TS::getMeshOrder() const
2371 return contentNotNullBase()->getMeshOrder();
2374 int MEDFileAnyTypeField1TS::getNumberOfComponents() const
2376 return contentNotNullBase()->getNumberOfComponents();
2379 bool MEDFileAnyTypeField1TS::isDealingTS(int iteration, int order) const
2381 return contentNotNullBase()->isDealingTS(iteration,order);
2384 std::pair<int,int> MEDFileAnyTypeField1TS::getDtIt() const
2386 return contentNotNullBase()->getDtIt();
2389 void MEDFileAnyTypeField1TS::fillIteration(std::pair<int,int>& p) const
2391 contentNotNullBase()->fillIteration(p);
2394 void MEDFileAnyTypeField1TS::fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const
2396 contentNotNullBase()->fillTypesOfFieldAvailable(types);
2399 void MEDFileAnyTypeField1TS::setInfo(const std::vector<std::string>& infos)
2401 contentNotNullBase()->setInfo(infos);
2404 const std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo() const
2406 return contentNotNullBase()->getInfo();
2408 std::vector<std::string>& MEDFileAnyTypeField1TS::getInfo()
2410 return contentNotNullBase()->getInfo();
2413 bool MEDFileAnyTypeField1TS::presenceOfMultiDiscPerGeoType() const
2415 return contentNotNullBase()->presenceOfMultiDiscPerGeoType();
2418 MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId)
2420 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2423 const MEDFileFieldPerMeshPerTypePerDisc *MEDFileAnyTypeField1TS::getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const
2425 return contentNotNullBase()->getLeafGivenMeshAndTypeAndLocId(mName,typ,locId);
2428 int MEDFileAnyTypeField1TS::getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const
2430 return contentNotNullBase()->getNonEmptyLevels(mname,levs);
2433 void MEDFileAnyTypeField1TS::convertMedBallIntoClassic()
2435 return contentNotNullBase()->convertMedBallIntoClassic();
2438 void MEDFileAnyTypeField1TS::makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl)
2440 return contentNotNullBase()->makeReduction(ct,tof,pfl);
2443 std::vector<TypeOfField> MEDFileAnyTypeField1TS::getTypesOfFieldAvailable() const
2445 return contentNotNullBase()->getTypesOfFieldAvailable();
2448 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,
2449 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
2451 return contentNotNullBase()->getFieldSplitedByType(mname,types,typesF,pfls,locs);
2455 * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this.
2456 * The returned instances are deep copy of \a this except that for globals that are shared with those contained in \a this.
2457 * ** WARNING ** do no forget to rename the output instances to avoid to write n-times in the same MED file field !
2459 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitComponents() const
2461 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2463 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitComponents : no content in this ! Unable to split components !");
2464 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit=content->splitComponents();
2465 std::size_t sz(contentsSplit.size());
2466 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2467 for(std::size_t i=0;i<sz;i++)
2469 ret[i]=shallowCpy();
2470 ret[i]->_content=contentsSplit[i];
2476 * This method returns as MEDFileAnyTypeField1TS new instances as number of spatial discretizations in \a this.
2477 * The returned instances are shallowed copied of \a this except that for globals that are shared with those contained in \a this.
2479 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitDiscretizations() const
2481 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2483 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitDiscretizations : no content in this ! Unable to split discretization !");
2484 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitDiscretizations());
2485 std::size_t sz(contentsSplit.size());
2486 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2487 for(std::size_t i=0;i<sz;i++)
2489 ret[i]=shallowCpy();
2490 ret[i]->_content=contentsSplit[i];
2496 * This method returns as MEDFileAnyTypeField1TS new instances as number of maximal number of discretization in \a this.
2497 * The returned instances are shallowed copied of \a this except that for globals that are shared with those contained in \a this.
2499 std::vector< MCAuto< MEDFileAnyTypeField1TS > > MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes() const
2501 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2503 throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TS::splitMultiDiscrPerGeoTypes : no content in this ! Unable to split discretization !");
2504 std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > contentsSplit(content->splitMultiDiscrPerGeoTypes());
2505 std::size_t sz(contentsSplit.size());
2506 std::vector< MCAuto< MEDFileAnyTypeField1TS > > ret(sz);
2507 for(std::size_t i=0;i<sz;i++)
2509 ret[i]=shallowCpy();
2510 ret[i]->_content=contentsSplit[i];
2515 MEDFileAnyTypeField1TS *MEDFileAnyTypeField1TS::deepCopy() const
2517 MCAuto<MEDFileAnyTypeField1TS> ret=shallowCpy();
2518 if((const MEDFileAnyTypeField1TSWithoutSDA *)_content)
2519 ret->_content=_content->deepCopy();
2520 ret->deepCpyGlobs(*this);
2524 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr)
2526 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*field));
2527 return copyTinyInfoFrom(field->timeDiscrSafe(),ft,arr);
2530 int MEDFileAnyTypeField1TS::copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr)
2532 return contentNotNullBase()->copyTinyInfoFrom(th,field,arr);
2538 * This method performs a copy with datatype modification ( float64->int32 ) of \a this. The globals information are copied
2539 * following the given input policy.
2541 * \param [in] isDeepCpyGlobs - a boolean that indicates the behaviour concerning globals (profiles and localizations)
2542 * By default (true) the globals are deeply copied.
2543 * \return MEDFileIntField1TS * - a new object that is the result of the conversion of \a this to int32 field.
2545 MEDFileIntField1TS *MEDFileField1TS::convertToInt(bool isDeepCpyGlobs) const
2547 MCAuto<MEDFileIntField1TS> ret;
2548 const MEDFileAnyTypeField1TSWithoutSDA *content(_content);
2551 const MEDFileField1TSWithoutSDA *contc=dynamic_cast<const MEDFileField1TSWithoutSDA *>(content);
2553 throw INTERP_KERNEL::Exception("MEDFileField1TS::convertToInt : the content inside this is not FLOAT64 ! This is incoherent !");
2554 MCAuto<MEDFileIntField1TSWithoutSDA> newc(contc->convertToInt());
2555 ret=static_cast<MEDFileIntField1TS *>(MEDFileAnyTypeField1TS::BuildNewInstanceFromContent((MEDFileIntField1TSWithoutSDA *)newc));
2558 ret=MEDFileIntField1TS::New();
2560 ret->deepCpyGlobs(*this);
2562 ret->shallowCpyGlobs(*this);
2566 MEDFileField1TS::MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms)
2567 try:MEDFileTemplateField1TS<double>(fid,loadAll,ms)
2570 catch(INTERP_KERNEL::Exception& e)
2573 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms)
2574 try:MEDFileTemplateField1TS<double>(fid,fieldName,loadAll,ms)
2577 catch(INTERP_KERNEL::Exception& e)
2580 MEDFileField1TS::MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms)
2581 try:MEDFileTemplateField1TS<double>(fid,fieldName,iteration,order,loadAll,ms)
2584 catch(INTERP_KERNEL::Exception& e)
2588 * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
2589 * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
2591 * \warning this is a shallow copy constructor
2593 MEDFileField1TS::MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
2594 try:MEDFileTemplateField1TS<double>(other,shallowCopyOfContent)
2597 catch(INTERP_KERNEL::Exception& e)
2600 MEDFileField1TS *MEDFileField1TS::shallowCpy() const
2602 return new MEDFileField1TS(*this);
2605 std::vector< std::vector<DataArrayDouble *> > MEDFileField1TS::getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
2606 std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const
2608 return contentNotNull()->getFieldSplitedByType2(mname,types,typesF,pfls,locs);
2611 //= MEDFileIntField1TS
2613 MCAuto<MEDCouplingFieldDouble> MEDFileIntField1TS::ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f)
2616 throw INTERP_KERNEL::Exception("MEDFileIntField1TS::ConvertFieldIntToFieldDouble : null input field !");
2618 double t0(f->getTime(t1,t2));
2619 std::string tu(f->getTimeUnit());
2620 MCAuto<MEDCouplingFieldTemplate> ft(MEDCouplingFieldTemplate::New(*f));
2621 MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*ft));
2622 ret->setTime(t0,t1,t2); ret->setTimeUnit(tu);
2626 //= MEDFileFloatField1TS
2628 //= MEDFileFloatField1TS