From: admin Date: Tue, 6 Oct 2009 07:45:00 +0000 (+0000) Subject: This commit was generated by cvs2git to create tag 'V1_ParaMEDSPLITTER'. X-Git-Tag: V1_ParaMEDSPLITTER X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=13088168ba1fecb46546a617769cd54bea7f3697;p=tools%2Fmedcoupling.git This commit was generated by cvs2git to create tag 'V1_ParaMEDSPLITTER'. Sprout from BR_ParaMEDSPLITTER 2009-08-13 13:45:18 UTC eap 'Parallel MED splitter' Cherrypick from BR_ParaMEDSPLITTER 2009-10-06 07:44:59 UTC eap '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 --- diff --git a/resources/Mesh3D_11.med b/resources/Mesh3D_11.med deleted file mode 100644 index 5088b55b3..000000000 Binary files a/resources/Mesh3D_11.med and /dev/null differ diff --git a/src/INTERP_KERNEL/InterpolationOptions.cxx b/src/INTERP_KERNEL/InterpolationOptions.cxx deleted file mode 100644 index a23422564..000000000 --- a/src/INTERP_KERNEL/InterpolationOptions.cxx +++ /dev/null @@ -1,25 +0,0 @@ -// 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.; diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx b/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx deleted file mode 100644 index 44854c8ef..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// 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 PlanarIntersectorP1P1 : public PlanarIntersector - { - 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& icellsS, MyMatrix& res); - int getNumberOfRowsOfResMatrix() const; - int getNumberOfColsOfResMatrix() const; - - double intersectGeometryGeneral(const std::vector& targetCoords, const std::vector& sourceCoords) { return asLeaf().intersectGeometryGeneral(targetCoords,sourceCoords); } - protected: - ConcreteP1P1Intersector& asLeaf() { return static_cast(*this); } - }; -} - -#endif diff --git a/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx b/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx deleted file mode 100644 index 66ab5e59d..000000000 --- a/src/INTERP_KERNEL/PlanarIntersectorP1P1.txx +++ /dev/null @@ -1,100 +0,0 @@ -// 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 - PlanarIntersectorP1P1::PlanarIntersectorP1P1(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double precision, double md3DSurf, double medianPlane, - bool doRotate, int orientation, int printLevel): - PlanarIntersector(meshT,meshS,dimCaracteristic,precision,md3DSurf,medianPlane,doRotate,orientation,printLevel) - { - } - - template - int PlanarIntersectorP1P1::getNumberOfRowsOfResMatrix() const - { - return PlanarIntersector::_meshT.getNumberOfNodes(); - } - - template - int PlanarIntersectorP1P1::getNumberOfColsOfResMatrix() const - { - return PlanarIntersector::_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 - void PlanarIntersectorP1P1::intersectCells(ConnType icellT, const std::vector& icellsS, MyMatrix& res) - { - int nbNodesT=PlanarIntersector::_connIndexT[icellT+1]-PlanarIntersector::_connIndexT[icellT]; - int orientation=1; - const ConnType *startOfCellNodeConn=PlanarIntersector::_connectT+OTT::conn2C(PlanarIntersector::_connIndexT[icellT]); - std::vector polygT; - PlanarIntersector::getRealTargetCoordinates(OTT::indFC(icellT),polygT); - for(int nodeIdT=0;nodeIdT::coo2C(startOfCellNodeConn[nodeIdT]); - PlanarIntersector::getRealTargetCoordinatesPermute(OTT::indFC(icellT),nodeIdT,polygT); - std::vector polygDualT(SPACEDIM*2*(nbNodesT-1)); - fillDualCellOfPolyg(&polygT[0],polygT.size()/SPACEDIM,&polygDualT[0]); - typename MyMatrix::value_type& resRow=res[curNodeTInCmode]; - for(typename std::vector::const_iterator iter=icellsS.begin();iter!=icellsS.end();iter++) - { - int iS=*iter; - int nbNodesS=PlanarIntersector::_connIndexS[iS+1]-PlanarIntersector::_connIndexS[iS]; - const ConnType *startOfCellNodeConnS=PlanarIntersector::_connectS+OTT::conn2C(PlanarIntersector::_connIndexS[iS]); - for(int nodeIdS=0;nodeIdS::coo2C(startOfCellNodeConnS[nodeIdS]); - std::vector polygS; - PlanarIntersector::getRealSourceCoordinatesPermute(OTT::indFC(iS),nodeIdS,polygS); - std::vector polygDualS(SPACEDIM*2*(nbNodesS-1)); - fillDualCellOfPolyg(&polygS[0],polygS.size()/SPACEDIM,&polygDualS[0]); - std::vector polygDualTTmp(polygDualT); - if(SPACEDIM==3) - orientation=PlanarIntersector::projectionThis(&polygDualS[0],&polygDualTTmp[0],polygDualS.size()/SPACEDIM,polygDualT.size()/SPACEDIM); - double surf=orientation*intersectGeometryGeneral(polygDualTTmp,polygDualS); - surf=PlanarIntersector::getValueRegardingOption(surf); - if(surf!=0.) - { - typename MyMatrix::value_type::const_iterator iterRes=resRow.find(OTT::indFC(curNodeSInCmode)); - if(iterRes==resRow.end()) - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),surf)); - else - { - double val=(*iterRes).second+surf; - resRow.erase(OTT::indFC(curNodeSInCmode)); - resRow.insert(std::make_pair(OTT::indFC(curNodeSInCmode),val)); - } - } - } - } - } - } -} - -#endif diff --git a/src/MEDCoupling/MEDCoupling.hxx b/src/MEDCoupling/MEDCoupling.hxx deleted file mode 100644 index 5779d27f7..000000000 --- a/src/MEDCoupling/MEDCoupling.hxx +++ /dev/null @@ -1,35 +0,0 @@ -// 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 diff --git a/src/MEDCoupling/MEDCouplingCMesh.cxx b/src/MEDCoupling/MEDCouplingCMesh.cxx deleted file mode 100644 index 33f7214c0..000000000 --- a/src/MEDCoupling/MEDCouplingCMesh.cxx +++ /dev/null @@ -1,182 +0,0 @@ -// 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(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; -} diff --git a/src/MEDCoupling/MEDCouplingCMesh.hxx b/src/MEDCoupling/MEDCouplingCMesh.hxx deleted file mode 100644 index 212535c44..000000000 --- a/src/MEDCoupling/MEDCouplingCMesh.hxx +++ /dev/null @@ -1,59 +0,0 @@ -// 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 diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx deleted file mode 100644 index 6987c1bff..000000000 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.cxx +++ /dev/null @@ -1,182 +0,0 @@ -// 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(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(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; -} diff --git a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx b/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx deleted file mode 100644 index 6061bf20f..000000000 --- a/src/MEDCoupling/MEDCouplingFieldDiscretization.hxx +++ /dev/null @@ -1,85 +0,0 @@ -// 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 diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx deleted file mode 100644 index b907df1f8..000000000 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ /dev/null @@ -1,161 +0,0 @@ -// 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(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(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(); - } -} diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx deleted file mode 100644 index 1865161d6..000000000 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ /dev/null @@ -1,155 +0,0 @@ -// 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 -#include - -namespace ParaMEDMEM -{ - template - 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 MemArray - { - public: - MemArray():_nb_of_elem(-1),_ownership(false),_dealloc(CPP_DEALLOC) { } - MemArray(const MemArray& 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 &operator=(const MemArray& other); - T operator[](int id) const { return _pointer.getConstPointer()[id]; } - T& operator[](int id) { return _pointer.getPointer()[id]; } - bool isEqual(const MemArray& 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 _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 _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 _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 _mem; - }; -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx deleted file mode 100644 index 8d6a8191f..000000000 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ /dev/null @@ -1,159 +0,0 @@ -// 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 -#include - -namespace ParaMEDMEM -{ - template - void MEDCouplingPointer::setInternal(T *pointer) - { - _internal=pointer; - _external=0; - } - - template - void MEDCouplingPointer::setExternal(const T *pointer) - { - _external=pointer; - _internal=0; - } - - template - MemArray::MemArray(const MemArray& 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 - void MemArray::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 - void MemArray::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 - bool MemArray::isEqual(const MemArray& 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 - void MemArray::alloc(int nbOfElements) - { - destroy(); - _nb_of_elem=nbOfElements; - _pointer.setInternal(new T[_nb_of_elem]); - _ownership=true; - _dealloc=CPP_DEALLOC; - } - - template - void MemArray::reAlloc(int newNbOfElements) - { - T *pointer=new T[newNbOfElements]; - std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min(_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 - void MemArray::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 - void MemArray::destroy() - { - if(_ownership) - destroyPointer((T *)_pointer.getConstPointer(),_dealloc); - _pointer.null(); - _ownership=false; - } - - template - MemArray &MemArray::operator=(const MemArray& other) - { - alloc(other._nb_of_elem); - std::copy(other._pointer.getConstPointer(),other._pointer.getConstPointer()+_nb_of_elem,_pointer.getPointer()); - return *this; - } -} - -#endif diff --git a/src/MEDCoupling/MEDCouplingNatureOfField.hxx b/src/MEDCoupling/MEDCouplingNatureOfField.hxx deleted file mode 100644 index baffb734d..000000000 --- a/src/MEDCoupling/MEDCouplingNatureOfField.hxx +++ /dev/null @@ -1,33 +0,0 @@ -// 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 diff --git a/src/MEDCoupling/MEDCouplingPointSet.cxx b/src/MEDCoupling/MEDCouplingPointSet.cxx deleted file mode 100644 index 3a2876ae7..000000000 --- a/src/MEDCoupling/MEDCouplingPointSet.cxx +++ /dev/null @@ -1,323 +0,0 @@ -// 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 -#include -#include - -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::max(); - bbox[idim*2+1]=-std::numeric_limits::max(); - } - const double *coords=_coords->getConstPointer(); - int nbnodes=getNumberOfNodes(); - for (int i=0; i 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; ideclareAsNew(); - 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& tinyInfo, std::vector& littleStrings) const -{ - if(_coords) - { - int spaceDim=getSpaceDimension(); - littleStrings.resize(spaceDim+1); - littleStrings[0]=getName(); - for(int i=0;igetInfoOnComponent(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& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& 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& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) -{ - if(tinyInfo[2]>=0 && tinyInfo[1]>=1) - { - setCoords(a2); - setName(littleStrings[0].c_str()); - for(int i=0;isetInfoOnComponent(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(),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(),1-cosa)); - std::transform(matrix,matrix+9,matrixTmp,matrix,std::plus()); - 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(),sina)); - std::transform(matrix,matrix+9,matrixTmp,matrix,std::plus()); - //rotation matrix computed. - double *coords=_coords->getPointer(); - int nbNodes=getNumberOfNodes(); - double tmp[3]; - for(int i=0; i()); - 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()); - 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]; - } -} diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx deleted file mode 100644 index e79f7b20b..000000000 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ /dev/null @@ -1,72 +0,0 @@ -// 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 - -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& tinyInfo, std::vector& littleStrings) const; - virtual void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings); - virtual void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - virtual void unserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, - const std::vector& littleStrings); - virtual void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& 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 diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.cxx b/src/MEDCoupling/MEDCouplingRefCountObject.cxx deleted file mode 100644 index c9825ed53..000000000 --- a/src/MEDCoupling/MEDCouplingRefCountObject.cxx +++ /dev/null @@ -1,46 +0,0 @@ -// 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() -{ -} diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.hxx b/src/MEDCoupling/MEDCouplingRefCountObject.hxx deleted file mode 100644 index d6ec6da01..000000000 --- a/src/MEDCoupling/MEDCouplingRefCountObject.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// 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 diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx deleted file mode 100644 index 6c75e607c..000000000 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.cxx +++ /dev/null @@ -1,403 +0,0 @@ -// 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 - -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& 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& tinyInfoI, std::vector& 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& tinyInfoI, const std::vector& tinyInfoD, const std::vector& tinyInfoS) -{ - _time_tolerance=tinyInfoD[0]; - int nbOfCompo=_array->getNumberOfComponents(); - for(int i=0;isetInfoOnComponent(i,tinyInfoS[i].c_str()); -} - -void MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(std::vector& tinyInfo) const -{ - tinyInfo.push_back(_time_tolerance); -} - -void MEDCouplingTimeDiscretization::getTinySerializationStrInformation(std::vector& tinyInfo) const -{ - int nbOfCompo=_array->getNumberOfComponents(); - for(int i=0;igetInfoOnComponent(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& 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& 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(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& tinyInfo) const -{ - MEDCouplingTimeDiscretization::getTinySerializationIntInformation(tinyInfo); - tinyInfo.push_back(_dt); - tinyInfo.push_back(_it); -} - -void MEDCouplingWithTimeStep::getTinySerializationDbleInformation(std::vector& tinyInfo) const -{ - MEDCouplingTimeDiscretization::getTinySerializationDbleInformation(tinyInfo); - tinyInfo.push_back(_time); -} - -void MEDCouplingWithTimeStep::finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& 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(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& arrays) const -{ - arrays.resize(2); - arrays[0]=_array; - arrays[1]=_end_array; -} - -void MEDCouplingTwoTimeSteps::resizeForUnserialization(const std::vector& tinyInfoI, std::vector& 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& tinyInfoI, const std::vector& tinyInfoD, const std::vector& 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]; -} diff --git a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx b/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx deleted file mode 100644 index 6764689ff..000000000 --- a/src/MEDCoupling/MEDCouplingTimeDiscretization.hxx +++ /dev/null @@ -1,167 +0,0 @@ -// 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 - -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& tinyInfo) const; - virtual void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - virtual void getTinySerializationStrInformation(std::vector& tinyInfo) const; - virtual void resizeForUnserialization(const std::vector& tinyInfoI, std::vector& arrays); - virtual void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& 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& 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& 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& tinyInfo) const; - void getTinySerializationDbleInformation(std::vector& tinyInfo) const; - void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& 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& 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& tinyInfoI, std::vector& arrays); - void finishUnserialization(const std::vector& tinyInfoI, const std::vector& tinyInfoD, const std::vector& 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 diff --git a/src/MEDCoupling/MEDCouplingTimeLabel.cxx b/src/MEDCoupling/MEDCouplingTimeLabel.cxx deleted file mode 100644 index 52e33f528..000000000 --- a/src/MEDCoupling/MEDCouplingTimeLabel.cxx +++ /dev/null @@ -1,48 +0,0 @@ -// 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 - -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::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& tinyInfo, std::vector& 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& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) -{ - std::vector 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& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings) -{ - std::vector 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& 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::max(); - elem_bb[i*2+1]=-std::numeric_limits::max(); - } - - for (int jface=conn_index[ielem]+1; jface 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."); -} diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx deleted file mode 100644 index ceced5640..000000000 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx +++ /dev/null @@ -1,71 +0,0 @@ -// 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 - -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& tinyInfo, std::vector& littleStrings) const; - void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings); - void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; - void unserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, - const std::vector& littleStrings); - void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& 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 _types; - }; -} - -#endif diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py deleted file mode 100644 index 336e0d059..000000000 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ /dev/null @@ -1,62 +0,0 @@ -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() diff --git a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i deleted file mode 100644 index c3a33b1be..000000000 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ /dev/null @@ -1,128 +0,0 @@ -// 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(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;idecrRef();" -%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 result=self->getAllTypes(); - std::set::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"); - } - } - }; -} diff --git a/src/ParaMEDMEM/GlobalizerMesh.cxx b/src/ParaMEDMEM/GlobalizerMesh.cxx deleted file mode 100644 index 909215846..000000000 --- a/src/ParaMEDMEM/GlobalizerMesh.cxx +++ /dev/null @@ -1,143 +0,0 @@ -// 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& lazyProcs):GlobalizerMesh(comm,localField),_distant_method(distantMeth),_lazy_procs(lazyProcs) - { - } - - GlobalizerMeshWorkingSide::~GlobalizerMeshWorkingSide() - { - } - - const std::vector& GlobalizerMeshWorkingSide::getProcIdsInInteraction() const - { - return _lazy_procs; - } - - /*! - * connected with GlobalizerMeshLazySide::recvFromWorkingSide - */ - void GlobalizerMeshWorkingSide::sendSumToLazySide(const std::vector< std::vector >& distantLocEltIds, const std::vector< std::vector >& partialSumRelToDistantIds) - { - int procId=0; - CommInterface comm; - for(vector::const_iterator iter=_lazy_procs.begin();iter!=_lazy_procs.end();iter++,procId++) - { - const vector& eltIds=distantLocEltIds[procId]; - const vector& 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 >& globalSumRelToDistantIds) - { - int procId=0; - CommInterface comm; - MPI_Status status; - for(vector::const_iterator iter=_lazy_procs.begin();iter!=_lazy_procs.end();iter++,procId++) - { - std::vector& 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& 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::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& ids=_ids_per_working_proc[procId]; - ids.resize(lgth); - vector 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::const_iterator iter=_compute_procs.begin();iter!=_compute_procs.end();iter++,procId++) - { - vector& ids=_ids_per_working_proc[procId]; - vector valsToSend(ids.size()); - vector::iterator iter3=valsToSend.begin(); - for(vector::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(); - } -} - diff --git a/src/ParaMEDMEM/GlobalizerMesh.hxx b/src/ParaMEDMEM/GlobalizerMesh.hxx deleted file mode 100644 index 3436545a8..000000000 --- a/src/ParaMEDMEM/GlobalizerMesh.hxx +++ /dev/null @@ -1,72 +0,0 @@ -// 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 -#include -#include - -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& lazyProcs); - ~GlobalizerMeshWorkingSide(); - // - const std::vector& getProcIdsInInteraction() const; - void sendSumToLazySide(const std::vector< std::vector >& distantLocEltIds, const std::vector< std::vector >& partialSumRelToDistantIds); - void recvSumFromLazySide(std::vector< std::vector >& globalSumRelToDistantIds); - private: - std::string _distant_method; - std::vector _lazy_procs; - }; - - class GlobalizerMeshLazySide : public GlobalizerMesh - { - public: - GlobalizerMeshLazySide(const MPI_Comm *comm, MEDCouplingFieldDouble *localField, const std::vector& computeProcs); - ~GlobalizerMeshLazySide(); - void recvFromWorkingSide(); - void sendToWorkingSide(); - private: - std::vector _compute_procs; - std::vector _values_added; - std::vector< std::vector > _ids_per_working_proc; - }; -} - -#endif diff --git a/src/ParaMEDMEM/Test/ParaMEDMEMTest_ICocoTrio.cxx b/src/ParaMEDMEM/Test/ParaMEDMEMTest_ICocoTrio.cxx deleted file mode 100644 index bb377556d..000000000 --- a/src/ParaMEDMEM/Test/ParaMEDMEMTest_ICocoTrio.cxx +++ /dev/null @@ -1,252 +0,0 @@ -#include "ParaMEDMEMTest.hxx" -#include -#include "CommInterface.hxx" -#include "ProcessorGroup.hxx" -#include "MPIProcessorGroup.hxx" -#include "DEC.hxx" -#include "IntersectionDEC.hxx" -#include -#include -#include "ICoCoTrioField.hxx" -#include -#include - -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 < emetteur_ids; - set 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 -#include "MEDLoader.hxx" -#include "MEDCouplingUMesh.hxx" -#include "MEDCouplingFieldDouble.hxx" - -#include -#include -#include -#include - -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 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 families=MEDLoader::GetMeshFamilyNames(fileName,meshNames[0].c_str()); - CPPUNIT_ASSERT_EQUAL(8,(int)families.size()); - CPPUNIT_ASSERT(families[2]=="FAMILLE_ELEMENT_3"); - // - vector 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 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 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 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 > 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 > 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()); - 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(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()); - 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(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 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 > 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()); - 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(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()); - 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(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()); - 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(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 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()); - 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 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 > 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(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()); - 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 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 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 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 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(); -} diff --git a/src/ParaMEDMEM/Test/test_perf.cxx b/src/ParaMEDMEM/Test/test_perf.cxx deleted file mode 100644 index 30e921527..000000000 --- a/src/ParaMEDMEM/Test/test_perf.cxx +++ /dev/null @@ -1,317 +0,0 @@ -#include -#include -#include -#include "ParaMEDMEMTest.hxx" -#include - -#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 - -// 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 -#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 self_procs; - set procs_source; - set procs_target; - - for (int i=0; icontainsMyRank()){ - string master = filename_xml1; - - ostringstream strstream; - if( nproc_source == 1 ) - strstream <getNumberOfCells(); - double *value=parafield->getField()->getArray()->getPointer(); - for(int ielem=0; ielemcontainsMyRank()){ - 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<<"_"<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; ielemcontainsMyRank()){ - 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"<