Salome HOME
Merge branch 'V9_9_BR'
[tools/medcoupling.git] / src / MEDLoader / MEDFileFieldMultiTS.cxx
index 672f1a5c375f0d73772c7e7835c3da2a87811ffe..cb705f3fa141aa4a9e659ca049902b14b832f503 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2017-2020  CEA/DEN, EDF R&D
+// Copyright (C) 2017-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -47,7 +47,7 @@ template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<Int64>;
 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<float>;
 
 extern INTERP_KERNEL::NormalizedCellType ConvertGeometryType(med_geometry_type geotype);
-  
+
 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
 
 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
@@ -147,7 +147,7 @@ MEDFileAnyTypeFieldMultiTSWithoutSDA *MEDFileAnyTypeFieldMultiTSWithoutSDA::buil
   std::size_t j=bg;
   for(int i=0;i<nbOfEntriesToKeep;i++,j+=step)
     {
-      if(j>=0 && j<sz)
+      if(j<sz)
         {
           const MEDFileAnyTypeField1TSWithoutSDA *tse=_time_steps[j];
           MCAuto<MEDFileAnyTypeField1TSWithoutSDA> tse2;
@@ -418,7 +418,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::simpleRepr(int bkOffset, std::ostream
   int i=0;
   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,i++)
     {
-      std::string chapter(17,'0'+i);
+      std::string chapter(17,(char)('0'+i));
       oss << startLine << chapter << std::endl;
       const MEDFileAnyTypeField1TSWithoutSDA *cur=(*it);
       if(cur)
@@ -496,18 +496,18 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysR
   MEDFileCapability mfcap(fid);
   if( ( !entities || entities->areAllStaticPresentAndNoDyn() ) && mfcap.isFastReader())
     {// no entities
-      int nentitype(MEDfieldnEntityType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT));
+      med_int nentitype(MEDfieldnEntityType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT));
       INTERP_KERNEL::AutoPtr<med_entity_type> types(new med_entity_type[nentitype]);
       med_int usedbyncs;
       MEDFILESAFECALLERRD0(MEDfieldEntityType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types,&usedbyncs));
       std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > entitiesFastP;
       for(int i=0;i<nentitype;i++)
         {
-          int ngeotype(MEDfieldnGeometryType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types[i]));
+          med_int ngeotype(MEDfieldnGeometryType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types[i]));
           INTERP_KERNEL::AutoPtr<med_geometry_type> geotypes(new med_geometry_type[ngeotype]);
           med_int geousedbyncs;
           MEDFILESAFECALLERRD0(MEDfieldGeometryType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types[i],geotypes,&geousedbyncs));
-          for(int j=0;j<ngeotype;j++)
+          for(med_int j=0;j<ngeotype;j++)
             {
               std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> p(MEDFileMesh::ConvertFromMEDFileEntity(types[i]),ConvertGeometryType(geotypes[j]));
               entitiesFastP.push_back(p);
@@ -680,7 +680,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::eraseTimeStepIds2(int bg, int end, in
 int MEDFileAnyTypeFieldMultiTSWithoutSDA::getPosOfTimeStep(int iteration, int order) const
 {
   int ret=0;
-  std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : "; 
+  std::ostringstream oss; oss << "MEDFileFieldMultiTSWithoutSDA::getPosOfTimeStep : No such time step (" << iteration << "," << order << ") !\nPossibilities are : ";
   for(std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA>  >::const_iterator it=_time_steps.begin();it!=_time_steps.end();it++,ret++)
     {
       const MEDFileAnyTypeField1TSWithoutSDA *tmp(*it);
@@ -730,7 +730,7 @@ std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getItera
 /*!
  * This method has 3 inputs 'iteration' 'order' 'mname'. 'mname' can be null if the user is the general case where there is only one meshName lying on 'this'
  * This method returns two things.
- * - The absolute dimension of 'this' in first parameter. 
+ * - The absolute dimension of 'this' in first parameter.
  * - The available ext levels relative to the absolute dimension returned in first parameter. These relative levels are relative
  *   to the first output parameter. The values in 'levs' will be returned in decreasing order.
  *
@@ -743,7 +743,7 @@ std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getItera
  *
  * This method is useful to make the link between meshDimension of the underlying mesh in 'this' and the levels on 'this'.
  * It is possible (even if it is not common) that the highest level in 'this' were not equal to the meshDimension of the underlying mesh in 'this'.
- * 
+ *
  * Let's consider the typical following case :
  * - a mesh 'm1' has a meshDimension 3 and has the following non empty levels
  * [0,-1,-2] for example 'm1' lies on TETRA4, HEXA8 TRI3 and SEG2
@@ -752,7 +752,7 @@ std::vector< std::pair<int,int> > MEDFileAnyTypeFieldMultiTSWithoutSDA::getItera
  * - 'f2' lies on 'm1' too and is defined on 2D and 1D cells for example TRI3 and SEG2
  *
  * In this case f1->getNonEmptyLevelsExt will return (3,[0,-2]) and f2->getNonEmptyLevelsExt will return (2,[0,-1])
- * 
+ *
  * To retrieve the highest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+0);//absDim-meshDim+relativeLev
  * To retrieve the lowest level of f1 it should be done, f1->getFieldAtLevel(ON_CELLS,3-3+(-2));//absDim-meshDim+relativeLev
  * To retrieve the highest level of f2 it should be done, f1->getFieldAtLevel(ON_CELLS,2-3+0);//absDim-meshDim+relativeLev
@@ -933,10 +933,10 @@ std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > MEDFileAnyTypeFieldM
       const MEDFileAnyTypeField1TSWithoutSDA *timeStep(_time_steps[i]);
       if(!timeStep)
         {
-          std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !"; 
+          std::ostringstream oss; oss << "MEDFileAnyTypeFieldMultiTSWithoutSDA::splitDiscretizations : time step #" << i << " is null !";
           throw INTERP_KERNEL::Exception(oss.str());
         }
-      items[i]=timeStep->splitDiscretizations();  
+      items[i]=timeStep->splitDiscretizations();
     }
   //
   std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > ret;
@@ -1157,6 +1157,36 @@ MEDFileInt32FieldMultiTSWithoutSDA *MEDFileFieldMultiTSWithoutSDA::convertToInt(
   return ret.retn();
 }
 
+MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileFieldMultiTSWithoutSDA::createNewWithSDA() const
+{
+  MCAuto<MEDFileFieldMultiTS> ret(MEDFileFieldMultiTS::New());
+  return DynamicCast<MEDFileFieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
+}
+
+//=
+
+MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileInt32FieldMultiTSWithoutSDA::createNewWithSDA() const
+{
+  MCAuto<MEDFileInt32FieldMultiTS> ret(MEDFileInt32FieldMultiTS::New());
+  return DynamicCast<MEDFileInt32FieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
+}
+
+//=
+
+MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileInt64FieldMultiTSWithoutSDA::createNewWithSDA() const
+{
+  MCAuto<MEDFileInt64FieldMultiTS> ret(MEDFileInt64FieldMultiTS::New());
+  return DynamicCast<MEDFileInt64FieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
+}
+
+//=
+
+MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileFloatFieldMultiTSWithoutSDA::createNewWithSDA() const
+{
+  MCAuto<MEDFileFloatFieldMultiTS> ret(MEDFileFloatFieldMultiTS::New());
+  return DynamicCast<MEDFileFloatFieldMultiTS,MEDFileAnyTypeFieldMultiTS>(ret);
+}
+
 //= MEDFileAnyTypeFieldMultiTS
 
 MEDFileAnyTypeFieldMultiTS::MEDFileAnyTypeFieldMultiTS()
@@ -1301,7 +1331,7 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromCont
       ret->_content=c;  c->incrRef();
       return ret.retn();
     }
-  throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 and INT32 has been built but not intercepted !");
+  throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent : internal error ! a content of type different from FLOAT64 FLOAT32 INT32 and INT64 has been built but not intercepted !");
 }
 
 MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid)
@@ -1618,7 +1648,7 @@ void MEDFileAnyTypeFieldMultiTS::writeLL(med_idt fid) const
  * This method alloc the arrays and load potentially huge arrays contained in this field.
  * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter.
  * This method can be also called to refresh or reinit values from a file.
- * 
+ *
  * \throw If the fileName is not set or points to a non readable MED file.
  */
 void MEDFileAnyTypeFieldMultiTS::loadArrays()
@@ -1632,7 +1662,7 @@ void MEDFileAnyTypeFieldMultiTS::loadArrays()
 /*!
  * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays.
  * But once data loaded once, this method does nothing.
- * 
+ *
  * \throw If the fileName is not set or points to a non readable MED file.
  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::unloadArrays
  */
@@ -1649,7 +1679,7 @@ void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary()
  * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false.
  * \b WARNING, this method does release arrays even if \a this does not come from a load of a MED file.
  * So this method can lead to a loss of data. If you want to unload arrays safely call MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss instead.
- * 
+ *
  * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary, MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss
  */
 void MEDFileAnyTypeFieldMultiTS::unloadArrays()
@@ -1661,7 +1691,7 @@ void MEDFileAnyTypeFieldMultiTS::unloadArrays()
  * 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.
  * This method is the symmetrical method of MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary.
  * This method is useful to reduce \b safely amount of heap memory necessary for \a this by using MED file as database.
- * 
+ *
  * \sa MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary
  */
 void MEDFileAnyTypeFieldMultiTS::unloadArraysWithoutDataLoss()
@@ -2059,6 +2089,7 @@ MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< type
 
 /*!
  * \a dts and \a ftmss are expected to have same size.
+ * see MEDFileFieldPerMeshPerTypePerDisc::Aggregate for description of \a dts.
  */
 MCAuto<MEDFileAnyTypeFieldMultiTS> MEDFileAnyTypeFieldMultiTS::Aggregate(const std::vector<const MEDFileAnyTypeFieldMultiTS *>& fmtss, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts)
 {
@@ -2178,7 +2209,7 @@ MEDFileAnyTypeFieldMultiTSIterator::MEDFileAnyTypeFieldMultiTSIterator(MEDFileAn
     }
 }
 
-MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator() 
+MEDFileAnyTypeFieldMultiTSIterator::~MEDFileAnyTypeFieldMultiTSIterator()
 {
 }