MEDCouplingDefinitionTime.cxx
MEDCouplingFieldOverTime.cxx
MEDCouplingCartesianAMRMesh.cxx
+ MEDCouplingAMRAttribute.cxx
MEDCouplingMatrix.cxx
)
--- /dev/null
+// Copyright (C) 2007-2014 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
+// License as published by the Free Software Foundation; either
+// 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay
+
+#include "MEDCouplingAMRAttribute.hxx"
+#include "MEDCouplingMemArray.hxx"
+
+using namespace ParaMEDMEM;
+
+DataArrayDoubleCollection *DataArrayDoubleCollection::New(const std::vector< std::pair<std::string,int> >& fieldNames)
+{
+ return new DataArrayDoubleCollection(fieldNames);
+}
+
+void DataArrayDoubleCollection::allocTuples(int nbOfTuples)
+{
+ std::size_t sz(_arrs.size());
+ for(std::size_t i=0;i<sz;i++)
+ _arrs[i]->reAlloc(nbOfTuples);
+}
+
+void DataArrayDoubleCollection::dellocTuples()
+{
+ std::size_t sz(_arrs.size());
+ for(std::size_t i=0;i<sz;i++)
+ _arrs[i]->reAlloc(0);
+}
+
+DataArrayDoubleCollection::DataArrayDoubleCollection(const std::vector< std::pair<std::string,int> >& fieldNames):_arrs(fieldNames.size())
+{
+ std::size_t sz(fieldNames.size());
+ std::vector<std::string> names(sz);
+ for(std::size_t i=0;i<sz;i++)
+ {
+ const std::pair<std::string,int>& info(fieldNames[i]);
+ _arrs[i]=DataArrayDouble::New();
+ _arrs[i]->alloc(0,info.second);
+ _arrs[i]->setName(info.first);
+ names[i]=info.second;
+ }
+ CheckDiscriminantNames(names);
+}
+
+std::size_t DataArrayDoubleCollection::getHeapMemorySizeWithoutChildren() const
+{
+ std::size_t ret(sizeof(DataArrayDoubleCollection));
+ ret+=_arrs.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>);
+ return ret;
+}
+
+std::vector<const BigMemoryObject *> DataArrayDoubleCollection::getDirectChildren() const
+{
+ std::vector<const BigMemoryObject *> ret;
+ for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> >::const_iterator it=_arrs.begin();it!=_arrs.end();it++)
+ {
+ const DataArrayDouble *pt(*it);
+ if(pt)
+ ret.push_back(pt);
+ }
+ return ret;
+}
+
+void DataArrayDoubleCollection::CheckDiscriminantNames(const std::vector<std::string>& names)
+{
+ std::set<std::string> s(names.begin(),names.end());
+ if(s.size()!=names.size())
+ throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::CheckDiscriminantNames : The names of fields must be different each other ! It is not the case !");
+}
+
+std::size_t MEDCouplingGridCollection::getHeapMemorySizeWithoutChildren() const
+{
+ std::size_t ret(sizeof(MEDCouplingGridCollection));
+ ret+=_map_of_dadc.capacity()*sizeof(std::pair<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++)
+ {
+ const DataArrayDoubleCollection *col((*it).second);
+ if(col)
+ ret.push_back(col);
+ }
+ return ret;
+}
+
+MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames)
+{
+ return new MEDCouplingAMRAttribute(gf,fieldNames);
+}
+
+void MEDCouplingAMRAttribute::alloc()
+{
+ _tlc.resetState();
+}
+
+void MEDCouplingAMRAttribute::dealloc()
+{//tony
+}
+
+bool MEDCouplingAMRAttribute::changeGodFather(MEDCouplingCartesianAMRMesh *gf)
+{
+ bool ret(MEDCouplingDataForGodFather::changeGodFather(gf));
+ return ret;
+}
+
+std::size_t MEDCouplingAMRAttribute::getHeapMemorySizeWithoutChildren() const
+{
+ std::size_t ret(sizeof(MEDCouplingAMRAttribute));
+ return ret;
+}
+
+std::vector<const BigMemoryObject *> MEDCouplingAMRAttribute::getDirectChildren() const
+{//tony
+ return std::vector<const BigMemoryObject *>();
+}
+
+void MEDCouplingAMRAttribute::updateTime() const
+{//tony
+}
+
+MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames):MEDCouplingDataForGodFather(gf)
+{
+}
--- /dev/null
+// Copyright (C) 2007-2014 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
+// License as published by the Free Software Foundation; either
+// 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
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony Geay
+
+#ifndef __MEDCOUPLINGAMRATTRIBUTE_HXX__
+#define __MEDCOUPLINGAMRATTRIBUTE_HXX__
+
+#include "MEDCoupling.hxx"
+#include "MEDCouplingCartesianAMRMesh.hxx"
+
+namespace ParaMEDMEM
+{
+ /// @cond INTERNAL
+ class DataArrayDoubleCollection : public RefCountObject
+ {
+ public:
+ static DataArrayDoubleCollection *New(const std::vector< std::pair<std::string,int> >& fieldNames);
+ void allocTuples(int nbOfTuples);
+ void dellocTuples();
+ private:
+ DataArrayDoubleCollection(const std::vector< std::pair<std::string,int> >& fieldNames);
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ std::vector<const BigMemoryObject *> getDirectChildren() const;
+ static void CheckDiscriminantNames(const std::vector<std::string>& names);
+ private:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > _arrs;
+ };
+
+ class MEDCouplingGridCollection : public RefCountObject
+ {
+ private:
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ std::vector<const BigMemoryObject *> getDirectChildren() const;
+ private:
+ std::vector< std::pair<MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > > _map_of_dadc;
+ };
+ /// @endcond
+
+ class MEDCouplingAMRAttribute : public MEDCouplingDataForGodFather, public TimeLabel
+ {
+ public:
+ MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames);
+ //
+ MEDCOUPLING_EXPORT void alloc();
+ MEDCOUPLING_EXPORT void dealloc();
+ MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMesh *gf);
+ //
+ MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
+ MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
+ MEDCOUPLING_EXPORT void updateTime() const;
+ private:
+ MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames);
+ private:
+ std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> > _levs;
+ };
+}
+
+#endif
return sizeof(MEDCouplingCartesianAMRPatchGF);
}
+MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMesh *gf):_gf(gf),_tlc(gf)
+{
+ if(!_gf)
+ throw INTERP_KERNEL::Exception("MEDCouplingDataForGodFather constructor : A data has to be attached to a AMR Mesh instance !");
+ _gf->setData(this);
+}
+
+void MEDCouplingDataForGodFather::checkGodFatherFrozen() const
+{
+ _tlc.checkConst();
+}
+
+bool MEDCouplingDataForGodFather::changeGodFather(MEDCouplingCartesianAMRMesh *gf)
+{
+ bool ret(_tlc.keepTrackOfNewTL(gf));
+ if(ret)
+ {
+ _gf=gf;
+ }
+ return ret;
+}
+
/// @endcond
int MEDCouplingCartesianAMRMeshGen::getSpaceDimension() const
if(!_patches.empty())
throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::setFactors : modification of factors is not allowed when presence of patches !");
_factors=newFactors;
+ declareAsNew();
}
int MEDCouplingCartesianAMRMeshGen::getMaxNumberOfLevelsRelativeToThis() const
void MEDCouplingCartesianAMRMeshGen::detachFromFather()
{
_father=0;
+ declareAsNew();
}
/*!
MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRMeshSub> zeMesh(new MEDCouplingCartesianAMRMeshSub(this,mesh));
MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRPatch> elt(new MEDCouplingCartesianAMRPatch(zeMesh,bottomLeftTopRight));
_patches.push_back(elt);
+ declareAsNew();
}
/// @cond INTERNAL
}
for(std::vector< MEDCouplingAutoRefCountObjectPtr<InternalPatch> >::const_iterator it=listOfPatchesOK.begin();it!=listOfPatchesOK.end();it++)
addPatch((*it)->getConstPart(),factors);
+ declareAsNew();
}
/*!
throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::createPatchesFromCriterion : the criterion DataArrayByte instance must be allocated and not NULL !");
std::vector<bool> crit(criterion->toVectorOfBool());//check that criterion has one component.
createPatchesFromCriterion(bso,crit,factors);
+ declareAsNew();
}
void MEDCouplingCartesianAMRMeshGen::removeAllPatches()
* \param [in,out] cellFieldOnPatch - The array of the cell field on the requested patch to be filled.
* \param [in] ghostLev - The size of the ghost zone (must be >=0 !)
* \param [in] arrsOnPatches - \b WARNING arrsOnPatches[patchId] is \b NOT \b const. All others are const.
+ *
+ * \sa fillCellFieldOnPatchOnlyGhostAdv
*/
void MEDCouplingCartesianAMRMeshGen::fillCellFieldOnPatchGhostAdv(int patchId, const DataArrayDouble *cellFieldOnThis, int ghostLev, const std::vector<const DataArrayDouble *>& arrsOnPatches) const
{
- int nbp(getNumberOfPatches()),dim(getSpaceDimension());
+ int nbp(getNumberOfPatches());
if(nbp!=(int)arrsOnPatches.size())
{
std::ostringstream oss; oss << "MEDCouplingCartesianAMRMesh::fillCellFieldOnPatchGhostAdv : there are " << nbp << " patches in this and " << arrsOnPatches.size() << " arrays in the last parameter !";
DataArrayDouble *theFieldToFill(const_cast<DataArrayDouble *>(arrsOnPatches[patchId]));
// first, do as usual
fillCellFieldOnPatchGhost(patchId,cellFieldOnThis,theFieldToFill,ghostLev);
- // all reference patch stuff
+ fillCellFieldOnPatchOnlyGhostAdv(patchId,ghostLev,arrsOnPatches);
+}
+
+void MEDCouplingCartesianAMRMeshGen::fillCellFieldOnPatchOnlyGhostAdv(int patchId, int ghostLev, const std::vector<const DataArrayDouble *>& arrsOnPatches) const
+{
+ int nbp(getNumberOfPatches()),dim(getSpaceDimension());
+ if(nbp!=(int)arrsOnPatches.size())
+ {
+ std::ostringstream oss; oss << "MEDCouplingCartesianAMRMesh::fillCellFieldOnPatchOnlyGhostAdv : there are " << nbp << " patches in this and " << arrsOnPatches.size() << " arrays in the last parameter !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ DataArrayDouble *theFieldToFill(const_cast<DataArrayDouble *>(arrsOnPatches[patchId]));
const MEDCouplingCartesianAMRPatch *refP(getPatch(patchId));
const std::vector< std::pair<int,int> >& refBLTR(refP->getBLTRRange());//[(1,4),(2,4)]
std::vector<int> dimsCoarse(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(refBLTR));//[3,2]
void MEDCouplingCartesianAMRMesh::setData(MEDCouplingDataForGodFather *data)
{
+ MEDCouplingDataForGodFather *myData(_data);
+ if(myData==data)
+ return ;
+ if(myData)
+ myData->changeGodFather(0);
_data=data;
+ if(data)
+ data->incrRef();
+}
+
+void MEDCouplingCartesianAMRMesh::allocData() const
+{
+ checkData();
+ _data->alloc();
+}
+
+void MEDCouplingCartesianAMRMesh::deallocData() const
+{
+ checkData();
+ _data->dealloc();
}
MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
ret.push_back(pt);
return ret;
}
+
+void MEDCouplingCartesianAMRMesh::checkData() const
+{
+ const MEDCouplingDataForGodFather *data(_data);
+ if(!data)
+ throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::checkData : no data set !");
+}
+
+MEDCouplingCartesianAMRMesh::~MEDCouplingCartesianAMRMesh()
+{
+ MEDCouplingDataForGodFather *data(_data);
+ if(!data)
+ data->changeGodFather(0);
+}
/// @cond INTERNAL
+ /*!
+ * This class does not inherit from TimeLabel so only const method should exist.
+ */
class MEDCouplingCartesianAMRPatchGen : public RefCountObject
{
public:
MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRMeshGen> _mesh;
};
+ /*!
+ * This class does not inherit from TimeLabel so only const method should exist.
+ */
class MEDCouplingCartesianAMRPatch : public MEDCouplingCartesianAMRPatchGen
{
public:
std::vector< std::pair<int,int> > _bl_tr;
};
+ /*!
+ * This class does not inherit from TimeLabel so only const method should exist.
+ */
class MEDCouplingCartesianAMRPatchGF : public MEDCouplingCartesianAMRPatchGen
{
public:
class MEDCouplingDataForGodFather : public RefCountObject
{
+ friend class MEDCouplingCartesianAMRMesh;
+ public:
+ MEDCOUPLING_EXPORT virtual void alloc() = 0;
+ MEDCOUPLING_EXPORT virtual void dealloc() = 0;
+ protected:
+ MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMesh *gf);
+ void checkGodFatherFrozen() const;
+ protected:
+ virtual bool changeGodFather(MEDCouplingCartesianAMRMesh *gf);
+ protected:
+ MEDCouplingCartesianAMRMesh *_gf;
+ TimeLabelConstOverseer _tlc;
};
/// @endcond
MEDCOUPLING_EXPORT void fillCellFieldOnPatch(int patchId, const DataArrayDouble *cellFieldOnThis, DataArrayDouble *cellFieldOnPatch) const;
MEDCOUPLING_EXPORT void fillCellFieldOnPatchGhost(int patchId, const DataArrayDouble *cellFieldOnThis, DataArrayDouble *cellFieldOnPatch, int ghostLev) const;
MEDCOUPLING_EXPORT void fillCellFieldOnPatchGhostAdv(int patchId, const DataArrayDouble *cellFieldOnThis, int ghostLev, const std::vector<const DataArrayDouble *>& arrsOnPatches) const;
+ MEDCOUPLING_EXPORT void fillCellFieldOnPatchOnlyGhostAdv(int patchId, int ghostLev, const std::vector<const DataArrayDouble *>& arrsOnPatches) const;
MEDCOUPLING_EXPORT void fillCellFieldComingFromPatch(int patchId, const DataArrayDouble *cellFieldOnPatch, DataArrayDouble *cellFieldOnThis) const;
MEDCOUPLING_EXPORT void fillCellFieldComingFromPatchGhost(int patchId, const DataArrayDouble *cellFieldOnPatch, DataArrayDouble *cellFieldOnThis, int ghostLev) const;
MEDCOUPLING_EXPORT DataArrayInt *findPatchesInTheNeighborhoodOf(int patchId, int ghostLev) const;
MEDCOUPLING_EXPORT const MEDCouplingDataForGodFather *getDataConst() const { return _data; }
MEDCOUPLING_EXPORT MEDCouplingDataForGodFather *getData() { return _data; }
MEDCOUPLING_EXPORT void setData(MEDCouplingDataForGodFather *data);
+ MEDCOUPLING_EXPORT void allocData() const;
+ MEDCOUPLING_EXPORT void deallocData() const;
private:
MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop,
const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop);
MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
+ void checkData() const;
+ ~MEDCouplingCartesianAMRMesh();
private:
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingDataForGodFather> _data;
+ mutable MEDCouplingAutoRefCountObjectPtr<MEDCouplingDataForGodFather> _data;
};
}
#include "MEDCouplingTimeLabel.hxx"
+#include "InterpKernelException.hxx"
+
+#include <limits>
+
using namespace ParaMEDMEM;
std::size_t TimeLabel::GLOBAL_TIME=0;
{
_time=other._time;
}
+
+TimeLabelConstOverseer::TimeLabelConstOverseer(const TimeLabel *tl):_tl(tl),_ref_time(std::numeric_limits<std::size_t>::max())
+{
+ if(!_tl)
+ throw INTERP_KERNEL::Exception("TimeLabelConstOverseer constructor : input instance must be not NULL !");
+ _tl->updateTime();
+ _ref_time=tl->getTimeOfThis();
+}
+
+/*!
+ * This method checks that the tracked instance is not NULL and if not NULL that its internal state has not changed.
+ */
+void TimeLabelConstOverseer::checkConst() const
+{
+ if(!_tl)
+ throw INTERP_KERNEL::Exception("TimeLabelConstOverseer::checkConst : NULL tracked instance !");
+ _tl->updateTime();
+ if(_ref_time!=_tl->getTimeOfThis())
+ throw INTERP_KERNEL::Exception("TimeLabelConstOverseer::checkConst : the state of the controlled instance of TimeLable has changed !");
+}
+
+bool TimeLabelConstOverseer::resetState()
+{
+ if(_tl)
+ {
+ _tl->updateTime();
+ _ref_time=_tl->getTimeOfThis();
+ return true;
+ }
+ else
+ return false;
+}
+
+bool TimeLabelConstOverseer::keepTrackOfNewTL(const TimeLabel *tl)
+{
+ if(_tl==tl)
+ return false;
+ _tl=tl;
+ if(_tl)
+ {
+ _tl->updateTime();
+ _ref_time=_tl->getTimeOfThis();
+ }
+ else
+ {
+ _ref_time=std::numeric_limits<std::size_t>::max();
+ }
+ return true;
+}
static std::size_t GLOBAL_TIME;
mutable std::size_t _time;
};
+
+ class TimeLabelConstOverseer
+ {
+ public:
+ MEDCOUPLING_EXPORT TimeLabelConstOverseer(const TimeLabel *tl);
+ MEDCOUPLING_EXPORT void checkConst() const;
+ MEDCOUPLING_EXPORT bool resetState();
+ MEDCOUPLING_EXPORT bool keepTrackOfNewTL(const TimeLabel *tl);
+ private:
+ const TimeLabel *_tl;
+ std::size_t _ref_time;
+ };
}
#endif
class MEDCouplingDataForGodFather : public RefCountObject
{
+ public:
+ virtual void alloc() throw(INTERP_KERNEL::Exception);
+ virtual void dealloc() throw(INTERP_KERNEL::Exception);
};
class MEDCouplingCartesianAMRMeshGen : public RefCountObject, public TimeLabel
self->fillCellFieldOnPatchGhostAdv(patchId,cellFieldOnThis,ghostLev,arrsOnPatches2);
}
+ void fillCellFieldOnPatchOnlyGhostAdv(int patchId, int ghostLev, PyObject *arrsOnPatches) const
+ {
+ std::vector<const ParaMEDMEM::DataArrayDouble *> arrsOnPatches2;
+ convertFromPyObjVectorOfObj<const ParaMEDMEM::DataArrayDouble *>(arrsOnPatches,SWIGTYPE_p_ParaMEDMEM__DataArrayDouble,"DataArrayDouble",arrsOnPatches2);
+ self->fillCellFieldOnPatchOnlyGhostAdv(patchId,ghostLev,arrsOnPatches2);
+ }
+
void __delitem__(int patchId) throw(INTERP_KERNEL::Exception)
{
self->removePatch(patchId);
{
public:
void setData(MEDCouplingDataForGodFather *data) throw(INTERP_KERNEL::Exception);
+ void allocData() const throw(INTERP_KERNEL::Exception);
+ void deallocData() const throw(INTERP_KERNEL::Exception);
%extend
{
static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception)