_arrs[i]->reAlloc(0);
}
+void DataArrayDoubleCollection::spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames)
+{
+ std::size_t sz(_arrs.size());
+ if(sz!=compNames.size())
+ throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::spillInfoOnComponents : first size of compNames has to be equal to the number of fields defined !");
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const std::vector<std::string>& names(compNames[i]);
+ _arrs[i]->setInfoOnComponents(names);
+ }
+}
+
DataArrayDoubleCollection::DataArrayDoubleCollection(const std::vector< std::pair<std::string,int> >& fieldNames):_arrs(fieldNames.size())
{
std::size_t sz(fieldNames.size());
return ret;
}
+void DataArrayDoubleCollection::updateTime() const
+{
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> >::const_iterator it=_arrs.begin();it!=_arrs.end();it++)
+ {
+ const DataArrayDouble *pt(*it);
+ if(pt)
+ updateTimeWith(*pt);
+ }
+}
+
void DataArrayDoubleCollection::CheckDiscriminantNames(const std::vector<std::string>& names)
{
std::set<std::string> s(names.begin(),names.end());
throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::CheckDiscriminantNames : The names of fields must be different each other ! It is not the case !");
}
+MEDCouplingGridCollection *MEDCouplingGridCollection::New(const std::vector<const MEDCouplingCartesianAMRMeshGen *>& ms, const std::vector< std::pair<std::string,int> >& fieldNames)
+{
+ return new MEDCouplingGridCollection(ms,fieldNames);
+}
+
+void MEDCouplingGridCollection::alloc(int ghostLev)
+{
+ for(std::vector< std::pair<const MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++)
+ {
+ int nbTuples((*it).first->getNumberOfCellsAtCurrentLevelGhost(ghostLev));
+ DataArrayDoubleCollection *dadc((*it).second);
+ if(dadc)
+ dadc->allocTuples(nbTuples);
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::alloc : internal error !");
+ }
+}
+
+void MEDCouplingGridCollection::dealloc()
+{
+ for(std::vector< std::pair<const MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++)
+ {
+ DataArrayDoubleCollection *dadc((*it).second);
+ if(dadc)
+ dadc->dellocTuples();
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::dealloc : internal error !");
+ }
+}
+
+void MEDCouplingGridCollection::spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames)
+{
+ for(std::vector< std::pair<const MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++)
+ (*it).second->spillInfoOnComponents(compNames);
+}
+
+MEDCouplingGridCollection::MEDCouplingGridCollection(const std::vector<const MEDCouplingCartesianAMRMeshGen *>& ms, const std::vector< std::pair<std::string,int> >& fieldNames):_map_of_dadc(ms.size())
+{
+ std::size_t sz(ms.size());
+ for(std::size_t i=0;i<sz;i++)
+ {
+ if(!ms[i])
+ throw INTERP_KERNEL::Exception("MEDCouplingGridCollection constructor : presence of NULL MEDCouplingCartesianAMRMeshGen instance !");
+ _map_of_dadc[i].first=ms[i];
+ _map_of_dadc[i].second=DataArrayDoubleCollection::New(fieldNames);
+ }
+}
+
std::size_t MEDCouplingGridCollection::getHeapMemorySizeWithoutChildren() const
{
std::size_t ret(sizeof(MEDCouplingGridCollection));
- ret+=_map_of_dadc.capacity()*sizeof(std::pair<MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> >);
+ ret+=_map_of_dadc.capacity()*sizeof(std::pair<const MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> >);
return ret;
}
std::vector<const BigMemoryObject *> MEDCouplingGridCollection::getDirectChildren() const
{
std::vector<const BigMemoryObject *> ret;
- for(std::vector< std::pair<MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++)
+ for(std::vector< std::pair<const MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++)
{
const DataArrayDoubleCollection *col((*it).second);
if(col)
return ret;
}
+void MEDCouplingGridCollection::updateTime() const
+{
+ for(std::vector< std::pair<const MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > >::const_iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++)
+ {
+ const MEDCouplingCartesianAMRMeshGen *a((*it).first);
+ if(a)
+ updateTimeWith(*a);
+ const DataArrayDoubleCollection *b((*it).second);
+ if(b)
+ updateTimeWith(*b);
+ }
+}
+
+/*!
+ * This method creates, attach to a main AMR mesh \a gf ( called god father :-) ) and returns a data linked to \a gf ready for the computation.
+ */
MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames)
{
return new MEDCouplingAMRAttribute(gf,fieldNames);
}
-void MEDCouplingAMRAttribute::alloc()
+/*!
+ * Assign the info on components for all DataArrayDouble instance recursively stored in \a this.
+ * The first dim of input \a compNames is the field id in the same order than those implicitely specified in \a fieldNames parameter of MEDCouplingAMRAttribute::New.
+ * The second dim of \a compNames represent the component names component per component corresponding to the field. The size of this 2nd dimension has
+ * to perfectly fit with those specified in MEDCouplingAMRAttribute::New.
+ */
+void MEDCouplingAMRAttribute::spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames)
+{
+ _tlc.checkConst();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> >::iterator it=_levs.begin();it!=_levs.end();it++)
+ (*it)->spillInfoOnComponents(compNames);
+}
+
+/*!
+ * This method allocates all DataArrayDouble instances stored recursively in \a this.
+ *
+ * \param [in] ghostLev - The size of ghost zone.
+ *
+ * \sa dealloc
+ */
+void MEDCouplingAMRAttribute::alloc(int ghostLev)
{
_tlc.resetState();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> >::iterator it=_levs.begin();it!=_levs.end();it++)
+ {
+ MEDCouplingGridCollection *elt(*it);
+ if(elt)
+ elt->alloc(ghostLev);
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::alloc : internal error !");
+ }
}
+/*!
+ * This method deallocates all DataArrayDouble instances stored recursively in \a this.
+ * \sa alloc
+ */
void MEDCouplingAMRAttribute::dealloc()
-{//tony
+{
+ _tlc.checkConst();
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> >::iterator it=_levs.begin();it!=_levs.end();it++)
+ {
+ MEDCouplingGridCollection *elt(*it);
+ if(elt)
+ elt->dealloc();
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::dealloc : internal error !");
+ }
}
bool MEDCouplingAMRAttribute::changeGodFather(MEDCouplingCartesianAMRMesh *gf)
std::size_t MEDCouplingAMRAttribute::getHeapMemorySizeWithoutChildren() const
{
std::size_t ret(sizeof(MEDCouplingAMRAttribute));
+ ret+=_levs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection>);
return ret;
}
std::vector<const BigMemoryObject *> MEDCouplingAMRAttribute::getDirectChildren() const
-{//tony
- return std::vector<const BigMemoryObject *>();
+{
+ std::vector<const BigMemoryObject *> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> >::const_iterator it=_levs.begin();it!=_levs.end();it++)
+ {
+ const MEDCouplingGridCollection *elt(*it);
+ if(elt)
+ ret.push_back(elt);
+ }
+ return ret;
}
void MEDCouplingAMRAttribute::updateTime() const
MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames):MEDCouplingDataForGodFather(gf)
{
+ //gf non empty, checked by constructor
+ int maxLev(gf->getMaxNumberOfLevelsRelativeToThis()+1);
+ _levs.resize(maxLev+1);
+ for(int i=0;i<maxLev;i++)
+ {
+ std::vector<MEDCouplingCartesianAMRPatchGen *> patches(gf->retrieveGridsAt(i));
+ std::size_t sz(patches.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatchGen> > patchesSafe(patches.size());
+ for(std::size_t j=0;j<sz;j++)
+ patchesSafe[j]=patches[j];
+ std::vector<const MEDCouplingCartesianAMRMeshGen *> ms(sz);
+ for(std::size_t j=0;j<sz;j++)
+ {
+ ms[j]=patches[j]->getMesh();
+ }
+ _levs[i]=MEDCouplingGridCollection::New(ms,fieldNames);
+ }
}
namespace ParaMEDMEM
{
/// @cond INTERNAL
- class DataArrayDoubleCollection : public RefCountObject
+ class DataArrayDoubleCollection : public RefCountObject, public TimeLabel
{
public:
static DataArrayDoubleCollection *New(const std::vector< std::pair<std::string,int> >& fieldNames);
void allocTuples(int nbOfTuples);
void dellocTuples();
+ void spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames);
private:
DataArrayDoubleCollection(const std::vector< std::pair<std::string,int> >& fieldNames);
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildren() const;
+ void updateTime() const;
static void CheckDiscriminantNames(const std::vector<std::string>& names);
private:
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > _arrs;
};
- class MEDCouplingGridCollection : public RefCountObject
+ class MEDCouplingGridCollection : public RefCountObject, public TimeLabel
{
+ public:
+ static MEDCouplingGridCollection *New(const std::vector<const MEDCouplingCartesianAMRMeshGen *>& ms, const std::vector< std::pair<std::string,int> >& fieldNames);
+ void alloc(int ghostLev);
+ void dealloc();
+ void spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames);
private:
+ MEDCouplingGridCollection(const std::vector<const MEDCouplingCartesianAMRMeshGen *>& ms, const std::vector< std::pair<std::string,int> >& fieldNames);
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildren() const;
+ void updateTime() const;
private:
- std::vector< std::pair<MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > > _map_of_dadc;
+ std::vector< std::pair<const MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > > _map_of_dadc;
};
/// @endcond
{
public:
MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames);
+ MEDCOUPLING_EXPORT void spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames);
//
- MEDCOUPLING_EXPORT void alloc();
+ MEDCOUPLING_EXPORT void alloc(int ghostLev);
MEDCOUPLING_EXPORT void dealloc();
MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMesh *gf);
//
return ret;
}
+/*!
+ * This method returns the number of cells of \a this with the help of the MEDCouplingIMesh instance representing \a this.
+ * The patches in \a this are ignored here.
+ * \sa getNumberOfCellsAtCurrentLevelGhost, getNumberOfCellsRecursiveWithOverlap
+ */
int MEDCouplingCartesianAMRMeshGen::getNumberOfCellsAtCurrentLevel() const
{
return _mesh->getNumberOfCells();
}
+/*!
+ * This method returns the number of cells of \a this with the help of the MEDCouplingIMesh instance representing \a this enlarged by \a ghostLev size
+ * to take into account of the ghost cells for future computation.
+ * The patches in \a this are ignored here.
+ *
+ * \sa getNumberOfCellsAtCurrentLevel
+ */
+int MEDCouplingCartesianAMRMeshGen::getNumberOfCellsAtCurrentLevelGhost(int ghostLev) const
+{
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingIMesh> tmp(_mesh->buildWithGhost(ghostLev));
+ return tmp->getNumberOfCells();
+}
+
+/*!
+ * This method returns the number of cells including the current level but \b also \b including recursively all cells of other levels
+ * starting from this. The set of cells which size is returned here are generally overlapping each other.
+ */
int MEDCouplingCartesianAMRMeshGen::getNumberOfCellsRecursiveWithOverlap() const
{
int ret(_mesh->getNumberOfCells());
return ret;
}
+/*!
+ * This method returns the max number of cells covering all the space without overlapping.
+ */
int MEDCouplingCartesianAMRMeshGen::getNumberOfCellsRecursiveWithoutOverlap() const
{
int ret(_mesh->getNumberOfCells());
data->incrRef();
}
-void MEDCouplingCartesianAMRMesh::allocData() const
+void MEDCouplingCartesianAMRMesh::allocData(int ghostLev) const
{
checkData();
- _data->alloc();
+ _data->alloc(ghostLev);
}
void MEDCouplingCartesianAMRMesh::deallocData() const