Sprout from BR_ParaMEDSPLITTER 2009-08-13 13:45:18 UTC eap <eap@opencascade.com> 'Parallel MED splitter'
Cherrypick from BR_ParaMEDSPLITTER 2009-10-06 07:44:59 UTC eap <eap@opencascade.com> 'missing config files':
adm_local/unix/config_files/check_parmetis.m4
Delete:
adm_local/unix/config_files/check_GUI.m4
adm_local/unix/config_files/check_opengl.m4
adm_local/unix/config_files/check_qt.m4
adm_local/unix/config_files/check_vtk.m4
adm_local_without_kernel/cmake_files/FindMPI.cmake
adm_local_without_kernel/cmake_files/FindPLATFORM.cmake
adm_local_without_kernel/cmake_files/am2cmake.py
adm_local_without_kernel/unix/config_files/check_htmlgen.m4
idl/MEDCouplingCorbaServant.idl
idl/MEDCouplingCorbaServantTest.idl
idl/ParaMEDMEMComponent.idl
resources/Mesh3D_10_2d1.med
resources/Mesh3D_10_2d2.med
resources/Mesh3D_11.med
src/INTERP_KERNEL/InterpolationOptions.cxx
src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx
src/INTERP_KERNEL/PlanarIntersectorP1P1.txx
src/MEDCoupling/MEDCoupling.hxx
src/MEDCoupling/MEDCouplingCMesh.cxx
src/MEDCoupling/MEDCouplingCMesh.hxx
src/MEDCoupling/MEDCouplingFieldDiscretization.cxx
src/MEDCoupling/MEDCouplingFieldDiscretization.hxx
src/MEDCoupling/MEDCouplingMemArray.cxx
src/MEDCoupling/MEDCouplingMemArray.hxx
src/MEDCoupling/MEDCouplingMemArray.txx
src/MEDCoupling/MEDCouplingNatureOfField.hxx
src/MEDCoupling/MEDCouplingPointSet.cxx
src/MEDCoupling/MEDCouplingPointSet.hxx
src/MEDCoupling/MEDCouplingRefCountObject.cxx
src/MEDCoupling/MEDCouplingRefCountObject.hxx
src/MEDCoupling/MEDCouplingTimeDiscretization.cxx
src/MEDCoupling/MEDCouplingTimeDiscretization.hxx
src/MEDCoupling/MEDCouplingTimeLabel.cxx
src/MEDCoupling/MEDCouplingTimeLabel.hxx
src/MEDCoupling/MEDCouplingUMeshDesc.cxx
src/MEDCoupling/MEDCouplingUMeshDesc.hxx
src/MEDCouplingCorba/Client/MEDCouplingClient.hxx
src/MEDCouplingCorba/Client/MEDCouplingFieldDoubleClient.cxx
src/MEDCouplingCorba/Client/MEDCouplingFieldDoubleClient.hxx
src/MEDCouplingCorba/Client/MEDCouplingMeshClient.cxx
src/MEDCouplingCorba/Client/MEDCouplingMeshClient.hxx
src/MEDCouplingCorba/Client/MEDCouplingUMeshClient.cxx
src/MEDCouplingCorba/Client/MEDCouplingUMeshClient.hxx
src/MEDCouplingCorba/Client/Makefile.am
src/MEDCouplingCorba/MEDCouplingCorba.hxx
src/MEDCouplingCorba/MEDCouplingFieldDoubleServant.cxx
src/MEDCouplingCorba/MEDCouplingFieldDoubleServant.hxx
src/MEDCouplingCorba/MEDCouplingFieldServant.cxx
src/MEDCouplingCorba/MEDCouplingFieldServant.hxx
src/MEDCouplingCorba/MEDCouplingMeshServant.cxx
src/MEDCouplingCorba/MEDCouplingMeshServant.hxx
src/MEDCouplingCorba/MEDCouplingPointSetServant.cxx
src/MEDCouplingCorba/MEDCouplingPointSetServant.hxx
src/MEDCouplingCorba/MEDCouplingRefCountServant.cxx
src/MEDCouplingCorba/MEDCouplingRefCountServant.hxx
src/MEDCouplingCorba/MEDCouplingUMeshServant.cxx
src/MEDCouplingCorba/MEDCouplingUMeshServant.hxx
src/MEDCouplingCorba/Makefile.am
src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponent.cxx
src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponent.hxx
src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponentClt.cxx
src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponentClt.hxx
src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponentServ.cxx
src/MEDCouplingCorba/Test/MEDCouplingMeshFieldFactoryComponentServ.hxx
src/MEDCouplingCorba/Test/Makefile.am
src/MEDCouplingCorba/Test/TestMEDCouplingCorbaClt.cxx
src/MEDCouplingCorba/Test/TestMEDCouplingCorbaServ.cxx
src/MEDCoupling_Swig/MEDCouplingBasicsTest.py
src/MEDCoupling_Swig/MEDCouplingTypemaps.i
src/MEDCoupling_Swig/Makefile.am
src/MEDCoupling_Swig/libMEDCoupling_Swig.i
src/MEDMEM/MEDMEM_MeshFuse.cxx
src/MEDMEM/MEDMEM_MeshFuse.hxx
src/MEDMEMCppTest/MEDMEMTest_MeshFuse.cxx
src/MEDMEMCppTest/MEDMEMTest_Utils.cxx
src/MEDMEMCppTest/MEDMEMTest_Utils.hxx
src/MEDSPLITTER/MEDSPLITTER_JointExchangeData.cxx
src/MEDSPLITTER/MEDSPLITTER_JointExchangeData.hxx
src/MEDSPLITTER/MEDSPLITTER_MeshSendReceive.cxx
src/MEDSPLITTER/MEDSPLITTER_MeshSendReceive.hxx
src/MEDSPLITTER/MEDSPLITTER_ParaDomainSelector.cxx
src/MEDSPLITTER/MEDSPLITTER_ParaDomainSelector.hxx
src/MEDSPLITTER/Test/MEDSPLITTERTest_Utils.cxx
src/MEDSPLITTER/Test/MEDSPLITTERTest_Utils.hxx
src/MEDSPLITTER/Test/ParaMEDSPLITTERTest.hxx
src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_MeshSendReceive.cxx
src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_ParaDomainSelector.cxx
src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_medsplitter_para.cxx
src/MEDSPLITTER/Test/TestParaMEDSPLITTER.cxx
src/MEDSPLITTER/Test/testParaMEDSPLITTER.py
src/MEDSPLITTER/medsplitter_para.cxx
src/MedClient/src/MEDClient.hxx
src/ParaMEDMEM/GlobalizerMesh.cxx
src/ParaMEDMEM/GlobalizerMesh.hxx
src/ParaMEDMEM/Test/ParaMEDMEMTest_ICocoTrio.cxx
src/ParaMEDMEM/Test/ParaMEDMEMTest_MEDLoader.cxx
src/ParaMEDMEM/Test/test_perf.cxx
src/ParaMEDMEMComponent/Makefile.am
src/ParaMEDMEMComponent/ParaMEDMEMComponent_i.cxx
src/ParaMEDMEMComponent/ParaMEDMEMComponent_i.hxx
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#include "InterpolationOptions.hxx"
-
-const double INTERP_KERNEL::InterpolationOptions::DFT_MEDIAN_PLANE=0.5;
-
-const double INTERP_KERNEL::InterpolationOptions::DFT_SURF3D_ADJ_EPS=1.e-4;
-
-const double INTERP_KERNEL::InterpolationOptions::DFT_MAX_DIST_3DSURF_INTERSECT=-1.;
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __PLANARINTERSECTORP1P1_HXX__
-#define __PLANARINTERSECTORP1P1_HXX__
-
-#include "PlanarIntersector.hxx"
-
-namespace INTERP_KERNEL
-{
- template<class MyMeshType, class MyMatrix, class ConcreteP1P1Intersector>
- class PlanarIntersectorP1P1 : public PlanarIntersector<MyMeshType,MyMatrix>
- {
- public:
- static const int SPACEDIM=MyMeshType::MY_SPACEDIM;
- static const int MESHDIM=MyMeshType::MY_MESHDIM;
- typedef typename MyMeshType::MyConnType ConnType;
- static const NumberingPolicy numPol=MyMeshType::My_numPol;
- protected:
- PlanarIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
- public:
- void intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res);
- int getNumberOfRowsOfResMatrix() const;
- int getNumberOfColsOfResMatrix() const;
-
- double intersectGeometryGeneral(const std::vector<double>& targetCoords, const std::vector<double>& sourceCoords) { return asLeaf().intersectGeometryGeneral(targetCoords,sourceCoords); }
- protected:
- ConcreteP1P1Intersector& asLeaf() { return static_cast<ConcreteP1P1Intersector&>(*this); }
- };
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-#ifndef __PLANARINTERSECTORP1P1_TXX__
-#define __PLANARINTERSECTORP1P1_TXX__
-
-#include "PlanarIntersectorP1P1.hxx"
-#include "InterpolationUtils.hxx"
-#include "CellModel.hxx"
-
-namespace INTERP_KERNEL
-{
- template<class MyMeshType, class MyMatrix, class ConcreteP1P1Intersector>
- PlanarIntersectorP1P1<MyMeshType,MyMatrix,ConcreteP1P1Intersector>::PlanarIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS,
- double dimCaracteristic, double precision, double md3DSurf, double medianPlane,
- bool doRotate, int orientation, int printLevel):
- PlanarIntersector<MyMeshType,MyMatrix>(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel)
- {
- }
-
- template<class MyMeshType, class MyMatrix, class ConcreteP1P1Intersector>
- int PlanarIntersectorP1P1<MyMeshType,MyMatrix,ConcreteP1P1Intersector>::getNumberOfRowsOfResMatrix() const
- {
- return PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getNumberOfNodes();
- }
-
- template<class MyMeshType, class MyMatrix, class ConcreteP1P1Intersector>
- int PlanarIntersectorP1P1<MyMeshType,MyMatrix,ConcreteP1P1Intersector>::getNumberOfColsOfResMatrix() const
- {
- return PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getNumberOfNodes();
- }
-
- /*!
- * This methods split on the fly, into triangles in order to compute dual mesh of target cell (with icellT id in target mesh in C mode).
- */
- template<class MyMeshType, class MyMatrix, class ConcreteP1P1Intersector>
- void PlanarIntersectorP1P1<MyMeshType,MyMatrix,ConcreteP1P1Intersector>::intersectCells(ConnType icellT, const std::vector<ConnType>& icellsS, MyMatrix& res)
- {
- int nbNodesT=PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT+1]-PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT];
- int orientation=1;
- const ConnType *startOfCellNodeConn=PlanarIntersector<MyMeshType,MyMatrix>::_connectT+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexT[icellT]);
- std::vector<double> polygT;
- PlanarIntersector<MyMeshType,MyMatrix>::getRealTargetCoordinates(OTT<ConnType,numPol>::indFC(icellT),polygT);
- for(int nodeIdT=0;nodeIdT<nbNodesT;nodeIdT++)
- {
- ConnType curNodeTInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConn[nodeIdT]);
- PlanarIntersector<MyMeshType,MyMatrix>::getRealTargetCoordinatesPermute(OTT<ConnType,numPol>::indFC(icellT),nodeIdT,polygT);
- std::vector<double> polygDualT(SPACEDIM*2*(nbNodesT-1));
- fillDualCellOfPolyg<SPACEDIM>(&polygT[0],polygT.size()/SPACEDIM,&polygDualT[0]);
- typename MyMatrix::value_type& resRow=res[curNodeTInCmode];
- for(typename std::vector<ConnType>::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++)
- {
- int iS=*iter;
- int nbNodesS=PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS+1]-PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS];
- const ConnType *startOfCellNodeConnS=PlanarIntersector<MyMeshType,MyMatrix>::_connectS+OTT<ConnType,numPol>::conn2C(PlanarIntersector<MyMeshType,MyMatrix>::_connIndexS[iS]);
- for(int nodeIdS=0;nodeIdS<nbNodesS;nodeIdS++)
- {
- ConnType curNodeSInCmode=OTT<ConnType,numPol>::coo2C(startOfCellNodeConnS[nodeIdS]);
- std::vector<double> polygS;
- PlanarIntersector<MyMeshType,MyMatrix>::getRealSourceCoordinatesPermute(OTT<ConnType,numPol>::indFC(iS),nodeIdS,polygS);
- std::vector<double> polygDualS(SPACEDIM*2*(nbNodesS-1));
- fillDualCellOfPolyg<SPACEDIM>(&polygS[0],polygS.size()/SPACEDIM,&polygDualS[0]);
- std::vector<double> polygDualTTmp(polygDualT);
- if(SPACEDIM==3)
- orientation=PlanarIntersector<MyMeshType,MyMatrix>::projectionThis(&polygDualS[0],&polygDualTTmp[0],polygDualS.size()/SPACEDIM,polygDualT.size()/SPACEDIM);
- double surf=orientation*intersectGeometryGeneral(polygDualTTmp,polygDualS);
- surf=PlanarIntersector<MyMeshType,MyMatrix>::getValueRegardingOption(surf);
- if(surf!=0.)
- {
- typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT<ConnType,numPol>::indFC(curNodeSInCmode));
- if(iterRes==resRow.end())
- resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),surf));
- else
- {
- double val=(*iterRes).second+surf;
- resRow.erase(OTT<ConnType,numPol>::indFC(curNodeSInCmode));
- resRow.insert(std::make_pair(OTT<ConnType,numPol>::indFC(curNodeSInCmode),val));
- }
- }
- }
- }
- }
- }
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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.
-//
-// 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
-//
-#ifndef _MEDCOUPLING_HXX_
-#define _MEDCOUPLING_HXX_
-
-#ifdef WNT
-# if defined medcoupling_EXPORTS
-# define MEDCOUPLING_EXPORT __declspec( dllexport )
-# else
-# define MEDCOUPLING_EXPORT __declspec( dllimport )
-# endif
-#else
-# define MEDCOUPLING_EXPORT
-#endif
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#include "MEDCouplingCMesh.hxx"
-#include "MEDCouplingMemArray.hxx"
-
-using namespace ParaMEDMEM;
-
-MEDCouplingCMesh::MEDCouplingCMesh():_x_array(0),_y_array(0),_z_array(0)
-{
-}
-
-MEDCouplingCMesh::~MEDCouplingCMesh()
-{
- if(_x_array)
- _x_array->decrRef();
- if(_y_array)
- _y_array->decrRef();
- if(_z_array)
- _z_array->decrRef();
-}
-
-MEDCouplingCMesh *MEDCouplingCMesh::New()
-{
- return new MEDCouplingCMesh;
-}
-
-void MEDCouplingCMesh::updateTime()
-{
- if(_x_array)
- updateTimeWith(*_x_array);
- if(_y_array)
- updateTimeWith(*_y_array);
- if(_z_array)
- updateTimeWith(*_z_array);
-}
-
-bool MEDCouplingCMesh::isEqual(const MEDCouplingMesh *other, double prec) const
-{
- const MEDCouplingCMesh *otherC=dynamic_cast<const MEDCouplingCMesh *>(other);
- if(!otherC)
- return false;
- return true;
-}
-
-void MEDCouplingCMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
-{
- const char msg0[]="Invalid ";
- const char msg1[]=" array ! Must contain more than 1 element.";
- if(_x_array)
- if(_x_array->getNbOfElems()<2)
- {
- std::ostringstream os; os << msg0 << 'X' << msg1;
- throw INTERP_KERNEL::Exception(os.str().c_str());
- }
- if(_y_array)
- if(_y_array->getNbOfElems()<2)
- {
- std::ostringstream os; os << msg0 << 'Y' << msg1;
- throw INTERP_KERNEL::Exception(os.str().c_str());
- }
- if(_z_array)
- if(_z_array->getNbOfElems()<2)
- {
- std::ostringstream os; os << msg0 << 'Z' << msg1;
- throw INTERP_KERNEL::Exception(os.str().c_str());
- }
-}
-
-bool MEDCouplingCMesh::isStructured() const
-{
- return true;
-}
-
-int MEDCouplingCMesh::getNumberOfCells() const
-{
- int ret=1;
- if(_x_array)
- ret*=_x_array->getNbOfElems()-1;
- if(_y_array)
- ret*=_y_array->getNbOfElems()-1;
- if(_z_array)
- ret*=_z_array->getNbOfElems()-1;
- return ret;
-}
-
-int MEDCouplingCMesh::getNumberOfNodes() const
-{
- int ret=1;
- if(_x_array)
- ret*=_x_array->getNbOfElems();
- if(_y_array)
- ret*=_y_array->getNbOfElems();
- if(_z_array)
- ret*=_z_array->getNbOfElems();
- return ret;
-}
-
-int MEDCouplingCMesh::getSpaceDimension() const
-{
- int ret=0;
- if(_x_array)
- ret++;
- if(_y_array)
- ret++;
- if(_z_array)
- ret++;
- return ret;
-}
-
-int MEDCouplingCMesh::getMeshDimension() const
-{
- int ret=0;
- if(_x_array)
- ret++;
- if(_y_array)
- ret++;
- if(_z_array)
- ret++;
- return ret;
-}
-
-DataArrayDouble *MEDCouplingCMesh::getCoordsAt(int i) const throw(INTERP_KERNEL::Exception)
-{
- switch(i)
- {
- case 0:
- return _x_array;
- case 1:
- return _y_array;
- case 2:
- return _z_array;
- default:
- throw INTERP_KERNEL::Exception("Invalid rank specified must be 0 or 1 or 2.");
- }
-}
-
-void MEDCouplingCMesh::setCoords(DataArrayDouble *coordsX, DataArrayDouble *coordsY, DataArrayDouble *coordsZ)
-{
- if(_x_array)
- _x_array->decrRef();
- _x_array=coordsX;
- if(_x_array)
- _x_array->incrRef();
- if(_y_array)
- _y_array->decrRef();
- _y_array=coordsY;
- if(_y_array)
- _y_array->incrRef();
- if(_z_array)
- _z_array->decrRef();
- _z_array=coordsZ;
- if(_z_array)
- _z_array->incrRef();
- declareAsNew();
-}
-
-void MEDCouplingCMesh::getBoundingBox(double *bbox) const
-{
- //not implemented yet !
-}
-
-MEDCouplingFieldDouble *MEDCouplingCMesh::getMeasureField() const
-{
- //not implemented yet !
- return 0;
-}
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__
-#define __PARAMEDMEM_MEDCOUPLINGCMESH_HXX__
-
-#include "MEDCoupling.hxx"
-#include "MEDCouplingMesh.hxx"
-
-namespace ParaMEDMEM
-{
- class DataArrayDouble;
-
- class MEDCouplingCMesh : public MEDCouplingMesh
- {
- public:
- static MEDCouplingCMesh *New();
- void updateTime();
- MEDCouplingMeshType getType() const { return CARTESIAN; }
- bool isEqual(const MEDCouplingMesh *other, double prec) const;
- void checkCoherency() const throw(INTERP_KERNEL::Exception);
- bool isStructured() const;
- int getNumberOfCells() const;
- int getNumberOfNodes() const;
- int getSpaceDimension() const;
- int getMeshDimension() const;
- DataArrayDouble *getCoordsAt(int i) const throw(INTERP_KERNEL::Exception);
- void setCoords(DataArrayDouble *coordsX,
- DataArrayDouble *coordsY=0,
- DataArrayDouble *coordsZ=0);
- // tools
- void getBoundingBox(double *bbox) const;
- MEDCouplingFieldDouble *getMeasureField() const;
- private:
- MEDCouplingCMesh();
- ~MEDCouplingCMesh();
- private:
- DataArrayDouble *_x_array;
- DataArrayDouble *_y_array;
- DataArrayDouble *_z_array;
- };
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#include "MEDCouplingFieldDiscretization.hxx"
-#include "MEDCouplingMesh.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-
-#include "MEDCouplingPointSet.hxx"
-
-using namespace ParaMEDMEM;
-
-const char MEDCouplingFieldDiscretizationP0::REPR[]="P0";
-
-const TypeOfField MEDCouplingFieldDiscretizationP0::TYPE=ON_CELLS;
-
-const char MEDCouplingFieldDiscretizationP1::REPR[]="P1";
-
-const TypeOfField MEDCouplingFieldDiscretizationP1::TYPE=ON_NODES;
-
-MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretization::New(TypeOfField type)
-{
- switch(type)
- {
- case MEDCouplingFieldDiscretizationP0::TYPE:
- return new MEDCouplingFieldDiscretizationP0;
- case MEDCouplingFieldDiscretizationP1::TYPE:
- return new MEDCouplingFieldDiscretizationP1;
- default:
- throw INTERP_KERNEL::Exception("Choosen discretization is not implemented yet.");
- }
-}
-
-TypeOfField MEDCouplingFieldDiscretizationP0::getEnum() const
-{
- return TYPE;
-}
-
-MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretizationP0::clone() const
-{
- return new MEDCouplingFieldDiscretizationP0;
-}
-
-const char *MEDCouplingFieldDiscretizationP0::getStringRepr() const
-{
- return REPR;
-}
-
-bool MEDCouplingFieldDiscretizationP0::isEqual(const MEDCouplingFieldDiscretization *other) const
-{
- const MEDCouplingFieldDiscretizationP0 *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationP0 *>(other);
- return otherC!=0;
-}
-
-int MEDCouplingFieldDiscretizationP0::getNumberOfTuples(const MEDCouplingMesh *mesh) const
-{
- return mesh->getNumberOfCells();
-}
-
-void MEDCouplingFieldDiscretizationP0::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception)
-{
-}
-
-void MEDCouplingFieldDiscretizationP0::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
-{
- if(mesh->getNumberOfCells()!=da->getNumberOfTuples())
- {
- std::ostringstream message;
- message << "Field on cells invalid because there are " << mesh->getNumberOfCells();
- message << " cells in mesh and " << da->getNumberOfTuples() << " tuples in field !";
- throw INTERP_KERNEL::Exception(message.str().c_str());
- }
-}
-
-MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP0::getWeightingField(const MEDCouplingMesh *mesh) const
-{
- return mesh->getMeasureField();
-}
-
-/*!
- * This method returns a submesh of 'mesh' instance constituting cell ids contained in array defined as an interval [start;end).
- * @ param di is an array returned that specifies entity ids (here cells ids) in mesh 'mesh' of entity in returned submesh.
- * Example : The first cell id of returned mesh has the (*di)[0] id in 'mesh'
- */
-MEDCouplingMesh *MEDCouplingFieldDiscretizationP0::buildSubMeshData(const int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const
-{
- MEDCouplingPointSet* ret=((const MEDCouplingPointSet *) mesh)->buildPartOfMySelf(start,end,false);
- di=DataArrayInt::New();
- di->alloc(end-start,1);
- int *pt=di->getPointer();
- std::copy(start,end,pt);
- return ret;
-}
-
-TypeOfField MEDCouplingFieldDiscretizationP1::getEnum() const
-{
- return TYPE;
-}
-
-MEDCouplingFieldDiscretization *MEDCouplingFieldDiscretizationP1::clone() const
-{
- return new MEDCouplingFieldDiscretizationP1;
-}
-
-const char *MEDCouplingFieldDiscretizationP1::getStringRepr() const
-{
- return REPR;
-}
-
-bool MEDCouplingFieldDiscretizationP1::isEqual(const MEDCouplingFieldDiscretization *other) const
-{
- const MEDCouplingFieldDiscretizationP1 *otherC=dynamic_cast<const MEDCouplingFieldDiscretizationP1 *>(other);
- return otherC!=0;
-}
-
-int MEDCouplingFieldDiscretizationP1::getNumberOfTuples(const MEDCouplingMesh *mesh) const
-{
- return mesh->getNumberOfNodes();
-}
-
-void MEDCouplingFieldDiscretizationP1::checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception)
-{
- if(nat!=ConservativeVolumic)
- throw INTERP_KERNEL::Exception("Invalid nature for P1 field !");
-}
-
-void MEDCouplingFieldDiscretizationP1::checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception)
-{
- if(mesh->getNumberOfNodes()!=da->getNumberOfTuples())
- {
- std::ostringstream message;
- message << "Field on nodes invalid because there are " << mesh->getNumberOfNodes();
- message << " cells in mesh and " << da->getNumberOfTuples() << " tuples in field !";
- throw INTERP_KERNEL::Exception(message.str().c_str());
- }
-}
-
-MEDCouplingFieldDouble *MEDCouplingFieldDiscretizationP1::getWeightingField(const MEDCouplingMesh *mesh) const
-{
- //not implemented yet.
- //Dual mesh to build
- return 0;
-}
-
-/*!
- * This method invert array 'di' that is a conversion map from Old to New node numbering to New to Old node numbering.
- */
-DataArrayInt *MEDCouplingFieldDiscretizationP1::invertArrayO2N2N2O(const MEDCouplingMesh *mesh, const DataArrayInt *di)
-{
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc(mesh->getNumberOfNodes(),1);
- int nbOfOldNodes=di->getNumberOfTuples();
- const int *old2New=di->getConstPointer();
- int *pt=ret->getPointer();
- for(int i=0;i!=nbOfOldNodes;i++)
- if(old2New[i]!=-1)
- pt[old2New[i]]=i;
- return ret;
-}
-
-MEDCouplingMesh *MEDCouplingFieldDiscretizationP1::buildSubMeshData(const int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const
-{
- MEDCouplingPointSet* ret=((const MEDCouplingPointSet *) mesh)->buildPartOfMySelf(start,end,true);
- DataArrayInt *diInv=ret->zipCoordsTraducer();
- di=invertArrayO2N2N2O(ret,diInv);
- diInv->decrRef();
- return ret;
-}
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __MEDCOUPLINGFIELDDISCRETIZATION_HXX__
-#define __MEDCOUPLINGFIELDDISCRETIZATION_HXX__
-
-#include "MEDCoupling.hxx"
-#include "MEDCouplingRefCountObject.hxx"
-#include "InterpKernelException.hxx"
-#include "MEDCouplingNatureOfField.hxx"
-
-namespace ParaMEDMEM
-{
- class DataArrayInt;
- class MEDCouplingMesh;
- class DataArrayDouble;
- class MEDCouplingFieldDouble;
-
- class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretization
- {
- public:
- static MEDCouplingFieldDiscretization *New(TypeOfField type);
- virtual TypeOfField getEnum() const = 0;
- virtual bool isEqual(const MEDCouplingFieldDiscretization *other) const = 0;
- virtual MEDCouplingFieldDiscretization *clone() const = 0;
- virtual const char *getStringRepr() const = 0;
- virtual int getNumberOfTuples(const MEDCouplingMesh *mesh) const = 0;
- virtual void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception) = 0;
- virtual void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception) = 0;
- virtual MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh) const = 0;
- virtual MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const = 0;
- };
-
- class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationP0 : public MEDCouplingFieldDiscretization
- {
- public:
- TypeOfField getEnum() const;
- MEDCouplingFieldDiscretization *clone() const;
- const char *getStringRepr() const;
- bool isEqual(const MEDCouplingFieldDiscretization *other) const;
- int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
- void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
- void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh) const;
- MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const;
- public:
- static const char REPR[];
- static const TypeOfField TYPE;
- };
-
- class MEDCOUPLING_EXPORT MEDCouplingFieldDiscretizationP1 : public MEDCouplingFieldDiscretization
- {
- public:
- TypeOfField getEnum() const;
- MEDCouplingFieldDiscretization *clone() const;
- const char *getStringRepr() const;
- bool isEqual(const MEDCouplingFieldDiscretization *other) const;
- int getNumberOfTuples(const MEDCouplingMesh *mesh) const;
- void checkCompatibilityWithNature(NatureOfField nat) const throw(INTERP_KERNEL::Exception);
- void checkCoherencyBetween(const MEDCouplingMesh *mesh, const DataArrayDouble *da) const throw(INTERP_KERNEL::Exception);
- MEDCouplingFieldDouble *getWeightingField(const MEDCouplingMesh *mesh) const;
- MEDCouplingMesh *buildSubMeshData(const int *start, const int *end, const MEDCouplingMesh *mesh, DataArrayInt *&di) const;
- static DataArrayInt *invertArrayO2N2N2O(const MEDCouplingMesh *mesh, const DataArrayInt *di);
- public:
- static const char REPR[];
- static const TypeOfField TYPE;
- };
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#include "MEDCouplingMemArray.txx"
-
-using namespace ParaMEDMEM;
-
-void DataArray::setName(const char *name)
-{
- _name=name;
-}
-
-bool DataArray::areInfoEquals(const DataArray& other) const
-{
- if(_nb_of_tuples!=other._nb_of_tuples)
- return false;
- if(_name!=other._name)
- return false;
- return _info_on_compo==other._info_on_compo;
-}
-
-DataArrayDouble *DataArrayDouble::New()
-{
- return new DataArrayDouble;
-}
-
-DataArrayDouble *DataArrayDouble::deepCopy() const
-{
- return new DataArrayDouble(*this);
-}
-
-DataArrayDouble *DataArrayDouble::performCpy(bool deepCpy) const
-{
- if(deepCpy)
- return deepCopy();
- else
- {
- incrRef();
- return const_cast<DataArrayDouble *>(this);
- }
-}
-
-void DataArrayDouble::alloc(int nbOfTuple, int nbOfCompo)
-{
- _nb_of_tuples=nbOfTuple;
- _info_on_compo.resize(nbOfCompo);
- _mem.alloc(nbOfCompo*_nb_of_tuples);
- declareAsNew();
-}
-
-bool DataArrayDouble::isEqual(const DataArrayDouble& other, double prec) const
-{
- if(!areInfoEquals(other))
- return false;
- return _mem.isEqual(other._mem,prec);
-}
-
-void DataArrayDouble::reAlloc(int nbOfTuples)
-{
- _mem.reAlloc(_info_on_compo.size()*nbOfTuples);
- _nb_of_tuples=nbOfTuples;
- declareAsNew();
-}
-
-void DataArrayDouble::setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet)
-{
- if(newArray!=arrayToSet)
- {
- if(arrayToSet)
- arrayToSet->decrRef();
- arrayToSet=newArray;
- if(arrayToSet)
- arrayToSet->incrRef();
- }
-}
-
-void DataArrayDouble::useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo)
-{
- _nb_of_tuples=nbOfTuple;
- _info_on_compo.resize(nbOfCompo);
- _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo);
- declareAsNew();
-}
-
-DataArrayInt *DataArrayInt::New()
-{
- return new DataArrayInt;
-}
-
-DataArrayInt *DataArrayInt::deepCopy() const
-{
- return new DataArrayInt(*this);
-}
-
-DataArrayInt *DataArrayInt::performCpy(bool deepCpy) const
-{
- if(deepCpy)
- return deepCopy();
- else
- {
- incrRef();
- return const_cast<DataArrayInt *>(this);
- }
-}
-
-void DataArrayInt::alloc(int nbOfTuple, int nbOfCompo)
-{
- _nb_of_tuples=nbOfTuple;
- _info_on_compo.resize(nbOfCompo);
- _mem.alloc(nbOfCompo*_nb_of_tuples);
- declareAsNew();
-}
-
-bool DataArrayInt::isEqual(const DataArrayInt& other) const
-{
- if(!areInfoEquals(other))
- return false;
- return _mem.isEqual(other._mem,0);
-}
-
-void DataArrayInt::useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo)
-{
- _nb_of_tuples=nbOfTuple;
- _info_on_compo.resize(nbOfCompo);
- _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo);
- declareAsNew();
-}
-
-void DataArrayInt::reAlloc(int nbOfTuples)
-{
- _mem.reAlloc(_info_on_compo.size()*nbOfTuples);
- _nb_of_tuples=nbOfTuples;
- declareAsNew();
-}
-
-void DataArrayInt::setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet)
-{
- if(newArray!=arrayToSet)
- {
- if(arrayToSet)
- arrayToSet->decrRef();
- arrayToSet=newArray;
- if(arrayToSet)
- arrayToSet->incrRef();
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__
-#define __PARAMEDMEM_MEDCOUPLINGMEMARRAY_HXX__
-
-#include "MEDCoupling.hxx"
-#include "MEDCouplingTimeLabel.hxx"
-#include "MEDCouplingRefCountObject.hxx"
-#include "InterpKernelException.hxx"
-
-#include <string>
-#include <vector>
-
-namespace ParaMEDMEM
-{
- template<class T>
- class MEDCouplingPointer
- {
- public:
- MEDCouplingPointer():_internal(0),_external(0) { }
- void null() { _internal=0; _external=0; }
- bool isNull() const { return _internal==0 && _external==0; }
- void setInternal(T *pointer);
- void setExternal(const T *pointer);
- const T *getConstPointer() const { if(_internal) return _internal; else return _external; }
- const T *getConstPointerLoc(int offset) const { if(_internal) return _internal+offset; else return _external+offset; }
- T *getPointer() const { if(_internal) return _internal; if(_external) throw INTERP_KERNEL::Exception("Trying to write on an external pointer."); else return 0; }
- private:
- T *_internal;
- const T *_external;
- };
-
- template<class T>
- class MemArray
- {
- public:
- MemArray():_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC) { }
- MemArray(const MemArray<T>& other);
- const T *getConstPointerLoc(int offset) const { return _pointer.getConstPointerLoc(offset); }
- const T *getConstPointer() const { return _pointer.getConstPointer(); }
- T *getPointer() const { return _pointer.getPointer(); }
- MemArray<T> &operator=(const MemArray<T>& other);
- T operator[](int id) const { return _pointer.getConstPointer()[id]; }
- T& operator[](int id) { return _pointer.getPointer()[id]; }
- bool isEqual(const MemArray<T>& other, T prec) const;
- void alloc(int nbOfElements);
- void reAlloc(int newNbOfElements);
- void useArray(const T *array, bool ownership, DeallocType type, int nbOfElem);
- void writeOnPlace(int id, T element0, const T *others, int sizeOfOthers);
- ~MemArray() { destroy(); }
- private:
- void destroy();
- static void destroyPointer(T *pt, DeallocType type);
- private:
- int _nb_of_elem;
- bool _ownership;
- MEDCouplingPointer<T> _pointer;
- //T *_pointer;
- DeallocType _dealloc;
- };
-
- class MEDCOUPLING_EXPORT DataArray : public RefCountObject, public TimeLabel
- {
- public:
- void setName(const char *name);
- bool areInfoEquals(const DataArray& other) const;
- std::string getName() const { return _name; }
- std::string getInfoOnComponent(int i) const { return _info_on_compo[i]; }
- void setInfoOnComponent(int i, const char *info) { _info_on_compo[i]=info; }
- int getNumberOfComponents() const { return _info_on_compo.size(); }
- int getNumberOfTuples() const { return _nb_of_tuples; }
- int getNbOfElems() const { return _info_on_compo.size()*_nb_of_tuples; }
- protected:
- DataArray():_nb_of_tuples(-1) { }
- protected:
- int _nb_of_tuples;
- std::string _name;
- std::vector<std::string> _info_on_compo;
- };
-}
-
-#include "MEDCouplingMemArray.txx"
-
-namespace ParaMEDMEM
-{
- class MEDCOUPLING_EXPORT DataArrayDouble : public DataArray
- {
- public:
- static DataArrayDouble *New();
- DataArrayDouble *deepCopy() const;
- DataArrayDouble *performCpy(bool deepCpy) const;
- void alloc(int nbOfTuple, int nbOfCompo);
- bool isEqual(const DataArrayDouble& other, double prec) const;
- //!alloc or useArray should have been called before.
- void reAlloc(int nbOfTuples);
- void getTuple(int tupleId, double *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
- double getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
- void setIJ(int tupleId, int compoId, double newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
- double *getPointer() const { return _mem.getPointer(); }
- static void setArrayIn(DataArrayDouble *newArray, DataArrayDouble* &arrayToSet);
- const double *getConstPointer() const { return _mem.getConstPointer(); }
- void useArray(const double *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
- void writeOnPlace(int id, double element0, const double *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
- //! nothing to do here because this class does not aggregate any TimeLabel instance.
- void updateTime() { }
- private:
- DataArrayDouble() { }
- private:
- MemArray<double> _mem;
- };
-
- class MEDCOUPLING_EXPORT DataArrayInt : public DataArray
- {
- public:
- static DataArrayInt *New();
- DataArrayInt *deepCopy() const;
- DataArrayInt *performCpy(bool deepCpy) const;
- void alloc(int nbOfTuple, int nbOfCompo);
- bool isEqual(const DataArrayInt& other) const;
- //!alloc or useArray should have been called before.
- void reAlloc(int nbOfTuples);
- void getTuple(int tupleId, int *res) const { std::copy(_mem.getConstPointerLoc(tupleId*_info_on_compo.size()),_mem.getConstPointerLoc((tupleId+1)*_info_on_compo.size()),res); }
- int getIJ(int tupleId, int compoId) const { return _mem[tupleId*_info_on_compo.size()+compoId]; }
- void setIJ(int tupleId, int compoId, int newVal) { _mem[tupleId*_info_on_compo.size()+compoId]=newVal; }
- int *getPointer() const { return _mem.getPointer(); }
- static void setArrayIn(DataArrayInt *newArray, DataArrayInt* &arrayToSet);
- const int *getConstPointer() const { return _mem.getConstPointer(); }
- void useArray(const int *array, bool ownership, DeallocType type, int nbOfTuple, int nbOfCompo);
- void writeOnPlace(int id, int element0, const int *others, int sizeOfOthers) { _mem.writeOnPlace(id,element0,others,sizeOfOthers); }
- //! nothing to do here because this class does not aggregate any TimeLabel instance.
- void updateTime() { }
- private:
- DataArrayInt() { }
- private:
- MemArray<int> _mem;
- };
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __PARAMEDMEM_MEDCOUPLINGMEMARRAY_TXX__
-#define __PARAMEDMEM_MEDCOUPLINGMEMARRAY_TXX__
-
-#include "MEDCouplingMemArray.hxx"
-#include "NormalizedUnstructuredMesh.hxx"
-#include "InterpKernelException.hxx"
-
-#include <sstream>
-#include <algorithm>
-
-namespace ParaMEDMEM
-{
- template<class T>
- void MEDCouplingPointer<T>::setInternal(T *pointer)
- {
- _internal=pointer;
- _external=0;
- }
-
- template<class T>
- void MEDCouplingPointer<T>::setExternal(const T *pointer)
- {
- _external=pointer;
- _internal=0;
- }
-
- template<class T>
- MemArray<T>::MemArray(const MemArray<T>& other):_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC)
- {
- if(!other._pointer.isNull())
- {
- T *pointer=new T[other._nb_of_elem];
- std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+other._nb_of_elem,pointer);
- useArray(pointer,true,CPP_DEALLOC,other._nb_of_elem);
- }
- }
-
- template<class T>
- void MemArray<T>::useArray(const T *array, bool ownership, DeallocType type, int nbOfElem)
- {
- _nb_of_elem=nbOfElem;
- destroy();
- if(ownership)
- _pointer.setInternal((T *)array);
- else
- _pointer.setExternal(array);
- _ownership=ownership;
- _dealloc=type;
- }
-
- template<class T>
- void MemArray<T>::writeOnPlace(int id, T element0, const T *others, int sizeOfOthers)
- {
- if(id+sizeOfOthers>=_nb_of_elem)
- reAlloc(2*_nb_of_elem+sizeOfOthers+1);
- T *pointer=_pointer.getPointer();
- pointer[id]=element0;
- std::copy(others,others+sizeOfOthers,pointer+id+1);
- }
-
- template<class T>
- bool MemArray<T>::isEqual(const MemArray<T>& other, T prec) const
- {
- if(_nb_of_elem!=other._nb_of_elem)
- return false;
- const T *pt1=_pointer.getConstPointer();
- const T *pt2=other._pointer.getConstPointer();
- if(pt1==0 && pt2==0)
- return true;
- if(pt1==0 || pt2==0)
- return false;
- for(int i=0;i<_nb_of_elem;i++)
- if(pt1[i]-pt2[i]<-prec || (pt1[i]-pt2[i])>prec)
- return false;
- return true;
- }
-
- template<class T>
- void MemArray<T>::alloc(int nbOfElements)
- {
- destroy();
- _nb_of_elem=nbOfElements;
- _pointer.setInternal(new T[_nb_of_elem]);
- _ownership=true;
- _dealloc=CPP_DEALLOC;
- }
-
- template<class T>
- void MemArray<T>::reAlloc(int newNbOfElements)
- {
- T *pointer=new T[newNbOfElements];
- std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min<int>(_nb_of_elem,newNbOfElements),pointer);
- if(_ownership)
- destroyPointer((T *)_pointer.getConstPointer(),_dealloc);
- _pointer.setInternal(pointer);
- _nb_of_elem=newNbOfElements;
- _ownership=true;
- _dealloc=CPP_DEALLOC;
- }
-
- template<class T>
- void MemArray<T>::destroyPointer(T *pt, DeallocType type)
- {
- switch(type)
- {
- case CPP_DEALLOC:
- {
- delete [] pt;
- return ;
- }
- case C_DEALLOC:
- {
- free(pt);
- return ;
- }
- default:
- std::stringstream stream;
- stream << "Invalid deallocation requested for pointer " << pt;
- throw INTERP_KERNEL::Exception(stream.str().c_str());
- }
- }
-
- template<class T>
- void MemArray<T>::destroy()
- {
- if(_ownership)
- destroyPointer((T *)_pointer.getConstPointer(),_dealloc);
- _pointer.null();
- _ownership=false;
- }
-
- template<class T>
- MemArray<T> &MemArray<T>::operator=(const MemArray<T>& other)
- {
- alloc(other._nb_of_elem);
- std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+_nb_of_elem,_pointer.getPointer());
- return *this;
- }
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __MEDCOUPLINGNATUREOFFIELD_HXX__
-#define __MEDCOUPLINGNATUREOFFIELD_HXX__
-
-namespace ParaMEDMEM
-{
- typedef enum
- {
- NoNature = 17,
- ConservativeVolumic = 26,
- Integral = 32,
- IntegralGlobConstraint = 35
- } NatureOfField;
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#include "MEDCouplingPointSet.hxx"
-#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingUMeshDesc.hxx"
-#include "MEDCouplingMemArray.hxx"
-
-#include <cmath>
-#include <limits>
-#include <numeric>
-
-using namespace ParaMEDMEM;
-
-MEDCouplingPointSet::MEDCouplingPointSet():_coords(0)
-{
-}
-
-MEDCouplingPointSet::MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy):MEDCouplingMesh(other),_coords(0)
-{
- if(other._coords)
- _coords=other._coords->performCpy(deepCpy);
-}
-
-MEDCouplingPointSet::~MEDCouplingPointSet()
-{
- if(_coords)
- _coords->decrRef();
-}
-
-int MEDCouplingPointSet::getNumberOfNodes() const
-{
- if(_coords)
- return _coords->getNumberOfTuples();
- else
- throw INTERP_KERNEL::Exception("Unable to get number of nodes because no coordinates specified !");
-}
-
-int MEDCouplingPointSet::getSpaceDimension() const
-{
- if(_coords)
- return _coords->getNumberOfComponents();
- else
- throw INTERP_KERNEL::Exception("Unable to get space dimension because no coordinates specified !");
-}
-
-void MEDCouplingPointSet::updateTime()
-{
- if(_coords)
- {
- updateTimeWith(*_coords);
- }
-}
-
-bool MEDCouplingPointSet::isStructured() const
-{
- return false;
-}
-
-void MEDCouplingPointSet::setCoords(DataArrayDouble *coords)
-{
- if( coords != _coords )
- {
- if (_coords)
- _coords->decrRef();
- _coords=coords;
- if(_coords)
- _coords->incrRef();
- declareAsNew();
- }
-}
-
-bool MEDCouplingPointSet::areCoordsEqual(const MEDCouplingPointSet& other, double prec) const
-{
- if(_coords==0 && other._coords==0)
- return true;
- if(_coords==0 || other._coords==0)
- return false;
- if(_coords==other._coords)
- return true;
- return _coords->isEqual(*other._coords,prec);
-}
-
-void MEDCouplingPointSet::getBoundingBox(double *bbox) const
-{
- int dim=getSpaceDimension();
- for (int idim=0; idim<dim; idim++)
- {
- bbox[idim*2]=std::numeric_limits<double>::max();
- bbox[idim*2+1]=-std::numeric_limits<double>::max();
- }
- const double *coords=_coords->getConstPointer();
- int nbnodes=getNumberOfNodes();
- for (int i=0; i<nbnodes; i++)
- {
- for (int idim=0; idim<dim;idim++)
- {
- if ( bbox[idim*2] > coords[i*dim+idim] )
- {
- bbox[idim*2] = coords[i*dim+idim] ;
- }
- if ( bbox[idim*2+1] < coords[i*dim+idim] )
- {
- bbox[idim*2+1] = coords[i*dim+idim] ;
- }
- }
- }
-}
-
-void MEDCouplingPointSet::zipCoords()
-{
- checkFullyDefined();
- DataArrayInt *traducer=zipCoordsTraducer();
- traducer->decrRef();
-}
-
-void MEDCouplingPointSet::rotate(const double *center, const double *vector, double angle)
-{
- int spaceDim=getSpaceDimension();
- if(spaceDim==3)
- rotate3D(center,vector,angle);
- else if(spaceDim==2)
- rotate2D(center,angle);
- else
- throw INTERP_KERNEL::Exception("MEDCouplingPointSet::rotate : invalid space dim for rotation must be 2 or 3");
- _coords->declareAsNew();
- updateTime();
-}
-
-void MEDCouplingPointSet::translate(const double *vector)
-{
- double *coords=_coords->getPointer();
- int nbNodes=getNumberOfNodes();
- int dim=getSpaceDimension();
- for(int i=0; i<nbNodes; i++)
- for(int idim=0; idim<dim;idim++)
- coords[i*dim+idim]+=vector[idim];
- _coords->declareAsNew();
- updateTime();
-}
-
-MEDCouplingPointSet *MEDCouplingPointSet::buildInstanceFromMeshType(MEDCouplingMeshType type)
-{
- switch(type)
- {
- case UNSTRUCTURED:
- return MEDCouplingUMesh::New();
- case UNSTRUCTURED_DESC:
- return MEDCouplingUMeshDesc::New();
- default:
- throw INTERP_KERNEL::Exception("Invalid type of mesh specified");
- }
-}
-
-void MEDCouplingPointSet::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
-{
- if(_coords)
- {
- int spaceDim=getSpaceDimension();
- littleStrings.resize(spaceDim+1);
- littleStrings[0]=getName();
- for(int i=0;i<spaceDim;i++)
- littleStrings[i+1]=getCoords()->getInfoOnComponent(i);
- tinyInfo.clear();
- tinyInfo.push_back(getType());
- tinyInfo.push_back(spaceDim);
- tinyInfo.push_back(getNumberOfNodes());
- }
- else
- {
- littleStrings.resize(1);
- littleStrings[0]=getName();
- tinyInfo.clear();
- tinyInfo.push_back(getType());
- tinyInfo.push_back(-1);
- tinyInfo.push_back(-1);
- }
-}
-
-void MEDCouplingPointSet::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
-{
- if(_coords)
- {
- a2=getCoords();
- a2->incrRef();
- }
- else
- a2=0;
-}
-
-void MEDCouplingPointSet::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings)
-{
- if(tinyInfo[2]>=0 && tinyInfo[1]>=1)
- {
- a2->alloc(tinyInfo[2],tinyInfo[1]);
- littleStrings.resize(tinyInfo[1]+1);
- }
- else
- {
- littleStrings.resize(1);
- }
-}
-
-void MEDCouplingPointSet::unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
-{
- if(tinyInfo[2]>=0 && tinyInfo[1]>=1)
- {
- setCoords(a2);
- setName(littleStrings[0].c_str());
- for(int i=0;i<tinyInfo[1];i++)
- getCoords()->setInfoOnComponent(i,littleStrings[i+1].c_str());
- }
- else
- setName(littleStrings[0].c_str());
-}
-
-// =============================================
-// Intersect Bounding Box given 2 Bounding Boxes
-// =============================================
-bool MEDCouplingPointSet::intersectsBoundingBox(const double* bb1, const double* bb2, int dim, double eps)
-{
- double* bbtemp = new double[2*dim];
- double deltamax=0.0;
-
- for (int i=0; i< dim; i++)
- {
- double delta = bb1[2*i+1]-bb1[2*i];
- if ( delta > deltamax )
- {
- deltamax = delta ;
- }
- }
- for (int i=0; i<dim; i++)
- {
- bbtemp[i*2]=bb1[i*2]-deltamax*eps;
- bbtemp[i*2+1]=bb1[i*2+1]+deltamax*eps;
- }
-
- for (int idim=0; idim < dim; idim++)
- {
- bool intersects = (bbtemp[idim*2]<bb2[idim*2+1])
- && (bb2[idim*2]<bbtemp[idim*2+1]) ;
- if (!intersects)
- {
- delete [] bbtemp;
- return false;
- }
- }
- delete [] bbtemp;
- return true;
-}
-
-/*!
- * 'This' is expected to be of spaceDim==3. Idem for 'center' and 'vect'
- */
-void MEDCouplingPointSet::rotate3D(const double *center, const double *vect, double angle)
-{
- double sina=sin(angle);
- double cosa=cos(angle);
- double vectorNorm[3];
- double matrix[9];
- double matrixTmp[9];
- double norm=sqrt(vect[0]*vect[0]+vect[1]*vect[1]+vect[2]*vect[2]);
- std::transform(vect,vect+3,vectorNorm,std::bind2nd(std::multiplies<double>(),1/norm));
- //rotation matrix computation
- matrix[0]=cosa; matrix[1]=0.; matrix[2]=0.; matrix[3]=0.; matrix[4]=cosa; matrix[5]=0.; matrix[6]=0.; matrix[7]=0.; matrix[8]=cosa;
- matrixTmp[0]=vectorNorm[0]*vectorNorm[0]; matrixTmp[1]=vectorNorm[0]*vectorNorm[1]; matrixTmp[2]=vectorNorm[0]*vectorNorm[2];
- matrixTmp[3]=vectorNorm[1]*vectorNorm[0]; matrixTmp[4]=vectorNorm[1]*vectorNorm[1]; matrixTmp[5]=vectorNorm[1]*vectorNorm[2];
- matrixTmp[6]=vectorNorm[2]*vectorNorm[0]; matrixTmp[7]=vectorNorm[2]*vectorNorm[1]; matrixTmp[8]=vectorNorm[2]*vectorNorm[2];
- std::transform(matrixTmp,matrixTmp+9,matrixTmp,std::bind2nd(std::multiplies<double>(),1-cosa));
- std::transform(matrix,matrix+9,matrixTmp,matrix,std::plus<double>());
- matrixTmp[0]=0.; matrixTmp[1]=-vectorNorm[2]; matrixTmp[2]=vectorNorm[1];
- matrixTmp[3]=vectorNorm[2]; matrixTmp[4]=0.; matrixTmp[5]=-vectorNorm[0];
- matrixTmp[6]=-vectorNorm[1]; matrixTmp[7]=vectorNorm[0]; matrixTmp[8]=0.;
- std::transform(matrixTmp,matrixTmp+9,matrixTmp,std::bind2nd(std::multiplies<double>(),sina));
- std::transform(matrix,matrix+9,matrixTmp,matrix,std::plus<double>());
- //rotation matrix computed.
- double *coords=_coords->getPointer();
- int nbNodes=getNumberOfNodes();
- double tmp[3];
- for(int i=0; i<nbNodes; i++)
- {
- std::transform(coords+i*3,coords+(i+1)*3,center,tmp,std::minus<double>());
- coords[i*3]=matrix[0]*tmp[0]+matrix[1]*tmp[1]+matrix[2]*tmp[2]+center[0];
- coords[i*3+1]=matrix[3]*tmp[0]+matrix[4]*tmp[1]+matrix[5]*tmp[2]+center[1];
- coords[i*3+2]=matrix[6]*tmp[0]+matrix[7]*tmp[1]+matrix[8]*tmp[2]+center[2];
- }
-}
-
-/*!
- * 'This' is expected to be of spaceDim==2. Idem for 'center' and 'vect'
- */
-void MEDCouplingPointSet::rotate2D(const double *center, double angle)
-{
- double cosa=cos(angle);
- double sina=sin(angle);
- double matrix[4];
- matrix[0]=cosa; matrix[1]=-sina; matrix[2]=sina; matrix[3]=cosa;
- double *coords=_coords->getPointer();
- int nbNodes=getNumberOfNodes();
- double tmp[2];
- for(int i=0; i<nbNodes; i++)
- {
- std::transform(coords+i*2,coords+(i+1)*2,center,tmp,std::minus<double>());
- coords[i*2]=matrix[0]*tmp[0]+matrix[1]*tmp[1]+center[0];
- coords[i*2+1]=matrix[2]*tmp[0]+matrix[3]*tmp[1]+center[1];
- }
-}
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __PARAMEDMEM_MEDCOUPLINGPOINTSET_HXX__
-#define __PARAMEDMEM_MEDCOUPLINGPOINTSET_HXX__
-
-#include "MEDCoupling.hxx"
-#include "MEDCouplingMesh.hxx"
-
-#include <vector>
-
-namespace ParaMEDMEM
-{
- class DataArrayInt;
- class DataArrayDouble;
-
- class MEDCOUPLING_EXPORT MEDCouplingPointSet : public MEDCouplingMesh
- {
- protected:
- MEDCouplingPointSet();
- MEDCouplingPointSet(const MEDCouplingPointSet& other, bool deepCpy);
- ~MEDCouplingPointSet();
- public:
- void updateTime();
- bool isStructured() const;
- int getNumberOfNodes() const;
- int getSpaceDimension() const;
- void setCoords(DataArrayDouble *coords);
- DataArrayDouble *getCoords() const { return _coords; }
- bool areCoordsEqual(const MEDCouplingPointSet& other, double prec) const;
- void getBoundingBox(double *bbox) const;
- void zipCoords();
- void rotate(const double *center, const double *vector, double angle);
- void translate(const double *vector);
- static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type);
- virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0;
- virtual MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0;
- virtual void renumberConnectivity(const int *newNodeNumbers) = 0;
- //! size of returned tinyInfo must be always the same.
- virtual void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
- virtual void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings);
- virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- virtual void unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2,
- const std::vector<std::string>& littleStrings);
- virtual void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems) = 0;
- virtual DataArrayInt *zipCoordsTraducer() = 0;
- protected:
- virtual void checkFullyDefined() const throw(INTERP_KERNEL::Exception) = 0;
- static bool intersectsBoundingBox(const double* bb1, const double* bb2, int dim, double eps);
- void rotate2D(const double *center, double angle);
- void rotate3D(const double *center, const double *vect, double angle);
- protected:
- DataArrayDouble *_coords;
- };
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#include "MEDCouplingRefCountObject.hxx"
-
-using namespace ParaMEDMEM;
-
-RefCountObject::RefCountObject():_cnt(1)
-{
-}
-
-RefCountObject::RefCountObject(const RefCountObject& other):_cnt(1)
-{
-}
-
-bool RefCountObject::decrRef()
-{
- bool ret=((--_cnt)==0);
- if(ret)
- delete this;
- return ret;
-}
-
-void RefCountObject::incrRef() const
-{
- _cnt++;
-}
-
-RefCountObject::~RefCountObject()
-{
-}
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __PARAMEDMEM_MEDCOUPLINGREFCOUNTOBJECT_HXX__
-#define __PARAMEDMEM_MEDCOUPLINGREFCOUNTOBJECT_HXX__
-
-#include "MEDCoupling.hxx"
-
-namespace ParaMEDMEM
-{
- typedef enum
- {
- C_DEALLOC = 2,
- CPP_DEALLOC = 3
- } DeallocType;
-
- typedef enum
- {
- ON_CELLS = 0,
- ON_NODES = 1
- } TypeOfField;
-
- typedef enum
- {
- NO_TIME = 4,
- ONE_TIME = 5,
- LINEAR_TIME = 6
- } TypeOfTimeDiscretization;
-
- class MEDCOUPLING_EXPORT RefCountObject
- {
- protected:
- RefCountObject();
- RefCountObject(const RefCountObject& other);
- public:
- bool decrRef();
- void incrRef() const;
- protected:
- virtual ~RefCountObject();
- private:
- mutable int _cnt;
- };
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#include "MEDCouplingTimeDiscretization.hxx"
-#include "MEDCouplingMemArray.hxx"
-
-#include <cmath>
-
-using namespace ParaMEDMEM;
-
-const char MEDCouplingNoTimeLabel::EXCEPTION_MSG[]="MEDCouplingNoTimeLabel::setTime : no time info attached.";
-
-const char MEDCouplingWithTimeStep::EXCEPTION_MSG[]="No data on this time.";
-
-const double MEDCouplingTimeDiscretization::TIME_TOLERANCE_DFT=1.e-12;
-
-MEDCouplingTimeDiscretization *MEDCouplingTimeDiscretization::New(TypeOfTimeDiscretization type)
-{
- switch(type)
- {
- case MEDCouplingNoTimeLabel::DISCRETIZATION:
- return new MEDCouplingNoTimeLabel;
- case MEDCouplingWithTimeStep::DISCRETIZATION:
- return new MEDCouplingWithTimeStep;
- default:
- throw INTERP_KERNEL::Exception("Time discretization not implemented yet");
- }
-}
-
-bool MEDCouplingTimeDiscretization::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
-{
- if(std::fabs(_time_tolerance-other->_time_tolerance)>1.e-16)
- return false;
- if(_array==0 && other->_array==0)
- return true;
- if(_array==0 || other->_array==0)
- return false;
- if(_array==other->_array)
- return true;
- return _array->isEqual(*other->_array,prec);
-}
-
-void MEDCouplingTimeDiscretization::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
-{
- if(_array)
- {
- tinyInfo.push_back(_array->getNumberOfTuples());
- tinyInfo.push_back(_array->getNumberOfComponents());
- }
- else
- {
- tinyInfo.push_back(-1);
- tinyInfo.push_back(-1);
- }
-}
-
-void MEDCouplingTimeDiscretization::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
-{
- arrays.resize(1);
- if(_array!=0)
- _array->decrRef();
- DataArrayDouble *arr=0;
- if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
- {
- arr=DataArrayDouble::New();
- arr->alloc(tinyInfoI[0],tinyInfoI[1]);
- }
- _array=arr;
- arrays[0]=arr;
-}
-
-void MEDCouplingTimeDiscretization::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
-{
- _time_tolerance=tinyInfoD[0];
- int nbOfCompo=_array->getNumberOfComponents();
- for(int i=0;i<nbOfCompo;i++)
- _array->setInfoOnComponent(i,tinyInfoS[i].c_str());
-}
-
-void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
-{
- tinyInfo.push_back(_time_tolerance);
-}
-
-void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const
-{
- int nbOfCompo=_array->getNumberOfComponents();
- for(int i=0;i<nbOfCompo;i++)
- tinyInfo.push_back(_array->getInfoOnComponent(i));
-}
-
-MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization():_time_tolerance(TIME_TOLERANCE_DFT),_array(0)
-{
-}
-
-MEDCouplingTimeDiscretization::MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy):_time_tolerance(other._time_tolerance)
-{
- if(other._array)
- _array=other._array->performCpy(deepCpy);
- else
- _array=0;
-}
-
-MEDCouplingTimeDiscretization::~MEDCouplingTimeDiscretization()
-{
- if(_array)
- _array->decrRef();
-}
-
-void MEDCouplingTimeDiscretization::setArray(DataArrayDouble *array, TimeLabel *owner)
-{
- if(array!=_array)
- {
- if(_array)
- _array->decrRef();
- _array=array;
- if(_array)
- _array->incrRef();
- owner->declareAsNew();
- }
-}
-
-void MEDCouplingTimeDiscretization::setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception)
-{
- if(arrays.size()!=1)
- throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretization::setArrays : number of arrays must be one.");
- setArray(arrays.back(),owner);
-}
-
-void MEDCouplingTimeDiscretization::getArrays(std::vector<DataArrayDouble *>& arrays) const
-{
- arrays.resize(1);
- arrays[0]=_array;
-}
-
-bool MEDCouplingTimeDiscretization::isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
-{
- int dt,it;
- double time1=getEndTime(dt,it)-_time_tolerance;
- double time2=other->getStartTime(dt,it)+other->getTimeTolerance();
- return time1<=time2;
-}
-
-bool MEDCouplingTimeDiscretization::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
-{
- int dt,it;
- double time1=getEndTime(dt,it)+_time_tolerance;
- double time2=other->getStartTime(dt,it)-other->getTimeTolerance();
- return time1<time2;
-}
-
-MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel()
-{
-}
-
-MEDCouplingNoTimeLabel::MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy)
-{
-}
-
-bool MEDCouplingNoTimeLabel::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
-{
- const MEDCouplingNoTimeLabel *otherC=dynamic_cast<const MEDCouplingNoTimeLabel *>(other);
- if(!otherC)
- return false;
- return MEDCouplingTimeDiscretization::isEqual(other,prec);
-}
-
-MEDCouplingTimeDiscretization *MEDCouplingNoTimeLabel::performCpy(bool deepCpy) const
-{
- return new MEDCouplingNoTimeLabel(*this,deepCpy);
-}
-
-void MEDCouplingNoTimeLabel::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-DataArrayDouble *MEDCouplingNoTimeLabel::getArrayOnTime(double time) const throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-bool MEDCouplingNoTimeLabel::isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-bool MEDCouplingNoTimeLabel::isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-double MEDCouplingNoTimeLabel::getStartTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-double MEDCouplingNoTimeLabel::getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-void MEDCouplingNoTimeLabel::setStartTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-void MEDCouplingNoTimeLabel::setEndTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-void MEDCouplingNoTimeLabel::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-void MEDCouplingNoTimeLabel::getValueOnDiscTime(int eltId, int dt, int it, double *value) const throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-MEDCouplingWithTimeStep::MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy):MEDCouplingTimeDiscretization(other,deepCpy),
- _time(other._time),_dt(other._dt),_it(other._it)
-{
-}
-
-MEDCouplingWithTimeStep::MEDCouplingWithTimeStep():_time(0.),_dt(-1),_it(-1)
-{
-}
-
-void MEDCouplingWithTimeStep::getTinySerializationIntInformation(std::vector<int>& tinyInfo) const
-{
- MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo);
- tinyInfo.push_back(_dt);
- tinyInfo.push_back(_it);
-}
-
-void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const
-{
- MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo);
- tinyInfo.push_back(_time);
-}
-
-void MEDCouplingWithTimeStep::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
-{
- MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
- _time=tinyInfoD[1];
- _dt=tinyInfoI[2];
- _it=tinyInfoI[3];
-}
-
-bool MEDCouplingWithTimeStep::isEqual(const MEDCouplingTimeDiscretization *other, double prec) const
-{
- const MEDCouplingWithTimeStep *otherC=dynamic_cast<const MEDCouplingWithTimeStep *>(other);
- if(!otherC)
- return false;
- if(_dt!=otherC->_dt)
- return false;
- if(_it!=otherC->_it)
- return false;
- if(std::fabs(_time-otherC->_time)>_time_tolerance)
- return false;
- return MEDCouplingTimeDiscretization::isEqual(other,prec);
-}
-
-MEDCouplingTimeDiscretization *MEDCouplingWithTimeStep::performCpy(bool deepCpy) const
-{
- return new MEDCouplingWithTimeStep(*this,deepCpy);
-}
-
-void MEDCouplingWithTimeStep::checkNoTimePresence() const throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception("No time specified on a field defined on one time");
-}
-
-void MEDCouplingWithTimeStep::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
-{
- if(std::fabs(time-_time)>_time_tolerance)
- {
- std::ostringstream stream;
- stream << "The field is defined on time " << _time << " with eps=" << _time_tolerance << " and asking time = " << time << " !";
- throw INTERP_KERNEL::Exception(stream.str().c_str());
- }
-}
-
-DataArrayDouble *MEDCouplingWithTimeStep::getArrayOnTime(double time) const throw(INTERP_KERNEL::Exception)
-{
- if(std::fabs(time-_time)<=_time_tolerance)
- {
- if(_array)
- _array->incrRef();
- return _array;
- }
- else
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-void MEDCouplingWithTimeStep::getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception)
-{
- if(std::fabs(time-_time)<=_time_tolerance)
- if(_array)
- _array->getTuple(eltId,value);
- else
- throw INTERP_KERNEL::Exception("No array existing.");
- else
- throw INTERP_KERNEL::Exception(EXCEPTION_MSG);
-}
-
-void MEDCouplingWithTimeStep::getValueOnDiscTime(int eltId, int dt, int it, double *value) const throw(INTERP_KERNEL::Exception)
-{
- if(_dt==dt && _it==it)
- if(_array)
- _array->getTuple(eltId,value);
- else
- throw INTERP_KERNEL::Exception("No array existing.");
- else
- throw INTERP_KERNEL::Exception("No data on this discrete time.");
-}
-
-MEDCouplingTwoTimeSteps::MEDCouplingTwoTimeSteps():_start_time(0.),_end_time(0.),_start_dt(-1),_end_dt(-1),_start_it(-1),_end_it(-1),_end_array(0)
-{
-}
-
-MEDCouplingTwoTimeSteps::~MEDCouplingTwoTimeSteps()
-{
- if(_end_array)
- _end_array->decrRef();
-}
-
-void MEDCouplingTwoTimeSteps::checkNoTimePresence() const throw(INTERP_KERNEL::Exception)
-{
- throw INTERP_KERNEL::Exception("The field presents a time to be specified in every access !");
-}
-
-void MEDCouplingTwoTimeSteps::checkTimePresence(double time) const throw(INTERP_KERNEL::Exception)
-{
- if(time<_start_time-_time_tolerance || time>_end_time+_time_tolerance)
- {
- std::ostringstream stream;
- stream << "The field is defined between times " << _start_time << " and " << _end_time << " with tolerance ";
- stream << _time_tolerance << " and trying to access on time = " << time;
- throw INTERP_KERNEL::Exception(stream.str().c_str());
- }
-}
-
-void MEDCouplingTwoTimeSteps::getArrays(std::vector<DataArrayDouble *>& arrays) const
-{
- arrays.resize(2);
- arrays[0]=_array;
- arrays[1]=_end_array;
-}
-
-void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays)
-{
- arrays.resize(2);
- if(_array!=0)
- _array->decrRef();
- if(_end_array!=0)
- _end_array->decrRef();
- DataArrayDouble *arr=0;
- if(tinyInfoI[0]!=-1 && tinyInfoI[1]!=-1)
- {
- arr=DataArrayDouble::New();
- arr->alloc(tinyInfoI[0],tinyInfoI[1]);
- }
- _array=arr;
- arrays[0]=arr;
- arr=0;
- if(tinyInfoI[2]!=-1 && tinyInfoI[3]!=-1)
- {
- arr=DataArrayDouble::New();
- arr->alloc(tinyInfoI[2],tinyInfoI[3]);
- }
- _end_array=arr;
- arrays[1]=arr;
-}
-
-void MEDCouplingTwoTimeSteps::finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS)
-{
- MEDCouplingTimeDiscretization::finishUnserialization(tinyInfoI,tinyInfoD,tinyInfoS);
- _start_time=tinyInfoD[1];
- _end_time=tinyInfoD[2];
- _start_dt=tinyInfoI[2];
- _end_dt=tinyInfoI[3];
- _start_it=tinyInfoI[4];
- _end_it=tinyInfoI[5];
-}
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __MEDCOUPLINGTIMEDISCRETIZATION_HXX__
-#define __MEDCOUPLINGTIMEDISCRETIZATION_HXX__
-
-#include "MEDCoupling.hxx"
-#include "MEDCouplingRefCountObject.hxx"
-#include "InterpKernelException.hxx"
-
-#include <vector>
-
-namespace ParaMEDMEM
-{
- class DataArrayDouble;
- class TimeLabel;
-
- class MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization
- {
- protected:
- MEDCouplingTimeDiscretization();
- MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy);
- public:
- static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
- virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
- virtual TypeOfTimeDiscretization getEnum() const = 0;
- virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
- virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
- virtual void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
- virtual void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
- virtual void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
- virtual MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const = 0;
- void setTimeTolerance(double val);
- double getTimeTolerance() const { return _time_tolerance; }
- virtual void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) = 0;
- virtual void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception) = 0;
- virtual void setArray(DataArrayDouble *array, TimeLabel *owner);
- virtual void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getArray() const { return _array; }
- virtual DataArrayDouble *getEndArray() const { return _array; }
- //! Warning contrary to getArray method this method returns an object to deal with.
- virtual DataArrayDouble *getArrayOnTime(double time) const throw(INTERP_KERNEL::Exception) = 0;
- virtual void getArrays(std::vector<DataArrayDouble *>& arrays) const;
- virtual bool isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
- virtual bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
- double getTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { return getStartTime(dt,it); }
- virtual double getStartTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) = 0;
- virtual double getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) = 0;
- void setTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) { setStartTime(time,dt,it); }
- virtual void setStartTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) = 0;
- virtual void setEndTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) = 0;
- virtual void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) = 0;
- virtual void getValueOnDiscTime(int eltId, int dt, int it, double *value) const throw(INTERP_KERNEL::Exception) = 0;
- virtual ~MEDCouplingTimeDiscretization();
- protected:
- double _time_tolerance;
- DataArrayDouble *_array;
- protected:
- static const double TIME_TOLERANCE_DFT;
- };
-
- class MEDCOUPLING_EXPORT MEDCouplingNoTimeLabel : public MEDCouplingTimeDiscretization
- {
- public:
- MEDCouplingNoTimeLabel();
- MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy);
- TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
- bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
- MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
- void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) { }
- void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *getArrayOnTime(double time) const throw(INTERP_KERNEL::Exception);
- bool isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
- bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
- double getStartTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception);
- double getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception);
- void setStartTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception);
- void setEndTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception);
- void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
- void getValueOnDiscTime(int eltId, int dt, int it, double *value) const throw(INTERP_KERNEL::Exception);
- public:
- static const TypeOfTimeDiscretization DISCRETIZATION=NO_TIME;
- private:
- static const char EXCEPTION_MSG[];
- };
-
- class MEDCOUPLING_EXPORT MEDCouplingWithTimeStep : public MEDCouplingTimeDiscretization
- {
- protected:
- MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy);
- public:
- MEDCouplingWithTimeStep();
- TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
- bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
- void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
- void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
- void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
- MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
- void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
- void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
- void setStartTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) { _time=time; _dt=dt; _it=it; }
- void setEndTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) { _time=time; _dt=dt; _it=it; }
- double getStartTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_dt; it=_it; return _time; }
- double getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_dt; it=_it; return _time; }
- DataArrayDouble *getArrayOnTime(double time) const throw(INTERP_KERNEL::Exception);
- void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
- void getValueOnDiscTime(int eltId, int dt, int it, double *value) const throw(INTERP_KERNEL::Exception);
- public:
- static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME;
- private:
- static const char EXCEPTION_MSG[];
- protected:
- double _time;
- int _dt;
- int _it;
- };
-
- class MEDCOUPLING_EXPORT MEDCouplingTwoTimeSteps : public MEDCouplingTimeDiscretization
- {
- protected:
- MEDCouplingTwoTimeSteps();
- ~MEDCouplingTwoTimeSteps();
- public:
- void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
- void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
- void getArrays(std::vector<DataArrayDouble *>& arrays) const;
- DataArrayDouble *getEndArray() const { return _end_array; }
- void setStartTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) { _start_time=time; _start_dt=dt; _start_it=it; }
- void setEndTime(double time, int dt, int it) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_dt=dt; _end_it=it; }
- double getStartTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_start_dt; it=_start_it; return _start_time; }
- double getEndTime(int& dt, int& it) const throw(INTERP_KERNEL::Exception) { dt=_end_dt; it=_end_it; return _end_time; }
- void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
- void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
- protected:
- double _start_time;
- double _end_time;
- int _start_dt;
- int _end_dt;
- int _start_it;
- int _end_it;
- DataArrayDouble *_end_array;
- };
-
- class MEDCOUPLING_EXPORT MEDCouplingLinearTime : public MEDCouplingTwoTimeSteps
- {
- public:
- TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
- static const TypeOfTimeDiscretization DISCRETIZATION=LINEAR_TIME;
- };
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#include "MEDCouplingTimeLabel.hxx"
-
-using namespace ParaMEDMEM;
-
-unsigned int TimeLabel::GLOBAL_TIME=0;
-
-TimeLabel::TimeLabel():_time(GLOBAL_TIME++)
-{
-}
-
-TimeLabel::~TimeLabel()
-{
-}
-
- TimeLabel& TimeLabel::operator=(const TimeLabel& other)
-{
- _time=GLOBAL_TIME++;
- return *this;
-}
-
-void TimeLabel::declareAsNew()
-{
- _time=GLOBAL_TIME++;
-}
-
-void TimeLabel::updateTimeWith(const TimeLabel& other)
-{
- if(_time<other._time)
- _time=other._time;
-}
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __PARAMEDMEM_TIMELABEL_HXX__
-#define __PARAMEDMEM_TIMELABEL_HXX__
-
-#include "MEDCoupling.hxx"
-
-namespace ParaMEDMEM
-{
- /*!
- * Class representing a label of time of the lastely modified part of this.
- * More _time is high more the object has been modified recently.
- */
- class MEDCOUPLING_EXPORT TimeLabel
- {
- public:
- TimeLabel& operator=(const TimeLabel& other);
- //! This method should be called when write access has been done on this.
- void declareAsNew();
- //! This method should be called on high level classes as Field or Mesh to take into acount modifications done in aggragates objects.
- virtual void updateTime() = 0;
- protected:
- TimeLabel();
- virtual ~TimeLabel();
- void updateTimeWith(const TimeLabel& other);
- private:
- static unsigned int GLOBAL_TIME;
- unsigned int _time;
- };
-}
-
-#endif
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#include "MEDCouplingUMeshDesc.hxx"
-#include "CellModel.hxx"
-#include "MEDCouplingMemArray.hxx"
-
-#include <limits>
-
-using namespace ParaMEDMEM;
-
-MEDCouplingUMeshDesc::MEDCouplingUMeshDesc():_mesh_dim(-1),_desc_connec(0),_desc_connec_index(0),
- _nodal_connec_face(0),_nodal_connec_face_index(0)
-{
-}
-
-MEDCouplingUMeshDesc::~MEDCouplingUMeshDesc()
-{
- if(_desc_connec)
- _desc_connec->decrRef();
- if(_desc_connec_index)
- _desc_connec_index->decrRef();
- if(_nodal_connec_face)
- _nodal_connec_face->decrRef();
- if(_nodal_connec_face_index)
- _nodal_connec_face_index->decrRef();
-}
-
-MEDCouplingUMeshDesc *MEDCouplingUMeshDesc::New()
-{
- return new MEDCouplingUMeshDesc;
-}
-
-MEDCouplingUMeshDesc *MEDCouplingUMeshDesc::New(const char *meshName, int meshDim)
-{
- MEDCouplingUMeshDesc *ret=new MEDCouplingUMeshDesc;
- ret->setName(meshName);
- ret->setMeshDimension(meshDim);
- return ret;
-}
-
-void MEDCouplingUMeshDesc::checkCoherency() const throw(INTERP_KERNEL::Exception)
-{
- for(std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iter=_types.begin();iter!=_types.end();iter++)
- {
- if(INTERP_KERNEL::CellModel::getCellModel(*iter).getDimension()!=_mesh_dim)
- {
- std::ostringstream message;
- message << "MeshDesc invalid because dimension is " << _mesh_dim << " and there is presence of cell(s) with type " << (*iter);
- throw INTERP_KERNEL::Exception(message.str().c_str());
- }
- }
-}
-
-void MEDCouplingUMeshDesc::setMeshDimension(unsigned meshDim)
-{
- _mesh_dim=meshDim;
- declareAsNew();
-}
-
-int MEDCouplingUMeshDesc::getNumberOfCells() const
-{
- if(_desc_connec_index)
- return _desc_connec_index->getNumberOfTuples()-1;
- else
- throw INTERP_KERNEL::Exception("Unable to get number of cells because no connectivity specified !");
-}
-
-int MEDCouplingUMeshDesc::getNumberOfFaces() const
-{
- if(_nodal_connec_face_index)
- return _nodal_connec_face_index->getNumberOfTuples()-1;
- else
- throw INTERP_KERNEL::Exception("Unable to get number of faces because no connectivity specified !");
-}
-
-int MEDCouplingUMeshDesc::getCellMeshLength() const
-{
- return _desc_connec->getNbOfElems();
-}
-
-int MEDCouplingUMeshDesc::getFaceMeshLength() const
-{
- return _nodal_connec_face->getNbOfElems();
-}
-
-void MEDCouplingUMeshDesc::setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx)
-{
- DataArrayInt::setArrayIn(descConn,_desc_connec);
- DataArrayInt::setArrayIn(descConnIndex,_desc_connec_index);
- DataArrayInt::setArrayIn(nodalFaceConn,_nodal_connec_face);
- DataArrayInt::setArrayIn(nodalFaceConnIndx,_nodal_connec_face_index);
- computeTypes();
-}
-
-void MEDCouplingUMeshDesc::getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
-{
- MEDCouplingPointSet::getTinySerializationInformation(tinyInfo,littleStrings);
- tinyInfo.push_back(getMeshDimension());
- tinyInfo.push_back(getNumberOfNodes());
- tinyInfo.push_back(getNumberOfCells());
- tinyInfo.push_back(getCellMeshLength());
- tinyInfo.push_back(getNumberOfFaces());
- tinyInfo.push_back(getFaceMeshLength());
-}
-
-void MEDCouplingUMeshDesc::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings)
-{
- std::vector<int> tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end());
- MEDCouplingPointSet::resizeForUnserialization(tinyInfoTmp,a1,a2,littleStrings);
- a1->alloc(tinyInfo[5]+tinyInfo[4]+1+tinyInfo[7]+tinyInfo[6]+1,1);
-}
-
-void MEDCouplingUMeshDesc::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
-{
- MEDCouplingPointSet::serialize(a1,a2);
- //
- a1=DataArrayInt::New();
- a1->alloc(getCellMeshLength()+getNumberOfCells()+1+getFaceMeshLength()+getNumberOfFaces()+1,1);
- int *ptA1=a1->getPointer();
- const int *descConn=_desc_connec->getConstPointer();
- const int *descConnIndex=_desc_connec_index->getConstPointer();
- const int *faceConn=_nodal_connec_face->getConstPointer();
- const int *faceConnIndex=_nodal_connec_face_index->getConstPointer();
- ptA1=std::copy(descConn,descConn+getCellMeshLength(),ptA1);
- ptA1=std::copy(descConnIndex,descConnIndex+getNumberOfCells()+1,ptA1);
- ptA1=std::copy(faceConn,faceConn+getFaceMeshLength(),ptA1);
- std::copy(faceConnIndex,faceConnIndex+getNumberOfFaces()+1,ptA1);
-}
-
-void MEDCouplingUMeshDesc::unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector<std::string>& littleStrings)
-{
- std::vector<int> tinyInfoTmp(tinyInfo.begin()+1,tinyInfo.end());
- MEDCouplingPointSet::unserialization(tinyInfoTmp,a1,a2,littleStrings);
- //
- const int *recvBuffer=a1->getConstPointer();
- DataArrayInt *descConn=DataArrayInt::New();
- descConn->alloc(tinyInfo[5],1);
- std::copy(recvBuffer,recvBuffer+tinyInfo[5],descConn->getPointer());
- DataArrayInt *descConnIndex=DataArrayInt::New();
- descConnIndex->alloc(tinyInfo[4]+1,1);
- std::copy(recvBuffer+tinyInfo[5],recvBuffer+tinyInfo[5]+tinyInfo[4]+1,descConnIndex->getPointer());
- DataArrayInt *faceConn=DataArrayInt::New();
- faceConn->alloc(tinyInfo[7],1);
- std::copy(recvBuffer+tinyInfo[5]+tinyInfo[4]+1,recvBuffer+tinyInfo[5]+tinyInfo[4]+1+tinyInfo[7],faceConn->getPointer());
- DataArrayInt *faceConnIndex=DataArrayInt::New();
- faceConnIndex->alloc(tinyInfo[6]+1,1);
- std::copy(recvBuffer+tinyInfo[5]+tinyInfo[4]+1+tinyInfo[7],
- recvBuffer+tinyInfo[5]+tinyInfo[5]+1+tinyInfo[7]+tinyInfo[6]+1,faceConnIndex->getPointer());
- setConnectivity(descConn,descConnIndex,faceConn,faceConnIndex);
- descConn->decrRef();
- descConnIndex->decrRef();
- faceConn->decrRef();
- faceConnIndex->decrRef();
- setMeshDimension(tinyInfo[2]);
-}
-
-void MEDCouplingUMeshDesc::giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems)
-{
- int dim=getSpaceDimension();
- double* elem_bb=new double[2*dim];
- const int* conn = _desc_connec->getConstPointer();
- const int* conn_index= _desc_connec_index->getConstPointer();
- const int* face = _nodal_connec_face->getConstPointer();
- const int* face_index= _nodal_connec_face_index->getConstPointer();
- const double* coords = getCoords()->getConstPointer();
- int nbOfCells=getNumberOfCells();
- for ( int ielem=0; ielem<nbOfCells;ielem++ )
- {
- for (int i=0; i<dim; i++)
- {
- elem_bb[i*2]=std::numeric_limits<double>::max();
- elem_bb[i*2+1]=-std::numeric_limits<double>::max();
- }
-
- for (int jface=conn_index[ielem]+1; jface<conn_index[ielem+1]; jface++)//+1 due to offset of cell type.
- {
- int iface=conn[jface];
- for(int inode=face_index[iface]+1;inode<face_index[iface+1];inode++)
- {
- int node=face[inode];
- for (int idim=0; idim<dim; idim++)
- {
- if ( coords[node*dim+idim] < elem_bb[idim*2] )
- {
- elem_bb[idim*2] = coords[node*dim+idim] ;
- }
- if ( coords[node*dim+idim] > elem_bb[idim*2+1] )
- {
- elem_bb[idim*2+1] = coords[node*dim+idim] ;
- }
- }
- }
- }
- if (intersectsBoundingBox(elem_bb, bbox, dim, eps))
- {
- elems.push_back(ielem);
- }
- }
- delete [] elem_bb;
-}
-
-MEDCouplingPointSet *MEDCouplingUMeshDesc::buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const
-{
- //not implemented yet.
- return 0;
-}
-
-MEDCouplingPointSet *MEDCouplingUMeshDesc::buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const
-{
- //not implemented yet
- return 0;
-}
-
-void MEDCouplingUMeshDesc::renumberConnectivity(const int *newNodeNumbers)
-{
-}
-
-MEDCouplingFieldDouble *MEDCouplingUMeshDesc::getMeasureField() const
-{
- //not implemented yet.
- return 0;
-}
-
-DataArrayInt *MEDCouplingUMeshDesc::zipCoordsTraducer()
-{
- //not implemented yet.
- return 0;
-}
-
-void MEDCouplingUMeshDesc::computeTypes()
-{
- if(_desc_connec && _desc_connec_index)
- {
- _types.clear();
- const int *conn=_desc_connec->getConstPointer();
- const int *connIndex=_desc_connec_index->getConstPointer();
- int nbOfElem=_desc_connec_index->getNbOfElems()-1;
- for(const int *pt=connIndex;pt!=connIndex+nbOfElem;pt++)
- _types.insert((INTERP_KERNEL::NormalizedCellType)conn[*pt]);
- }
-}
-
-void MEDCouplingUMeshDesc::checkFullyDefined() const throw(INTERP_KERNEL::Exception)
-{
- if(!_desc_connec || !_desc_connec_index || !_nodal_connec_face || !_nodal_connec_face_index || !_coords)
- throw INTERP_KERNEL::Exception("full connectivity and coordinates not set in unstructured mesh.");
-}
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __PARAMEDMEM_MEDCOUPLINGUMESHDESC_HXX__
-#define __PARAMEDMEM_MEDCOUPLINGUMESHDESC_HXX__
-
-#include "MEDCouplingPointSet.hxx"
-#include "MEDCoupling.hxx"
-#include "NormalizedUnstructuredMesh.hxx"
-
-#include <set>
-
-namespace ParaMEDMEM
-{
- class MEDCOUPLING_EXPORT MEDCouplingUMeshDesc : public MEDCouplingPointSet
- {
- public:
- static MEDCouplingUMeshDesc *New();
- static MEDCouplingUMeshDesc *New(const char *meshName, int meshDim);
- void checkCoherency() const throw(INTERP_KERNEL::Exception);
- void setMeshDimension(unsigned meshDim);
- int getNumberOfCells() const;
- int getNumberOfFaces() const;
- int getCellMeshLength() const;
- int getFaceMeshLength() const;
- int getMeshDimension() const { return _mesh_dim; }
- MEDCouplingMeshType getType() const { return UNSTRUCTURED_DESC; }
- void setConnectivity(DataArrayInt *descConn, DataArrayInt *descConnIndex, DataArrayInt *nodalFaceConn, DataArrayInt *nodalFaceConnIndx);
- //tools to overload
- void getTinySerializationInformation(std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const;
- void resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings);
- void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const;
- void unserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2,
- const std::vector<std::string>& littleStrings);
- void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
- MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const;
- MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const;
- void renumberConnectivity(const int *newNodeNumbers);
- MEDCouplingFieldDouble *getMeasureField() const;
- DataArrayInt *zipCoordsTraducer();
- private:
- MEDCouplingUMeshDesc();
- ~MEDCouplingUMeshDesc();
- void computeTypes();
- void checkFullyDefined() const throw(INTERP_KERNEL::Exception);
- private:
- unsigned _mesh_dim;
- DataArrayInt *_desc_connec;
- DataArrayInt *_desc_connec_index;
- DataArrayInt *_nodal_connec_face;
- DataArrayInt *_nodal_connec_face_index;
- std::set<INTERP_KERNEL::NormalizedCellType> _types;
- };
-}
-
-#endif
+++ /dev/null
-from libMEDCoupling_Swig import *
-import unittest
-
-class MEDCouplingBasicsTest(unittest.TestCase):
- def testMesh(self):
- tab4=[1, 2, 8, 7, 2, 3, 9, 8, 3,
- 4, 10, 9, 4, 5, 11, 10, 5,
- 0, 6, 11, 0, 1, 7, 6 ]
- nbOfNodes=12
- nbOfCells=6
- coords=[ 0.024155, 0.04183768725682622, -0.305, 0.04831000000000001, -1.015761910347357e-17,
- -0.305, 0.09662000000000001, -1.832979297858306e-18, -0.305, 0.120775, 0.04183768725682623,
- -0.305, 0.09662000000000001, 0.08367537451365245, -0.305, 0.04831000000000001, 0.08367537451365246,
- -0.305, 0.024155, 0.04183768725682622, -0.2863, 0.04831000000000001, -1.015761910347357e-17, -0.2863,
- 0.09662000000000001, -1.832979297858306e-18, -0.2863, 0.120775, 0.04183768725682623, -0.2863, 0.09662000000000001,
- 0.08367537451365245, -0.2863, 0.04831000000000001, 0.08367537451365246, -0.2863 ]
- mesh=MEDCouplingUMesh.New()
- mesh.setMeshDimension(2)
- mesh.allocateCells(8);
- mesh.setName("mesh1")
- self.failUnless(mesh.getName()=="mesh1")
- for i in range(nbOfCells):
- mesh.insertNextCell(NORM_QUAD4,4,tab4[4*i:4*(i+1)]);
- pass
- mesh.finishInsertingCells()
- self.failUnless(mesh.getNumberOfCells()==nbOfCells)
- self.failUnless(mesh.getNodalConnectivity().getNbOfElems()==30)
- self.failUnless(mesh.getNodalConnectivityIndex().getNbOfElems()==nbOfCells+1)
- myCoords=DataArrayDouble.New()
- myCoords.setValues(coords,nbOfNodes,3);
- self.failUnless(myCoords.getIJ(3,2)==-0.305)
- mesh.setCoords(myCoords);
- mesh.checkCoherency();
- self.failUnless(mesh.getAllTypes()==[4])
- myFalseConn=DataArrayInt.New()
- myFalseConn.setValues(tab4,6,4)
- self.failUnless(myFalseConn.getIJ(1,1)==3)
- #
- field=MEDCouplingFieldDouble.New(ON_CELLS)
- field.setMesh(mesh)
- field.setNature(Integral)
- myCoords=DataArrayDouble.New()
- sampleTab=[]
- for i in range(nbOfCells*9):
- sampleTab.append(float(i))
- myCoords.setValues(sampleTab,nbOfCells,9);
- field.setArray(myCoords)
- self.failUnless(3==mesh.getSpaceDimension())
- field.checkCoherency()
- mesh2=mesh.clone(False)
- mesh3=mesh.clone(True)
- mesh3=0
- mesh2=0
- ## deep full recursively copy of field -> both field and mesh underneath copied
- field2=field.clone(True)
- field2.setMesh(field.getMesh().clone(True))
- pass
- def setUp(self):
- pass
- pass
-
-unittest.main()
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-
-static PyObject* convertMesh(ParaMEDMEM::MEDCouplingMesh* mesh, int owner)
-{
- PyObject *ret;
- if(dynamic_cast<ParaMEDMEM::MEDCouplingUMesh *>(mesh))
- ret=SWIG_NewPointerObj((void*)mesh,SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh,owner);
- return ret;
-}
-
-static PyObject *convertIntArrToPyList(const int *ptr, int size)
-{
- PyObject *ret=PyList_New(size);
- for(int i=0;i<size;i++)
- PyList_SetItem(ret,i,PyInt_FromLong(ptr[i]));
- return ret;
-}
-
-static int *convertPyToNewIntArr(PyObject *pyLi, int size)
-{
- if(PyList_Check(pyLi))
- {
- int *tmp=new int[size];
- for(int i=0;i<size;i++)
- {
- PyObject *o=PyList_GetItem(pyLi,i);
- if(PyInt_Check(o))
- {
- int val=(int)PyInt_AS_LONG(o);
- tmp[i]=val;
- }
- else
- {
- PyErr_SetString(PyExc_TypeError,"list must contain integers only");
- return NULL;
- }
- }
- return tmp;
- }
- else
- {
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr : not a list");
- return 0;
- }
-}
-
-static int *convertPyToNewIntArr2(PyObject *pyLi)
-{
- if(PyList_Check(pyLi))
- {
- int size=PyList_Size(pyLi);
- int *tmp=new int[size];
- for(int i=0;i<size;i++)
- {
- PyObject *o=PyList_GetItem(pyLi,i);
- if(PyInt_Check(o))
- {
- int val=(int)PyInt_AS_LONG(o);
- tmp[i]=val;
- }
- else
- {
- PyErr_SetString(PyExc_TypeError,"list must contain integers only");
- return NULL;
- }
- }
- return tmp;
- }
- else
- {
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr : not a list");
- return 0;
- }
-}
-
-static PyObject *convertDblArrToPyList(const double *ptr, int size)
-{
- PyObject *ret=PyList_New(size);
- for(int i=0;i<size;i++)
- PyList_SetItem(ret,i,PyFloat_FromDouble(ptr[i]));
- return ret;
-}
-
-static double *convertPyToNewDblArr2(PyObject *pyLi)
-{
- if(PyList_Check(pyLi))
- {
- int size=PyList_Size(pyLi);
- double *tmp=new double[size];
- for(int i=0;i<size;i++)
- {
- PyObject *o=PyList_GetItem(pyLi,i);
- if(PyFloat_Check(o))
- {
- double val=PyFloat_AS_DOUBLE(o);
- tmp[i]=val;
- }
- else
- {
- PyErr_SetString(PyExc_TypeError,"list must contain floats only");
- return NULL;
- }
- }
- return tmp;
- }
- else
- {
- PyErr_SetString(PyExc_TypeError,"convertPyToNewIntArr : not a list");
- return 0;
- }
-}
+++ /dev/null
-# MED MEDMEM_SWIG : binding of C++ implementation and Python
-#
-# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-#
-# 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.
-#
-# 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
-#
-
-include $(top_srcdir)/adm_local/unix/make_common_starter.am
-
-lib_LTLIBRARIES = _libMEDCoupling_Swig.la
-
-salomeinclude_HEADERS = \
- libMEDCoupling_Swig.i MEDCouplingTypemaps.i
-
-SWIG_DEF = libMEDCoupling_Swig.i MEDCouplingTypemaps.i
-
-SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL/Bases
-
-dist__libMEDCoupling_Swig_la_SOURCES = libMEDCoupling_Swig.i MEDCouplingTypemaps.i
-nodist__libMEDCoupling_Swig_la_SOURCES = libMEDCoupling_Swig_wrap.cxx
-libMEDCoupling_Swig.py: libMEDCoupling_Swig_wrap.cxx
-
-libMEDCoupling_Swig_wrap.cxx: $(SWIG_DEF)
- $(SWIG) $(SWIG_FLAGS) -o $@ $<
-
-_libMEDCoupling_Swig_la_CPPFLAGS = $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) $(PYTHON_INCLUDES) \
- $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
- -I$(srcdir)/../MEDCoupling -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases
-
-_libMEDCoupling_Swig_la_LDFLAGS = -module $(MED2_LIBS) $(HDF5_LIBS) $(PYTHON_LIBS) $(MPI_LIBS) \
- ../MEDCoupling/libmedcoupling.la ../INTERP_KERNEL/libinterpkernel.la
-
-CLEANFILES = libMEDCoupling_Swig_wrap.cxx libMEDCoupling_Swig.py
-
-nodist_salomescript_DATA= libMEDCoupling_Swig.py
-
-dist_salomescript_DATA= MEDCouplingBasicsTest.py
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-%module libMEDCoupling_Swig
-
-#define MEDCOUPLING_EXPORT
-
-%{
-#include "MEDCouplingMemArray.hxx"
-#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingField.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-#include "MEDCouplingTypemaps.i"
-
-using namespace ParaMEDMEM;
-using namespace INTERP_KERNEL;
-%}
-
-%typemap(out) ParaMEDMEM::MEDCouplingMesh*
-{
- $result=convertMesh($1,$owner);
-}
-
-%newobject ParaMEDMEM::DataArrayDouble::New;
-%newobject ParaMEDMEM::DataArrayInt::New;
-%newobject ParaMEDMEM::MEDCouplingUMesh::New;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::New;
-%newobject ParaMEDMEM::MEDCouplingUMesh::clone;
-%newobject ParaMEDMEM::DataArrayDouble::deepCopy;
-%newobject ParaMEDMEM::DataArrayDouble::performCpy;
-%newobject ParaMEDMEM::DataArrayInt::deepCopy;
-%newobject ParaMEDMEM::DataArrayInt::performCpy;
-%newobject ParaMEDMEM::MEDCouplingFieldDouble::clone;
-%newobject ParaMEDMEM::MEDCouplingUMesh::buildPartOfMySelf;
-%newobject ParaMEDMEM::MEDCouplingUMesh::zipCoordsTraducer;
-%feature("unref") DataArrayDouble "$this->decrRef();"
-%feature("unref") MEDCouplingUMesh "$this->decrRef();"
-%feature("unref") DataArrayInt "$this->decrRef();"
-%feature("unref") MEDCouplingFieldDouble "$this->decrRef();"
-
-%ignore ParaMEDMEM::TimeLabel::operator=;
-%ignore ParaMEDMEM::MemArray::operator=;
-%ignore ParaMEDMEM::MemArray::operator[];
-
-%nodefaultctor;
-%include "MEDCouplingTimeLabel.hxx"
-%include "MEDCouplingRefCountObject.hxx"
-%include "MEDCouplingMesh.hxx"
-%include "MEDCouplingPointSet.hxx"
-%include "MEDCouplingMemArray.hxx"
-%include "MEDCouplingMesh.hxx"
-%include "NormalizedUnstructuredMesh.hxx"
-%include "MEDCouplingField.hxx"
-%include "MEDCouplingNatureOfField.hxx"
-
-namespace ParaMEDMEM
-{
- class MEDCouplingUMesh : public ParaMEDMEM::MEDCouplingPointSet
- {
- public:
- static MEDCouplingUMesh *New();
- MEDCouplingUMesh *clone(bool recDeepCpy) const;
- void updateTime();
- void checkCoherency() const throw(INTERP_KERNEL::Exception);
- void setMeshDimension(int meshDim);
- void allocateCells(int nbOfCells);
- void setCoords(DataArrayDouble *coords);
- DataArrayDouble *getCoords() const;
- void finishInsertingCells();
- void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true);
- DataArrayInt *getNodalConnectivity() const;
- DataArrayInt *getNodalConnectivityIndex() const;
- INTERP_KERNEL::NormalizedCellType getTypeOfCell(int cellId) const;
- int getNumberOfNodesInCell(int cellId) const;
- bool isStructured() const;
- int getNumberOfCells() const;
- int getNumberOfNodes() const;
- int getSpaceDimension() const;
- int getMeshDimension() const;
- int getMeshLength() const;
- //tools
- void zipCoords();
- DataArrayInt *zipCoordsTraducer();
- void getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const;
- MEDCouplingUMesh *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const;
- %extend {
- void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li)
- {
- int *tmp=convertPyToNewIntArr(li,size);
- self->insertNextCell(type,size,tmp);
- delete [] tmp;
- }
- PyObject *getAllTypes() const
- {
- std::set<INTERP_KERNEL::NormalizedCellType> result=self->getAllTypes();
- std::set<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
- PyObject *res = PyList_New(result.size());
- for (int i=0;iL!=result.end(); i++, iL++)
- PyList_SetItem(res,i,PyInt_FromLong(*iL));
- return res;
- }
- }
- };
-}
-
-%extend ParaMEDMEM::DataArrayDouble
- {
- void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple)
- {
- double *tmp=convertPyToNewDblArr2(li);
- self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
- }
-
- PyObject *getValues()
- {
- const double *vals=self->getPointer();
- return convertDblArrToPyList(vals,self->getNbOfElems());
- }
- };
-
-%extend ParaMEDMEM::DataArrayInt
- {
- void setValues(PyObject *li, int nbOfTuples, int nbOfElsPerTuple)
- {
- int *tmp=convertPyToNewIntArr2(li);
- self->useArray(tmp,true,CPP_DEALLOC,nbOfTuples,nbOfElsPerTuple);
- }
-
- PyObject *getValues()
- {
- const int *vals=self->getPointer();
- return convertIntArrToPyList(vals,self->getNbOfElems());
- }
- };
-
-%include "MEDCouplingField.hxx"
-
-namespace ParaMEDMEM
-{
- class MEDCouplingFieldDouble : public ParaMEDMEM::MEDCouplingField
- {
- public:
- static MEDCouplingFieldDouble *New(TypeOfField type);
- MEDCouplingFieldDouble *clone(bool recDeepCpy) const;
- void checkCoherency() const throw(INTERP_KERNEL::Exception);
- double getIJ(int tupleId, int compoId) const;
- void setArray(DataArrayDouble *array);
- DataArrayDouble *getArray() const { return _array; }
- void applyLin(double a, double b, int compoId);
- int getNumberOfComponents() const;
- int getNumberOfTuples() const throw(INTERP_KERNEL::Exception);
- NatureOfField getNature() const { return _nature; }
- void setNature(NatureOfField nat) throw(INTERP_KERNEL::Exception);
- void updateTime();
- %extend {
- void setValues(PyObject *li)
- {
- if(self->getArray()!=0)
- {
- double *tmp=convertPyToNewDblArr2(li);
- int nbTuples=self->getArray()->getNumberOfTuples();
- int nbOfCompo=self->getArray()->getNumberOfComponents();
- self->getArray()->useArray(tmp,true,CPP_DEALLOC,nbTuples,nbOfCompo);
- }
- else
- PyErr_SetString(PyExc_TypeError,"setValuesCpy : field must contain an array behind");
- }
- }
- };
-}
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#include "GlobalizerMesh.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-#include "CommInterface.hxx"
-
-using namespace std;
-
-namespace ParaMEDMEM
-{
- GlobalizerMesh::GlobalizerMesh(const MPI_Comm *comm, MEDCouplingFieldDouble *localField):_comm(comm),_local_field(localField)
- {
- if(_local_field)
- _local_field->incrRef();
- }
-
- GlobalizerMesh::~GlobalizerMesh()
- {
- if(_local_field)
- _local_field->decrRef();
- }
-
- NatureOfField GlobalizerMesh::getLocalNature() const
- {
- return _local_field->getNature();
- }
-
- GlobalizerMeshWorkingSide::GlobalizerMeshWorkingSide(const MPI_Comm *comm, MEDCouplingFieldDouble *localField,
- const std::string& distantMeth, const std::vector<int>& lazyProcs):GlobalizerMesh(comm,localField),_distant_method(distantMeth),_lazy_procs(lazyProcs)
- {
- }
-
- GlobalizerMeshWorkingSide::~GlobalizerMeshWorkingSide()
- {
- }
-
- const std::vector<int>& GlobalizerMeshWorkingSide::getProcIdsInInteraction() const
- {
- return _lazy_procs;
- }
-
- /*!
- * connected with GlobalizerMeshLazySide::recvFromWorkingSide
- */
- void GlobalizerMeshWorkingSide::sendSumToLazySide(const std::vector< std::vector<int> >& distantLocEltIds, const std::vector< std::vector<double> >& partialSumRelToDistantIds)
- {
- int procId=0;
- CommInterface comm;
- for(vector<int>::const_iterator iter=_lazy_procs.begin();iter!=_lazy_procs.end();iter++,procId++)
- {
- const vector<int>& eltIds=distantLocEltIds[procId];
- const vector<double>& valued=partialSumRelToDistantIds[procId];
- int lgth=eltIds.size();
- comm.send(&lgth,1,MPI_INT,*iter,1114,*_comm);
- comm.send((void *)&eltIds[0],lgth,MPI_INT,*iter,1115,*_comm);
- comm.send((void *)&valued[0],lgth,MPI_DOUBLE,*iter,1116,*_comm);
- }
- }
-
- /*!
- * connected with GlobalizerMeshLazySide::sendToWorkingSide
- */
- void GlobalizerMeshWorkingSide::recvSumFromLazySide(std::vector< std::vector<double> >& globalSumRelToDistantIds)
- {
- int procId=0;
- CommInterface comm;
- MPI_Status status;
- for(vector<int>::const_iterator iter=_lazy_procs.begin();iter!=_lazy_procs.end();iter++,procId++)
- {
- std::vector<double>& vec=globalSumRelToDistantIds[procId];
- comm.recv(&vec[0],vec.size(),MPI_DOUBLE,*iter,1117,*_comm,&status);
- }
- }
-
- GlobalizerMeshLazySide::GlobalizerMeshLazySide(const MPI_Comm *comm, MEDCouplingFieldDouble *localField, const std::vector<int>& computeProcs):GlobalizerMesh(comm,localField),_compute_procs(computeProcs)
- {
- }
-
- GlobalizerMeshLazySide::~GlobalizerMeshLazySide()
- {
- }
-
- /*!
- * connected with GlobalizerMeshWorkingSide::sendSumToLazySide
- */
- void GlobalizerMeshLazySide::recvFromWorkingSide()
- {
- _values_added.resize(_local_field->getNumberOfTuples());
- int procId=0;
- CommInterface comm;
- _ids_per_working_proc.resize(_compute_procs.size());
- MPI_Status status;
- for(vector<int>::const_iterator iter=_compute_procs.begin();iter!=_compute_procs.end();iter++,procId++)
- {
- int lgth;
- comm.recv(&lgth,1,MPI_INT,*iter,1114,*_comm,&status);
- vector<int>& ids=_ids_per_working_proc[procId];
- ids.resize(lgth);
- vector<double> values(lgth);
- comm.recv(&ids[0],lgth,MPI_INT,*iter,1115,*_comm,&status);
- comm.recv(&values[0],lgth,MPI_DOUBLE,*iter,1116,*_comm,&status);
- for(int i=0;i<lgth;i++)
- _values_added[ids[i]]+=values[i];
- }
- }
-
- /*!
- * connected with GlobalizerMeshWorkingSide::recvSumFromLazySide
- */
- void GlobalizerMeshLazySide::sendToWorkingSide()
- {
- int procId=0;
- CommInterface comm;
- for(vector<int>::const_iterator iter=_compute_procs.begin();iter!=_compute_procs.end();iter++,procId++)
- {
- vector<int>& ids=_ids_per_working_proc[procId];
- vector<double> valsToSend(ids.size());
- vector<double>::iterator iter3=valsToSend.begin();
- for(vector<int>::const_iterator iter2=ids.begin();iter2!=ids.end();iter2++,iter3++)
- *iter3=_values_added[*iter2];
- comm.send(&valsToSend[0],ids.size(),MPI_DOUBLE,*iter,1117,*_comm);
- ids.clear();
- }
- _ids_per_working_proc.clear();
- }
-}
-
+++ /dev/null
-// Copyright (C) 2007-2008 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.
-//
-// 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
-//
-#ifndef __GLOBALIZERMESH_HXX__
-#define __GLOBALIZERMESH_HXX__
-
-#include "MEDCouplingNatureOfField.hxx"
-
-#include <mpi.h>
-#include <string>
-#include <vector>
-
-namespace ParaMEDMEM
-{
- class MEDCouplingFieldDouble;
-
- class GlobalizerMesh
- {
- protected:
- GlobalizerMesh(const MPI_Comm *comm, MEDCouplingFieldDouble *localField);
- public:
- NatureOfField getLocalNature() const;
- virtual ~GlobalizerMesh();
- protected:
- const MPI_Comm *_comm;
- MEDCouplingFieldDouble *_local_field;
- };
-
- class GlobalizerMeshWorkingSide : public GlobalizerMesh
- {
- public:
- GlobalizerMeshWorkingSide(const MPI_Comm *comm, MEDCouplingFieldDouble *localField, const std::string& distantMeth, const std::vector<int>& lazyProcs);
- ~GlobalizerMeshWorkingSide();
- //
- const std::vector<int>& getProcIdsInInteraction() const;
- void sendSumToLazySide(const std::vector< std::vector<int> >& distantLocEltIds, const std::vector< std::vector<double> >& partialSumRelToDistantIds);
- void recvSumFromLazySide(std::vector< std::vector<double> >& globalSumRelToDistantIds);
- private:
- std::string _distant_method;
- std::vector<int> _lazy_procs;
- };
-
- class GlobalizerMeshLazySide : public GlobalizerMesh
- {
- public:
- GlobalizerMeshLazySide(const MPI_Comm *comm, MEDCouplingFieldDouble *localField, const std::vector<int>& computeProcs);
- ~GlobalizerMeshLazySide();
- void recvFromWorkingSide();
- void sendToWorkingSide();
- private:
- std::vector<int> _compute_procs;
- std::vector<double> _values_added;
- std::vector< std::vector<int> > _ids_per_working_proc;
- };
-}
-
-#endif
+++ /dev/null
-#include "ParaMEDMEMTest.hxx"
-#include <string>
-#include "CommInterface.hxx"
-#include "ProcessorGroup.hxx"
-#include "MPIProcessorGroup.hxx"
-#include "DEC.hxx"
-#include "IntersectionDEC.hxx"
-#include <set>
-#include <time.h>
-#include "ICoCoTrioField.hxx"
-#include <iostream>
-#include <assert.h>
-
-using namespace std;
-using namespace ParaMEDMEM;
-using namespace ICoCo;
-
-typedef enum {sync_and,sync_or} synctype;
-void synchronize_bool(bool& stop, synctype s)
-{
- int my_stop;
- int my_stop_temp = stop?1:0;
-
- if (s==sync_and)
- MPI_Allreduce(&my_stop_temp,&my_stop,1,MPI_INTEGER,MPI_MIN,MPI_COMM_WORLD);
- else if (s==sync_or)
- MPI_Allreduce(&my_stop_temp,&my_stop,1,MPI_INTEGER,MPI_MAX,MPI_COMM_WORLD);
- stop =(my_stop==1);
-}
-
-void synchronize_dt(double& dt)
-{
- double dttemp=dt;
- MPI_Allreduce(&dttemp,&dt,1,MPI_DOUBLE,MPI_MIN,MPI_COMM_WORLD);
-}
-
-
-void affiche( const TrioField& field)
-{
- cout <<field.getName()<<endl;
- for (int ele=0;ele<field._nb_elems;ele++)
- cout <<ele <<": "<<field._field[ele]<<endl;;
-
-}
-
-void remplit_coord(double* coords)
-{
- coords[0*3+0]=0.;
- coords[0*3+1]=0.;
- coords[0*3+2]=0.;
-
- coords[1*3+0]=1.;
- coords[1*3+1]=0.;
- coords[1*3+2]=0.;
-
-
- coords[2*3+0]=0.;
- coords[2*3+1]=0.;
- coords[2*3+2]=1.;
-
- coords[3*3+0]=1.;
- coords[3*3+1]=0.;
- coords[3*3+2]=1.;
-
- for (int i=4;i<8;i++)
- {
- for (int d=0;d<3;d++)
- coords[i*3+d]=coords[(i-4)*3+d];
- coords[i*3+1]+=1e-5;
- }
-
-}
-
-void init_quad(TrioField& champ_quad)
-{
-
- champ_quad.setName("champ_quad");
- champ_quad._space_dim=3;
- champ_quad._mesh_dim=2;
- champ_quad._nbnodes=8;
- champ_quad._nodes_per_elem=4;
- champ_quad._nb_elems=2;
- champ_quad._itnumber=0;
- champ_quad._time1=0;
- champ_quad._time2=1;
- champ_quad._nb_field_components=1;
-
- champ_quad._coords=new double[champ_quad._nbnodes*champ_quad._space_dim];
- //memcpy(afield._coords,sommets.addr(),champ_quad._nbnodes*champ_quad._space_dim*sizeof(double));
-
- remplit_coord(champ_quad._coords);
-
-
- champ_quad._connectivity=new int[champ_quad._nb_elems*champ_quad._nodes_per_elem];
- champ_quad._connectivity[0*champ_quad._nodes_per_elem+0]=0;
- champ_quad._connectivity[0*champ_quad._nodes_per_elem+1]=1;
- champ_quad._connectivity[0*champ_quad._nodes_per_elem+2]=3;
- champ_quad._connectivity[0*champ_quad._nodes_per_elem+3]=2;
- champ_quad._connectivity[1*champ_quad._nodes_per_elem+0]=4;
- champ_quad._connectivity[1*champ_quad._nodes_per_elem+1]=5;
- champ_quad._connectivity[1*champ_quad._nodes_per_elem+2]=7;
- champ_quad._connectivity[1*champ_quad._nodes_per_elem+3]=6;
-
-
- champ_quad._has_field_ownership=false;
- champ_quad._field=0;
- //champ_quad._field=new double[champ_quad._nb_elems];
- // assert(champ_quad._nb_field_components==1);
-}
-void init_triangle(TrioField& champ_triangle)
-{
-
- champ_triangle.setName("champ_triangle");
- champ_triangle._space_dim=3;
- champ_triangle._mesh_dim=2;
- champ_triangle._nbnodes=8;
- champ_triangle._nodes_per_elem=3;
- champ_triangle._nb_elems=4;
- champ_triangle._itnumber=0;
- champ_triangle._time1=0;
- champ_triangle._time2=1;
- champ_triangle._nb_field_components=1;
-
- champ_triangle._coords=new double[champ_triangle._nbnodes*champ_triangle._space_dim];
- //memcpy(afield._coords,sommets.addr(),champ_triangle._nbnodes*champ_triangle._space_dim*sizeof(double));
- remplit_coord(champ_triangle._coords);
-
- champ_triangle._connectivity=new int[champ_triangle._nb_elems*champ_triangle._nodes_per_elem];
- champ_triangle._connectivity[0*champ_triangle._nodes_per_elem+0]=0;
- champ_triangle._connectivity[0*champ_triangle._nodes_per_elem+1]=1;
- champ_triangle._connectivity[0*champ_triangle._nodes_per_elem+2]=2;
- champ_triangle._connectivity[1*champ_triangle._nodes_per_elem+0]=1;
- champ_triangle._connectivity[1*champ_triangle._nodes_per_elem+1]=3;
- champ_triangle._connectivity[1*champ_triangle._nodes_per_elem+2]=2;
-
- champ_triangle._connectivity[2*champ_triangle._nodes_per_elem+0]=4;
- champ_triangle._connectivity[2*champ_triangle._nodes_per_elem+1]=5;
- champ_triangle._connectivity[2*champ_triangle._nodes_per_elem+2]=7;
- champ_triangle._connectivity[3*champ_triangle._nodes_per_elem+0]=4;
- champ_triangle._connectivity[3*champ_triangle._nodes_per_elem+1]=7;
- champ_triangle._connectivity[3*champ_triangle._nodes_per_elem+2]=6;
-
- champ_triangle._has_field_ownership=false;
- // champ_triangle._field=new double[champ_triangle._nb_elems];
- champ_triangle._field=0;
-}
-
-void ParaMEDMEMTest::testICocoTrio1()
-{
- int size;
- int rank;
- MPI_Comm_size(MPI_COMM_WORLD,&size);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
-
- //the test is meant to run on five processors
- if (size !=2) return ;
-
- CommInterface comm;
- set<int> emetteur_ids;
- set<int> recepteur_ids;
- emetteur_ids.insert(0);
- recepteur_ids.insert(1);
-
- MPIProcessorGroup recepteur_group(comm,recepteur_ids);
- MPIProcessorGroup emetteur_group(comm,emetteur_ids);
-
-
- string cas;
- if (recepteur_group.containsMyRank())
- {
- cas="recepteur";
-
- }
- else
- cas="emetteur";
-
- IntersectionDEC dec_emetteur(emetteur_group, recepteur_group);
-
- TrioField champ_emetteur, champ_recepteur;
-
- init_triangle(champ_emetteur);
- //init_triangle(champ_emetteur);
- init_quad(champ_recepteur);
- //init_emetteur(champ_recepteur);
-
- if (cas=="emetteur")
- {
- champ_emetteur._field=new double[champ_emetteur._nb_elems];
- for (int ele=0;ele<champ_emetteur._nb_elems;ele++)
- champ_emetteur._field[ele]=1;
-
- champ_emetteur._has_field_ownership=true;
- }
-
-
- MPI_Barrier(MPI_COMM_WORLD);
-
- clock_t clock0= clock ();
- int compti=0;
-
- bool init=true; // first time step ??
- bool stop=false;
- //boucle sur les pas de quads
- while (!stop) {
-
- compti++;
- clock_t clocki= clock ();
- cout << compti << " CLOCK " << (clocki-clock0)*1.e-6 << endl;
- for (int non_unif=0;non_unif<2;non_unif++)
- {
- // if (champ_recepteur._field)
- // delete [] champ_recepteur._field;
- champ_recepteur._field=0;
- // champ_recepteur._has_field_ownership=false;
-
-
-
- if (cas=="emetteur")
- if (non_unif)
- champ_emetteur._field[0]=40;
- bool ok=false; // Is the time interval successfully solved ?
-
- // Loop on the time interval tries
- if(1) {
-
-
- if (cas=="emetteur")
- dec_emetteur.attachLocalField((ICoCo::Field*) &champ_emetteur);
- else
- dec_emetteur.attachLocalField((ICoCo::Field*) &champ_recepteur);
-
- dec_emetteur.setNature(ConservativeVolumic);
-
- if(init)
- dec_emetteur.synchronize();
- init=false;
-
- if (cas=="emetteur") {
- dec_emetteur.sendData();
- affiche(champ_emetteur);
- }
- else if (cas=="recepteur") {
- dec_emetteur.recvData();
- affiche(champ_recepteur);
- }
- else
- throw 0;
- }
- stop=true;
- }
-}
-}
+++ /dev/null
-#include "ParaMEDMEMTest.hxx"
-#include <cppunit/TestAssert.h>
-#include "MEDLoader.hxx"
-#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-
-#include <algorithm>
-#include <numeric>
-#include <iostream>
-#include <iterator>
-
-using namespace std;
-using namespace INTERP_KERNEL;
-using namespace ParaMEDMEM;
-
-void ParaMEDMEMTest::testMEDLoaderRead1()
-{
- string medRootDir=getenv("MED_ROOT_DIR");
- medRootDir+="/share/salome/resources/med/pointe_import22.med";
- const char *fileName=medRootDir.c_str();
- vector<string> meshNames=MEDLoader::GetMeshNames(fileName);
- CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
- MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName,meshNames[0].c_str(),0);
- CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(16,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size());
- for(int i=0;i<12;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i));
- for(int i=12;i<14;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(i));
- for(int i=14;i<16;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(i));
- CPPUNIT_ASSERT_EQUAL(90,mesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(701,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+90,0));
- CPPUNIT_ASSERT_EQUAL(711,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+17,0));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
- mesh->decrRef();
- //
- vector<string> families=MEDLoader::GetMeshFamilyNames(fileName,meshNames[0].c_str());
- CPPUNIT_ASSERT_EQUAL(8,(int)families.size());
- CPPUNIT_ASSERT(families[2]=="FAMILLE_ELEMENT_3");
- //
- vector<string> families2;
- families2.push_back(families[2]);
- mesh=MEDLoader::ReadUMeshFromFamilies(fileName,meshNames[0].c_str(),0,families2);
- CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(2,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
- CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(0));
- CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(1));
- CPPUNIT_ASSERT_EQUAL(11,mesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(132,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+11,0));
- CPPUNIT_ASSERT_EQUAL(16,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+3,0));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
- mesh->decrRef();
- //
- vector<string> groups=MEDLoader::GetMeshGroupsNames(fileName,meshNames[0].c_str());
- CPPUNIT_ASSERT_EQUAL(5,(int)groups.size());
- CPPUNIT_ASSERT(groups[0]=="groupe1");
- CPPUNIT_ASSERT(groups[1]=="groupe2");
- CPPUNIT_ASSERT(groups[2]=="groupe3");
- CPPUNIT_ASSERT(groups[3]=="groupe4");
- CPPUNIT_ASSERT(groups[4]=="groupe5");
- vector<string> groups2;
- groups2.push_back(groups[0]);
- mesh=MEDLoader::ReadUMeshFromGroups(fileName,meshNames[0].c_str(),0,groups2);
- CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(7,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
- for(int i=0;i<6;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i));
- CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(6));
- CPPUNIT_ASSERT_EQUAL(36,mesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(254,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+36,0));
- CPPUNIT_ASSERT_EQUAL(141,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+8,0));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
- mesh->decrRef();
- //
- std::vector<std::string> fieldsName=MEDLoader::GetCellFieldNamesOnMesh(fileName,meshNames[0].c_str());
- CPPUNIT_ASSERT_EQUAL(2,(int)fieldsName.size());
- CPPUNIT_ASSERT(fieldsName[0]=="fieldcelldoublescalar");
- CPPUNIT_ASSERT(fieldsName[1]=="fieldcelldoublevector");
- std::vector<std::pair<int,int> > its0=MEDLoader::GetCellFieldIterations(fileName,fieldsName[0].c_str());
- CPPUNIT_ASSERT_EQUAL(1,(int)its0.size());
- CPPUNIT_ASSERT_EQUAL(-1,its0[0].first);
- CPPUNIT_ASSERT_EQUAL(-1,its0[0].second);
- std::vector<std::pair<int,int> > its1=MEDLoader::GetCellFieldIterations(fileName,fieldsName[1].c_str());
- CPPUNIT_ASSERT_EQUAL(1,(int)its1.size());
- CPPUNIT_ASSERT_EQUAL(-1,its1[0].first);
- CPPUNIT_ASSERT_EQUAL(-1,its1[0].second);
- //
- MEDCouplingFieldDouble *field0=MEDLoader::ReadFieldDoubleCell(fileName,meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second);
- field0->checkCoherency();
- CPPUNIT_ASSERT(field0->getName()==fieldsName[0]);
- CPPUNIT_ASSERT_EQUAL(1,field0->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(16,field0->getNumberOfTuples());
- const double expectedValues[16]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,3.,3.,2.,2.};
- double diffValue[16];
- std::transform(field0->getArray()->getPointer(),field0->getArray()->getPointer()+16,expectedValues,diffValue,std::minus<double>());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue,diffValue+16),1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue,diffValue+16),1e-12);
- const MEDCouplingUMesh *constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0->getMesh());
- CPPUNIT_ASSERT(constMesh);
- CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
- for(int i=0;i<12;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
- for(int i=12;i<14;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i));
- for(int i=14;i<16;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i));
- CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0));
- CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
- field0->decrRef();
- //
- MEDCouplingFieldDouble *field1=MEDLoader::ReadFieldDoubleCell(fileName,meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second);
- field1->checkCoherency();
- CPPUNIT_ASSERT(field1->getName()==fieldsName[1]);
- CPPUNIT_ASSERT_EQUAL(3,field1->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(16,field1->getNumberOfTuples());
- const double expectedValues2[48]={1.,0.,1.,1.,0.,1.,1.,0.,1.,2.,1.,0.,2.,1.,0.,2.,1.,0.,3.,0.,1.,3.,0.,1.,3.,0.,1.,4.,1.,0.,4.,1.,0.,4.,1.,0.,6.,1.,1.,6.,0.,0.,5.,0.,0.,5.,1.,1.};
- double diffValue2[48];
- std::transform(field1->getArray()->getPointer(),field1->getArray()->getPointer()+48,expectedValues2,diffValue2,std::minus<double>());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue2,diffValue2+48),1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue2,diffValue2+48),1e-12);
- constMesh=dynamic_cast<const MEDCouplingUMesh *>(field1->getMesh());
- CPPUNIT_ASSERT(constMesh);
- CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
- for(int i=0;i<12;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
- for(int i=12;i<14;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i));
- for(int i=14;i<16;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i));
- CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0));
- CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
- field1->decrRef();
- //fields on nodes
- std::vector<std::string> fieldsNameNode=MEDLoader::GetNodeFieldNamesOnMesh(fileName,meshNames[0].c_str());
- CPPUNIT_ASSERT_EQUAL(2,(int)fieldsNameNode.size());
- CPPUNIT_ASSERT(fieldsNameNode[0]=="fieldnodedouble");
- CPPUNIT_ASSERT(fieldsNameNode[1]=="fieldnodeint");
- std::vector<std::pair<int,int> > its0Node=MEDLoader::GetNodeFieldIterations(fileName,fieldsNameNode[0].c_str());
- CPPUNIT_ASSERT_EQUAL(3,(int)its0Node.size());
- CPPUNIT_ASSERT_EQUAL(1,its0Node[0].first);
- CPPUNIT_ASSERT_EQUAL(-1,its0Node[0].second);
- CPPUNIT_ASSERT_EQUAL(2,its0Node[1].first);
- CPPUNIT_ASSERT_EQUAL(-1,its0Node[1].second);
- CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].first);//strange but like that
- CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].second);
- MEDCouplingFieldDouble *field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName,meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second);
- field0Nodes->checkCoherency();
- CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
- CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(19,field0Nodes->getNumberOfTuples());
- const double expectedValues3[19]={1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.};
- double diffValue3[19];
- std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues3,diffValue3,std::minus<double>());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12);
- constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0Nodes->getMesh());
- CPPUNIT_ASSERT(constMesh);
- field0Nodes->decrRef();
- //
- field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName,meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[1].first,its0Node[1].second);
- field0Nodes->checkCoherency();
- CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
- CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(19,field0Nodes->getNumberOfTuples());
- const double expectedValues4[19]={1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.,7.,7.};
- std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues4,diffValue3,std::minus<double>());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12);
- constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0Nodes->getMesh());
- CPPUNIT_ASSERT(constMesh);
- CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
- for(int i=0;i<12;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
- for(int i=12;i<14;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i));
- for(int i=14;i<16;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i));
- CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0));
- CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
- field0Nodes->decrRef();
- //
- field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName,meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second);
- field0Nodes->checkCoherency();
- CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]);
- CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(19,field0Nodes->getNumberOfTuples());
- const double expectedValues5[19]={1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.};
- std::transform(field0Nodes->getArray()->getPointer(),field0Nodes->getArray()->getPointer()+19,expectedValues5,diffValue3,std::minus<double>());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue3,diffValue3+19),1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue3,diffValue3+19),1e-12);
- constMesh=dynamic_cast<const MEDCouplingUMesh *>(field0Nodes->getMesh());
- CPPUNIT_ASSERT(constMesh);
- CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(3,constMesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(16,constMesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(19,constMesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size());
- for(int i=0;i<12;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i));
- for(int i=12;i<14;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i));
- for(int i=14;i<16;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i));
- CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0));
- CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12);
- field0Nodes->decrRef();
-}
-
-void ParaMEDMEMTest::testMEDLoaderPolygonRead()
-{
- string medRootDir=getenv("MED_ROOT_DIR");
- medRootDir+="/share/salome/resources/med/polygones.med";
- const char *fileName=medRootDir.c_str();
- vector<string> meshNames=MEDLoader::GetMeshNames(fileName);
- CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
- CPPUNIT_ASSERT(meshNames[0]=="Bord");
- MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName,meshNames[0].c_str(),0);
- mesh->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(538,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(579,mesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
- for(int i=0;i<514;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(i));
- for(int i=514;i<538;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(i));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+1737,0),1e-12);
- const double expectedVals1[12]={1.4851585216522212,-0.5,0.,1.4851585216522212,-0.4,0.,1.4851585216522212,-0.3,0., 1.5741585216522211, -0.5, 0. };
- double diffValue1[12];
- std::transform(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+12,expectedVals1,diffValue1,std::minus<double>());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue1,diffValue1+12),1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue1,diffValue1+12),1e-12);
- CPPUNIT_ASSERT_EQUAL(2768,mesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(651050,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+2768,0));
- CPPUNIT_ASSERT_EQUAL(725943,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+539,0));
- mesh->decrRef();
- //
- std::vector<std::string> fieldsName=MEDLoader::GetCellFieldNamesOnMesh(fileName,meshNames[0].c_str());
- CPPUNIT_ASSERT_EQUAL(3,(int)fieldsName.size());
- CPPUNIT_ASSERT(fieldsName[0]=="bord_:_distorsion");
- CPPUNIT_ASSERT(fieldsName[1]=="bord_:_familles");
- CPPUNIT_ASSERT(fieldsName[2]=="bord_:_non-ortho");
- std::vector<std::pair<int,int> > its0=MEDLoader::GetCellFieldIterations(fileName,fieldsName[0].c_str());
- CPPUNIT_ASSERT_EQUAL(1,(int)its0.size());
- MEDCouplingFieldDouble *field=MEDLoader::ReadFieldDoubleCell(fileName,meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second);
- field->checkCoherency();
- CPPUNIT_ASSERT(field->getName()==fieldsName[0]);
- CPPUNIT_ASSERT_EQUAL(1,field->getNumberOfComponents());
- CPPUNIT_ASSERT_EQUAL(538,field->getNumberOfTuples());
- const MEDCouplingUMesh *constMesh=dynamic_cast<const MEDCouplingUMesh *>(field->getMesh());
- CPPUNIT_ASSERT(constMesh);
- CPPUNIT_ASSERT_EQUAL(3,constMesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(2,constMesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(538,constMesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(579,constMesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(2,(int)constMesh->getAllTypes().size());
- for(int i=0;i<514;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,constMesh->getTypeOfCell(i));
- for(int i=514;i<538;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,constMesh->getTypeOfCell(i));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+1737,0),1e-12);
- std::transform(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+12,expectedVals1,diffValue1,std::minus<double>());
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue1,diffValue1+12),1e-12);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::min_element(diffValue1,diffValue1+12),1e-12);
- CPPUNIT_ASSERT_EQUAL(2768,constMesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(651050,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+2768,0));
- CPPUNIT_ASSERT_EQUAL(725943,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+539,0));
- const double *values=field->getArray()->getPointer();
- CPPUNIT_ASSERT_DOUBLES_EQUAL(2.87214203182918,std::accumulate(values,values+538,0.),1e-12);
- field->decrRef();
-}
-
-void ParaMEDMEMTest::testMEDLoaderPolyhedronRead()
-{
- string medRootDir=getenv("MED_ROOT_DIR");
- medRootDir+="/share/salome/resources/med/poly3D.med";
- const char *fileName=medRootDir.c_str();
- vector<string> meshNames=MEDLoader::GetMeshNames(fileName);
- CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
- CPPUNIT_ASSERT(meshNames[0]=="poly3D");
- MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName,meshNames[0].c_str(),0);
- mesh->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(3,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
- CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(0));
- CPPUNIT_ASSERT_EQUAL(NORM_POLYHED,mesh->getTypeOfCell(1));
- CPPUNIT_ASSERT_EQUAL(NORM_POLYHED,mesh->getTypeOfCell(2));
- CPPUNIT_ASSERT_EQUAL(98,mesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(725,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+98,0));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(110.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
- CPPUNIT_ASSERT_EQUAL(155,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+4,0));
- mesh->decrRef();
- //
- mesh=MEDLoader::ReadUMeshFromFile(fileName,meshNames[0].c_str(),-1);
- mesh->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(17,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size());
- for(int i=0;i<6;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(i));
- for(int i=6;i<14;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(i));
- for(int i=14;i<17;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(i));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(110.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12);
- CPPUNIT_ASSERT_EQUAL(83,mesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(619,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+83,0));
- mesh->decrRef();
- //
- vector<string> families=MEDLoader::GetMeshFamilyNames(fileName,meshNames[0].c_str());
- CPPUNIT_ASSERT_EQUAL(4,(int)families.size());
- CPPUNIT_ASSERT(families[0]=="FAMILLE_FACE_POLYGONS3");
- CPPUNIT_ASSERT(families[1]=="FAMILLE_FACE_QUAD41");
- CPPUNIT_ASSERT(families[2]=="FAMILLE_FACE_TRIA32");
- CPPUNIT_ASSERT(families[3]=="FAMILLE_ZERO");
- vector<string> families2;
- families2.push_back(families[0]);
- mesh=MEDLoader::ReadUMeshFromFamilies(fileName,meshNames[0].c_str(),-1,families2);
- mesh->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(3,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(1,(int)mesh->getAllTypes().size());
- for(int i=0;i<3;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(i));
- CPPUNIT_ASSERT_EQUAL(19,mesh->getNodalConnectivity()->getNbOfElems());
- CPPUNIT_ASSERT_EQUAL(117,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+19,0));
- mesh->decrRef();
- //
- mesh=MEDLoader::ReadUMeshFromFamilies(fileName,meshNames[0].c_str(),0,families2);
- CPPUNIT_ASSERT_EQUAL(3,mesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(0,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(3,mesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(0,(int)mesh->getAllTypes().size());
- mesh->decrRef();
-}
-
-void ParaMEDMEMTest::testMEDLoaderWrite1()
-{
- const char meshName[]="MEDLoaderWrite1";
- string tmpRootDir=getenv("TMP");
- string outFileName=tmpRootDir+"/toto22137.med";
- double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
- int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
- mesh->setMeshDimension(2);
- mesh->allocateCells(5);
- mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
- mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
- mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
- mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
- mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
- mesh->finishInsertingCells();
- DataArrayDouble *myCoords=DataArrayDouble::New();
- myCoords->alloc(9,2);
- std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
- mesh->setCoords(myCoords);
- myCoords->decrRef();
- mesh->checkCoherency();
- CPPUNIT_ASSERT_EQUAL(2,mesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(5,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(9,mesh->getNumberOfNodes());
- bool normalThrow=false;
- try
- {
- MEDLoader::writeUMesh(outFileName.c_str(),mesh);
- }
- catch(INTERP_KERNEL::Exception& e)
- {
- normalThrow=true;
- }
- CPPUNIT_ASSERT(normalThrow);
- mesh->setName(meshName);
- MEDLoader::writeUMesh(outFileName.c_str(),mesh);
- mesh->decrRef();
- //
- mesh=MEDLoader::ReadUMeshFromFile(outFileName.c_str(),meshName,0);
- CPPUNIT_ASSERT_EQUAL(2,mesh->getSpaceDimension());
- CPPUNIT_ASSERT_EQUAL(2,mesh->getMeshDimension());
- CPPUNIT_ASSERT_EQUAL(5,mesh->getNumberOfCells());
- CPPUNIT_ASSERT_EQUAL(9,mesh->getNumberOfNodes());
- CPPUNIT_ASSERT_EQUAL(2,(int)mesh->getAllTypes().size());
- for(int i=0;i<2;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(i));
- for(int i=2;i<5;i++)
- CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(i));
- CPPUNIT_ASSERT_DOUBLES_EQUAL(3.6,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+18,0.),1.e-12);
- mesh->decrRef();
-}
-
-void ParaMEDMEMTest::testMEDLoaderPolygonWrite()
-{
- string medRootDir=getenv("MED_ROOT_DIR");
- medRootDir+="/share/salome/resources/med/polygones.med";
- const char *fileName=medRootDir.c_str();
- vector<string> meshNames=MEDLoader::GetMeshNames(fileName);
- CPPUNIT_ASSERT_EQUAL(1,(int)meshNames.size());
- CPPUNIT_ASSERT(meshNames[0]=="Bord");
- MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName,meshNames[0].c_str(),0);
- mesh->checkCoherency();
- string tmpRootDir=getenv("TMP");
- string outFileName=tmpRootDir+"/toto22138.med";
- MEDLoader::writeUMesh(outFileName.c_str(),mesh);
- //
- MEDCouplingUMesh *mesh2=MEDLoader::ReadUMeshFromFile(outFileName.c_str(),meshNames[0].c_str(),0);
- //
- mesh2->decrRef();
- mesh->decrRef();
-}
+++ /dev/null
-#include <time.h>
-#include <sys/times.h>
-#include <sys/time.h>
-#include "ParaMEDMEMTest.hxx"
-#include <cppunit/TestAssert.h>
-
-#include "CommInterface.hxx"
-#include "ProcessorGroup.hxx"
-#include "MPIProcessorGroup.hxx"
-#include "Topology.hxx"
-#include "DEC.hxx"
-#include "MxN_Mapping.hxx"
-#include "IntersectionDEC.hxx"
-#include "ParaMESH.hxx"
-#include "ParaFIELD.hxx"
-#include "ComponentTopology.hxx"
-#include "ICoCoMEDField.hxx"
-#include "MEDLoader.hxx"
-
-#include <string>
-
-// use this define to enable lines, execution of which leads to Segmentation Fault
-#define ENABLE_FAULTS
-
-// use this define to enable CPPUNIT asserts and fails, showing bugs
-#define ENABLE_FORCED_FAILURES
-
-#ifndef CLK_TCK
-#include <unistd.h>
-#define CLK_TCK sysconf(_SC_CLK_TCK);
-#endif
-
-using namespace std;
-using namespace ParaMEDMEM;
-
-void testIntersectionDEC_2D(const string& filename1, const string& meshname1,
- const string& filename2, const string& meshname2,
- int nproc_source, double epsilon, bool tri, bool all);
-void get_time( float *telps, float *tuser, float *tsys, float *tcpu );
-
-int main(int argc, char *argv[])
-{
- string filename1, filename2;
- string meshname1, meshname2;
- int nproc_source=1, rank;
- double epsilon=1.e-6;
- int count=0;
- bool tri=false;
- bool all=false;
-
- MPI_Init(&argc,&argv);
-
- for(int i=1;i<argc;i++){
- if( strcmp(argv[i],"-f1") == 0 ){
- filename1 = argv[++i];
- count++;
- }
- else if( strcmp(argv[i],"-f2") == 0 ){
- filename2 = argv[++i];
- count++;
- }
- else if( strcmp(argv[i],"-m1") == 0 ){
- meshname1 = argv[++i];
- count++;
- }
- else if( strcmp(argv[i],"-m2") == 0 ){
- meshname2 = argv[++i];
- count++;
- }
- else if( strcmp(argv[i],"-ns") == 0 ){
- nproc_source = atoi(argv[++i]);
- }
- else if( strcmp(argv[i],"-eps") == 0 ){
- epsilon = atof(argv[++i]);
- }
- else if( strcmp(argv[i],"-tri") == 0 ){
- tri = true;
- }
- else if( strcmp(argv[i],"-all") == 0 ){
- all = true;
- }
- }
-
- if( count != 4 ){
- cout << "usage test_perf -f1 filename1 -m1 meshname1 -f2 filename2 -m2 meshname2 (-ns nproc_source -eps epsilon -tri -all)" << endl;
- exit(0);
- }
-
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
- testIntersectionDEC_2D(filename1,meshname1,filename2,meshname2,nproc_source,epsilon,tri,all);
-
- MPI_Finalize();
-}
-
-void testIntersectionDEC_2D(const string& filename_xml1, const string& meshname1,
- const string& filename_xml2, const string& meshname2,
- int nproc_source, double epsilon, bool tri, bool all)
-{
- float tcpu, tcpu_u, tcpu_s, telps;
- int size;
- int rank;
- MPI_Comm_size(MPI_COMM_WORLD,&size);
- MPI_Comm_rank(MPI_COMM_WORLD,&rank);
-
- set<int> self_procs;
- set<int> procs_source;
- set<int> procs_target;
-
- for (int i=0; i<nproc_source; i++)
- procs_source.insert(i);
- for (int i=nproc_source; i<size; i++)
- procs_target.insert(i);
- self_procs.insert(rank);
-
- ParaMEDMEM::CommInterface interface;
-
- ParaMEDMEM::ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
- ParaMEDMEM::ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
- ParaMEDMEM::ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
-
- //loading the geometry for the source group
-
- ParaMEDMEM::IntersectionDEC dec (*source_group,*target_group);
- if(tri)
- dec.setIntersectionType(INTERP_KERNEL::Triangulation);
- else
- dec.setIntersectionType(INTERP_KERNEL::Convex);
-
- ParaMEDMEM::MEDCouplingUMesh* mesh;
- ParaMEDMEM::ParaMESH* paramesh;
- ParaMEDMEM::ParaFIELD* parafield;
- ICoCo::Field* icocofield ;
-
- // To remove tmp files from disk
- ParaMEDMEMTest_TmpFilesRemover aRemover;
-
- MPI_Barrier(MPI_COMM_WORLD);
- if (source_group->containsMyRank()){
- string master = filename_xml1;
-
- ostringstream strstream;
- if( nproc_source == 1 )
- strstream <<master<<".med";
- else
- strstream <<master<<rank+1<<".med";
-
- ostringstream meshname ;
- if( nproc_source == 1 )
- meshname<< meshname1;
- else
- meshname<< meshname1<<"_"<< rank+1;
-
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- mesh=MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0);
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- if( rank == 0 )
- cout << "IO : Telapse = " << telps << " TuserCPU = " << tcpu_u << " TsysCPU = " << tcpu_s << " TCPU = " << tcpu << endl;
- mesh->incrRef();
-
- paramesh=new ParaMESH (mesh,*source_group,"source mesh");
-
- ParaMEDMEM::ComponentTopology comptopo;
- parafield = new ParaFIELD(ON_CELLS, NO_TIME, paramesh, comptopo);
-
- int nb_local=mesh->getNumberOfCells();
- double *value=parafield->getField()->getArray()->getPointer();
- for(int ielem=0; ielem<nb_local;ielem++)
- value[ielem]=1.0;
-
- icocofield=new ICoCo::MEDField(paramesh,parafield);
-
- dec.attachLocalField(icocofield);
- }
-
- //loading the geometry for the target group
- if (target_group->containsMyRank()){
- string master= filename_xml2;
- ostringstream strstream;
- if( (size-nproc_source) == 1 )
- strstream << master<<".med";
- else
- strstream << master<<(rank-nproc_source+1)<<".med";
- ostringstream meshname ;
- if( (size-nproc_source) == 1 )
- meshname<< meshname2;
- else
- meshname<< meshname2<<"_"<<rank-nproc_source+1;
-
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- mesh = MEDLoader::ReadUMeshFromFile(strstream.str().c_str(),meshname.str().c_str(),0);
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- mesh->incrRef();
-
- paramesh=new ParaMESH (mesh,*target_group,"target mesh");
- ParaMEDMEM::ComponentTopology comptopo;
- parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo);
-
- int nb_local=mesh->getNumberOfCells();
- double *value=parafield->getField()->getArray()->getPointer();
- for(int ielem=0; ielem<nb_local;ielem++)
- value[ielem]=0.0;
- icocofield=new ICoCo::MEDField(paramesh,parafield);
-
- dec.attachLocalField(icocofield);
- }
-
-
- //attaching a DEC to the source group
- double field_before_int;
- double field_after_int;
-
- if (source_group->containsMyRank()){
- field_before_int = parafield->getVolumeIntegral(0);
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- dec.synchronize();
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- if( rank == 0 )
- cout << "SYNCHRONIZE : Telapse = " << telps << " TuserCPU = " << tcpu_u << " TsysCPU = " << tcpu_s << " TCPU = " << tcpu << endl;
- cout<<"DEC usage"<<endl;
- dec.setForcedRenormalization(false);
- if(all)
- dec.setAllToAllMethod(PointToPoint);
-
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- dec.sendData();
-
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- if( rank == 0 )
- cout << "SEND DATA : Telapse = " << telps << " TuserCPU = " << tcpu_u << " TsysCPU = " << tcpu_s << " TCPU = " << tcpu << endl;
- dec.recvData();
-
- field_after_int = parafield->getVolumeIntegral(0);
-// CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, epsilon);
-
- }
-
- //attaching a DEC to the target group
- if (target_group->containsMyRank()){
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- dec.synchronize();
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- dec.setForcedRenormalization(false);
- if(all)
- dec.setAllToAllMethod(PointToPoint);
-
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- dec.recvData();
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- dec.sendData();
- }
-
- get_time( &telps, &tcpu_u, &tcpu_s, &tcpu );
- if( rank == 0 )
- cout << "RECV DATA : Telapse = " << telps << " TuserCPU = " << tcpu_u << " TsysCPU = " << tcpu_s << " TCPU = " << tcpu << endl;
-
- delete source_group;
- delete target_group;
- delete self_group;
- delete paramesh;
- delete parafield;
- mesh->decrRef() ;
- delete icocofield;
-
- MPI_Barrier(MPI_COMM_WORLD);
- cout << "end of IntersectionDEC_2D test"<<endl;
-}
-
-void get_time( float *telps, float *tuser, float *tsys, float *tcpu )
-{
-
- /* Variables declaration */
- static time_t zsec = 0;
- static long zusec = 0;
- time_t nsec;
- long nusec;
- static clock_t zclock = 0;
- clock_t nclock;
- static clock_t zuser = 0;
- static clock_t zsys = 0;
- clock_t nuser, nsys;
-
- struct timeval tp;
- struct timezone tzp;
- struct tms local;
-
- MPI_Barrier(MPI_COMM_WORLD);
-
- /* Elapsed time reading */
-
- gettimeofday(&tp,&tzp);
- nsec = tp.tv_sec;
- nusec = tp.tv_usec;
- *telps = (float)(nsec-zsec) + (float)(nusec-zusec)/(float)CLOCKS_PER_SEC;
-
- zsec = nsec;
- zusec = nusec;
-
- /* User and system CPU time reading */
-
- times(&local);
- nuser = local.tms_utime;
- nsys = local.tms_stime;
- *tuser = (float)(nuser-zuser) / (float)CLK_TCK;
- *tsys = (float)(nsys-zsys) / (float)CLK_TCK;
-
- zuser = nuser;
- zsys = nsys;
-
- /* CPU time reading */
-
- nclock = clock();
- *tcpu = (float)(nclock-zclock) / (float)CLOCKS_PER_SEC;
- zclock = nclock;
-
-}
-
-