-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024 CEA, EDF
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingMesh.hxx"
-#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MCAuto.hxx"
#include <sstream>
#include <algorithm>
-using namespace ParaMEDMEM;
+using namespace MEDCoupling;
-MEDCouplingMultiFields *MEDCouplingMultiFields::New(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception)
+MEDCouplingMultiFields *MEDCouplingMultiFields::New(const std::vector<MEDCouplingFieldDouble *>& fs)
{
return new MEDCouplingMultiFields(fs);
}
return new MEDCouplingMultiFields;
}
-MEDCouplingMultiFields *MEDCouplingMultiFields::deepCpy() const
+MEDCouplingMultiFields *MEDCouplingMultiFields::deepCopy() const
{
return new MEDCouplingMultiFields(*this);
}
std::string MEDCouplingMultiFields::getName() const
{
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ std::vector< MCAuto<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
for(;it!=_fs.end();it++)
if((const MEDCouplingFieldDouble *)(*it))
return (*it)->getName();
std::string MEDCouplingMultiFields::getDescription() const
{
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ std::vector< MCAuto<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
for(;it!=_fs.end();it++)
if((const MEDCouplingFieldDouble *)(*it))
return (*it)->getDescription();
std::string MEDCouplingMultiFields::getTimeUnit() const
{
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ std::vector< MCAuto<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
for(;it!=_fs.end();it++)
if((const MEDCouplingFieldDouble *)(*it))
return (*it)->getTimeUnit();
return std::string();
}
-double MEDCouplingMultiFields::getTimeResolution() const throw(INTERP_KERNEL::Exception)
+double MEDCouplingMultiFields::getTimeResolution() const
{
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ std::vector< MCAuto<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
for(;it!=_fs.end();it++)
if((const MEDCouplingFieldDouble *)(*it))
return (*it)->getTimeTolerance();
std::vector<MEDCouplingMesh *> ms;
std::vector<int> refms;
try
- {
+ {
ms=getDifferentMeshes(refms);
ret << ms.size() << "\n";
- }
- catch(INTERP_KERNEL::Exception& e)
- { ret << "Current instance is INVALID !\n"; }
+ }
+ catch(INTERP_KERNEL::Exception& /*e*/)
+ { ret << "Current instance is INVALID !\n"; }
return ret.str();
}
return true;
}
-const MEDCouplingFieldDouble *MEDCouplingMultiFields::getFieldWithId(int id) const throw(INTERP_KERNEL::Exception)
+const MEDCouplingFieldDouble *MEDCouplingMultiFields::getFieldWithId(int id) const
{
- if(id>=(int)_fs.size() || id < 0)
+ if(id>=ToIdType(_fs.size()) || id < 0)
throw INTERP_KERNEL::Exception("MEDCouplingMultiFields::getFieldWithId : invalid id outside boundaries !");
return _fs[id];
}
return (int)_fs.size();
}
-const MEDCouplingFieldDouble *MEDCouplingMultiFields::getFieldAtPos(int id) const throw(INTERP_KERNEL::Exception)
+const MEDCouplingFieldDouble *MEDCouplingMultiFields::getFieldAtPos(int id) const
{
- if(id<0 || id>=(int)_fs.size())
+ if(id<0 || id>=ToIdType(_fs.size()))
{
std::ostringstream oss; oss << "MEDCouplingMultiFields::getFieldAtPos : Invalid given pos : should be >=0 and < " << _fs.size() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
void MEDCouplingMultiFields::updateTime() const
{
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ std::vector< MCAuto<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
for(;it!=_fs.end();it++)
if((const MEDCouplingFieldDouble *)(*it))
(*it)->updateTime();
updateTimeWith(*(*it));
}
-std::size_t MEDCouplingMultiFields::getHeapMemorySize() const
+std::size_t MEDCouplingMultiFields::getHeapMemorySizeWithoutChildren() const
+{
+ return 0;
+}
+
+std::vector<const BigMemoryObject *> MEDCouplingMultiFields::getDirectChildrenWithNull() const
{
- std::vector<int> tmp;
- std::vector< std::vector<int> > tmp2;
- std::vector<MEDCouplingMesh *> ms=getDifferentMeshes(tmp);
- std::vector<DataArrayDouble *> arrs=getDifferentArrays(tmp2);
- std::size_t ret=0;
- for(std::vector<MEDCouplingMesh *>::const_iterator it=ms.begin();it!=ms.end();it++)
- if(*it)
- ret+=(*it)->getHeapMemorySize();
- for(std::vector<DataArrayDouble *>::const_iterator it=arrs.begin();it!=arrs.end();it++)
- if(*it)
- ret+=(*it)->getHeapMemorySize();
+ std::vector<const BigMemoryObject *> ret;
+ for(std::vector< MCAuto<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++)
+ ret.push_back((const MEDCouplingFieldDouble *)*it);
return ret;
}
-std::vector<MEDCouplingMesh *> MEDCouplingMultiFields::getMeshes() const throw(INTERP_KERNEL::Exception)
+std::vector<MEDCouplingMesh *> MEDCouplingMultiFields::getMeshes() const
{
std::vector<MEDCouplingMesh *> ms;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++)
+ for(std::vector< MCAuto<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++)
{
const MEDCouplingMesh *m=0;
if((const MEDCouplingFieldDouble *)(*it))
return ms;
}
-std::vector<MEDCouplingMesh *> MEDCouplingMultiFields::getDifferentMeshes(std::vector<int>& refs) const throw(INTERP_KERNEL::Exception)
+std::vector<MEDCouplingMesh *> MEDCouplingMultiFields::getDifferentMeshes(std::vector<int>& refs) const
{
refs.resize(_fs.size());
std::vector<MEDCouplingMesh *> ms;
int id=0;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++,id++)
+ for(std::vector< MCAuto<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++,id++)
{
const MEDCouplingMesh *m=0;
if((const MEDCouplingFieldDouble *)(*it))
return ms;
}
-std::vector<DataArrayDouble *> MEDCouplingMultiFields::getArrays() const throw(INTERP_KERNEL::Exception)
+std::vector<DataArrayDouble *> MEDCouplingMultiFields::getArrays() const
{
std::vector<DataArrayDouble *> tmp;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++)
+ for(std::vector< MCAuto<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++)
{
std::vector<DataArrayDouble *> tmp2=(*it)->getArrays();
tmp.insert(tmp.end(),tmp2.begin(),tmp2.end());
return tmp;
}
-std::vector<DataArrayDouble *> MEDCouplingMultiFields::getDifferentArrays(std::vector< std::vector<int> >& refs) const throw(INTERP_KERNEL::Exception)
+std::vector<DataArrayDouble *> MEDCouplingMultiFields::getDifferentArrays(std::vector< std::vector<int> >& refs) const
{
refs.resize(_fs.size());
int id=0;
std::vector<DataArrayDouble *> ret;
- for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++,id++)
+ for(std::vector< MCAuto<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();it!=_fs.end();it++,id++)
{
std::vector<DataArrayDouble *> tmp2;
if((const MEDCouplingFieldDouble *)(*it))
return ret;
}
-void MEDCouplingMultiFields::checkCoherency() const throw(INTERP_KERNEL::Exception)
+void MEDCouplingMultiFields::checkConsistencyLight() const
{
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
+ std::vector< MCAuto<MEDCouplingFieldDouble> >::const_iterator it=_fs.begin();
for(;it!=_fs.end();it++)
{
if((const MEDCouplingFieldDouble *)(*it)==0)
- throw INTERP_KERNEL::Exception("MEDCouplingMultiFields::checkCoherency : There is an empty Field in array...");
- (*it)->checkCoherency();
+ throw INTERP_KERNEL::Exception("MEDCouplingMultiFields::checkConsistencyLight : There is an empty Field in array...");
+ (*it)->checkConsistencyLight();
}
}
-MEDCouplingMultiFields::MEDCouplingMultiFields(const std::vector<MEDCouplingFieldDouble *>& fs) throw(INTERP_KERNEL::Exception):_fs(fs.size())
+MEDCouplingMultiFields::MEDCouplingMultiFields(const std::vector<MEDCouplingFieldDouble *>& fs):_fs(fs.size())
{
int id=0;
for(std::vector< MEDCouplingFieldDouble * >::const_iterator it=fs.begin();it!=fs.end();it++,id++)
(*it)->incrRef();
else
throw INTERP_KERNEL::Exception("MEDCouplingMultiFields constructor : empty field found in vector !");
- (*it)->checkCoherency();
+ (*it)->checkConsistencyLight();
_fs[id]=*it;
}
}
/*!
- * Performs deepCpy.
+ * Performs deepCopy.
*/
-MEDCouplingMultiFields::MEDCouplingMultiFields(const MEDCouplingMultiFields& other)
+MEDCouplingMultiFields::MEDCouplingMultiFields(const MEDCouplingMultiFields& other):RefCountObject(other)
{
std::size_t sz=other._fs.size();
_fs.resize(sz);
std::vector< std::vector<int> > refs2;
std::vector<MEDCouplingMesh *> ms=other.getDifferentMeshes(refs);
std::size_t msLgh=ms.size();
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> > ms2(msLgh);
+ std::vector< MCAuto<MEDCouplingMesh> > ms2(msLgh);
for(std::size_t i=0;i<msLgh;i++)
- ms2[i]=ms[i]->deepCpy();
+ ms2[i]=ms[i]->deepCopy();
std::vector<DataArrayDouble *> das=other.getDifferentArrays(refs2);
std::size_t dasLgth=das.size();
- std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > das2(dasLgth);
+ std::vector< MCAuto<DataArrayDouble> > das2(dasLgth);
for(std::size_t i=0;i<dasLgth;i++)
- das2[i]=das[i]->deepCpy();
+ das2[i]=das[i]->deepCopy();
for(std::size_t i=0;i<sz;i++)
{
if((const MEDCouplingFieldDouble *)other._fs[i])
tmp2[j]=0;
}
_fs[i]->setArrays(tmp2);
- std::vector<int> tinyInfo;
+ std::vector<mcIdType> tinyInfo;
std::vector<double> tinyInfo2;
other._fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationIntInformation2(tinyInfo);
other._fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationDbleInformation2(tinyInfo2);
{
}
-void MEDCouplingMultiFields::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<double>& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const
+void MEDCouplingMultiFields::getTinySerializationInformation(std::vector<mcIdType>& tinyInfo, std::vector<double>& tinyInfo2, int& nbOfDiffMeshes, int& nbOfDiffArr) const
{
std::vector<int> refs;
std::vector<MEDCouplingMesh *> ms=getDifferentMeshes(refs);
std::vector<DataArrayDouble *> fs=getDifferentArrays(refs2);
nbOfDiffArr=(int)fs.size();
//
- std::size_t sz=refs.size();//==_fs.size()
- int sz2=0;
- for(std::size_t i=0;i<sz;i++)
- sz2+=(int)refs2[i].size();
+ mcIdType sz=ToIdType(refs.size());//==_fs.size()
+ mcIdType sz2=0;
+ for(mcIdType i=0;i<sz;i++)
+ sz2+=ToIdType(refs2[i].size());
//
tinyInfo2.clear();
std::vector<int> doubleDaInd(sz);
std::vector<int> timeDiscrInt;
tinyInfo.resize(sz2+5*sz+3);
- tinyInfo[0]=(int)sz;
+ tinyInfo[0]=sz;
tinyInfo[1]=sz2;
- for(std::size_t i=0;i<sz;i++)
+ for(mcIdType i=0;i<sz;i++)
{
std::vector<double> tmp;
- std::vector<int> tmp2;
+ std::vector<mcIdType> tmp2;
_fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationDbleInformation2(tmp);
_fs[i]->getTimeDiscretizationUnderGround()->getTinySerializationIntInformation2(tmp2);
- tinyInfo[3*sz+3+i]=(int)tmp.size();
- tinyInfo[4*sz+3+i]=(int)tmp2.size();
+ tinyInfo[3*sz+3+i]=ToIdType(tmp.size());
+ tinyInfo[4*sz+3+i]=ToIdType(tmp2.size());
tinyInfo2.insert(tinyInfo2.end(),tmp.begin(),tmp.end());
timeDiscrInt.insert(timeDiscrInt.end(),tmp2.begin(),tmp2.end());
}
- int sz3=(int)timeDiscrInt.size();
+ mcIdType sz3=ToIdType(timeDiscrInt.size());
tinyInfo[2]=sz3;
//
- for(std::size_t i=0;i<sz;i++)
+ for(mcIdType i=0;i<sz;i++)
tinyInfo[i+3]=refs[i];
- for(std::size_t i=0;i<sz;i++)
- tinyInfo[i+sz+3]=(int)refs2[i].size();
- for(std::size_t i=0;i<sz;i++)
- tinyInfo[i+2*sz+3]=(int)_fs[i]->getTimeDiscretization();
+ for(mcIdType i=0;i<sz;i++)
+ tinyInfo[i+sz+3]=ToIdType(refs2[i].size());
+ for(mcIdType i=0;i<sz;i++)
+ tinyInfo[i+2*sz+3]=ToIdType(_fs[i]->getTimeDiscretization());
int k=0;
- for(std::size_t i=0;i<sz;i++)
+ for(mcIdType i=0;i<sz;i++)
for(std::vector<int>::const_iterator it=refs2[i].begin();it!=refs2[i].end();it++,k++)
tinyInfo[5*sz+k+3]=*it;
tinyInfo.insert(tinyInfo.end(),timeDiscrInt.begin(),timeDiscrInt.end());//tinyInfo has lgth==sz3+sz2+5*sz+3
}
-void MEDCouplingMultiFields::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD,
+void MEDCouplingMultiFields::finishUnserialization(const std::vector<mcIdType>& tinyInfoI, const std::vector<double>& tinyInfoD,
const std::vector<MEDCouplingFieldTemplate *>& ft, const std::vector<MEDCouplingMesh *>& ms,
const std::vector<DataArrayDouble *>& das)
{
- int sz=tinyInfoI[0];
+ mcIdType sz=tinyInfoI[0];
_fs.resize(sz);
- int sz2=tinyInfoI[1];
+ mcIdType sz2=tinyInfoI[1];
// dealing with ft with no mesh set.
- for(int i=0;i<sz;i++)
+ for(mcIdType i=0;i<sz;i++)
{
- int meshId=tinyInfoI[3+i];
+ mcIdType meshId=tinyInfoI[3+i];
if(meshId!=-1)
ft[i]->setMesh(ms[meshId]);
}
// dealing with fieldtemplate->fielddouble
- int k=0;
- int offI=0;
- int offD=0;
- for(int i=0;i<sz;i++)
+ mcIdType k=0;
+ mcIdType offI=0;
+ mcIdType offD=0;
+ for(mcIdType i=0;i<sz;i++)
{
_fs[i]=MEDCouplingFieldDouble::New(*ft[i],(TypeOfTimeDiscretization)tinyInfoI[2*sz+3+i]);
- int sz3=tinyInfoI[sz+i+3];
+ mcIdType sz3=tinyInfoI[sz+i+3];
std::vector<DataArrayDouble *> tmp(sz3);
- for(int j=0;j<sz3;j++,k++)
+ for(mcIdType j=0;j<sz3;j++,k++)
{
- int daId=tinyInfoI[5*sz+k+3];
+ mcIdType daId=tinyInfoI[5*sz+k+3];
if(daId!=-1)
tmp[j]=das[daId];
else
}
_fs[i]->setArrays(tmp);
// time discr tiny info
- int lgthI=tinyInfoI[4*sz+3+i];
- int lgthD=tinyInfoI[3*sz+3+i];
+ mcIdType lgthI=tinyInfoI[4*sz+3+i];
+ mcIdType lgthD=tinyInfoI[3*sz+3+i];
//
- std::vector<int> tdInfoI(tinyInfoI.begin()+sz2+5*sz+3+offI,tinyInfoI.begin()+sz2+5*sz+3+offI+lgthI);
+ std::vector<mcIdType> tdInfoI(tinyInfoI.begin()+sz2+5*sz+3+offI,tinyInfoI.begin()+sz2+5*sz+3+offI+lgthI);
std::vector<double> tdInfoD(tinyInfoD.begin()+offD,tinyInfoD.begin()+offD+lgthD);
_fs[i]->getTimeDiscretizationUnderGround()->finishUnserialization2(tdInfoI,tdInfoD);
//