From: ageay Date: Thu, 4 Apr 2013 09:23:55 +0000 (+0000) Subject: MEDMEM suppression X-Git-Tag: EndAGWork4413~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=56b2fc84ee4f5a22c38a3d340833f938d088dcac;p=modules%2Fmed.git MEDMEM suppression --- diff --git a/src/MEDGUI/CMakeLists.txt b/src/MEDGUI/CMakeLists.txt index 617197425..93571d22d 100644 --- a/src/MEDGUI/CMakeLists.txt +++ b/src/MEDGUI/CMakeLists.txt @@ -20,14 +20,13 @@ INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/UseQT4EXT.cmake) SET(MEDGUI_SOURCES - MEDGUI.cxx MEDGUIFileContentDial.cxx MEDGUISelection.cxx MEDGUISelectComponents.cxx MEDGUIDataBaseDockWidget.cxx ) -SET(MEDGUI_HEADERS MEDGUI.h MEDGUIFileContentDial.h MEDGUISelectComponents.h) +SET(MEDGUI_HEADERS MEDGUIFileContentDial.h MEDGUISelectComponents.h) SET(MEDGUI_FORMS MEDGUIFileContentDial.ui MEDGUISelectComponents.ui) #SET(MEDGUI_RESOURCES images.qrc) diff --git a/src/MEDGUI/MEDGUI.cxx b/src/MEDGUI/MEDGUI.cxx deleted file mode 100644 index 46f08af78..000000000 --- a/src/MEDGUI/MEDGUI.cxx +++ /dev/null @@ -1,647 +0,0 @@ -// Copyright (C) 2007-2013 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 -// - -// MED MEDGUI : MED component GUI implemetation -// File : MEDGUI.cxx -// Module : MED -// -#include "MEDGUI.h" - -#include "MEDGUIFileContentDial.h" -#include "MEDGUIDataBaseDockWidget.hxx" -#include "MEDGUISelection.hxx" - -#include - -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" -#include "utilities.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -static CORBA::ORB_var _orb; - -//============================================================================= -/*! - * - */ -//============================================================================= -MedGUI::MedGUI() : SalomeApp_Module( "MED" ) -{ -} - -void MedGUI::createMedAction( const int id, const QString& po_id, const QString& icon_id ) -{ - QWidget* parent = application()->desktop(); - SUIT_ResourceMgr* mgr = application()->resourceMgr(); - - QPixmap pix; - QIcon icon; - if( !icon_id.isEmpty() ) - pix = mgr->loadPixmap( "MED", tr( (const char*)icon_id.toLatin1() ) ); -// else -// pix = mgr->loadPixmap( "MED", tr( QString( "ICO_" )+po_id ) ); - - if ( !pix.isNull() ) - icon = QIcon( pix ); - - createAction( id, - tr( (const char*)("TOP_" + po_id).toLatin1() ), - icon, - tr( (const char*)("MEN_" + po_id).toLatin1() ), - tr( (const char*)("STB_" + po_id).toLatin1() ), - 0, - parent, - false, - this, - SLOT( onGUIEvent() ) ); - - if ( action( id ) ) - action( id )->setObjectName( QString( "Action %1" ).arg( id ) ); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void MedGUI::initialize( CAM_Application* app ) -{ - SalomeApp_Module::initialize( app ); - - //QWidget* parent = application()->desktop(); - - createMedAction( 931, "MESHSEL", "ICO_TB_MESHSEL" ); - createMedAction( 932, "FIELDSEL", "ICO_TB_FIELDSEL" ); - createMedAction( 934, "DUMPMESH" ); - createMedAction( 935, "DUMPSUBMESH" ); - createMedAction( 936, "EXPLORE", "ICO_TB_EXPLORE"); - - createMedAction( 4031, "MESHSEL", "ICO_TB_MESHSEL" ); - createMedAction( 4032, "FIELDSEL", "ICO_TB_FIELDSEL" ); - createMedAction( 4034, "EXPLORE", "ICO_TB_EXPLORE"); - - int MedId = createMenu( tr( "MED" ), -1, 50, 10 ); - createMenu( separator(), MedId, 10 ); - createMenu( 931, MedId, 11 ); - createMenu( 932, MedId, 11 ); - createMenu( 934, MedId, 11 ); - createMenu( 935, MedId, 11 ); - createMenu( 936, MedId, 11 ); - - int medTb = createTool( tr( "TB_MED" ) ); - createTool( 4031, medTb ); - createTool( 4032, medTb ); - createTool( 4034, medTb ); - - _data_base = new MEDGUIDataBaseDockWidget(application(),application()->desktop()); - application()->desktop()->addDockWidget(Qt::LeftDockWidgetArea,_data_base); -} - -QString MedGUI::engineIOR() const -{ - QString anIOR( "" ); - SALOME_MED::MED_Gen_ptr aMedGen = InitMedGen(); - if ( !CORBA::is_nil( aMedGen) ) - { - CORBA::String_var objStr = getApp()->orb()->object_to_string( aMedGen ); - anIOR = QString( objStr.in() ); - } - return anIOR; -} - -void MedGUI::windows( QMap& mappa ) const -{ - mappa.clear(); - mappa.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea ); - mappa.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea ); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -#include -#include -void MedGUI::onGUIEvent() -{ - const QtxAction* obj = qobject_cast(sender()); - if ( !obj ) - return; - int id = actionId( obj ); - if ( id != -1 ) - OnGUIEvent( id ); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void MedGUI::EmitSignalCloseAllDialogs() -{ - emit SignalCloseAllDialogs(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool MedGUI::deactivateModule( SUIT_Study* study ) -{ - setMenuShown( false ); - setToolShown( false ); - - _data_base->setVisible( false ); - _data_base->toggleViewAction()->setVisible( false ); - - disconnect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), - this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); - - EmitSignalCloseAllDialogs(); - - return SalomeApp_Module::deactivateModule( study ); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool MedGUI::activateModule( SUIT_Study* study ) -{ - bool res = SalomeApp_Module::activateModule( study ); - - setMenuShown( true ); - setToolShown( true ); - - _data_base->setVisible( true ); - _data_base->toggleViewAction()->setVisible( true ); - - connect( application()->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ), - this, SLOT( onWindowActivated( SUIT_ViewWindow* ) ) ); - return res; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void MedGUI::onWindowActivated( SUIT_ViewWindow* ) -{ -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool MedGUI::OnGUIEvent (int theCommandID) -{ - setOrb(); - - SalomeApp_Study* myActiveStudy = dynamic_cast< SalomeApp_Study* >( application()->activeStudy() ); - if( !myActiveStudy ) - return false; - - _PTR(Study) aStudy = myActiveStudy->studyDS(); - //SALOME_NamingService* myNameService = parent->getNameService(); - - QString file; - QStringList filtersList ; - - filtersList.append( tr("MED_MEN_IMPORT_MED") ); - filtersList.append( tr("MED_MEN_ALL_FILES") ) ; - - SalomeApp_Application* app = dynamic_cast( application() ); - if( !app ) - return false; - - switch (theCommandID) - { - case 4031: - case 9031: - case 931: - { - MESSAGE("command " << theCommandID << " activated"); - - QString myStudyName = myActiveStudy->studyName(); - bool ok=FALSE; -// int myStudyId = myActiveStudy->id(); - - // load MED engine - SALOME_MED::MED_Gen_ptr medgen = InitMedGen(); - - // Selection du Fichier - file = SUIT_FileDlg::getFileName(application()->desktop(), - "", - filtersList, - tr("MED_MEN_IMPORT"), - true); - - // Selection du Maillage - if (!file.isEmpty() ) - { - SCRUTE((const char*)file.toLatin1()); - QString meshName; - meshName = QInputDialog::getText( application()->desktop(), - tr("MED_INF_MESHNAME"), - QString::null, - QLineEdit::Normal, - QString::null, - &ok ); - if ( ok && !meshName.isEmpty() ) - { - try - { - medgen->readMeshInFile( (const char*)file.toLatin1(), - (const char*)myStudyName.toLatin1(), - (const char*)meshName.toLatin1() ); - if (myActiveStudy->studyDS()->GetProperties()->IsLocked()) { - SUIT_MessageBox::warning ( application()->desktop(), - tr("WRN_WARNING"), - tr("WRN_STUDY_LOCKED") ); - //QObject::tr("BUT_OK")); by default - } - } - catch (const SALOME::SALOME_Exception & S_ex) - { - SalomeApp_Tools::QtCatchCorbaException(S_ex); - } - } - updateObjBrowser(); - } - break; - } - case 4032: - case 9032: - case 932: - { - MESSAGE("command " << theCommandID << " activated"); - - QString myStudyName = myActiveStudy->studyName(); - bool ok=FALSE; -// int myStudyId = myActiveStudy->id(); - - // load MED engine - SALOME_MED::MED_Gen_ptr medgen = InitMedGen(); - - // Selection du Fichier - QString anInitialPath = ""; - if ( SUIT_FileDlg::getLastVisitedPath().isEmpty() ) - anInitialPath = QDir::currentPath(); - - file = SUIT_FileDlg::getFileName(application()->desktop(), - anInitialPath, - filtersList, - tr("MED_MEN_IMPORT"), - true); - - // Selection du Maillage - if (!file.isEmpty() ) - { - SCRUTE((const char*)file.toLatin1()); - QString fieldName; - fieldName = QInputDialog::getText( application()->desktop(), - tr("MED_INF_FIELDNAME"), - QString::null, - QLineEdit::Normal, - QString::null, - &ok ); - if ( ok && !fieldName.isEmpty()) - { - try - { - medgen->readFieldInFile( (const char*)file.toLatin1(), - (const char*)myStudyName.toLatin1(), - (const char*)fieldName.toLatin1(), - -1, - -1 ); - if (myActiveStudy->studyDS()->GetProperties()->IsLocked()) { - SUIT_MessageBox::warning ( application()->desktop(), - tr("WRN_WARNING"), - tr("WRN_STUDY_LOCKED") ); - //tr("BUT_OK")); by default - } - } - catch (const SALOME::SALOME_Exception & S_ex) - { - SalomeApp_Tools::QtCatchCorbaException(S_ex); - } - updateObjBrowser (); - } - } - break; - } - case 934: - { - //Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter( MESH ); - - SALOME_ListIO list; - SalomeApp_Application* app = getApp(); - LightApp_SelectionMgr* mgr = app ? app->selectionMgr() : NULL; - if( mgr ) - mgr->selectedObjects( list ); - //Sel->AddFilter(aMeshFilter) ; - - int nbSel = list.Extent(); - if ( nbSel == 1 ) - { - // SMESH::SMESH_Mesh_var aM; - SALOME_MED::MESH_var aMesh; - Handle(SALOME_InteractiveObject) IObject = list.First(); - if ( IObject->hasEntry() ) - { - _PTR(SObject) aMorSM = aStudy->FindObjectID( IObject->getEntry() ); - if ( aMorSM ) - { - _PTR(GenericAttribute) anAttr; - _PTR(AttributeIOR) anIOR; - if (aMorSM->FindAttribute(anAttr, "AttributeIOR")) - { - anIOR = anAttr; - aMesh = SALOME_MED::MESH::_narrow( _orb->string_to_object(anIOR->Value().c_str()) ); - if ( aMesh->_is_nil() ) - { - SUIT_MessageBox::warning - ( application()->desktop(), - tr ("MED_WRN_WARNING"), - tr ("MED_INF_NOTIMPL") ); - break; - } - DumpMesh( aMesh ); - //Sel->ClearFilters() ; - } - else - { - SUIT_MessageBox::warning - ( application()->desktop(), - tr ("MED_WRN_WARNING"), - tr ("MED_INF_NOIOR") ); - //tr ("MED_BUT_OK") ); by default - break; - } - } - } - } - break; - } - - case 935: - { - //Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter( SUBMESH ); - - SALOME_ListIO list; - SalomeApp_Application* app = getApp(); - LightApp_SelectionMgr* mgr = app ? app->selectionMgr() : NULL; - if( mgr ) - mgr->selectedObjects( list ); - - //Sel->AddFilter(aSubMeshFilter) ; - - int nbSel = list.Extent(); - if ( nbSel == 1 ) - { - // SMESH::SMESH_subMesh_var aSubM; - SALOME_MED::FAMILY_var aFam; - Handle(SALOME_InteractiveObject) IObject = list.First(); - if ( IObject->hasEntry() ) - { - _PTR(SObject) aMorSM = aStudy->FindObjectID( IObject->getEntry() ); - if ( aMorSM ) - { - _PTR(GenericAttribute) anAttr; - _PTR(AttributeIOR) anIOR; - if (aMorSM->FindAttribute(anAttr, "AttributeIOR")) - { - anIOR = anAttr; - } - else - { - SUIT_MessageBox::warning - ( application()->desktop(), - tr ("MED_WRN_WARNING"), - tr ("MED_INFNOIOR") ); - // tr ("MED_BUT_OK") ); by default - break; - } - } - } - } - break; - } - case 936 : - case 4034 : - { - - MEDGUIFileContentDial* mfcd = new MEDGUIFileContentDial(_data_base, application()->desktop()); - mfcd->show(); - break; - } - } - - app->updateActions(); //SRN: To update a Save button in the toolbar - - return true; -} - - -//============================================================================= -/*! - * - */ -//============================================================================= -bool MedGUI::OnMousePress (QMouseEvent* pe , - SUIT_ViewWindow* wnd ) -{ - MESSAGE("MedGUI::OnMousePress"); - return true; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool MedGUI::OnMouseMove (QMouseEvent* pe , - SUIT_ViewWindow* wnd ) -{ - // MESSAGE("MedGUI::OnMouseMouve"); - return true; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool MedGUI::OnKeyPress (QKeyEvent* pe, - SUIT_ViewWindow* wnd) -{ - MESSAGE("MedGUI::OnKeyPress"); - - return true; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool MedGUI::DumpMesh( SALOME_MED::MESH_var MEDMesh) -{ - - if ( MEDMesh->_is_nil() ) - { - return false; - } - - std::string name = MEDMesh->getName(); - SCRUTE(name); - - int dim2 = MEDMesh->getSpaceDimension(); - SCRUTE(dim2); - - int k = MEDMesh->getNumberOfNodes() ; - SCRUTE(k); - SALOME_TYPES::ListOfDouble_var coords = MEDMesh->getCoordinates( SALOME_MED::MED_FULL_INTERLACE ); - int i = 0; - int lu = 0; - while (lu < k ) { - if (dim2==3) - { - MESSAGE ( " Coordinates X = " << coords[i] << " Y = " << coords[i+1] << " Z = " << coords[i+2] ); - i = i + 3; - } - else - { - MESSAGE ( " Coordinates X = " << coords[i] << " Y = " << coords[i+1] ); - i = i + 2; - } - lu=lu+1; - } - - int nbfam=MEDMesh->getNumberOfFamilies(SALOME_MED::MED_NODE); - SCRUTE(nbfam); - SALOME_MED::Family_array_var Families=MEDMesh->getFamilies(SALOME_MED::MED_NODE) ; - - for (k=0; k < nbfam; k++) { - SCRUTE(k); - std::string nomFam=Families[k]->getName(); - SCRUTE(nomFam); - SALOME_TYPES::ListOfLong_var tabnoeuds=Families[k]->getNumber(SALOME_MED::MED_NONE); - for (int l=0;l<(int)tabnoeuds->length();l++) - SCRUTE(tabnoeuds[l]); - } - - return true; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool MedGUI::DumpSubMesh( SALOME_MED::FAMILY_var Fam ) -{ - - if ( Fam->_is_nil() ) - return false; - - SALOME_TYPES::ListOfLong_var tabnoeuds=Fam->getNumber(SALOME_MED::MED_NONE); - for (int l=0;l<(int)tabnoeuds->length();l++) - SCRUTE(tabnoeuds[l]); - - return true; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -SALOME_MED::MED_Gen_ptr MedGUI::InitMedGen() const -{ - SalomeApp_Application* app = dynamic_cast( application() ); - Engines::EngineComponent_var comp = - SALOME_LifeCycleCORBA(app->namingService()).FindOrLoad_Component( "FactoryServer", "MED" ); - - MESSAGE("_________________________________________"); - SALOME_MED::MED_Gen_var clr = SALOME_MED::MED_Gen::_narrow(comp); - ASSERT(!CORBA::is_nil(clr)); - return clr._retn(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void MedGUI::setOrb() -{ - try { - ORB_INIT &init = *SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init( 0 , 0 ); - } catch (...) { - INFOS("internal error : orb not found"); - _orb = 0; - } - ASSERT(! CORBA::is_nil(_orb)); -} - -extern "C" { - Standard_EXPORT CAM_Module* createModule() { - return new MedGUI(); - } - - Standard_EXPORT char* getModuleVersion() { - return (char*)SALOMEMED_VERSION_STR; - } -} diff --git a/src/MEDGUI/MEDGUI.h b/src/MEDGUI/MEDGUI.h deleted file mode 100644 index fe661d070..000000000 --- a/src/MEDGUI/MEDGUI.h +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2007-2013 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 -// - -// MED MEDGUI : MED component GUI implemetation -// File : MEDGUI.h -// Module : MED -// -#ifndef __MEDGUI_HXX_ -#define __MEDGUI_HXX__ - -#include -#include - -#include -#include CORBA_CLIENT_HEADER(MED_Gen) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) - -class MEDGUIDataBaseDockWidget; - -class MedGUI: public SalomeApp_Module -{ - Q_OBJECT - -public: - MedGUI(); - - virtual void initialize( CAM_Application* ); - virtual QString engineIOR() const; - virtual void windows( QMap& mappa ) const; - - virtual bool OnGUIEvent(int theCommandID); - virtual bool OnKeyPress(QKeyEvent* pe, SUIT_ViewWindow* ); - virtual bool OnMousePress(QMouseEvent* pe, SUIT_ViewWindow* ); - virtual bool OnMouseMove(QMouseEvent* pe, SUIT_ViewWindow* ); - - void createMedAction( const int, const QString&, const QString& = "" ); - - //virtual void contextMenuPopup( const QString&, QMenu*, QString& ); - - //virtual bool SetSettings (); - //virtual bool CustomPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, - // const QString & theParent, const QString & theObject ); - //virtual void DefinePopup ( QString & theContext, QString & theParent, QString & theObject ); - //virtual bool ActiveStudyChanged( QAD_Desktop* parent ); - - /*static*/ SALOME_MED::MED_Gen_ptr InitMedGen() const; - - static bool DumpMesh( SALOME_MED::MESH_var aMesh ); - static bool DumpSubMesh( SALOME_MED::FAMILY_var Fam ) ; - - static void setOrb(); - - void EmitSignalCloseAllDialogs(); - -signals : - void SignalCloseAllDialogs(); - -public slots: - virtual bool deactivateModule( SUIT_Study* ); - virtual bool activateModule( SUIT_Study* ); - -protected: - MEDGUIDataBaseDockWidget *_data_base; - -private slots: - void onGUIEvent(); - void onWindowActivated( SUIT_ViewWindow* ); - -}; - -#endif diff --git a/src/MEDGUI/MED_msg_en.ts b/src/MEDGUI/MED_msg_en.ts index e3fdf59ff..bd0eed30f 100644 --- a/src/MEDGUI/MED_msg_en.ts +++ b/src/MEDGUI/MED_msg_en.ts @@ -128,19 +128,4 @@ Popup test - - MedGUI - - MED_MEN_ALL_FILES - All Files ( * ) - - - MED_MEN_IMPORT - Import - - - MED_MEN_IMPORT_MED - MED Files ( *.med ) - - diff --git a/src/MEDGUI/MED_msg_fr.ts b/src/MEDGUI/MED_msg_fr.ts index e1b39160f..614684374 100644 --- a/src/MEDGUI/MED_msg_fr.ts +++ b/src/MEDGUI/MED_msg_fr.ts @@ -128,19 +128,4 @@ Tester un menu contextuel - - MedGUI - - MED_MEN_ALL_FILES - Tous les Fichiers ( * ) - - - MED_MEN_IMPORT - Importer - - - MED_MEN_IMPORT_MED - Fichiers MED ( *.med ) - - diff --git a/src/MEDGUI/Makefile.am b/src/MEDGUI/Makefile.am index 7f5ccdd8e..cc2f10dca 100644 --- a/src/MEDGUI/Makefile.am +++ b/src/MEDGUI/Makefile.am @@ -31,7 +31,7 @@ BUILT_SOURCES = $(UIC_FILES) EXTRA_DIST+= MEDGUIFileContentDial.ui MEDGUISelectComponents.ui dist_libMEDGUI_la_SOURCES = MEDGUIFileContentDial.h MEDGUISelection.hxx \ - MEDGUI.h MEDGUI.cxx MEDGUIFileContentDial.cxx MEDGUISelection.cxx \ + MEDGUIFileContentDial.cxx MEDGUISelection.cxx \ MEDGUISelectComponents.h MEDGUISelectComponents.cxx MEDGUIDataBaseDockWidget.hxx \ MEDGUIDataBaseDockWidget.cxx diff --git a/src/MEDSPLITTER/CMakeLists.txt b/src/MEDSPLITTER/CMakeLists.txt deleted file mode 100644 index 2b302b540..000000000 --- a/src/MEDSPLITTER/CMakeLists.txt +++ /dev/null @@ -1,131 +0,0 @@ -# Copyright (C) 2012-2013 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 -# - -IF(CPPUNIT_IS_OK) - ADD_SUBDIRECTORY(Test) -ENDIF(CPPUNIT_IS_OK) - -INCLUDE_DIRECTORIES( - ${PARMETIS_INCLUDE_DIRS} - ${METIS_INCLUDE_DIRS} - ${SCOTCH_INCLUDE_DIRS} - ${BOOST_INCLUDE_DIRS} - ${METIS_INCLUDE_DIRS} - ${LIBXML_INCLUDE_DIRS} - ${MED3_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS} - ${MPI_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDMEM - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Geometric2D - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/ExprEval - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints - ) - -SET(medsplittercpp_HEADERS_HXX - MEDSPLITTER_Topology.hxx - MEDSPLITTER_MESHCollection.hxx - MEDSPLITTER_MESHCollection.H - MEDSPLITTER_MESHCollectionDriver.H - MEDSPLITTER_MESHCollectionMedXMLDriver.H - MEDSPLITTER_MESHCollectionMedAsciiDriver.H - MEDSPLITTER_MESHCollectionDriver.hxx - MEDSPLITTER_MESHCollectionMedXMLDriver.hxx - MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx - MEDSPLITTER_ParallelTopology.hxx - MEDSPLITTER_FaceModel.hxx - MEDSPLITTER_Graph.hxx - MEDSPLITTER_UserGraph.hxx - MEDSPLITTER_API.hxx - MEDSPLITTER_SequentialTopology.hxx - MEDSPLITTER_utils.hxx - MEDSPLITTER.hxx - MEDSPLITTER_ParaDomainSelector.hxx - MEDSPLITTER_MeshSendReceive.hxx - MEDSPLITTER_JointExchangeData.hxx - ) - -SET(medsplittercpp_SOURCES - MEDSPLITTER_MESHCollection.cxx - MEDSPLITTER_MESHCollectionDriver.cxx - MEDSPLITTER_MESHCollectionMedXMLDriver.cxx - MEDSPLITTER_MESHCollectionMedAsciiDriver.cxx - MEDSPLITTER_ParallelTopology.cxx - MEDSPLITTER_Graph.cxx - MEDSPLITTER_UserGraph.cxx - MEDSPLITTER_API.cxx - MEDSPLITTER_ParaDomainSelector.cxx - MEDSPLITTER_MeshSendReceive.cxx - MEDSPLITTER_JointExchangeData.cxx - ) - -SET(medsplittercpp_DEFINITIONS "${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${BOOST_DEFINITIONS} ${LIBXML_DEFINITIONS} ${MPI_DEFINITIONS} ${PLATFORM_DEFINITIONS}") -SET(medsplittercpp_LDFLAGS medmem ${LIBXML_LIBS} interpkernel ${MPI_LIBS} ${HDF5_LIBS} ${MED3_LIBS_C_ONLY} ${STDLIB} ${PLATFORM_LIBS}) - -IF(MED_ENABLE_SCOTCH) - SET(medsplittercpp_SOURCES ${medsplittercpp_SOURCES} MEDSPLITTER_SCOTCHGraph.cxx) - SET(medsplittercpp_HEADERS_HXX ${medsplittercpp_HEADERS_HXX} MEDSPLITTER_SCOTCHGraph.hxx) - SET(medsplittercpp_DEFINITIONS "${medsplittercpp_DEFINITIONS} ${SCOTCH_DEFINITIONS}") - SET(medsplittercpp_LDFLAGS ${medsplittercpp_LDFLAGS} ${SCOTCH_LIBS}) -ENDIF(MED_ENABLE_SCOTCH) - -IF(MED_ENABLE_METIS) - SET(medsplittercpp_HEADERS_HXX ${medsplittercpp_HEADERS_HXX} MEDSPLITTER_METISGraph.hxx) -ENDIF(MED_ENABLE_METIS) - -IF(MPI_IS_OK) - IF(MED_ENABLE_PARMETIS) - SET(medsplittercpp_SOURCES ${medsplittercpp_SOURCES} MEDSPLITTER_METISGraph.cxx) - SET(medsplittercpp_DEFINITIONS "${medsplittercpp_DEFINITIONS} ${MPI_DEFINITIONS} ${PARMETIS_DEFINITIONS}") - SET(medsplittercpp_LDFLAGS ${medsplittercpp_LDFLAGS} ${PARMETIS_LIBS}) - ENDIF(MED_ENABLE_PARMETIS) -ELSE(MPI_IS_OK) - IF(MED_ENABLE_METIS) - SET(medsplittercpp_SOURCES ${medsplittercpp_SOURCES} MEDSPLITTER_METISGraph.cxx) - SET(medsplittercpp_DEFINITIONS "${medsplittercpp_DEFINITIONS} ${METIS_DEFINITIONS}") - SET(medsplittercpp_LDFLAGS ${medsplittercpp_LDFLAGS} ${METIS_LIBS}) - ENDIF(MED_ENABLE_METIS) -ENDIF(MPI_IS_OK) - -SET(medsplitter_LDFLAGS ${medsplittercpp_LDFLAGS}) -IF(MED_ENABLE_KERNEL) - INCLUDE_DIRECTORIES(${KERNEL_ROOT_DIR}/include/salome) - SET(medsplittercpp_LDFLAGS ${medsplittercpp_LDFLAGS} ${BOSST_LIBS} ${SALOMELocalTrace}) - SET(medsplitter_LDFLAGS ${medsplittercpp_LDFLAGS} ${SALOMEBasics}) -ENDIF(MED_ENABLE_KERNEL) - -ADD_EXECUTABLE(medsplitter medsplitter.cxx) -SET_TARGET_PROPERTIES(medsplitter PROPERTIES COMPILE_FLAGS "${medsplittercpp_DEFINITIONS}") -TARGET_LINK_LIBRARIES(medsplitter medsplittercpp ${medsplitter_LDFLAGS}) -INSTALL(TARGETS medsplitter DESTINATION ${MED_salomebin_BINS}) - -IF(MPI_IS_OK) - ADD_EXECUTABLE(medsplitter_para medsplitter_para.cxx) - SET_TARGET_PROPERTIES(medsplitter_para PROPERTIES COMPILE_FLAGS "${medsplittercpp_DEFINITIONS}") - TARGET_LINK_LIBRARIES(medsplitter_para medsplittercpp ${medsplitter_LDFLAGS}) - INSTALL(TARGETS medsplitter_para DESTINATION ${MED_salomebin_BINS}) -ENDIF(MPI_IS_OK) - -ADD_LIBRARY(medsplittercpp SHARED ${medsplittercpp_SOURCES}) -SET_TARGET_PROPERTIES(medsplittercpp PROPERTIES COMPILE_FLAGS "${medsplittercpp_DEFINITIONS}") -TARGET_LINK_LIBRARIES(medsplittercpp ${medsplittercpp_LDFLAGS}) -INSTALL(TARGETS medsplittercpp DESTINATION ${MED_salomelib_LIBS}) - -INSTALL(FILES ${medsplittercpp_HEADERS_HXX} DESTINATION ${MED_salomeinclude_HEADERS}) diff --git a/src/MEDSPLITTER/MEDSPLITTER.hxx b/src/MEDSPLITTER/MEDSPLITTER.hxx deleted file mode 100755 index a93b92685..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER.hxx +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2007-2013 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 -// - -// File : MEDSPLITTER.hxx -// Author : Alexander A. BORODIN -// Module : MED -// Exporting/Importing defines for Windows Platform -// -#ifndef MEDSPLITTER_HXX_ -#define MEDSPLITTER_HXX_ - -#ifdef WIN32 -# if defined MEDSPLITTERCPP_EXPORTS || defined medsplittercpp_EXPORTS -# define MEDSPLITTER_EXPORT __declspec( dllexport ) -# else -# define MEDSPLITTER_EXPORT __declspec( dllimport ) -# endif -#else -# define MEDSPLITTER_EXPORT -#endif - -#endif //MEDSPLITTER_HXX_ diff --git a/src/MEDSPLITTER/MEDSPLITTER_API.cxx b/src/MEDSPLITTER/MEDSPLITTER_API.cxx deleted file mode 100644 index 635e51053..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_API.cxx +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (C) 2007-2013 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 -// - -/*! - * API for the MEDSPLITTER tool - * - * API has a C binding so that it can be used - * in a C/C++ program and it can easily be wrapped - * in a Fortran program - */ - -#include "MEDSPLITTER_API.hxx" - -#include -#include "MEDMEM_define.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDSPLITTER_Graph.hxx" -#include "MEDSPLITTER_MESHCollection.hxx" -#include "MEDSPLITTER_Topology.hxx" -#include "MEDSPLITTER_ParaDomainSelector.hxx" - -using namespace std; -/*! - * MEDSPLITTER high-level API - * - * \param inputfilename name of the input file - * \param mesh name of the input mesh (only used for the sequential input file case) - * \param outputfilename name out the master output file - * \param is_distributed sequential input (0) or distributed input (1) - * \param nbdomains number of subdomains - * \param method METIS(0) or SCOTCH(1) - * \param meshonly projects mesh and fields (0) or only the mesh (1) - * \param plainmaster creates a plain masterfile (1) instead of an XML file (0), - * \param createboundaryfaces creates the necessary faces so that face joints are created - * \param familysplitting preserves the family names (1) instead of focusing on the groups (0) - * \param emptygroups creates empty groups in zones that do not contain a group from the original domain -*/ - -int medsplitter(const char* inputfilename, - const char* mesh, - const char* outputfilename, - int is_distributed, - int nbdomains, - int method, - int meshonly, - int plainmaster, - int createboundaryfaces, - int familysplitting, - int emptygroups) -{ - - //Pointer to the initial collection - MEDSPLITTER::MESHCollection* collection; - - // Loading the mesh collection - string input(inputfilename); - - if (is_distributed ==0) - { - string meshname (mesh); - collection=new MEDSPLITTER::MESHCollection(input,meshname); - } - else - collection = new MEDSPLITTER::MESHCollection(input); - - // Creating the graph and partitioning it - MEDSPLITTER::Topology* new_topo; - if (method==0) - new_topo = collection->createPartition(nbdomains,MEDSPLITTER::Graph::METIS); - else - new_topo = collection->createPartition(nbdomains,MEDSPLITTER::Graph::SCOTCH); - - // Creating a new mesh collection from the partitioning - MEDSPLITTER::MESHCollection new_collection(*collection, new_topo, familysplitting, emptygroups); - - //Writing the output files (master + MED files) - if (plainmaster) - new_collection.setDriverType(MEDSPLITTER::MedAscii); - new_collection.setSubdomainBoundaryCreates(createboundaryfaces); - string output(outputfilename); - new_collection.write(output); - - // Casting the fields on the new collection - if (meshonly!=0) - new_collection.castAllFields(*collection); - delete collection; - - return 0; -} - - -/*! - * Parallel MEDSPLITTER high-level API - * - * \param inputfilename name of the input distributed MED file - * \param outputfilename name out the master output file - * \param nprocs number of subdomains - * \param method METIS(0) or SCOTCH(1) - * \param create_boundary_faces creates the necessary faces so that faces joints are created in the output files - * \param family_splitting preserves the family names instead of focusing on the groups - */ - -int medsplitter_para(const char* inputfilename, - const char* outputfilename, - const int nprocs, - const int method, - const bool create_boundary_faces, - const bool family_splitting) -{ - // Parallelizer - MEDSPLITTER::ParaDomainSelector parallelizer; - - // Loading the mesh collection - MEDSPLITTER::MESHCollection collection (inputfilename, parallelizer); - - // Creating the graph and partitioning it - auto_ptr new_topo; - if (method==0) - new_topo.reset( collection.createPartition(nprocs,MEDSPLITTER::Graph::METIS)); - else - new_topo.reset( collection.createPartition(nprocs,MEDSPLITTER::Graph::SCOTCH)); - - // Creating a new mesh collection from the partitioning - MEDSPLITTER::MESHCollection new_collection(collection, new_topo.get(),family_splitting); - new_collection.setSubdomainBoundaryCreates(create_boundary_faces); - - //Writing the output files (master + MED files) - string output(outputfilename); - new_collection.write(output); - - return 0; -} diff --git a/src/MEDSPLITTER/MEDSPLITTER_API.hxx b/src/MEDSPLITTER/MEDSPLITTER_API.hxx deleted file mode 100644 index c682b6c0e..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_API.hxx +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2007-2013 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 MEDSPLITTER_API_HXX_ -#define MEDSPLITTER_API_HXX_ - -#include "MEDSPLITTER.hxx" - -MEDSPLITTER_EXPORT -extern "C" int medsplitter(const char* inputfilename, - const char* mesh, - const char* outputfilename, - int is_distributed, - int nbdomains, - int method, - int meshonly, - int plainmaster, - int createboundaryfaces, - int familysplitting, - int emptygroups); - -MEDSPLITTER_EXPORT -extern "C" int medsplitter_para(const char* inputfilename, - const char* outputfilename, - const int nprocs, - const int method, - const bool create_boundary_faces, - const bool family_splitting); - -#endif diff --git a/src/MEDSPLITTER/MEDSPLITTER_FaceModel.hxx b/src/MEDSPLITTER/MEDSPLITTER_FaceModel.hxx deleted file mode 100644 index 23c127551..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_FaceModel.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2007-2013 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 MEDSPLITTER_FACEMODEL_HXX_ -#define MEDSPLITTER_FACEMODEL_HXX_ - -namespace MEDMEM -{ - class CELLMODEL; -} - -namespace MEDSPLITTER -{ - - class MEDSPLITTER_FaceModel - { - public: - MEDSPLITTER_FaceModel():_conn(0){}; - virtual ~MEDSPLITTER_FaceModel() {if (_conn!=0) delete[] _conn;} - MED_EN::medGeometryElement getType() const {return _type;} - void setType(MED_EN::medGeometryElement type) {_type=type;} - void setNbNodes(int nbnodes){_conn=new int[nbnodes];} - int& operator[](int i){return *(_conn+i);} - int getGlobal(){return _global;} - void setGlobal(int i){_global=i;} - - // Makes face common for two given cells (implemented in MEDSPLITTER_MESHCollection.cxx) - static MEDSPLITTER_FaceModel* getCommonFace(const int* nodes1, - const int* nodes1_local, - const MEDMEM::CELLMODEL& celltype1, - const int* nodes2, - int nb_nodes2, - int global_id); - - private: - int _nbnodes; - int* _conn; - MED_EN::medGeometryElement _type; - int _global; - }; - -} - -#endif /*MEDSPLITTER_FACEMODEL_HXX_*/ diff --git a/src/MEDSPLITTER/MEDSPLITTER_Graph.cxx b/src/MEDSPLITTER/MEDSPLITTER_Graph.cxx deleted file mode 100644 index 8de09e721..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_Graph.cxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2007-2013 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 "MEDSPLITTER_Graph.hxx" - -using namespace MEDSPLITTER; - -Graph::Graph(MEDMEM::MEDSKYLINEARRAY* array, int* edgeweight):m_graph(array),m_partition(0),m_edgeweight(edgeweight),m_cellweight(0) -{ -} - -//================================================================================ -/*! - * \brief Destructor - */ -//================================================================================ - -Graph::~Graph() -{ - if (m_partition) - { - delete m_partition; - m_partition=0; - } - if (m_graph) - { - delete m_graph; - m_graph=0; - } -} - diff --git a/src/MEDSPLITTER/MEDSPLITTER_Graph.hxx b/src/MEDSPLITTER/MEDSPLITTER_Graph.hxx deleted file mode 100644 index f52e2f90a..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_Graph.hxx +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2007-2013 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 GRAPH_HXX_ -#define GRAPH_HXX_ - -#include "MEDSPLITTER.hxx" - -#include "MEDMEM_SkyLineArray.hxx" - -namespace MEDSPLITTER { - -class ParaDomainSelector; - -class MEDSPLITTER_EXPORT Graph -{ - public: - typedef enum {METIS,SCOTCH} splitter_type; - - Graph(){} - - //creates a graph from a SKYLINEARRAY - Graph(MEDMEM::MEDSKYLINEARRAY* graph, int* edgeweight=0); - - virtual ~Graph(); - - void setEdgesWeights(int* edgeweight){m_edgeweight=edgeweight;} - void setVerticesWeights(int* cellweight){m_cellweight=cellweight;} - - //computes partitioning of the graph - virtual void partGraph(int ndomain, const string&, ParaDomainSelector* sel=0)=0; - - //! returns the partitioning - const int* getPart() const {return m_partition->getValue();} - - //! returns the number of graph vertices (which can correspond to the cells in the mesh!) - int nbVertices() const {return m_graph->getNumberOf();} - - const MEDMEM::MEDSKYLINEARRAY* getGraph() const {return m_graph;} - - protected: - - MEDMEM::MEDSKYLINEARRAY* m_graph; - - MEDMEM::MEDSKYLINEARRAY* m_partition; - - int* m_edgeweight; - - int* m_cellweight; - }; - -} -#endif /*GRAPH_HXX_*/ diff --git a/src/MEDSPLITTER/MEDSPLITTER_JointExchangeData.cxx b/src/MEDSPLITTER/MEDSPLITTER_JointExchangeData.cxx deleted file mode 100644 index 0830bdc9e..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_JointExchangeData.cxx +++ /dev/null @@ -1,346 +0,0 @@ -// Copyright (C) 2007-2013 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 -// -// File : MEDSPLITTER_JointExchangeData.cxx -// Created : Thu Jul 23 13:01:35 2009 -// Author : Edward AGAPOV (eap) -// - -#include "MEDSPLITTER_JointExchangeData.hxx" - -#include "MEDSPLITTER_FaceModel.hxx" - -#include -#include - -using namespace MEDSPLITTER; -using namespace MED_EN; - -//================================================================================ -/*! - * \brief Initialization - */ -//================================================================================ - -JointExchangeData::JointExchangeData(): - _dist_domain(-1), _loc_domain(-1), _conn_here_size(0), _dist_mesh(0), _loc_mesh(0) -{ -} - -//================================================================================ -/*! - * \brief Set meshes - */ -//================================================================================ - -void JointExchangeData::setMeshes( int domain_dist, const MEDMEM::MESH* mesh_dist, - int domain_here, const MEDMEM::MESH* mesh_here) -{ - _dist_domain = domain_dist; - _loc_domain = domain_here; - _dist_mesh = mesh_dist; - _loc_mesh = mesh_here; -} - -//================================================================================ -/*! - * \brief Stores cell/cell pair of joint between domains (residing different procs by default) - * \param mesh - mesh on this proc - * \param domain_dist - distant domain - * \param domain_here - local domain - * \param glob_dist - global id of a distant domain - * \param glob_here - global id of a local domain - * \param loc_here - local id of a local domain (counted from 1) - * \param loc_dist - local id of a another domain (counted from 1) - */ -//================================================================================ - -void JointExchangeData::addCellCorrespondence(const MEDMEM::MESH* mesh, - int domain_dist, int domain_here, - int glob_dist, int glob_here, - int loc_here, int loc_dist) -{ - int glob_key = ( domain_dist < domain_here ) ? glob_dist : glob_here; - _glob_to_locs_here_and_dist.insert ( make_pair( glob_key, make_pair( loc_here, loc_dist ))); - - _conn_here_size += mesh->getElementType( MED_CELL, loc_here ) % 100; -} - -//================================================================================ -/*! - * \brief Return data to send and size of data to receive - */ -//================================================================================ - -int JointExchangeData::serialize(vector & out_data) const -{ - int data_size = - _glob_to_locs_here_and_dist.size() + _local_conn_here.size() + _global_conn_here.size(); - out_data.resize( data_size ); - - int i = 0; - TGlob2LocsHD::const_iterator glob_hloc_dloc = _glob_to_locs_here_and_dist.begin(); - for ( ; glob_hloc_dloc != _glob_to_locs_here_and_dist.end(); ++ glob_hloc_dloc ) - out_data[i++] = glob_hloc_dloc->second.first; - - for ( int n = 0; n < _local_conn_here.size(); ++n ) - out_data[i++] = _local_conn_here[n]; - - for ( int n = 0; n < _global_conn_here.size(); ++n ) - out_data[i++] = _global_conn_here[n]; - - // evaluate size of data to receive - - medGeometryElement last_type = - _dist_mesh->getTypes(MED_CELL)[ _dist_mesh->getNumberOfTypes(MED_CELL)-1 ]; - - int max_nb_node_by_cell = last_type % 100; - - data_size = - _glob_to_locs_here_and_dist.size() + - 2 * max_nb_node_by_cell * _dist_mesh->getNumberOfElements( MED_CELL, MED_ALL_ELEMENTS ); - - return data_size; -} - -//================================================================================ -/*! - * \brief Stores received data - */ -//================================================================================ - -void JointExchangeData::deserialize(const std::vector & in_data) -{ - const int* dist_loc = &in_data[0]; - - int conn_real_size = 0; - TGlob2LocsHD::iterator glob_hloc_dloc = _glob_to_locs_here_and_dist.begin(); - for ( ; glob_hloc_dloc != _glob_to_locs_here_and_dist.end(); ++ glob_hloc_dloc ) - { - conn_real_size += _dist_mesh->getElementType( MED_CELL, *dist_loc ) % 100; - glob_hloc_dloc->second.second = *dist_loc++; - } - - const int* dist_loc_conn = dist_loc; - const int* dist_glob_conn = dist_loc + conn_real_size; - - _global_conn_dist.resize( conn_real_size ); - _local_conn_dist.resize ( conn_real_size ); - - for ( int n = 0; n < conn_real_size; ++n ) - { - _global_conn_dist[n] = *dist_glob_conn++; - _local_conn_dist [n] = *dist_loc_conn++; - } -} - -//================================================================================ -/*! - * \brief Create cell/cell correspondency array of the joint - */ -//================================================================================ - -MEDMEM::MEDSKYLINEARRAY* JointExchangeData::makeCellCorrespArray() const -{ - int nb_cells_here = _loc_mesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); - int cells_value_size = _glob_to_locs_here_and_dist.size(); - int* cell_index = new int [nb_cells_here+1]; - int* cell_value = new int [cells_value_size]; - - TGlob2LocsHD::const_iterator glob_hloc_dloc = _glob_to_locs_here_and_dist.begin(); - - // sort local/local pairs by locals of _loc_domain - multiset< pair< int, int > > here_and_dist_cells; - for ( ; glob_hloc_dloc != _glob_to_locs_here_and_dist.end(); ++ glob_hloc_dloc ) - here_and_dist_cells.insert( glob_hloc_dloc->second ); - - multiset< pair< int, int > >::const_iterator here_dist_ids = here_and_dist_cells.begin(); - if ( here_dist_ids->second < 1 ) - throw MED_EXCEPTION("MEDSPLITTER::JointExchangeData::makeConnectZone(): " - "ParaDomainSelector::exchangeJoint() must be called before!"); - cell_index[0]=1; - for ( int loc_id_here = 1, i_dist = 0; loc_id_here <= nb_cells_here; ++loc_id_here) - { - cell_index[ loc_id_here ] = cell_index[ loc_id_here-1 ]; - while ( here_dist_ids != here_and_dist_cells.end() && - here_dist_ids->first == loc_id_here ) - { - cell_value[ i_dist ] = here_dist_ids->second; - cell_index[ loc_id_here ]++; - here_dist_ids++; - i_dist++; - } - } - - MEDMEM::MEDSKYLINEARRAY* cell_cell= - new MEDMEM::MEDSKYLINEARRAY( nb_cells_here, cells_value_size, - cell_index, cell_value,/*shallowcopy=*/true); - return cell_cell; -} - -namespace -{ - //================================================================================ - /*! - * \brief Return CELLMODEL for the geom type - */ - //================================================================================ - - const MEDMEM::CELLMODEL& getCellModel( medGeometryElement geom_type ) - { - static map< medGeometryElement, MEDMEM::CELLMODEL > cell_models; - MEDMEM::CELLMODEL& model = cell_models[ geom_type ]; - if ( model.getNumberOfNodes() < 1 ) - model = MEDMEM::CELLMODEL( geom_type ); - return model; - } -} - -//================================================================================ -/*! - * \brief Creates CONNECTZONE with MED_CELL and MED_NODE data filled. - * - * It must be exchanged with the corresponding joint on other proc using - * ParaDomainSelector::exchangeJoint() - */ -//================================================================================ - -MEDMEM::CONNECTZONE* JointExchangeData::makeConnectZone(TGeom2FacesByDomian& face_map) -{ - MEDMEM::CONNECTZONE* cz= new MEDMEM::CONNECTZONE(); - cz->setLocalMesh (const_cast(_loc_mesh)); - cz->setDistantMesh (const_cast(_dist_mesh)); - cz->setLocalDomainNumber (_loc_domain); - cz->setDistantDomainNumber(_dist_domain); - cz->setName ("Connect zone defined by SPLITTER"); - cz->setEntityCorresp( MED_CELL, MED_CELL, makeCellCorrespArray() ); - - // node/node correspondency - - // map local node id on this proc to local node id on distant proc - map< int, int > here_2_dist_loc_nodes; - int iconn_here = 0, iconn_dist = 0; - - TGlob2LocsHD::const_iterator glob_hloc_dloc = _glob_to_locs_here_and_dist.begin(); - for ( ; glob_hloc_dloc != _glob_to_locs_here_and_dist.end(); ++ glob_hloc_dloc ) - { - int cell_here = glob_hloc_dloc->second.first; - int cell_dist = glob_hloc_dloc->second.second; - int nb_cell_nodes_here = _loc_mesh->getElementType( MED_CELL, cell_here ) % 100; - int nb_cell_nodes_dist = _dist_mesh->getElementType( MED_CELL, cell_dist ) % 100; - for ( int n_here = 0; n_here < nb_cell_nodes_here; ++n_here ) - { - for ( int n_dist = 0; n_dist < nb_cell_nodes_dist; ++n_dist ) - if ( _global_conn_here[ n_here + iconn_here ] == _global_conn_dist[ n_dist + iconn_dist]) - { - here_2_dist_loc_nodes.insert( make_pair( _local_conn_here[ n_here + iconn_here ], - _local_conn_dist[ n_dist + iconn_dist ])); - break; - } - } - iconn_here += nb_cell_nodes_here; - iconn_dist += nb_cell_nodes_dist; - } - // create MEDSKYLINEARRAY - int nb_nodes_here = here_2_dist_loc_nodes.size(); - int node_value_size = nb_nodes_here * 2; - int* node_index = new int [nb_nodes_here+1]; - int* node_value = new int [node_value_size]; - MEDMEM::MEDSKYLINEARRAY* node_node = - new MEDMEM::MEDSKYLINEARRAY( nb_nodes_here, node_value_size, - node_index, node_value,/*shallowcopy=*/true); - - map< int, int >::const_iterator here_dist_ids = here_2_dist_loc_nodes.begin(); - for ( int i = 1; here_dist_ids != here_2_dist_loc_nodes.end(); ++here_dist_ids) - { - *node_index++ = i++; - *node_value++ = here_dist_ids->first; - *node_value++ = here_dist_ids->second; - } - *node_index = nb_nodes_here+1; - - here_2_dist_loc_nodes.clear(); - - cz->setNodeCorresp (node_node); - - // Create faces - - if ( face_map.size() > _loc_domain ) - { - TGeom2Faces& faces_of_geom = face_map[ _loc_domain ]; - - int iconn_here = 0, iconn_dist = 0; - glob_hloc_dloc = _glob_to_locs_here_and_dist.begin(); - for ( int iface = 0; glob_hloc_dloc != _glob_to_locs_here_and_dist.end(); ++glob_hloc_dloc ) - { - int cell_here = glob_hloc_dloc->second.first; - int cell_dist = glob_hloc_dloc->second.second; - medGeometryElement type_here = _loc_mesh ->getElementType( MED_CELL, cell_here ); - medGeometryElement type_dist = _dist_mesh->getElementType( MED_CELL, cell_dist ); - const MEDMEM::CELLMODEL& model_here = getCellModel( type_here ); - - MEDSPLITTER_FaceModel* face = - MEDSPLITTER_FaceModel::getCommonFace( &_global_conn_here[iconn_here], - &_local_conn_here [iconn_here], - model_here, - &_global_conn_dist[iconn_dist], - type_dist % 100, - _first_glob_sub_id + iface); - faces_of_geom[ face->getType() ].push_back( face ); - - iconn_here += type_here % 100; - iconn_dist += type_dist % 100; - iface++; - } - } - - // clear - _glob_to_locs_here_and_dist.clear(); - _global_conn_here.clear(); - _global_conn_dist.clear(); - _local_conn_here.clear(); - _local_conn_dist.clear(); - - return cz; -} - -//================================================================================ -/*! - * \brief Set local and global conncetivity of joint cells - */ -//================================================================================ - -void JointExchangeData::setConnectivity(const int* glob_fused_nodes) -{ - _global_conn_here.reserve( _conn_here_size ); - _local_conn_here.reserve ( _conn_here_size ); - const int* conn = _loc_mesh->getConnectivity(MED_NODAL, MED_CELL, MED_ALL_ELEMENTS); - const int* index = _loc_mesh->getConnectivityIndex(MED_NODAL, MED_CELL); - - TGlob2LocsHD::iterator glob_locs_here_dist = _glob_to_locs_here_and_dist.begin(); - TGlob2LocsHD::iterator glob_locs_here_dist_end = _glob_to_locs_here_and_dist.end(); - for ( ; glob_locs_here_dist != glob_locs_here_dist_end; ++glob_locs_here_dist ) - { - int loc_cell_h = glob_locs_here_dist->second.first; - _local_conn_here.insert( _local_conn_here.end(), - conn + index[ loc_cell_h-1 ]- 1, - conn + index[ loc_cell_h ]- 1); - } - for ( int i = 0; i < _conn_here_size; ++i ) - _global_conn_here.push_back( glob_fused_nodes[ _local_conn_here[i]-1 ]); -} diff --git a/src/MEDSPLITTER/MEDSPLITTER_JointExchangeData.hxx b/src/MEDSPLITTER/MEDSPLITTER_JointExchangeData.hxx deleted file mode 100644 index 225e58ff2..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_JointExchangeData.hxx +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2007-2013 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 -// -// File : MEDSPLITTER_JointExchangeData.hxx -// Created : Wed Jul 22 15:29:44 2009 -// Author : Edward AGAPOV (eap) - - -#ifndef __MEDSPLITTER_JointExchangeData_HXX__ -#define __MEDSPLITTER_JointExchangeData_HXX__ - -#include "MEDSPLITTER_Topology.hxx" - -#include -#include - -namespace MEDMEM -{ - class MESH; - class CONNECTZONE; - class MEDSKYLINEARRAY; -} - -namespace MEDSPLITTER -{ - /*! - * \brief Class storing data of the joint between domains residing different procs. - * It also provides services to pack/unpack data to be exchanged between proc and - * it creates MEDMEM::CONNECTZONE after data exchange. - */ - class JointExchangeData - { - public: - - JointExchangeData(); - - // Store cell/cell pair of joint between domains (residing different procs by default) - void addCellCorrespondence(const MEDMEM::MESH* mesh_here, - int domain_dist, int domain_here, - int glob_dist, int glob_here, - int loc_here, int loc_dist = -1 ); - - // Return nb of cell pairs - int nbCellPairs() const { return _glob_to_locs_here_and_dist.size(); } - - // Stores meshes and corresponding domain ids - void setMeshes( int domain_dist, const MEDMEM::MESH* mesh_dist, - int domain_here, const MEDMEM::MESH* mesh_here); - - // Stores local and global connectivity of joint cells on this proc - void setConnectivity( const int* glob_fused_nodes); - - int distantDomain() const { return _dist_domain; } - int localDomain() const { return _loc_domain; } - - // Exchanging - int serialize (std::vector & out_data) const; - void deserialize(const std::vector & in_data); - - //!< Set starting global id for sub-entitis of joint to create - void setFisrtGlobalIdOfSubentity(int id) { _first_glob_sub_id = id; } - - // Create MEDSKYLINEARRAY describing cell/cell correspondencies of the joint - MEDMEM::MEDSKYLINEARRAY* makeCellCorrespArray() const; - - // Creates CONNECTZONE - MEDMEM::CONNECTZONE* makeConnectZone(TGeom2FacesByDomian& face_map); - - private: - - // map global cell id on of procs to pair of local cell ids: here and distant - typedef std::multimap > TGlob2LocsHD; - TGlob2LocsHD _glob_to_locs_here_and_dist; - - int _dist_domain, _loc_domain, _conn_here_size, _nb_cell_pairs, _first_glob_sub_id; - - const MEDMEM::MESH* _dist_mesh; - const MEDMEM::MESH* _loc_mesh; - - std::vector _global_conn_here, _global_conn_dist; - std::vector _local_conn_here, _local_conn_dist; - - }; -} -#endif diff --git a/src/MEDSPLITTER/MEDSPLITTER_MESHCollection.H b/src/MEDSPLITTER/MEDSPLITTER_MESHCollection.H deleted file mode 100644 index d89dd517b..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_MESHCollection.H +++ /dev/null @@ -1,287 +0,0 @@ -// Copyright (C) 2007-2013 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 __MEDSPLITTER_MESHCOLLECTION_H__ -#define __MEDSPLITTER_MESHCOLLECTION_H__ - -/*! Projects an integer or double field onto a new mesh - * - * \param old_collection initial mesh collection supporting the field - * \param fieldname name of the field to be cast - * \param itnumber time iteration number of the field to be cast - * \param ordernumber inner iteration number of the field to be cast - * \param type_of_template dummy argument passed for separate template instanciation - */ - -template -void MESHCollection::castFields (const MESHCollection& old_collection, - const string& fieldname, int itnumber, int ordernumber) -{ - char fieldchar[80]; - strcpy(fieldchar,fieldname.c_str()); - - int nb_old_domains=old_collection._topology->nbDomain(); - int nb_new_domains=_topology->nbDomain(); - - vector > element_array (_topology->nbDomain()); - - vector *> old_fields ; - - //cout << "MEDSPLITTER - reading fields from old collection"<readFields(old_fields,fieldchar, itnumber, ordernumber); - - //if (dynamic_cast*> (old_fields[0])==0) - // old_collection.getDriver()->readFieldsDouble(old_fields,fieldchar, itnumber, ordernumber); - //else - // old_collection.getDriver()->readFieldsInt(old_fields,fieldchar, itnumber, ordernumber); - //cout <<"MEDSPLITTER - end of read"< old_supports(nb_old_domains); - vector new_supports(nb_new_domains); - vector *> new_fields(nb_new_domains); - - for (int iold = 0; iold < nb_old_domains; iold++) - { - old_supports[iold]=old_fields[iold]->getSupport(); - } - for (int inew = 0; inew < nb_new_domains; inew++) - { - new_supports[inew]=new MEDMEM::SUPPORT(); - } - - //cout << "MEDSPLITTER - casting supports"<getNumberOfComponents(); - const string* components_names = old_fields[0]->getComponentsNames(); - const string* components_description = old_fields[0]->getComponentsDescriptions(); - const string* components_units = old_fields[0]->getMEDComponentsUnits(); - if (itnumber != old_fields[0]->getIterationNumber()) {cout << "PB with iteration number"<getIterationNumber(); - int order_number=old_fields[0]->getOrderNumber(); - double time=old_fields[0]->getTime(); - bool has_gauss_pts = old_fields[0]->getGaussPresence(); - //bool has_gauss_pts=true; - - // Creating the fields objects - // Two different procedures are used whether the field contains Gauss points - // or not - - vector *> medarray (nb_new_domains); - - for (int inew=0; inew < nb_new_domains; inew++) - { - if (!has_gauss_pts) { - new_fields[inew] = new MEDMEM::FIELD(new_supports[inew],nb_components); - new_fields[inew]->setName(fieldname); - new_fields[inew]->setComponentsNames(components_names); - new_fields[inew]->setComponentsDescriptions(components_description); - new_fields[inew]->setMEDComponentsUnits(components_units); - new_fields[inew]->setIterationNumber(iteration_number); - new_fields[inew]->setOrderNumber(order_number); - new_fields[inew]->setTime(time); - } - if (has_gauss_pts) - { - new_fields[inew]=new MEDMEM::FIELD(); - //copying the structures describing the field - new_fields[inew]->setNumberOfComponents(nb_components); - new_fields[inew]->setSupport(new_supports[inew]); - new_fields[inew]->setName(fieldname); - new_fields[inew]->setComponentsNames(components_names); - new_fields[inew]->setComponentsDescriptions(components_description); - new_fields[inew]->setMEDComponentsUnits(components_units); - new_fields[inew]->setIterationNumber(iteration_number); - new_fields[inew]->setOrderNumber(order_number); - new_fields[inew]->setTime(time); - - //counters for the gauss points - //nbtypegeo is the number of geometric types on the field - //nbelgeoc is the count of element for each type - //nbgaussgeo is the number of gauss points for each type - int nbtypegeo=0; - int* nbelgeoc=0; - int* nbgaussgeo=0; - - vector gauss_pts_number; - vector nb_elem; - - // the GaussLocalization structures are browsed in the old field - // and copied to the new one - // the nbtypegeo counter is incremented so that - // it contains the number of types for which a gauss localization is defined - MED_EN::MESH_ENTITIES::const_iterator currentEntity; - std::list::const_iterator iter; - currentEntity = MED_EN::meshEntities.find(MED_EN::MED_CELL); - for (iter = (*currentEntity).second.begin();iter != (*currentEntity).second.end(); iter++) - { - // getGaussLocalization throws an exception - // if the GaussLocalization is not available - try - { - MEDMEM::GAUSS_LOCALIZATION - gaussloc(old_fields[0]->getGaussLocalization(*iter)); - new_fields[inew]->setGaussLocalization(*iter,gaussloc); - - nbtypegeo++; - gauss_pts_number.push_back(gaussloc.getNbGauss()); - - nb_elem.push_back(new_supports[inew]->getNumberOfElements(*iter)); - } - catch(...) - { - continue; - } - } - - // les tableaux nbelgeoc commencent a 1 - nbelgeoc = new int [nbtypegeo+1]; - nbgaussgeo= new int [nbtypegeo+1]; - int size=0; - nbelgeoc[0]=0; - nbgaussgeo[0]=-1; - for (int i=1; i<=nbtypegeo;i++) - { - size+=nb_elem[i-1]; - nbelgeoc [i]=nb_elem[i-1]+nbelgeoc[i-1]; - nbgaussgeo[i]=gauss_pts_number[i-1]; - } - - //a MEDMEM_Array structure is created to contain - //the data on the Gauss points - - medarray[inew]=new MEDMEM::MEDMEM_Array - (new_fields[inew]->getNumberOfComponents(), size, nbtypegeo, - static_cast(nbelgeoc), - static_cast (nbgaussgeo)); - new_fields[inew]->setArray(medarray[inew]); - // delete[] nbelgeoc; - // delete[] nbgaussgeo; - } - } - - for (int idomain=0; idomain < old_collection._topology->nbDomain(); idomain++) - { - //retrieves the group igroup on domain idomain - - const MEDMEM::SUPPORT* support = old_supports[idomain]; - int nbelem = support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - if (nbelem==0) continue; - int* list_of_elems=0; - - if (support->isOnAllElements()) - { - list_of_elems = new int[nbelem]; - for (int i=0; i (support->getNumber(MED_EN::MED_ALL_ELEMENTS)); - - int* array=new int[nbelem]; - int* ip=0; - int* local=0; - int* initial_local=0; - int* full_array=0; - - int size=0; - MED_EN::medEntityMesh entity = support->getEntity(); - switch (entity) - { - case MED_EN::MED_CELL : - ip=new int[nbelem]; - local=new int[nbelem]; - initial_local=list_of_elems; - old_collection.getTopology()->convertCellToGlobal(idomain,list_of_elems,nbelem,array); - _topology->convertGlobalCellList(array,nbelem,local,ip); - size=nbelem; - break; - case MED_EN::MED_FACE : - old_collection.getTopology()->convertFaceToGlobal(idomain,list_of_elems,nbelem,array); - _topology->convertGlobalFaceListWithTwins(array,nbelem,local,ip,full_array,size); - initial_local=new int[size]; - old_collection.getTopology()->convertGlobalFaceList(full_array,size,initial_local,idomain); - delete[] full_array; - break; - case MED_EN::MED_NODE : - old_collection.getTopology()->convertNodeToGlobal(idomain,list_of_elems,nbelem,array); - _topology->convertGlobalNodeListWithTwins(array,nbelem,local,ip,full_array,size); - initial_local=new int[size]; - old_collection.getTopology()->convertGlobalNodeList(full_array,size,initial_local,idomain); - delete[] full_array; - break; - } - - if (!has_gauss_pts) { - for (int i=0; igetValueIJ(initial_local[i],j+1); - - new_fields[ip[i]]->setValueIJ(local[i],j+1, value); - } - } - } - else - { - for (int i=0; igetElementType(entity,initial_local[i]); - int nb_gauss_points=old_fields[idomain]->getNumberOfGaussPoints(type); - for (int j=0; jgetValueIJK(initial_local[i],j+1,k+1); - medarray[ip[i]]->setIJK(local[i],j+1,k+1, value); - } - } - } - delete[]array; - delete[]ip; - delete[]local; - if (support->isOnAllElements()) - { - delete[] list_of_elems; - list_of_elems=0; - } - if (entity==MED_EN::MED_FACE || entity==MED_EN::MED_NODE) delete[] initial_local; - } - - retrieveDriver()->writeFields(new_fields,fieldchar); - //if (dynamic_cast*>(new_fields[0])==0) - // retrieveDriver()->writeFieldsDouble(new_fields,fieldchar); - //else - // retrieveDriver()->writeFieldsInt(new_fields,fieldchar); - for (int i=0; iremoveReference(); - new_supports[i]->removeReference(); - //delete medarray[i]; - } - for (unsigned i=0; iremoveReference(); - //old_supports[i]->removeReference();//as we did not addReference() neither created it - } -} - -#endif /*MEDSPLITTER_MESHCOLLECTION_H_*/ diff --git a/src/MEDSPLITTER/MEDSPLITTER_MESHCollection.cxx b/src/MEDSPLITTER/MEDSPLITTER_MESHCollection.cxx deleted file mode 100644 index 03a870352..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_MESHCollection.cxx +++ /dev/null @@ -1,2449 +0,0 @@ -// Copyright (C) 2007-2013 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 "MEDMEM_ConnectZone.hxx" -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_GaussLocalization.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_MeshFuse.hxx" - -#include "MEDMEM_Exception.hxx" - -#include "MEDSPLITTER_utils.hxx" - -#include "MEDSPLITTER_Graph.hxx" - -#include "MEDSPLITTER_Topology.hxx" -#include "MEDSPLITTER_ParallelTopology.hxx" -#include "MEDSPLITTER_SequentialTopology.hxx" -#include "MEDSPLITTER_ParaDomainSelector.hxx" -#include "MEDSPLITTER_MeshSendReceive.hxx" -#include "MEDSPLITTER_JointExchangeData.hxx" - -#include "MEDSPLITTER_MESHCollection.hxx" -#include "MEDSPLITTER_MESHCollectionDriver.hxx" -#include "MEDSPLITTER_MESHCollectionMedXMLDriver.hxx" -#include "MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx" - -#include "MEDSPLITTER_UserGraph.hxx" - -#if defined(MED_ENABLE_METIS) || defined(MED_ENABLE_PARMETIS) -#include "MEDSPLITTER_METISGraph.hxx" -#endif -#ifdef MED_ENABLE_SCOTCH -#include "MEDSPLITTER_SCOTCHGraph.hxx" -#endif - -#include "InterpKernelHashMap.hxx" - -#include -#include -#include - -#include -#include - -using namespace MEDSPLITTER; - -using namespace INTERP_KERNEL; - -//template inclusion -#include "MEDSPLITTER_MESHCollection.H" - -MESHCollection::MESHCollection() - : _topology(0), - _owns_topology(false), - _driver(0), - _domain_selector( 0 ), - _i_non_empty_mesh(-1), - _driver_type(MEDSPLITTER::MedXML), - _subdomain_boundary_creates(false), - _family_splitting(false), - _create_empty_groups(false) -{ -} - -namespace -{ - //================================================================================ - /*! - * \brief Creates a new domain mesh - */ - //================================================================================ - - MEDMEM::MESH* newMesh(const std::string& name, int dim, int space, MEDMEM::MESH* meshToDelete=0) - { - delete meshToDelete; - MEDMEM::MESHING* mesh = new MEDMEM::MeshFuse; - mesh->setName( name ); - //mesh->setMeshDimension ( dim ); - //mesh->setSpaceDimension( space ); - return mesh; - } -} - -/*!constructor creating a new mesh collection (mesh series + topology) - *from an old collection and a new topology - * - * On output, the constructor has built the meshes corresponding to the new mesh collection. - * The new topology has been updated so that face and node mappings are included. - * The families have been cast to their projections in the new topology. - * - * \param initial_collection collection from which the data (coordinates, connectivity) are taken - * \param topology topology containing the cell mappings - */ - -MESHCollection::MESHCollection(const MESHCollection& initial_collection, Topology* topology, bool family_splitting, bool create_empty_groups) - : _topology(topology), - _owns_topology(false), - _cell_graph(topology->getGraph()), - _driver(0), - _domain_selector( initial_collection._domain_selector ), - _i_non_empty_mesh(-1), - _name(initial_collection._name), - _driver_type(MEDSPLITTER::MedXML), - _subdomain_boundary_creates(false), - _family_splitting(family_splitting), - _create_empty_groups(create_empty_groups) -{ - string mesh_name = initial_collection.getName(); - _mesh.resize(_topology->nbDomain()); - - int space_dim = initial_collection.getSpaceDimension(); - int mesh_dim = initial_collection.getMeshDimension(); - if ( mesh_dim < 1 ) - space_dim = mesh_dim = initial_collection._driver->readMeshDimension(); - - for (int idomain=0; idomain < _topology->nbDomain(); idomain++) - { - //creating the new mesh - _mesh[idomain]= newMesh( MEDMEM::STRING(mesh_name)<<"_"<getNumberOfNodes() > 0 ) - _i_non_empty_mesh = idomain; - } - - _topology->createFaceMapping(initial_collection, *this ); - for (int idomain=0; idomain<_topology->nbDomain(); idomain++) - { - switch (mesh_dim) - { - case 3: - createNodalConnectivity(initial_collection,idomain, MED_EN::MED_FACE); - break; - case 2: - createNodalConnectivity(initial_collection,idomain, MED_EN::MED_EDGE); - break; - default : - if ( !isParallelMode() || _domain_selector->isMyDomain( idomain )) - cerr<<"MEDSPLITTER : Mesh dimension must be 2 or 3"<setNbDomains( _topology->nbDomain() ); - - vector< MeshSendReceive > mesh_sender( _topology->nbDomain() ); - list domainsToClear; // sent domains - bool isSent; - // first, send domains - for (int idomain=0; idomain<_topology->nbDomain(); idomain++) - { - // get node numbers global over all procs - vector glob_nodes_all_proc( _topology->getNodeNumber( idomain )); // to fill in - vector glob_cells_all_proc( _topology->getCellNumber( idomain )); - vector glob_faces_all_proc( _topology->getFaceNumber( idomain )); - if ( !glob_cells_all_proc.empty() ) - { - // get ids global on this proc - _topology->getNodeList( idomain, & glob_nodes_all_proc[0] ); - _topology->getCellList( idomain, & glob_cells_all_proc[0] ); - _topology->getFaceList( idomain, & glob_faces_all_proc[0] ); - // convert cell ids to ids global over all procs - int cell_shift = _domain_selector->getProcShift(); - for ( int i = 0; i < glob_cells_all_proc.size(); ++i ) - glob_cells_all_proc[i] += cell_shift; - } - if ( _domain_selector->isMyDomain( idomain )) - { - // prepare to receiving other parts of the domain - ((MEDMEM::MeshFuse*) _mesh[idomain])->setNodeNumbers( glob_nodes_all_proc ); - _topology->getFusedCellNumbers( idomain ) = glob_cells_all_proc; - _topology->getFusedFaceNumbers( idomain ) = glob_faces_all_proc; - } - else - { - // sending - int target_proc = _domain_selector->getProccessorID( idomain ); - mesh_sender[ idomain ].send( target_proc, idomain, _mesh[idomain], - glob_cells_all_proc, - glob_faces_all_proc, - glob_nodes_all_proc ); - if ( !glob_nodes_all_proc.empty() ) - domainsToClear.push_back( idomain ); - } - // clear just sent domain meshes - for ( list::iterator dom = domainsToClear.begin(); dom != domainsToClear.end(); ) - { - if (( isSent = mesh_sender[ *dom ].isSent() )) - _mesh[*dom] = newMesh( _mesh[*dom]->getName(), mesh_dim, space_dim, _mesh[*dom]); - dom = isSent ? domainsToClear.erase( dom ) : ++dom; - } - } - - // then, receive domains - MeshSendReceive mesh_receiver; - int this_proc = _domain_selector->rank(); - for (int idomain=0; idomain<_topology->nbDomain(); idomain++) - { - if ( _domain_selector->isMyDomain( idomain )) - { - for (int iproc = 0; iproc < _domain_selector->nbProcs(); ++iproc) - { - if ( iproc == this_proc ) continue; - vector nodes_other_proc, cells_other_proc, faces_other_proc; - mesh_receiver.recv( iproc, idomain, cells_other_proc, faces_other_proc,nodes_other_proc); - if ( MEDMEM::MESH* received_mesh = mesh_receiver.getMesh() ) - { - // unite meshes and global node numbers stored in MeshFuse - MEDMEM::MeshFuse* fuse = (MEDMEM::MeshFuse*) _mesh[idomain]; - fuse->concatenate( received_mesh, nodes_other_proc ); - delete received_mesh; - - // unite global element numbers - fuse->append( MED_EN::MED_CELL, - _topology->getFusedCellNumbers( idomain ), cells_other_proc ); - - fuse->append( mesh_dim==3 ? MED_EN::MED_FACE : MED_EN::MED_EDGE, - _topology->getFusedFaceNumbers( idomain ), faces_other_proc ); - - if ( _mesh[idomain]->getNumberOfNodes() > 0 ) - _i_non_empty_mesh = idomain; - } - } - } - // clear just sent domain meshes - for ( list::iterator dom = domainsToClear.begin(); dom != domainsToClear.end(); ) - { - if (( isSent = mesh_sender[ *dom ].isSent() )) - _mesh[*dom] = newMesh( _mesh[*dom]->getName(), mesh_dim, space_dim,_mesh[*dom]); - dom = isSent ? domainsToClear.erase( dom ) : ++dom; - } - } - // clear sent domain meshes - mesh_sender.clear(); - for ( list::iterator dom = domainsToClear.begin(); dom != domainsToClear.end(); ++dom) - _mesh[*dom] = newMesh( _mesh[*dom]->getName(), mesh_dim, space_dim,_mesh[*dom]); - - _topology->recreateMappingAfterFusion( getMesh() ); - } - if ( _i_non_empty_mesh < 0 ) // non of domains resides on this proc, - _i_non_empty_mesh = 0; // in this case we need only dimension that is set to all meshes - -} - -/*! constructing the MESH collection from a distributed file - * - * \param filename name of the master file containing the list of all the MED files - */ -MESHCollection::MESHCollection(const string& filename) - : _topology(0), - _owns_topology(true), - _driver(0), - _domain_selector( 0 ), - _i_non_empty_mesh(-1), - _driver_type(MEDSPLITTER::Undefined), - _subdomain_boundary_creates(false), - _family_splitting(false), - _create_empty_groups(false) -{ - char filenamechar[256]; - strcpy(filenamechar,filename.c_str()); - try - { - _driver=new MESHCollectionMedXMLDriver(this); - _driver->read (filenamechar); - _driver_type = MedXML; - - } - catch(MEDEXCEPTION&){ - delete _driver; - try - { - _driver=new MESHCollectionMedAsciiDriver(this); - _driver->read (filenamechar); - _driver_type=MedAscii; - } - catch(MEDEXCEPTION&) - { - delete _driver; - throw MEDEXCEPTION("file does not comply with any recognized format"); - } - } - for ( int idomain = 0; idomain < _mesh.size(); ++idomain ) - if ( _mesh[idomain] && _mesh[idomain]->getNumberOfNodes() > 0 ) - _i_non_empty_mesh = idomain; -} - -/*! Constructing the MESH collection from selected domains of a distributed file - * - * \param filename - name of the master file containing the list of all the MED files - * \param domainSelector - selector of domains to load - */ -MESHCollection::MESHCollection(const string& filename, ParaDomainSelector& domainSelector) - : _topology(0), - _owns_topology(true), - _driver(0), - _domain_selector( domainSelector.nbProcs() > 1 ? & domainSelector : 0 ), - _i_non_empty_mesh(-1), - _driver_type(MEDSPLITTER::Undefined), - _subdomain_boundary_creates(false), - _family_splitting(false), - _create_empty_groups(false) -{ - try - { - _driver=new MESHCollectionMedXMLDriver(this); - _driver->read ( (char*)filename.c_str(), _domain_selector ); - _driver_type = MedXML; - } - catch(MEDEXCEPTION&) - { - delete _driver; - try - { - _driver=new MESHCollectionMedAsciiDriver(this); - _driver->read ( (char*)filename.c_str(), _domain_selector ); - _driver_type=MedAscii; - } - catch(MEDEXCEPTION&) - { - delete _driver; - throw MEDEXCEPTION("file does not comply with any recognized format"); - } - } - if ( isParallelMode() ) - // to know nb of cells on each proc to compute global cell ids from locally global - _domain_selector->gatherNbOf( MED_EN::MED_CELL, getMesh() ); - - // find non-empty domain mesh - for ( int idomain = 0; idomain < _mesh.size(); ++idomain ) - if ( _mesh[idomain] && _mesh[idomain]->getNumberOfNodes() > 0 ) - _i_non_empty_mesh = idomain; -} - -/*! constructing the MESH collection from a sequential MED-file - * - * \param filename MED file - * \param meshname name of the mesh that is to be read - */ -MESHCollection::MESHCollection(const string& filename, const string& meshname) - : _topology(0), - _owns_topology(true), - _driver(0), - _domain_selector( 0 ), - _i_non_empty_mesh(-1), - _name(meshname), - _driver_type(MEDSPLITTER::MedXML), - _subdomain_boundary_creates(false), - _family_splitting(false), - _create_empty_groups(false) -{ - char filenamechar[256]; - char meshnamechar[256]; - strcpy(filenamechar,filename.c_str()); - strcpy(meshnamechar,meshname.c_str()); - try // avoid memory leak in case of inexistent filename - { - retrieveDriver()->readSeq (filenamechar,meshnamechar); - } - catch ( MED_EXCEPTION& e ) - { - if ( _driver ) delete _driver; _driver=0; - throw e; - } - if ( _mesh[0] && _mesh[0]->getNumberOfNodes() > 0 ) - _i_non_empty_mesh = 0; -} - -MESHCollection::~MESHCollection() -{ - for (unsigned i=0; i<_mesh.size();i++) - if (_mesh[i]!=0) {/*delete*/ _mesh[i]->removeReference(); } - for (unsigned i=0; i<_connect_zones.size();i++) - if (_connect_zones[i]!=0) {delete _connect_zones[i];} - if (_driver !=0) {delete _driver; _driver=0;} - if (_topology!=0 && _owns_topology) {delete _topology; _topology=0;} -} - -/*!gets the connectivity for a certain type - * - * The output array type_connectivity should have been allocated - * at dimension nbnode_per_type* nb_cells before the call - * - * \param cell_list list of elements (global cell numbers) for which the connectivity is required - * \param nb_cells number of elements - * \param entity type of entity for which the nodal connectivity is required - * \param type type of the elements for which the connectivity is required - * \param type_connectivity on output contains the connectivity of all the elements of the list - * */ - -void MESHCollection::getNodeConnectivity(const int* cell_list,int nb_cells,MED_EN::medEntityMesh entity, - MED_EN::medGeometryElement type, int* type_connectivity) const -{ - int *local=new int[nb_cells]; - int *ip=new int[nb_cells]; - switch (entity) - { - case MED_EN::MED_CELL: - _topology->convertGlobalCellList(cell_list,nb_cells,local,ip); - break; - case MED_EN::MED_FACE: - case MED_EN::MED_EDGE: - _topology->convertGlobalFaceList(cell_list,nb_cells,local,ip); - break; - } - - - // int nbnode_per_type=(int)type%100; - // vector number_of_types_array(_topology->nbDomain(),0); - // for (int i=0; i<_topology->nbDomain(); i++) - // number_of_types_array[i]=_mesh[i]->getNumberOfTypes(entity); - - //defining a connectivity table for different domains - vector conn_ip(_topology->nbDomain()); - vector conn_index_ip(_topology->nbDomain()); - - - vector< map > offset; - // offset.resize(_topology->nbDomain()); - - for (int i=0; i<_topology->nbDomain();i++) - { - if ( !_mesh[i] ) continue; - int nb_elem = _mesh[i]->getNumberOfElements(entity,type); - if (nb_elem>0) - { - conn_ip[i]=_mesh[i]->getConnectivity(MED_EN::MED_NODAL,entity,MED_EN::MED_ALL_ELEMENTS); - conn_index_ip[i] = _mesh[i]->getConnectivityIndex(MED_EN::MED_NODAL,entity); - // global_index= _mesh[i]->getGlobalNumberingIndex(entity); - } - else - { - conn_ip[i]=0; - conn_index_ip[i]=0; - } - // int number_of_types = number_of_types_array[i]; - // const MEDMEM::CELLMODEL* types = _mesh[ip[icell]]->getCellsTypes(entity); - // for (int itype=0; itypeconvertNodeToGlobal(ip[icell],conn[inode-1]); - type_connectivity_ptr++; - } - } - - delete[]local; - delete[]ip; -} - -/*!gets the connectivity for MED_POLYGON type - * - * \param cell_list list of elements (global cell numbers) for which the connectivity is required - * \param nb_cells number of elements - * \param entity type of entity for which the nodal connectivity is required - * \param type_connectivity on output contains the connectivity of all the elements of the list - * \param connectivity_index on output contains the connectivity index for all polygons - * */ - -void MESHCollection::getPolygonNodeConnectivity(const int* cell_list,int nb_cells,MED_EN::medEntityMesh entity, - vector& type_connectivity, vector& connectivity_index) const -{ - - int *local=new int[nb_cells]; - int *ip=new int[nb_cells]; - switch (entity) - { - case MED_EN::MED_CELL: - _topology->convertGlobalCellList(cell_list,nb_cells,local,ip); - break; - case MED_EN::MED_FACE: - case MED_EN::MED_EDGE: - _topology->convertGlobalFaceList(cell_list,nb_cells,local,ip); - break; - } - - - //defining a connectivity table for different domains - vector conn_ip(_topology->nbDomain()); - vector conn_index_ip(_topology->nbDomain()); - vector conn_face_index(_topology->nbDomain()); - vector nb_plain_elems(_topology->nbDomain()); - - vector< map > offset; - - for (int i=0; i<_topology->nbDomain();i++) - { - int nb_elem = _mesh[i]->getNumberOfElements(entity,MED_EN::MED_POLYGON); - if (nb_elem>0) - { - conn_ip[i]=_mesh[i]->getConnectivity(MED_EN::MED_NODAL,entity,MED_EN::MED_ALL_ELEMENTS); - conn_index_ip[i] = _mesh[i]->getConnectivityIndex(MED_EN::MED_NODAL,entity); - } - else - { - conn_ip[i]=0; - conn_index_ip[i]=0; - } - } - - connectivity_index.resize(nb_cells+1); - connectivity_index[0]=1; - for (int icell=0; icellconvertNodeToGlobal(ip[icell],conn[inode-1])); - } - connectivity_index[icell+1]=connectivity_index[icell] - -conn_index[local[icell]-1/*-nb_plain*/]+conn_index[local[icell]/*-nb_plain*/]; - } - - delete[]local; - delete[]ip; -} - - -/*!gets the connectivity for MED_POLYHEDRA type - * - * \param cell_list list of elements (global cell numbers) for which the connectivity is required - * \param nb_cells number of elements - * \param entity type of entity for which the nodal connectivity is required - * \param type_connectivity on output contains the connectivity of all the elements of the list - * \param connectivity_index on output contains the connectivity index for all polygons - * */ - -void MESHCollection::getPolyhedraNodeConnectivity(const int* cell_list,int nb_cells,MED_EN::medEntityMesh entity, - vector& type_connectivity, vector& connectivity_index/*, vector& face_connectivity_index*/) const -{ - - int *local=new int[nb_cells]; - int *ip=new int[nb_cells]; - switch (entity) - { - case MED_EN::MED_CELL: - _topology->convertGlobalCellList(cell_list,nb_cells,local,ip); - break; - case MED_EN::MED_FACE: - case MED_EN::MED_EDGE: - _topology->convertGlobalFaceList(cell_list,nb_cells,local,ip); - break; - } - - - //defining a connectivity table for different domains - vector conn_ip(_topology->nbDomain()); - vector conn_index_ip(_topology->nbDomain()); - vector nb_plain_elems(_topology->nbDomain()); - - vector< map > offset; - - for (int i=0; i<_topology->nbDomain();i++) - { - nb_plain_elems[i] = _mesh[i]->getNumberOfElements(entity, MED_EN::MED_ALL_ELEMENTS); - int nb_elem = _mesh[i]->getNumberOfElements(entity,MED_EN::MED_POLYHEDRA); - if (nb_elem>0) - { - conn_ip[i]=_mesh[i]->getConnectivity(MED_EN::MED_NODAL,MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - conn_index_ip[i] = _mesh[i]->getConnectivityIndex(MED_EN::MED_NODAL,MED_EN::MED_CELL); - } - else - { - conn_ip[i]=0; - conn_index_ip[i]=0; - } - } - - connectivity_index.resize(nb_cells+1); - connectivity_index[0]=1; - for (int icell=0; icellconvertNodeToGlobal(ip[icell],conn[inode-1])); - } - - } - - delete[]local; - delete[]ip; -} - -/*! constructing the MESH collection from a file - * - * The method creates as many MED-files as there are domains in the - * collection. It also creates a master file that lists all the MED files. - * The MED files created in ths manner contain joints that describe the - * connectivity between subdomains. - * - * \param filename name of the master file that will contain the list of the MED files - * - */ -void MESHCollection::write(const string& filename) -{ - //building the connect zones necessary for writing joints - cout<<"Building Connect Zones"<nbDomain()>1) - buildConnectZones(); - cout <<"End of connect zones building"<write (filenamechar, _domain_selector); -} - -/*! creates or gets the link to the collection driver - */ -MESHCollectionDriver* MESHCollection::retrieveDriver() -{ - if (_driver==0) - { - switch(_driver_type) - { - case MedXML: - _driver=new MESHCollectionMedXMLDriver(this); - break; - case MedAscii: - _driver=new MESHCollectionMedAsciiDriver(this); - break; - default: - throw MEDEXCEPTION("Unrecognized driver"); - } - } - - return _driver; -} - - -/*! gets an existing driver - * - */ -MESHCollectionDriver* MESHCollection::getDriver() const -{ - return _driver; -} - - -/*! gets the list of types for global numbers cell_list - * - * \param cell_list list of global numbers - * \param entity entity type - * \param type_list on output, list of types for the cells given in cell_list - */ -void MESHCollection::getTypeList(int* cell_list,int nb_cells, - MED_EN::medEntityMesh entity, - MED_EN::medGeometryElement* type_list) const -{ - MESSAGE_MED (" Beginning of getTypeList with entity "<convertGlobalCellList(cell_list,nb_cells,local,ip); - break; - case MED_EN::MED_FACE: - case MED_EN::MED_EDGE: - _topology->convertGlobalFaceList(cell_list,nb_cells,local,ip); - break; - } - - for (int icell=0; icellgetElementType(entity,local[icell]); - } - delete[]local; - delete[]ip; - MESSAGE_MED("end of getTypeList"); -} - - - -/*!gets the descending connectivity for a certain type - * - * The output array type_connectivity should have been allocated - * at dimension nbnode_per_type* nb_cells before the call - * - * \param cell_list list of elements (global cell numbers) for which the connectivity is required - * \param nb_cells number of elements - * \param entity type of entity for which the nodal connectivity is required - * \param type type of the elements for which the connectivity is required - * \param type_connectivity on output contains the connectivity of all the elements of the list - * */ - -void MESHCollection::getFaceConnectivity(const int* cell_list,int nb_cells,MED_EN::medEntityMesh entity, - MED_EN::medGeometryElement type, int* type_connectivity) const -{ - int *local=new int[nb_cells]; - int *ip=new int[nb_cells]; - switch (entity) - { - case MED_EN::MED_CELL: - _topology->convertGlobalCellList(cell_list,nb_cells,local,ip); - break; - case MED_EN::MED_FACE: - case MED_EN::MED_EDGE: - _topology->convertGlobalFaceList(cell_list,nb_cells,local,ip); - break; - } - - - int nbface_per_type; - switch (type){ - case 308: - nbface_per_type=6; - break; - case 304: - nbface_per_type=4; - break; - case 306: - nbface_per_type=5; - break; - } - - vector number_of_types_array(_topology->nbDomain(),0); - for (int i=0; i<_topology->nbDomain(); i++) - number_of_types_array[i]=_mesh[i]->getNumberOfTypes(entity); - - //defining a connectivity table for different domains - vector conn_ip(_topology->nbDomain()); - for (int i=0; i<_topology->nbDomain();i++) - { - int nb_elem = _mesh[i]->getNumberOfElements(entity,type); - if (nb_elem>0) - conn_ip[i]=_mesh[i]->getConnectivity(MED_EN::MED_DESCENDING,entity,type); - else - conn_ip[i]=0; - } - - for (int icell=0; icellgetCellsTypes(entity); - int type_offset=0; - for (int itype=0; itype< number_of_types; itype++) - { - if (types[itype].getType() < type) - type_offset += _mesh[ip[icell]]->getNumberOfElements(entity,types[itype].getType()); - } - const int* conn=conn_ip[ip[icell]]; - for (int iface=0; ifaceconvertFaceToGlobal - (ip[icell], abs(conn[(local[icell] - type_offset - 1) * nbface_per_type + iface])); - } - } - - delete[]local; - delete[]ip; -} - -/*! gets the list of coordinates for a given list of global node numbers - * - * The vector containing the coordinates on output should - * have been allocated at a dimension _space_dimension * nb_nodes - * before the call - * - * \param node_list list of global node numbers - * \param nb_nodes number of nodes in the list - * \param coordinates on output, contains the coordinates - */ - -void MESHCollection::getCoordinates(int* node_list,int nb_nodes, double* coordinates) const -{ - int* local=new int[nb_nodes]; - int* ip=new int[nb_nodes]; - int space_dimension= getSpaceDimension(); - _topology->convertGlobalNodeList(node_list,nb_nodes,local,ip); - for (int i=0; i< nb_nodes; i++) - { - const double* coord=_mesh[ip[i]]->getCoordinates(MED_EN::MED_FULL_INTERLACE); - for (int icoord=0; icoordgetSpaceDimension(); -} -/*! retrieves the mesh dimension*/ -int MESHCollection::getMeshDimension() const -{ - return _i_non_empty_mesh < 0 ? -1 : _mesh[_i_non_empty_mesh]->getMeshDimension(); -} - -/*! retrieves the type of coordinates system*/ -string MESHCollection::getSystem() const -{ - return _i_non_empty_mesh < 0 ? "" : _mesh[_i_non_empty_mesh]->getCoordinatesSystem(); -} - -/*!retrieves the name of the mesh*/ -string MESHCollection::getMeshName() const -{ - return _i_non_empty_mesh < 0 ? (_mesh[0] ? _mesh[0]->getName() : "") : _mesh[_i_non_empty_mesh]->getName(); -} - -vector& MESHCollection::getMesh() -{ - return _mesh; -} - -MEDMEM::MESH* MESHCollection::getMesh(int idomain) const -{ - return _mesh[idomain]; -} - -vector& MESHCollection::getCZ() -{ - return _connect_zones; -} - -Topology* MESHCollection::getTopology() const -{ - return _topology; -} - -void MESHCollection::setTopology(Topology* topo) -{ - if (_topology!=0) - { - throw MED_EXCEPTION(STRING("Erreur : topology is already set")); - } - else - _topology = topo; -} - -void MESHCollection::setIndivisibleGroup(const string& name) -{ - _indivisible_regions.push_back(name); - -} - -/*! Browses the domains and the regions that have - * been marked as indivisible in order to create a vector - * the dimlension of which is the total number of cells, and - * that contains 0 if the cell belongs to no indivisible group - * and that contains an integer corresponding to the group otherwise. - * - * \param indivisible_tag on input is an int* allocated as int[nbcells] - * on output contains the tags - */ - - -void MESHCollection::treatIndivisibleRegions(int* indivisible_tag) -{ - //tag 0 is positioned on all the cells that are not affected by these tags - for (int i=0; i<_topology->nbCells(); i++) - indivisible_tag[i]=0; - - //treating cell groups - for (int idomain=0; idomain<_topology->nbDomain();idomain++) - for (int igroup=0; igroup<_mesh[idomain]->getNumberOfGroups(MED_EN::MED_CELL); igroup++) - for (unsigned i=0; i<_indivisible_regions.size(); i++) - { - const MEDMEM::GROUP* group = _mesh[idomain]->getGroup(MED_EN::MED_CELL,igroup+1); - string groupname = group->getName(); - if (trim(groupname)==trim(_indivisible_regions[i])) - { - int nbcells=group->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - const int* numbers=group->getNumber(MED_EN::MED_ALL_ELEMENTS); - int* global=new int[nbcells]; - _topology->convertCellToGlobal(idomain,numbers,nbcells,global); - for (int icell=0; icellnode and node->cell connectivities for domains - */ -//================================================================================ - -template -void MESHCollection::fillGlobalConnectivity(TID2CONN & node2cell, TID2CONN & cell2node ) -{ - for (int idomain=0; idomain<_topology->nbDomain(); idomain++) - { - if ( !_mesh[idomain] ) continue; - // MED_EN::medGeometryElement* type_array; - int nb_cells= _topology->nbCells(idomain); - int* cell_list = new int[nb_cells]; - - //retrieving global id list - _topology->getCellList(idomain, cell_list); - - int nb_plain_cells = _mesh[idomain]->getNumberOfElements(MED_EN::MED_CELL, - MED_EN::MED_ALL_ELEMENTS); - if (nb_plain_cells >0) - { - const int* conn_index = _mesh[idomain]->getConnectivityIndex(MED_EN::MED_NODAL, - MED_EN::MED_CELL); - - const int* conn = _mesh[idomain]->getConnectivity(MED_EN::MED_NODAL, - MED_EN::MED_CELL, - MED_EN::MED_ALL_ELEMENTS); - int nbnodes = conn_index[nb_plain_cells]-1; - int* global_nodes =new int [nbnodes]; - _topology->convertNodeToGlobal(idomain, conn, nbnodes, global_nodes); - for (int icell=0; icell< nb_plain_cells; icell++) - { - for (int inode=conn_index[icell]; inode < conn_index[icell+1]; inode++) - { - int node_global_id = global_nodes[inode-1]; - if ( node_global_id > 0 ) - { - int cell_global_id = cell_list[icell]; - cell2node [cell_global_id].push_back(node_global_id); - node2cell [node_global_id].push_back(cell_global_id); - } - } - } - delete[] global_nodes; - } - - delete[] cell_list; - } -} - -/*! Method creating the cell graph - * - * \param array returns the pointer to the structure that contains the graph - * \param edgeweight returns the pointer to the table that contains the edgeweights - * (only used if indivisible regions are required) - */ - -void MESHCollection::buildCellGraph(MEDMEM::MEDSKYLINEARRAY* & array,int *& edgeweights ) -{ - - int cell_number=1; - int node_number=1; - for (int i=0; i<_topology->nbDomain(); i++) - { - cell_number+=_topology->getCellNumber(i); - node_number+=_topology->getNodeNumber(i); - } - //list of cells for a given node - //vector< vector > node2cell(node_number); - map< int, vector > node2cell; - - //list of nodes for a given cell - //vector< vector > cell2node(cell_number); - map< int, vector > cell2node; - - // map type_cell_list; - - //tagging for the indivisible regions - int* indivisible_tag=0; - bool has_indivisible_regions=false; - if (!_indivisible_regions.empty()) - { - has_indivisible_regions=true; - indivisible_tag=new int[_topology->nbCells()]; - treatIndivisibleRegions(indivisible_tag); - } - - fillGlobalConnectivity(node2cell, cell2node ); - - cout << "beginning of skyline creation"<nbCells()]; - int** temp=new int*[_topology->nbCells()]; - int** temp_edgeweight=0; - if (has_indivisible_regions) - temp_edgeweight=new int*[_topology->nbCells()]; - - int cell_glob_shift = 0; - - // Get connection to cells on other procs - multimap< int, int > loc2dist; // global cell ids on this proc -> other proc cells - if ( isParallelMode() ) - { - cell_glob_shift = _domain_selector->getProcShift(); - - set loc_domains; // domains on this proc - for ( int idom = 0; idom < _mesh.size(); ++idom ) - if ( _mesh[ idom ] ) - loc_domains.insert( idom ); - - for ( int idom = 0; idom < _mesh.size(); ++idom ) - { - if ( !_mesh[idom] ) continue; - vector loc2glob_corr; // pairs of corresponding cells (loc_loc & glob_dist) - retrieveDriver()->readLoc2GlobCellConnect(idom, loc_domains, _domain_selector, loc2glob_corr); - //MEDMEM::STRING out; - for ( int i = 0; i < loc2glob_corr.size(); i += 2 ) - { - int glob_here = _topology->convertCellToGlobal(idom,loc2glob_corr[i]); - int glob_there = loc2glob_corr[i+1]; - loc2dist.insert ( make_pair( glob_here, glob_there)); - //out << glob_here << "-" << glob_there << " "; - } - //cout << "\nRank " << _domain_selector->rank() << ": BndCZ: " << out << endl; - } - } - - //going across all cells - - map cells_neighbours; - for (int i=0; i< _topology->nbCells(); i++) - { - - - vector cells(50); - - for (unsigned inode=0; inode< cell2node[i+1].size(); inode++) - { - int nodeid=cell2node[i+1][inode]; - for (unsigned icell=0; icell::const_iterator iter=cells_neighbours.begin(); iter != cells_neighbours.end(); iter++) - { - if (iter->second >= dimension && iter->first != i+1) - { - cells.push_back(iter->first + cell_glob_shift); - // cells[isize++]=iter->first; - } - } - // add neighbour cells from distant domains - multimap< int, int >::iterator loc_dist = loc2dist.find( i+1 ); - for (; loc_dist!=loc2dist.end() && loc_dist->first==( i+1 ); ++loc_dist ) - cells.push_back( loc_dist->second ); - - size[i]=cells.size(); - - temp[i]=new int[size[i]]; - if (has_indivisible_regions) - temp_edgeweight[i]=new int[size[i]]; - // - int itemp=0; - - for (vector::const_iterator iter=cells.begin(); iter!=cells.end();iter++) - { - temp[i][itemp]=*iter; - if (has_indivisible_regions) - { - int tag1 = indivisible_tag[(i+1)-1]; - int tag2 = indivisible_tag[*iter-1]; - if (tag1==tag2 && tag1!=0) - temp_edgeweight[i][itemp]=_topology->nbCells()*100000; - else - temp_edgeweight[i][itemp]=1; - } - itemp++; - } - cells_neighbours.clear(); - } - cout <<"end of graph definition"<nbCells()+1]; - index[0]=1; - for (int i=0; i<_topology->nbCells(); i++) - index[i+1]=index[i]+size[i]; - - node2cell.clear(); - cell2node.clear(); - if (indivisible_tag!=0) delete [] indivisible_tag; - - //SKYLINEARRAY structure holding the cell graph - array= new MEDMEM::MEDSKYLINEARRAY(_topology->nbCells(),index[_topology->nbCells()]-index[0]); - array->setIndex(index); - - for (int i=0; i<_topology->nbCells(); i++) - { - array->setI(i+1,temp[i]); - delete[]temp[i]; - } - - if (has_indivisible_regions) - { - edgeweights=new int[array->getLength()]; - for (int i=0; i<_topology->nbCells(); i++) - { - for (int j=index[i]; j0"); - MEDMEM::MEDSKYLINEARRAY* array=0; - int* edgeweights=0; - - MESSAGE_MED("Building cell graph"); - buildCellGraph(array,edgeweights); - - switch (split) - { - case Graph::METIS: -#if defined(MED_ENABLE_METIS) || defined(MED_ENABLE_PARMETIS) - _cell_graph=boost::shared_ptr(new METISGraph(array,edgeweights)); -#else - throw MEDEXCEPTION("METIS Graph is not available. Check your products, please."); -#endif - break; - case Graph::SCOTCH: -#ifdef MED_ENABLE_SCOTCH - _cell_graph=boost::shared_ptr(new SCOTCHGraph(array,edgeweights)); -#else - throw MEDEXCEPTION("SCOTCH Graph is not available. Check your products, please."); -#endif - break; - } - - //!user-defined weights - if (user_edge_weights!=0) - _cell_graph->setEdgesWeights(user_edge_weights); - if (user_vertices_weights!=0) - _cell_graph->setVerticesWeights(user_vertices_weights); - - MESSAGE_MED("Partitioning graph"); - _cell_graph->partGraph(nbdomain,options_string,_domain_selector); - - // DEBUG -// MEDMEM::STRING out("RESULT GRAPH #"); -// out << (_domain_selector?_domain_selector->rank():0) << ": "; -// const int* part = _cell_graph->getPart(); -// int n = _cell_graph->nbVertices(); -// for ( int e=0; e < n; ++e ) -// out << part[e] <<" "; -// cout << out << endl; - - - MESSAGE_MED("Building new topology"); - //_cell_graph is a shared pointer - Topology* topology = new ParallelTopology (_cell_graph, nbdomain, getMeshDimension()); - - //cleaning - if (edgeweights!=0) delete[] edgeweights; - //if (array!=0) delete array; - MESSAGE_MED("End of partition creation"); - return topology; -} - -/*! Creates a topology for a partition specified by the user - * - * \param table user-specified partition (for each cell contains the domain number from 0 to n-1) - * - * returns a topology based on the new partition - */ -Topology* MESHCollection::createPartition(const int* partition) -{ - MEDMEM::MEDSKYLINEARRAY* array=0; - int* edgeweights=0; - - buildCellGraph(array,edgeweights); - - set domains; - for (int i=0; i<_topology->nbCells(); i++) - { - domains.insert(partition[i]); - } - int nbdomain=domains.size(); - - _cell_graph=boost::shared_ptr(new UserGraph(array, partition, _topology->nbCells())); - - //_cell_graph is a shared pointer - Topology* topology = new ParallelTopology (_cell_graph, nbdomain, getMeshDimension()); - - //if (array!=0) delete array; - return topology; -} - - -/*! building Connect Zones for storing the informations - * of the connectivity - * - * The connect zones are created for every domain that has common nodes with - * domain \a idomain - * - * \param idomain domain number for which the connect zones are created - * */ - -// void MESHCollection::buildConnectZones(int idomain) -// { -// // constructing node/node correspondencies -// vector node_node_correspondency; -// node_node_correspondency.resize(_topology->nbDomain()); - -// cout << "Computing node/node corresp"<computeNodeNodeCorrespondencies(idomain, node_node_correspondency ); - -// for (int idistant=0; idistant< _topology->nbDomain(); idistant++) -// { -// // on regarde si une correspondance noeud/noeud a été trouvée -// // entre idomain et idistant -// // si oui, on crée une connectzone -// if (node_node_correspondency[idistant]!=0) -// { -// MEDMEM::CONNECTZONE* cz= new MEDMEM::CONNECTZONE(); -// cz->setLocalMesh(_mesh[idomain]); -// cz->setDistantMesh(_mesh[idistant]); -// cz->setLocalDomainNumber(idomain); -// cz->setDistantDomainNumber(idistant); -// cz-> setName ("Connect zone defined by SPLITTER"); -// cz->setNodeCorresp(node_node_correspondency[idistant]); -// _connect_zones.push_back(cz); -// } -// } -// cout << "Computing node/node corresp"< cell_cell_correspondency; -// cell_cell_correspondency.resize(_topology->nbDomain()); -// _topology->computeCellCellCorrespondencies(idomain, cell_cell_correspondency, _cell_graph.get()); - -// for (int idistant=0; idistant< _topology->nbDomain(); idistant++) -// { -// //the connect zone has been created by the node/node computation -// if (cell_cell_correspondency[idistant]!=0) -// { -// MEDMEM::CONNECTZONE* cz=0; -// for (int icz=0; icz<_connect_zones.size();icz++) -// if (_connect_zones[icz]->getLocalDomainNumber()==idomain && -// _connect_zones[icz]->getDistantDomainNumber()==idistant) -// cz = _connect_zones[icz]; -// if (cz!=0) -// cz->setEntityCorresp(MED_EN::MED_CELL,MED_EN::MED_CELL, cell_cell_correspondency[idistant]); -// else -// throw MEDEXCEPTION("MESHCollection::buildConnectZones() -A connect zone should exist"); -// //delete cell_cell_correspondency[idistant]; -// } - -// } -// } - -//================================================================================ -/*! - * \brief Adds a group of joint faces - * \param loc_face_ids - local numbers of faces - * \param idomian - domain index where faces are local - * \param idistant - the other domain index - */ -//================================================================================ - -void MESHCollection::addJointGroup(const std::vector& loc_face_ids, int idomain, int idistant) -{ - MEDMEM::MESHING* meshing = dynamic_cast (_mesh[idomain]); - MED_EN::medEntityMesh constituent_entity = getSubEntity(); - - MEDMEM::STRING jointname("joint_"); - jointname< groups = meshing->getGroups( constituent_entity ); - // for ( int g = 0; g < groups.size(); ++g ) - // if ( groups[g]->getName() == jointname.str() ) - // { - // joint_group = groups[g]; - // break; - // } - // assure uniqueness of group name - bool unique = false; - vector groups = meshing->getGroups( constituent_entity ); - do - { - unique = true; - for ( int g = 0; unique && g < groups.size(); ++g ) - unique = ( groups[g]->getName() != jointname ); - if ( !unique ) - jointname << "_" << idomain+1; - } - while ( !unique ); - joint_group->setName(jointname); - joint_group->setMesh(meshing); - joint_group->setEntity(constituent_entity); - map > joint_types; - - int nbfaces = loc_face_ids.size(); - for (int i=0; igetElementType(constituent_entity,loc_face_ids[i]); - joint_types[type].push_back(loc_face_ids[i]); - } - joint_group->setNumberOfGeometricType(joint_types.size()); - MED_EN::medGeometryElement* types=new MED_EN::medGeometryElement[joint_types.size()]; - int* nb_in_types=new int[joint_types.size()]; - int* group_index=new int[joint_types.size()+1]; - - group_index[0]=1; - int itype=0; - int iface =0; - int* group_value=new int[nbfaces]; - for (map >::const_iterator iterj=joint_types.begin(); - iterj != joint_types.end(); - iterj++) - { - nb_in_types[itype]=(iterj->second).size(); - types[itype]=iterj->first; - itype++; - group_index[itype]=group_index[itype-1]+(iterj->second).size(); - for (int i=0; i< (iterj->second).size(); i++) - group_value[iface++]=(iterj->second)[i]; - } - joint_group->setGeometricType(types); - joint_group->setNumberOfElements(nb_in_types); - joint_group->setNumber(group_index, group_value, /*shallowCopy=*/true); - delete[] types; - delete[] nb_in_types; - - if ( joint_group == tmp_grp ) - meshing->addGroup(*tmp_grp); - tmp_grp->removeReference(); -} - -/*! building Connect Zones for storing the informations - * of the connectivity - * */ - -void MESHCollection::buildConnectZones() -{ - vector > > face_map(_topology->nbDomain()); - map< pair, MEDMEM::MEDSKYLINEARRAY*> cell_corresp_here; - - MED_EN::medEntityMesh constituent_entity = getSubEntity(); - - if ( isParallelMode() ) - { - buildConnectZonesBetweenProcs(face_map, cell_corresp_here); - } - - cout << "Computing node/node corresp"<nbDomain(); idomain++) - { - - // constructing node/node correspondencies - vector node_node_correspondency(_topology->nbDomain()); - _topology->computeNodeNodeCorrespondencies(idomain, node_node_correspondency ); - - for (int idistant=0; idistant< _topology->nbDomain(); idistant++) - { - // on regarde si une correspondance noeud/noeud a été trouvée - // entre idomain et idistant - // si oui, on crée une connectzone - if (node_node_correspondency[idistant]!=0) - { - MEDMEM::CONNECTZONE* cz= new MEDMEM::CONNECTZONE(); - cz->setLocalMesh(_mesh[idomain]); - cz->setDistantMesh(_mesh[idistant]); - cz->setLocalDomainNumber(idomain); - cz->setDistantDomainNumber(idistant); - cz-> setName ("Connect zone defined by SPLITTER"); - cz->setNodeCorresp(node_node_correspondency[idistant]); - _connect_zones.push_back(cz); - } - } - } - cout << "Computing face corresp"<getFaceNumber()+1; - //int global_face_id = _topology->getMaxGlobalFace()+1; - - map , vector > faces_in_joint; - - if ( !isParallelMode() ) - // taking faces that are already present in the mesh into account - for (int idomain=0; idomain<_topology->nbDomain(); idomain++) - { - getFaces(idomain,face_map[idomain]); - } - - // creating faces that are located at the interface between - // subdomains - - vector nb_added_groups( _topology->nbDomain(), 0 ); - - for (int idomain=0; idomain<_topology->nbDomain(); idomain++) - { - vector cell_cell_correspondency( _topology->nbDomain() ); - if ( !isParallelMode() ) - _topology->computeCellCellCorrespondencies(idomain, cell_cell_correspondency, _cell_graph.get()); - - for (int idistant=0; idistant< _topology->nbDomain(); idistant++) - { - if (idistant <= idomain) continue; - - MEDMEM::MEDSKYLINEARRAY* cell_correspondency = 0; - if ( isParallelMode() ) - cell_correspondency = cell_corresp_here[ make_pair (idomain,idistant)]; - else - cell_correspondency = cell_cell_correspondency[idistant]; - - //the connect zone has been created by the node/node computation - - if ( cell_correspondency ) - { - int nbcells = cell_correspondency->getNumberOf(); - const int* index = cell_correspondency->getIndex(); - const int* value = cell_correspondency->getValue(); - if ( isParallelMode() ) - global_face_id = _domain_selector->getFisrtGlobalIdOfSubentity( idomain, idistant ); - - for (int ilocal=0; ilocalgetType()].push_back(face); - MEDSPLITTER_FaceModel* face2 = getCommonFace(idistant,distant_id,idomain, ilocal+1,global_face_id); - face_map[idistant][face->getType()].push_back(face2); - faces_in_joint[make_pair(idomain,idistant)].push_back(global_face_id); - global_face_id++; - } - } - } - - } - //cleaning up - for (int idistant=0; idistant< _topology->nbDomain(); idistant++) - delete cell_cell_correspondency[idistant]; - } - - - _topology->recreateFaceMapping(face_map); - - //transforming the face_map into a constituent entity connectivity - for (int idomain=0; idomain< _topology->nbDomain();idomain++) - { - int nbtypes = face_map[idomain].size(); - vector types; - vector nb_elems; - vector conn; - - MEDMEM::MESHING* meshing = dynamic_cast (_mesh[idomain]); - if ( !meshing->getConnectivityptr() ) - continue; // no cells in idomain - - for (map >::const_iterator iter= face_map[idomain].begin(); - iter != face_map[idomain].end(); iter ++) - { - types.push_back(iter->first); - int nb_elem_in_type = (iter->second).size(); - nb_elems.push_back(nb_elem_in_type); - int nb_node_per_type=(iter->first)%100; - int* connectivity= new int [nb_node_per_type*nb_elem_in_type]; - for (int ielem=0; ielemsecond)[ielem])[inode]; - } - conn.push_back(connectivity); - - } - //setting the faces in the mesh - meshing->setNumberOfTypes(nbtypes,constituent_entity); - meshing->setTypes(&types[0],constituent_entity); - meshing->setNumberOfElements(&nb_elems[0],constituent_entity); - - for (int itype=0; itypesetConnectivity( constituent_entity, types[itype], conn[itype] ); - delete[]conn[itype]; - } - for (int idistant =0; idistant<_topology->nbDomain(); idistant++) - { - map , vector >::iterator iter; - iter = faces_in_joint.find(make_pair(idomain,idistant)); - if (iter == faces_in_joint.end()) - { - iter = faces_in_joint.find (make_pair(idistant,idomain)); - if (iter == faces_in_joint.end()) - continue; - } - - int nbfaces = (iter->second).size(); - vector face_joint(nbfaces*2); - MEDMEM::CONNECTZONE* cz=0; - for (unsigned icz=0; icz<_connect_zones.size();icz++) - if (_connect_zones[icz]->getLocalDomainNumber()==idomain && - _connect_zones[icz]->getDistantDomainNumber()==idistant) - cz = _connect_zones[icz]; - - int nbtotalfaces= _topology->getFaceNumber(idomain); - - //creating arrays for the MEDSKYLINEARRAY structure containing the joint - int* index =new int[nbtotalfaces+1]; - for (int i=0; i faces; - vector local_faces( nbfaces ); - for (int iface=0; ifacesecond)[iface]; - int localid=_topology->convertGlobalFace(iglobal,idomain); - int distantid=_topology->convertGlobalFace(iglobal,idistant); - faces.insert(make_pair(localid,distantid)); - local_faces[iface]=localid; - } - - int iloc=0; - index[0]=1; - for (map::const_iterator iter=faces.begin(); - iter != faces.end(); - iter++) - { - index[iter->first]=1; - value[iloc++]=iter->second; - } - - for (int i=0; isetEntityCorresp(constituent_entity,constituent_entity,skarray); - else - throw MEDEXCEPTION("MESHCollection::buildConnectZones() -A connect zone should exist"); - // Creating a group of the faces constituting the joint - addJointGroup( local_faces, idomain, idistant ); - nb_added_groups[ idomain ]++; - } - } - - if ( isParallelMode() ) - { - // Now all faces have got local ids and we can receive local ids from other procs. - // Set face/face data to zones with other procs and create a group - for (int icz=0; icz<_connect_zones.size();icz++) - { - MEDMEM::CONNECTZONE* cz=_connect_zones[icz]; - if ( _domain_selector->isMyDomain( cz->getDistantDomainNumber()) ) continue; - - int glob_id = _domain_selector->getFisrtGlobalIdOfSubentity( cz->getLocalDomainNumber(), - cz->getDistantDomainNumber()); - int nb_cz_faces = _domain_selector->getNbCellPairs( cz->getDistantDomainNumber(), - cz->getLocalDomainNumber()); - vector< int > loc_ids_here( nb_cz_faces ); - for ( int i = 0; i < nb_cz_faces; ++i ) - loc_ids_here[i] = _topology->convertGlobalFace(glob_id++,cz->getLocalDomainNumber()); - - int* loc_ids_dist = _domain_selector->exchangeSubentityIds( cz->getLocalDomainNumber(), - cz->getDistantDomainNumber(), - loc_ids_here ); - int nb_faces_here= _topology->getFaceNumber(cz->getLocalDomainNumber()); - int* face_index = new int[ nb_faces_here+1 ]; - face_index[0]=1; - for ( int loc_id = 0, i = 0; loc_id < nb_faces_here; ++loc_id) - { - face_index[ loc_id+1 ] = face_index[ loc_id ]; - if ( i < loc_ids_here.size() && loc_ids_here[i] == loc_id+1 ) - { - face_index[ loc_id+1 ]++; - i++; - } - } - MEDMEM::MEDSKYLINEARRAY* skarray= - new MEDMEM::MEDSKYLINEARRAY(nb_faces_here, nb_cz_faces, face_index, loc_ids_dist, true); - cz->setEntityCorresp(constituent_entity,constituent_entity,skarray); - - addJointGroup( loc_ids_here, cz->getLocalDomainNumber(), cz->getDistantDomainNumber()); - nb_added_groups[ cz->getLocalDomainNumber() ]++; - } - } - - for (int idomain=0; idomain<_topology->nbDomain(); idomain++) - { - // delete face_map - for (map >::const_iterator iter= face_map[idomain].begin(); - iter != face_map[idomain].end(); iter ++) - for (unsigned i=0; i<(iter->second).size();i++) - delete (iter->second)[i]; - - if ( nb_added_groups[ idomain ] > 0 && - _mesh[idomain]->getNumberOfFamilies( constituent_entity ) > 0 ) - // needed because if there were face families before, driver won't - // create families from just added groups (see MEDMEM_MedMeshDriver.cxx:3330), - // actually it is a bug of driver - it must check presence of groups in families - _mesh[idomain]->createFamilies(); - } - } - - if ( isParallelMode() ) - // Excange info on types of constituent_entity needed while writing joints - // to get ids local in geom type for distant procs - _domain_selector->gatherEntityTypesInfo( _mesh, constituent_entity ); - - cout << "Computing cell/cell corresp"<nbDomain();idomain++) - { - vector cell_cell_correspondency( _topology->nbDomain() ); - if ( !isParallelMode() ) - _topology->computeCellCellCorrespondencies(idomain,cell_cell_correspondency,_cell_graph.get()); - - for (int idistant=0; idistant< _topology->nbDomain(); idistant++) - { - MEDMEM::MEDSKYLINEARRAY* cell_correspondency = 0; - if ( isParallelMode() ) - cell_correspondency = cell_corresp_here[ make_pair (idomain,idistant)]; - else - cell_correspondency = cell_cell_correspondency[idistant]; - - //the connect zone has been created by the node/node computation - if ( cell_correspondency ) - { - MEDMEM::CONNECTZONE* cz=0; - for (unsigned icz=0; icz<_connect_zones.size();icz++) - if (_connect_zones[icz]->getLocalDomainNumber()==idomain && - _connect_zones[icz]->getDistantDomainNumber()==idistant) - cz = _connect_zones[icz]; - if (cz!=0) - cz->setEntityCorresp(MED_EN::MED_CELL,MED_EN::MED_CELL, cell_correspondency); - else - throw MEDEXCEPTION("MESHCollection::buildConnectZones() -A connect zone should exist"); - } - } - } -} - -/*! building Connect Zones for storing the informations - * of the connectivity in the parallel mode - * */ - -void MESHCollection::buildConnectZonesBetweenProcs(TGeom2FacesByDomian & face_map, - map< pair, MEDMEM::MEDSKYLINEARRAY*> & cell_cell_correspondency_here) -{ - using namespace MED_EN; - - // graph over all procs - auto_ptr global_graph( _domain_selector->gatherGraph( _cell_graph.get() )); - - vector< vector< JointExchangeData > > joints_of_domain( _topology->nbDomain() ); - - for (int idomain=0; idomain<_topology->nbDomain(); idomain++) - { - if ( !_domain_selector->isMyDomain( idomain )) continue; - - vector< JointExchangeData > & joints = joints_of_domain[ idomain ]; - joints.resize( _topology->nbDomain() ); - - // Find corresponding cells on other procs - - const int* gra_index = global_graph->getGraph()->getIndex(); - const int* gra_value = global_graph->getGraph()->getValue(); - const int* partition = global_graph->getPart(); - const int dj = gra_index[0]; - - vector< int > glob_cells_here( _topology->getCellNumber( idomain )); - _topology->getCellList( idomain, & glob_cells_here[0]); - for ( int loc_here = 0; loc_here < glob_cells_here.size(); ++loc_here ) - { - int glob_here = glob_cells_here[ loc_here ]; - for ( int j = gra_index[ glob_here-1 ]; j < gra_index[ glob_here ]; ++j ) - { - int glob_neighbor = gra_value[ j-dj ]; - int neighbor_dom = partition[ glob_neighbor-1 ]; - if ( neighbor_dom == idomain ) continue; - - if ( _domain_selector->isMyDomain( neighbor_dom )) - { - joints[ neighbor_dom ].addCellCorrespondence - (_mesh[idomain], neighbor_dom, idomain, glob_neighbor, glob_here, loc_here + 1, - _topology->convertGlobalCell(glob_neighbor).second ); - } - else - { - joints[ neighbor_dom ].addCellCorrespondence - (_mesh[idomain], neighbor_dom, idomain, glob_neighbor, glob_here, loc_here + 1 ); - } - } - } - } - global_graph.reset(); // free memory - - // set joints in a queue to exchange - typedef map< int, JointExchangeData* > TOrderedJoints; - TOrderedJoints queue; - for (int idomain=0; idomain<_topology->nbDomain(); idomain++) - { - if ( !_domain_selector->isMyDomain( idomain )) continue; - - vector< JointExchangeData > & joints = joints_of_domain[ idomain ]; - for (int idist=0; idist<_topology->nbDomain(); ++idist ) - { - JointExchangeData& joint = joints[idist]; - - int nb_cell_pairs = joint.nbCellPairs(); - if ( nb_cell_pairs == 0 ) - continue; - else - _domain_selector->setNbCellPairs( nb_cell_pairs, idist, idomain ); - - joint.setMeshes( idist, _mesh[idist], idomain, _mesh[idomain] ); - - if ( _domain_selector->isMyDomain( idist )) - { - // a joint on this proc - cell_cell_correspondency_here[ make_pair( idomain, idist )] = joint.makeCellCorrespArray(); - } - else - { - // a joint with distant proc - joint.setConnectivity( & ((MEDMEM::MeshFuse*)_mesh[idomain])->getNodeNumbers()[0] ); - int order = _domain_selector->jointId( idomain, idist ); - queue[ order ] = & joint; - } - } - } - // gather info on cell geom types needed to exchange joints - _domain_selector->gatherEntityTypesInfo( _mesh, MED_EN::MED_CELL ); - - // gather info on nb of sub-entities to compute their global numbers for joints - _domain_selector->gatherNbOf( getSubEntity(), _mesh ); - _domain_selector->gatherNbCellPairs(); - if ( _subdomain_boundary_creates ) - { - // taking faces that are already present in the mesh into account - for (int idomain=0; idomain<_topology->nbDomain(); idomain++) - if ( _domain_selector->isMyDomain( idomain )) - getFaces(idomain,face_map[idomain]); - } - else - { - face_map.clear(); // mark for the joint not to create faces - } - - // exchange joint data with other procs and make CONNECTZONEs - TOrderedJoints::iterator ord_joint = queue.begin(); - for ( ; ord_joint != queue.end(); ++ord_joint ) - { - JointExchangeData* joint = ord_joint->second; - - _domain_selector->exchangeJoint( joint ); - if ( _subdomain_boundary_creates ) - { - int first_sub_id = _domain_selector->getFisrtGlobalIdOfSubentity( joint->localDomain(), - joint->distantDomain() ); - joint->setFisrtGlobalIdOfSubentity( first_sub_id ); - } - _connect_zones.push_back ( joint->makeConnectZone( face_map )); - } -} - -/*! projects old collection families on new collection families - */ -void MESHCollection::castFamilies(const MESHCollection& old_collection) -{ - vector > element_array (_topology->nbDomain()); - - //loop on old domains to create groups out of the existing families - if (_family_splitting) - for (int idomain=0; idomain < old_collection._topology->nbDomain(); idomain++) - old_collection.getMesh(idomain)->createGroups(); - - //definition of the entities array which - //defines the entities over which the information is cast - MED_EN::medEntityMesh entities[3]; - entities[0]=MED_EN::MED_NODE; - entities[1]=getSubEntity(); - entities[2]=MED_EN::MED_CELL; - - for (int ientity=0; ientity<=2;ientity++) - { - - //int nbgroups = old_collection.getMesh(0)->getNumberOfGroups(entities[ientity]); - - map > group_map; - for (int idomain=0; idomain < old_collection._topology->nbDomain(); idomain++) - { - if ( !old_collection.getMesh(idomain) ) continue; - for (int igroup=0; igroupgetNumberOfGroups(entities[ientity]); igroup++) - { - //retrieves a group - MEDMEM::GROUP* group = (old_collection.getMesh(idomain)->getGroups(entities[ientity]))[igroup]; - //increments the number of groups if it is a new group - //if (group_map.find(group->getName())==group_map.end()) - - group_map[group->getName()].insert(idomain); - // group_map.insert(make_pair(group->getName(), idomain); - - } - } - int nbgroups=group_map.size(); - vector igroupold(old_collection._topology->nbDomain(),0); - map >::const_iterator iter=group_map.begin(); - - for (int igroup=0; igroup old_supports(old_collection._topology->nbDomain()); - string group_name = iter->first; - iter++; - - //parameters stored for passing group description - // from the old meshes to the new ones - - for (int idomain=0; idomain < old_collection._topology->nbDomain(); idomain++) - { - // for (set::iterator iter=group_map[group_name].begin(); iter!=group_map[group_name].end(); iter++) - // cout << *iter<<" "; - // cout <getGroups(entities[ientity]))[igroupold[idomain]]; - old_supports[idomain] = static_cast (group); - igroupold[idomain]++; - } - - vector new_groups(_topology->nbDomain()); - vector new_supports(_topology->nbDomain()); - for (int i=0; i<_topology->nbDomain(); i++) - { - new_groups[i]=new MEDMEM::GROUP(); - new_supports[i]=static_cast(new_groups[i]); - } - castSupport(old_collection,old_supports,new_supports); - - //creating new groups from the previous list of elements - for (int idomain=0; idomain <_topology->nbDomain(); idomain++) - { - MEDMEM::MESHING* mesh_builder=static_cast (_mesh[idomain]); - if ( new_supports[idomain] ) - mesh_builder->addGroup(*new_groups[idomain]); - } - //groups are copied by the addGroup method, - //so they can be safely deleted here - for (int i=0; i<_topology->nbDomain(); i++) - { - if ( new_supports[i] ) new_groups[i]->removeReference(); - } - - }// on groups - }//on entities -} - - -void MESHCollection::castSupport(const MESHCollection& old_collection, vector& old_support, vector& new_support) -{ - - if (old_collection._topology->nbDomain() != (int)old_support.size()) - { - throw MED_EXCEPTION(STRING("Error : wrong call to MESHCollection::castSupport")); - } - vector > element_array (_topology->nbDomain()); - - //parameters stored for passing description - // from the old meshes to the new ones - string name; - string description; - MED_EN::medEntityMesh entity; - vector support_name(1); - support_name[0]="support"; - for (int inew=0; inew< _topology->nbDomain(); inew++) - element_array[inew].clear(); - - for (int idomain=0; idomain < old_collection._topology->nbDomain(); idomain++) - { - //retrieves the group igroup on domain idomain - const MEDMEM::SUPPORT* support = old_support[idomain]; - if (old_support[idomain]==0) continue; - name = support->getName(); - description=support->getDescription(); - int nbelem = support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - if (nbelem==0 && !_create_empty_groups) continue; - - int* list_of_elems; - if (support->isOnAllElements()) - { - list_of_elems = new int[nbelem]; - for (int i=0; i (support->getNumber(MED_EN::MED_ALL_ELEMENTS)); - - int* array=new int[nbelem]; - int* ip=0; - int* local=0; - int* full_array=0; - entity = support->getEntity(); - int size; - - switch (entity) - { - case MED_EN::MED_CELL : - ip=new int[nbelem]; - local= new int[nbelem]; - size=nbelem; - old_collection.getTopology()->convertCellToGlobal(idomain,list_of_elems,nbelem,array); - _topology->convertGlobalCellList(array,nbelem,local,ip); - for (int i=0; iconvertFaceToGlobal(idomain,list_of_elems,nbelem,array); - _topology->convertGlobalFaceListWithTwins(array,nbelem,local,ip,full_array,size); - for (int i=0; iconvertNodeToGlobal(idomain,list_of_elems,nbelem,array); - _topology->convertGlobalNodeListWithTwins(array,nbelem,local,ip,full_array,size); - for (int i=0; iisOnAllElements()) delete[] list_of_elems; - } - - //creating new groups from the previous list of elements - for (int idomain=0; idomain <_topology->nbDomain(); idomain++) - { - if ( _mesh[idomain]->getNumberOfNodes() < 1 || - (element_array[idomain].empty() && !_create_empty_groups)) - { - new_support[idomain]->removeReference(); - new_support[idomain]=0; - continue; - } - MEDMEM::SUPPORT* support= new_support[idomain]; - support->setName(name); - support->setMesh(_mesh[idomain]); - support->setDescription(description); - support->setEntity(entity); - - if ( !element_array[idomain].empty() ) /* if() was added for issue 0021576 - to prevent creation of faces */ - { - element_array[idomain].sort(); - element_array[idomain].unique(); - - if (entity != MED_EN::MED_NODE) - support->fillFromElementList(element_array[idomain]); - else - support->fillFromNodeList(element_array[idomain]); - } - } -} - -void MESHCollection::castField(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber) -{ - int type=old_collection.getDriver()->getFieldType(fieldname); - char field_char[80]; - strcpy(field_char,fieldname.c_str()); - - if (type ==0) - castFields(old_collection, field_char, itnumber, ordernumber); - else - castFields(old_collection, field_char, itnumber, ordernumber); -} - -void MESHCollection::castAllFields(const MESHCollection& initial_collection) -{ - vector field_names; - vector iternumber; - vector ordernumber; - vector types; - initial_collection.getDriver()->readFileStruct(field_names,iternumber,ordernumber,types); - - for (unsigned i=0; i(initial_collection, field_char, iternumber[i], ordernumber[i]); - else - castFields(initial_collection, field_char, iternumber[i], ordernumber[i]); - } -} - -void MESHCollection::createNodalConnectivity(const MESHCollection& initial_collection,int idomain, MED_EN::medEntityMesh entity) -{ - MESSAGE_MED ("beginning of createNodalConnectivity for entity "<(_mesh[idomain]); - - - //number of elements per type - std::map type_numbers; - - //creating arrays for storing global numbers and cell types - switch (entity) - { - case MED_EN::MED_CELL: - dimension=initial_collection.getMeshDimension(); - nb_elems=_topology->getCellNumber(idomain); - break; - case MED_EN::MED_EDGE: - case MED_EN::MED_FACE: - dimension=initial_collection.getMeshDimension()-1; - nb_elems=_topology->getFaceNumber(idomain); - break; - default: - nb_elems=0; - break; - } - - if (nb_elems == 0) return; - SCRUTE_MED(nb_elems); - - - int *list= new int[nb_elems]; - MED_EN::medGeometryElement *cell_type_list= new MED_EN::medGeometryElement[nb_elems]; - - - // cout << "Beginning of retrieval "<getCellList(idomain,list); - break; - case MED_EN::MED_EDGE: - case MED_EN::MED_FACE: - _topology->getFaceList(idomain,list); - break; - default: - - break; - } - - //retrieving cell_types - initial_collection.getTypeList(list,nb_elems,entity,cell_type_list); - // cout <<"end of type retrieval"<::iterator iter= type_numbers.find(cell_type_list[icell]); - if (iter!=type_numbers.end()) - (iter->second)++; - else - type_numbers[cell_type_list[icell]]=1; - - } - //cout << "Nombre de tetras"< index; - - map type_cell_list; - - MED_EN::MESH_ENTITIES::const_iterator currentEntity; - std::map::const_iterator iter; - //currentEntity = MED_EN::meshEntities.find(entity); - for (iter = type_numbers.begin();iter != type_numbers.end(); iter++) - { - MED_EN::medGeometryElement type = iter->first; - if (!isDimensionOK(type,dimension)) continue; - //if (iter->second==0) continue; - index[type]=0; - type_cell_list[type]=new int[type_numbers[type]]; - // cout << "type :"<first; - if (!isDimensionOK(type,dimension)) continue; - - type_array[itype]=type; - - present_type_numbers[itype]=type_numbers[type]; - - MESSAGE_MED("Nombre d'elements de type "< type_connectivity; - vector polygon_conn; - vector polygon_conn_index; - vector polyhedron_conn; - vector polyhedron_conn_index; - vector polyhedron_face_index; - - //Treating nodes - - - for (iter = type_numbers.begin();iter != type_numbers.end(); iter++) - { - MED_EN::medGeometryElement type = iter->first; - - - if (!isDimensionOK(type,dimension)) continue; - if (type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) - { - int nbnode_per_type = (int)type%100; - type_connectivity[type]=new int[type_numbers[type]*nbnode_per_type]; - initial_collection.getNodeConnectivity(type_cell_list[type],type_numbers[type],entity,type,type_connectivity[type]); - } - else if (type == MED_EN::MED_POLYGON && dimension==2) - { - initial_collection.getPolygonNodeConnectivity(type_cell_list[type],type_numbers[type],entity,polygon_conn,polygon_conn_index); - } - else if (type == MED_EN::MED_POLYHEDRA && dimension==3) - { - initial_collection.getPolyhedraNodeConnectivity(type_cell_list[type],type_numbers[type],entity,polyhedron_conn,polyhedron_conn_index); - } - delete[] type_cell_list[type]; - } - - //creating node mapping - //!TODO : compute the total number of nodes - if (entity==MED_EN::MED_CELL) - { - _topology->createNodeMapping(type_connectivity,type_numbers,polygon_conn,polygon_conn_index, - polyhedron_conn,polyhedron_conn_index,polyhedron_face_index,idomain); - } - - //converting node global numberings to local numberings - //for (iter = (*currentEntity).second.begin();iter != (*currentEntity).second.end(); iter++) - for (iter = type_numbers.begin();iter != type_numbers.end(); iter++) - { - MED_EN::medGeometryElement type = iter->first; - - if (!isDimensionOK(type, dimension)) continue; - if (type_numbers[type]==0) continue; - if (type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) - { - int nbnode_per_type = (int)type%100; - _topology->convertToLocal2ndVersion(type_connectivity[type],type_numbers[type]*nbnode_per_type,idomain); - } - else if (type == MED_EN::MED_POLYGON && dimension==2) - { - int nbpoly = type_numbers[type]; - _topology->convertToLocal2ndVersion(&polygon_conn[0], polygon_conn_index[nbpoly]-1, idomain); - } - else if (type == MED_EN::MED_POLYHEDRA && dimension==3) - { - int nbpoly = type_numbers[type]; - _topology->convertToLocal2ndVersion(&polyhedron_conn[0], polyhedron_face_index[polyhedron_conn_index[nbpoly]-1]-1, idomain); - } - - } - - - //writing coordinates - if (entity==MED_EN::MED_CELL) - { - //setting coordinates from initial_collection coordinates - int nbnode=_topology->getNodeNumber(idomain); - MESSAGE_MED("Number of nodes on domain "<< idomain <<" : "<getNodeList(idomain,node_list); - initial_collection.getCoordinates(node_list,nbnode,coordinates); - delete[] node_list; - - // redundant specification of number of nodes is required!! MED imperfection, sorry... - - //TODO : change MEDMEM so that it accepts a direct setting of coordinates - // (in the present version, it is deep-copied) - mesh_builder->setCoordinates(initial_collection.getSpaceDimension(), - nbnode, coordinates, initial_collection.getSystem(), - MED_EN::MED_FULL_INTERLACE); - delete [] coordinates; - } - - int nb_plain_types=0; - for (iter = type_numbers.begin();iter != type_numbers.end(); iter++) - { - MED_EN::medGeometryElement type = iter->first; - - if (!isDimensionOK(type, dimension)) continue; - if (type_numbers[type]==0) continue; - nb_plain_types++; - } - mesh_builder->setNumberOfTypes(nb_plain_types,entity); - mesh_builder->setTypes(type_array,entity); - mesh_builder->setNumberOfElements(present_type_numbers,entity); - - delete[]present_type_numbers; - delete[]type_array; - //setting node connectivities - for (iter = type_numbers.begin();iter != type_numbers.end(); iter++) - { - MED_EN::medGeometryElement type = iter->first; - - if (!isDimensionOK(type,dimension)) continue; - if (type_numbers[type]==0) continue; - - if (type != MED_EN::MED_POLYHEDRA && type != MED_EN::MED_POLYGON) - { - mesh_builder->setConnectivity(entity,type,type_connectivity[type]); - delete[] type_connectivity[type]; - } - else if (type == MED_EN::MED_POLYGON && dimension ==2) - { - mesh_builder->setConnectivity(entity,type,&polygon_conn[0],&polygon_conn_index[0]); - } - else if (type == MED_EN::MED_POLYHEDRA && dimension ==3) - { - mesh_builder->setConnectivity(entity,type,&polyhedron_conn[0],&polyhedron_conn_index[0]); - } - } - MESSAGE_MED("end of createNodalConnectivity"); -} - - -/*! retrieves the faces that are present in a mesh and stores them in a - * dynamic structure made of a map of MEDSPLITTER_FaceModel - * - * \param idomain domain id on which the faces are collected - * \param face_map container storing the faces - */ -void MESHCollection::getFaces(int idomain, - map >& face_map) -{ - MED_EN::medEntityMesh constituent_entity = getSubEntity(); - const medGeometryElement* types; - try - { - types = _mesh[idomain]->getTypes(constituent_entity); - if ( !types ) return; - } - catch(MEDEXCEPTION&){ return;} - - int nbtypes = _mesh[idomain]->getNumberOfTypes(constituent_entity); - const int* global_numbering= _mesh[idomain]->getGlobalNumberingIndex(constituent_entity); - int* conn = const_cast (_mesh[idomain]->getConnectivity(MED_EN::MED_NODAL,constituent_entity, MED_EN::MED_ALL_ELEMENTS)); - for (int itype=0; itypesetType(type); - int nbnodes = type%100; - face_model->setNbNodes(nbnodes); - face_model->setGlobal(_topology->convertFaceToGlobal(idomain,iface)); - for (int i=0; igetElementType(MED_EN::MED_CELL,ilocal1); - MEDMEM::CELLMODEL celltype1 (type1); - - const int* conn_index1 = _mesh[ip1]->getConnectivityIndex(MED_EN::MED_NODAL,MED_EN::MED_CELL); - const int* conn1 = _mesh[ip1]->getConnectivity(MED_EN::MED_NODAL,MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - - // MED_EN::medGeometryElement type2 = _mesh[ip2]->getElementType(MED_EN::MED_CELL,ilocal2); - //MEDMEM::CELLTYPE celltype2 (type2); - const int* conn_index2 = _mesh[ip2]->getConnectivityIndex(MED_EN::MED_NODAL,MED_EN::MED_CELL); - const int* conn2 = _mesh[ip2]->getConnectivity(MED_EN::MED_NODAL,MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - - vector nodes1, nodes1_local; - vector nodes2; - for (int i= conn_index1[ilocal1-1]; iconvertNodeToGlobal(ip1,*(conn1+i-1))); - nodes1_local.push_back( conn1[i-1] ); - } - for (int i= conn_index2[ilocal2-1]; iconvertNodeToGlobal(ip2,*(conn2+i-1))); - - return MEDSPLITTER_FaceModel::getCommonFace( &nodes1[0], &nodes1_local[0], celltype1, - &nodes2[0], nodes2.size(), face_index); -} - -//================================================================================ -/*! - * \brief Makes a face common for two given cells - * \param nodes1 - globl nodes of the first cell - * \param nodes1_local - local nodes of the first cell - * \param celltype1 - cell model of the first cell - * \param nodes2 - globl nodes of the second cell - * \param nb_nodes2 - nb of nodes of the second cell - * \param global_id - id of the new common face - */ -//================================================================================ - -MEDSPLITTER_FaceModel* -MEDSPLITTER_FaceModel::getCommonFace(const int* nodes1, - const int* nodes1_local, - const MEDMEM::CELLMODEL& celltype1, - const int* nodes2, - int nb_nodes2, - int global_id) -{ - int nbfaces= celltype1.getNumberOfConstituents(1); - int ** faces = celltype1.getConstituents(1); - MED_EN::medGeometryElement* types = celltype1.getConstituentsType(1); - int iface=0; - int dimension=celltype1.getDimension(); - - while (iface=dimension) break; - iface++; - } - - if (iface==nbfaces) - throw MEDEXCEPTION("MEDSPLITTER::getCommonFace - No common face found !"); - - MEDSPLITTER_FaceModel* face_model = new MEDSPLITTER_FaceModel; - face_model->setType(types[iface]); - int nbnodes = types[iface]%100; - face_model->setNbNodes(nbnodes); - face_model->setGlobal(global_id); - for (int i=0; i -#include - - -namespace MEDMEM -{ - class MESH; - class CONNECTZONE; - class MEDSKYLINEARAY; - class SUPPORT; -} - -namespace MEDSPLITTER -{ - - class Topology; - class MESHCollectionDriver; - class ParaDomainSelector; - - typedef enum{MedAscii, MedXML, Undefined} DriverType; - - class MEDSPLITTER_EXPORT MESHCollection - { - - public: - - //Default constructor - MESHCollection(); - - //Constructing from an existing mesh and a new topology - MESHCollection(const MESHCollection&, Topology*, bool family_splitting=false, bool create_empty_groups=false); - - //Constructing the mesh collection from a file - MESHCollection(const std::string& filename); - - //Constructing the mesh collection from a file - MESHCollection(const std::string& filename, ParaDomainSelector& domainSelector); - - //Constructing the mesh collection from a file - MESHCollection(const std::string& filename, const std::string& meshname); - - ~MESHCollection(); - - bool isParallelMode() const { return _domain_selector; } - - //writing to a distributed file - void write(const std::string& filename); - - //getting the driver - MESHCollectionDriver* retrieveDriver(); - MESHCollectionDriver* getDriver() const; - void setDriverType(MEDSPLITTER::DriverType type) {_driver_type=type;} - - //creation of the cell graph - void buildCellGraph(MEDMEM::MEDSKYLINEARRAY* & array,int *& edgeweights ); - - //creation and partition of the associated graph - Topology* createPartition(int nbdomain, Graph::splitter_type type = Graph::METIS, - const string& ="", int* edgeweights=0, int* verticesweights=0); - - //creation of a user specified partition - Topology* createPartition(const int* partition); - - //retrieving list of types - void getTypeList(int* cell_list,int nb_cells,MED_EN::medEntityMesh entity, - MED_EN::medGeometryElement* type_list) const ; - - //getting list of coordinates - void getCoordinates(int* node_list,int nb_nodes, double* coordinates) const ; - - //getting connectivities - void getNodeConnectivity( const int* cell_list,int nb_cells,MED_EN::medEntityMesh,MED_EN::medGeometryElement type, int* type_connectivity) const ; - void getPolygonNodeConnectivity(const int* cell_list,int nb_cells,MED_EN::medEntityMesh entity, - vector& type_connectivity, vector& connectivity_index) const; - void getPolyhedraNodeConnectivity(const int* cell_list,int nb_cells,MED_EN::medEntityMesh entity, - vector& type_connectivity, vector& connectivity_index/*, vector& face_connectivity_index*/) const; - - void getFaceConnectivity( const int* cell_list,int nb_cells,MED_EN::medEntityMesh,MED_EN::medGeometryElement type, int* type_connectivity) const ; - - //void getFaceConnectivity( const int* cell_list,int nb_cells,MED_EN::medGeometryElement type, int* type_connectivity) const ; - - //getting mesh dimension - int getMeshDimension() const ; - - //getting space dimension - int getSpaceDimension() const ; - - //getting system of coordinates - std::string getSystem() const; - - //getting name of the mesh - std::string getMeshName() const; - - //return constituent entity - MED_EN::medEntityMesh getSubEntity() const; - - //getting a reference to mesh vector - std::vector& getMesh() ; - - //getting a reference to a domain mesh - MEDMEM::MESH* getMesh(int) const; - - //getting a reference to connect zones vector - std::vector& getCZ(); - - //getting a pointer to topology - Topology* getTopology() const ; - - - //settig a new topology - void setTopology(Topology* topology); - - //getting/setting the name of the global mesh (as opposed - //to the name of a subdomain \a nn, which is name_nn) - string getName() const {return _name;} - void setName(const string& name) {_name=name;} - - //getting/setting the description of the global mesh - string getDescription() const {return _description;} - void setDescription(const string& name) { _description=name;} - - //!transfers families from an old MESHCollection to new mesh - void castFamilies(const MESHCollection& old_collection); - - void castSupport(const MESHCollection& old_collection, std::vector& old_support, std::vector& new_support); - - //!casts all the fields to the new mesh collection - void castAllFields(const MESHCollection& old_collection); - - //!casts one specific field to the new mesh collection - void castField(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber); - - //choosing a group to be indivisible - void setIndivisibleGroup(const string& a); - - //!constructing connect zones - // void buildConnectZones(int idomain); - void buildConnectZones(); - void buildConnectZonesBetweenProcs(std::vector > > &, map< pair, MEDMEM::MEDSKYLINEARRAY*> & local_cell_cell_correspondency); - - void addJointGroup(const std::vector&, int idomain, int idistant); - - static bool isDimensionOK(MED_EN::medGeometryElement type, int dim) - { - return ((type/100 == dim) || (dim==2 && type == MED_EN::MED_POLYGON) || (dim==3 && type == MED_EN::MED_POLYHEDRA)); - } - void setSubdomainBoundaryCreates(bool flag) { _subdomain_boundary_creates=flag;} - bool getSubdomainBoundaryCreates(){return _subdomain_boundary_creates;} - - void setFamilySplitting(bool flag){_family_splitting=flag;} - bool getFamilySplitting(){return _family_splitting;} - - void setCreateEmptyGroups(bool flag){_create_empty_groups=flag;} - bool getCreateEmptyGroups(){return _create_empty_groups;} - - - private: - - //!creates connectivities for a domain and an entity (face or cell) - void createNodalConnectivity(const MESHCollection & initial_collection, int idomain, MED_EN::medEntityMesh entity); - - //!creates the tags for indivisible groups - void treatIndivisibleRegions(int* tag); - - //!projects a field from an old collection to the present one - //!field is identified by (name, dt, it) - template - void castFields(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber); - - void getFaces(int idomain, std::map >&); - - MEDSPLITTER_FaceModel* getCommonFace(int ip1,int ilocal1,int ip2,int ilocal2,int face_index); - - template - void fillGlobalConnectivity(TID2CONN & node2cell, TID2CONN & cell2node ); - - //!link to mesh_collection topology - Topology* _topology; - - //!control over topology - bool _owns_topology; - - //!link to graph - boost::shared_ptr _cell_graph; - - //! Driver for read/write operations - MESHCollectionDriver* _driver; - - //! Parallelizer - mark of parallel execution mode - ParaDomainSelector* _domain_selector; - - //!links to meshes - std::vector _mesh; - - //!index of a non empty mesh within _mesh (in parallel mode all of meshes can be empty) - int _i_non_empty_mesh; - - //!links to connectzones - std::vector _connect_zones; - - //!list of groups that are not to be splitted - std::vector _indivisible_regions; - - //!name of global mesh - string _name; - - //!description of global mesh - string _description; - - //! specifies the driver associated to the collection - DriverType _driver_type; - - /*! flag specifying that the splitter should create boundary constituent entity - so that they are written in joints*/ - bool _subdomain_boundary_creates; - - /*! flag specifying that families must be preserved by the - splitting*/ - bool _family_splitting; - - /*! flag specifying that groups must be created on all domains, - even if they are empty*/ - bool _create_empty_groups; - }; - -}//of namespace - -#endif /*MESHCOLLECTION_*/ diff --git a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.H b/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.H deleted file mode 100644 index b17694130..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.H +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2007-2013 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 MEDSPLITTER_MESHCOLLECTIONDRIVER_H -#define MEDSPLITTER_MESHCOLLECTIONDRIVER_H - - -#include -#include -#include -#include - -/*!reads a distributed field - * - * \param fields vector of fields (one field per subdomain) - * \param fieldname name of the field - * \param itnumber number of iteration - * \param ordernumber internal number inside the iteration - * */ -template -void MESHCollectionDriver::readFields(vector* >& fields,char* fieldname, int itnumber, int ordernumber) -{ - for (int i=0; i<_collection->getMesh().size(); i++) - { - char filename[256]; - strcpy(filename,_filename[i].c_str()); - cout << "maillage : " << filename << " champ : " << fieldname << endl; - // MEDMEM::FIELD* field = new MEDMEM::FIELD(MEDMEM::MED_DRIVER,filename,fieldname,itnumber,ordernumber); - fields.push_back (new MEDMEM::FIELD(MEDMEM::MED_DRIVER,filename,fieldname,itnumber,ordernumber)); - } -} - - -/*!writes a distributed field - * - * \param fields vector of fields (one field per subdomain) - * \param fieldname name of the field - * */ -template -void MESHCollectionDriver::writeFields(vector* >& fields,char* fieldname) -{ - xmlDocPtr master_doc=xmlParseFile(_master_filename.c_str()); - - if (!master_doc) - throw MEDEXCEPTION("MEDSPLITTER writeFields - Master File does not exist"); - - //number of domains - - xmlXPathContextPtr xpathCtx = xmlXPathNewContext(master_doc); - xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(BAD_CAST "//mapping/mesh", xpathCtx); - //assuming there is only one mesh in the XML file - xmlNodePtr mesh_node= xpathObj->nodesetval->nodeTab[0]; - xmlNodePtr field_node = xmlNewChild(mesh_node, 0, BAD_CAST "field",0); - xmlNewProp(field_node,BAD_CAST "name",BAD_CAST fieldname); - - - for (int i=0; i<_collection->getMesh().size(); i++) - { - char filename[256]; - strcpy(filename,_filename[i].c_str()); - int driverid = fields[i]->addDriver(MEDMEM::MED_DRIVER, filename, fieldname); - fields[i]->write(driverid); - xmlNodePtr chunk_node= xmlNewChild(field_node,0,BAD_CAST "chunk",0); - char id[8]; - sprintf(id,"%d",i+1); - xmlNewProp(chunk_node,BAD_CAST "subdomain",BAD_CAST id); - xmlNewProp(chunk_node,BAD_CAST "name", BAD_CAST fieldname); - - } - xmlSaveFormatFileEnc(_master_filename.c_str(), master_doc, "UTF-8", 1); - xmlFreeDoc(master_doc); - //xmlCleanupParser(); - -} - -#endif diff --git a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.cxx b/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.cxx deleted file mode 100644 index cf4a7a432..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.cxx +++ /dev/null @@ -1,753 +0,0 @@ -// Copyright (C) 2007-2013 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 -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#ifndef WIN32 -#include -#else -#include -#include -#endif -//Debug macros -#include "MEDMEM_Utilities.hxx" - -//MEDMEM includes -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_MedFileBrowser.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_ConnectZone.hxx" -#include "MEDMEM_MeshFuse.hxx" -#include "MEDMEM_MedMeshDriver.hxx" - -//MEDSPLITTER includes -#include "MEDSPLITTER_Topology.hxx" -#include "MEDSPLITTER_ParallelTopology.hxx" -#include "MEDSPLITTER_SequentialTopology.hxx" -#include "MEDSPLITTER_MESHCollectionDriver.hxx" -#include "MEDSPLITTER_MESHCollection.hxx" -#include "MEDSPLITTER_ParaDomainSelector.hxx" - -using namespace MEDSPLITTER; - -//template inclusion -//#include "MEDSPLITTER_MESHCollectionDriver.H" - - -MESHCollectionDriver::MESHCollectionDriver(MESHCollection* collection):_collection(collection) -{ -} - - -/*!reads a unique MED File v>=2.1 - * and mounts the corresponding mesh in memory - *\param filename binary file - *\param meshname mesh name in the MED file - * */ -int MESHCollectionDriver::readSeq(char* filename, char* meshname) -{ - const char* LOC = "MEDSPLITTER::MESHCollectionDriver::readSeq()"; - BEGIN_OF_MED(LOC); - - _filename.resize(1); - _filename[0]=string(filename); - //puts the only mesh in the mesh vector - //MEDMEM::MESH* new_mesh = new MEDMEM::MESH(MEDMEM::MED_DRIVER,filename, meshname); - MEDMEM::MESH* new_mesh = new MEDMEM::MESH; - MED_MESH_RDONLY_DRIVER meshDrv(filename,new_mesh); - meshDrv.setMeshName( meshname ); - meshDrv.desactivateFacesComputation(); // we need not all faces - meshDrv.open(); - meshDrv.read(); - meshDrv.close(); - (_collection->getMesh()).push_back(new_mesh); - - _collection->setName(meshname); - (_collection->getCZ()).clear(); - vector cellglobal,nodeglobal,faceglobal; - cellglobal.resize(1); - nodeglobal.resize(1); - faceglobal.resize(1); - cellglobal[0]=0; - nodeglobal[0]=0; - faceglobal[0]=0; - //creation of topology from mesh - //connectzone argument is 0 - ParallelTopology* aPT = new ParallelTopology - ((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal); - _collection->setTopology(aPT); - END_OF_MED(LOC); - return 0; -} - -/*! - * Reads the file structure to determine the list - * of all the available fields - * - * \param field_names, vector containing the field names - * \param iternumber, vector containing the iteration numbers - * \param ordernumber, vector containing the order numbers - * \param types, vector containing 0 for int fields and 1 for double fields - * - */ - -void MESHCollectionDriver::readFileStruct(vector & field_names,vector& iternumber,vector & ordernumber, vector & types) -{ - const char* LOC = "MEDSPLITTER::MESHCollectionDriver::readFileStruct()"; - BEGIN_OF_MED(LOC); - - const MEDMEM::MEDFILEBROWSER med_struct (_filename[0]); - int nb_fields = med_struct.getNumberOfFields(); - - MESSAGE_MED("found "< names = med_struct.getFieldNames(); - for (int ifield = 0; ifield < nb_fields; ifield++) - { - MEDMEM::VEC_DT_IT_ dtit=med_struct.getFieldIteration(names[ifield]); - for (unsigned i = 0; i < dtit.size(); i++) - { - field_names.push_back(names[ifield]); - iternumber.push_back(dtit[i].dt); - ordernumber.push_back(dtit[i].it); - types.push_back( MED_REEL64 == med_struct.getFieldType( names[ifield] )); - } - } - END_OF_MED(LOC); -} - -//!retrieves the type of a field for a given fieldname -int MESHCollectionDriver::getFieldType(const string& fieldname) -{ - const char* LOC = "MEDSPLITTER::MESHCollectionDriver::getFieldType()"; - BEGIN_OF_MED(LOC); - const MEDMEM::MEDFILEBROWSER med_struct (_filename[0]); - - int ret = ( MED_REEL64 == med_struct.getFieldType( fieldname )); - END_OF_MED(LOC); - - return ret; -} -namespace -{ -//================================================================================ -/*! - * \brief Structure used in the method below - */ -struct TJointData -{ - char _name[MED_NAME_SIZE+1]; - int _nb_couples; - med_2_3::med_int _distant_domain; - med_2_3::med_geometry_type _geo_local, _geo_dist; -}; -} - -//================================================================================ -/*! - * \brief Read CELL-CELL correspondences of joints with domains on other procs - * \param idomain - domain index to return correspondence for - * \param loc_domains - domians on this pocessor - * \param domain_selector - info on cell distribution among procs - * \param loc2glob_corr - out, correspondence pairs where distant ids are global - */ -//================================================================================ - -void MESHCollectionDriver::readLoc2GlobCellConnect(int idomain, - const set& loc_domains, - ParaDomainSelector* domain_selector, - vector & loc2glob_corr) -{ - using namespace med_2_3; - med_2_3::med_err err; - - // find joints of domains touching idomain and loaded on other processors - - TJointData joint; - list< TJointData > joints; - int total_nb_couples = 0; - - MEDMEM::MESH* loc_mesh = _collection->getMesh()[idomain]; - char* meshname = (char*) _meshname[idomain].c_str(); - char* filename = (char*) _filename[idomain].c_str(); - //cout << "#" << domain_selector->rank() << ": mesh - " << meshname << endl; - - const int loc_mesh_dim = loc_mesh->getMeshDimension(); - - const MED_EN::medGeometryElement* types = loc_mesh->getTypes(MED_EN::MED_CELL); - int nbtypes = loc_mesh->getNumberOfTypes(MED_EN::MED_CELL); - const list& all_types = MED_EN::meshEntities[ MED_EN::MED_CELL ]; - - med_idt fid = MEDfileOpen( filename, med_2_3::MED_ACC_RDONLY ); - int njoint = MEDnSubdomainJoint(fid, meshname); - for (int ijoint=0; ijoint::const_iterator dist_type = all_types.begin(); - for ( ; dist_type != all_types.end(); ++dist_type ) - { - if ( !_collection->isDimensionOK( *dist_type, loc_mesh_dim )) - continue; - joint._geo_dist = (med_geometry_type) *dist_type; - err = MEDsubdomainCorrespondenceSize(fid, meshname, joint._name, - MED_NO_DT, MED_NO_DT, - med_2_3::MED_CELL, joint._geo_local, - med_2_3::MED_CELL, joint._geo_dist, - & joint._nb_couples ); - if ( !err && joint._nb_couples > 0 ) - { - joints.push_back( joint ); - total_nb_couples += joint._nb_couples; - } - } - } - } - - // read cell pairs of found joints and replace distant local ids with global ones - - loc2glob_corr.resize( 2 * total_nb_couples ); - if ( total_nb_couples > 0 ) - { - int* cell_corresp = & loc2glob_corr[0]; - - list< TJointData >::iterator jnt = joints.begin(); - for ( ; jnt != joints.end(); ++jnt ) - { - // read cell couples - err = MEDsubdomainCorrespondenceRd(fid, meshname, jnt->_name, - MED_NO_DT,MED_NO_IT, - med_2_3::MED_CELL, jnt->_geo_local, - med_2_3::MED_CELL, jnt->_geo_dist, - cell_corresp); - if ( err ) continue; - - // distant local ids -> global ids - if ( int shift_to_global = domain_selector->getDomainShift( jnt->_distant_domain )) - for ( int i = 0 ; i < jnt->_nb_couples; ++i ) - cell_corresp[ 2*i + 1 ] += shift_to_global; - - cell_corresp += 2 * jnt->_nb_couples; - } - } - MEDfileClose( fid ); -} - -//================================================================================ -/*! - * \brief Return mesh dimension from the distributed med file having been read - */ -//================================================================================ - -int MESHCollectionDriver::readMeshDimension() const -{ - const char* LOC = "MESHCollectionDriver::readMeshDimension(): "; - if ( _filename.empty() || _meshname.empty() ) - throw MED_EXCEPTION( MEDMEM::STRING(LOC) << "file name or mesh name not available"); - - med_2_3::med_idt fid = med_2_3::MEDfileOpen(_filename[0].c_str(),med_2_3::MED_ACC_RDONLY); - if ( fid < 0 ) - throw MED_EXCEPTION( MEDMEM::STRING(LOC) << "can't open file " << _filename[0]); - - med_2_3::med_int meshDimension, spaceDimension; - med_2_3::med_mesh_type meshType; - char commentp3[MED_COMMENT_SIZE+1]; - char dtunittp3[MED_LNAME_SIZE+1]; - med_2_3::med_sorting_type sttp3; - int nstep; - med_2_3::med_axis_type axtypp3; - char *t1pp3=new char[10*MED_SNAME_SIZE+1]; // preview 10-dimensional space :) - char *t2pp3=new char[10*MED_SNAME_SIZE+1]; - int err= med_2_3::MEDmeshInfoByName(fid,_meshname[0].c_str(), - &spaceDimension, &meshDimension, &meshType, - commentp3,dtunittp3,&sttp3,&nstep,&axtypp3,t1pp3,t2pp3); - delete [] t1pp3; - delete [] t2pp3; - - med_2_3::MEDfileClose(fid); - - if ( err ) - throw MED_EXCEPTION( MEDMEM::STRING(LOC) << "mesh name is invalid"); - - return meshDimension; -} - -void MESHCollectionDriver::readSubdomain(vector& cellglobal, - vector& faceglobal, - vector& nodeglobal, int idomain) -{ - const char* LOC = "MEDSPLITTER::MESHCollectionDriver::readSubdomain()"; - BEGIN_OF_MED(LOC); - char file[256]; - char meshname[MED_NAME_SIZE+1]; - - strcpy(meshname,_meshname[idomain].c_str()); - strcpy(file,_filename[idomain].c_str()); - cout << "Reading "<<_meshname[idomain]<<" in "<<_filename[idomain]<getMesh())[idomain]=new MEDMEM::MESH; - MED_MESH_RDONLY_DRIVER meshDrv(file,mesh); - meshDrv.setMeshName( _meshname[idomain] ); - meshDrv.desactivateFacesComputation(); // else global face numbering becomes invalid - meshDrv.open(); - meshDrv.read(); - meshDrv.close(); - cout <<"End of Read"<setName(string(name)); - cz->setDescription(joint_description); - cz->setLocalDomainNumber(idomain); - cz->setDistantDomainNumber(distant); - cz->setLocalMesh((_collection->getMesh())[idomain]); - cz->setDistantMesh((_collection->getMesh())[distant]); - cz->setNodeCorresp(node_corresp,ncouples); - (_collection->getCZ()).push_back(cz); - - }//loop on correspom_topology->nbDomain())ndances - }//loop on joints - - // Reading global numbering - // - int ncell=(_collection->getMesh())[idomain]->getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - if (ncell>0) - { - int * array=new int[ncell]; - int offset=0; - MESSAGE_MED("Reading cell global numbering for mesh "<< idomain); - list::const_iterator iter; - char meshchar[MED_NAME_SIZE+1]; - strcpy(meshchar,(_collection->getMesh())[idomain]->getName().c_str()); - int nbtypes = (_collection->getMesh())[idomain]->getNumberOfTypes(MED_EN::MED_CELL); - const MED_EN::medGeometryElement* types =(_collection->getMesh())[idomain]->getTypes(MED_EN::MED_CELL); - for (int itype=0; itypeisDimensionOK(type,(_collection->getMesh())[idomain]->getMeshDimension())) - continue; - int ntype = (_collection->getMesh())[idomain]->getNumberOfElements(MED_EN::MED_CELL,type); - if (ntype==0) continue; - med_2_3::MEDmeshGlobalNumberRd(fid, meshname, - MED_NO_DT, MED_NO_IT, - med_2_3::MED_CELL, (med_2_3::med_geometry_type)type, - array+offset ); - offset+=ntype; - } - cellglobal[idomain]=array; - } - - MESSAGE_MED("Reading node global numbering"); - int nnode= (_collection->getMesh())[idomain]->getNumberOfNodes(); - { - int* array=new int[nnode]; - med_2_3::MEDmeshGlobalNumberRd(fid,meshname, - MED_NO_DT, MED_NO_IT, - med_2_3::MED_NODE, MED_POINT1, - array); - nodeglobal[idomain]=array; - } - - MESSAGE_MED("Reading face global numbering for mesh "<getMeshDimension()==3)?MED_EN::MED_FACE:MED_EN::MED_EDGE; - int nbface=(_collection->getMesh())[idomain]->getNumberOfElements(entity,MED_EN::MED_ALL_ELEMENTS); - if (nbface!=0) - { - int* array=new int[nbface]; - int offset=0; - int nbtypes = mesh->getNumberOfTypes( entity ); - const MED_EN::medGeometryElement* types =mesh->getTypes(entity); - - for (int itype=0; itype< nbtypes; itype++) - { - MED_EN::medGeometryElement type = types[itype]; - if (!_collection->isDimensionOK(type,mesh->getMeshDimension()-1)) continue; - - int ntype = mesh->getNumberOfElements(entity,type); - if (ntype==0) continue; - med_2_3::MEDmeshGlobalNumberRd( fid, meshname, - MED_NO_DT, MED_NO_IT, - med_2_3::MED_CELL, (med_2_3::med_geometry_type)type, - array+offset ); - offset+=ntype; - } - faceglobal[idomain]=array; - } - med_2_3::MEDfileClose(fid); - - END_OF_MED(LOC); -} - -void MESHCollectionDriver::writeSubdomain(int idomain, int nbdomains, char* distfilename, - ParaDomainSelector* /*domain_selector*/) -{ - MESSAGE_MED(" Number of connect zones "<<(_collection->getCZ()).size()); - - //writing connect zones in joints - - med_2_3::med_idt fid = med_2_3::MEDfileOpen(distfilename,med_2_3::MED_ACC_RDWR); - - int index_joint=0; - - - for (unsigned icz=0; icz<(_collection->getCZ()).size(); icz++) - { - if ((_collection->getCZ())[icz]->getLocalDomainNumber()==idomain) - { - med_2_3::med_err error; - int idistant=(_collection->getCZ())[icz]->getDistantDomainNumber(); - char joint_name[MED_NAME_SIZE+1]; - sprintf(joint_name,"joint_%i",idistant+1); - char desc[MED_COMMENT_SIZE+1]; - sprintf(desc,"connect_zone_%d",icz+1); - - char distant_name[MED_NAME_SIZE+1]; - //sprintf(distant_name,"domain_%i",(_collection->getCZ())[icz]->getDistantDomainNumber()); - - // sprintf(distant_name,(_collection->getMesh())[idistant]->getName().c_str()); - sprintf(distant_name,"domain_%i",idistant); - char mesh_name[MED_NAME_SIZE+1]; - - strcpy (mesh_name, _collection->getMesh(idomain)->getName().c_str()); - SCRUTE_MED(_collection->getMesh(idomain)->getName()); - error = med_2_3::MEDsubdomainJointCr(fid,mesh_name, joint_name, desc, - idistant, distant_name); - if (error==-1) cout << "erreur creation de joint "<getCZ())[icz]->getNodeNumber(); - int* node_corresp=const_cast((_collection->getCZ())[icz]->getNodeCorrespValue()); - - /* Nodes are reordered so that the ordering on the local and the distant domain - correspond. The chosen order is the natural ordering on the domain - with lowest proc id*/ - if (_collection->getSubdomainBoundaryCreates()) - { - if (idomaingetSubdomainBoundaryCreates()) - { - MED_EN::medEntityMesh constituent_entity = - (_collection->getMeshDimension()==3)?MED_EN::MED_FACE:MED_EN::MED_EDGE; - writeElementJoint(constituent_entity, icz, idomain, idistant, mesh_name,joint_name,fid); - } - index_joint++; - } - } - - char meshchar[MED_NAME_SIZE+1]; - strcpy(meshchar,(_collection->getMesh())[idomain]->getName().c_str()); - - // Writing cell global numbering - // - { - int ncell=_collection->getTopology()->getCellNumber(idomain); - int* array=new int[ncell]; - _collection->getTopology()->getCellList(idomain,array); - int offset=0; - - MED_EN::MESH_ENTITIES::const_iterator currentEntity; - list::const_iterator iter; - currentEntity = MED_EN::meshEntities.find(MED_EN::MED_CELL); - - int nbtypes = (_collection->getMesh())[idomain]->getNumberOfTypes(MED_EN::MED_CELL); - const MED_EN::medGeometryElement* types =(_collection->getMesh())[idomain]->getTypes(MED_EN::MED_CELL); - for (int itype=0; itypeisDimensionOK(type,(_collection->getMesh())[idomain]->getMeshDimension())) - continue; - int ntype = (_collection->getMesh())[idomain]->getNumberOfElements(MED_EN::MED_CELL,type); - if (ntype==0) continue; - med_2_3::MEDmeshGlobalNumberWr(fid,meshchar, - MED_NO_DT, MED_NO_IT, - med_2_3::MED_CELL, (med_2_3::med_geometry_type)type, - ntype, array+offset); - offset+=ntype; - } - delete[] array; - } - - MED_EN::medEntityMesh constituent_entity; - if (_collection->getMeshDimension()==3) - constituent_entity=MED_EN::MED_FACE; - else if (_collection->getMeshDimension()==2) - constituent_entity=MED_EN::MED_EDGE; - else throw MEDEXCEPTION("Wrong dimension"); - - - //writing face global numbering - { - int offset=0; - int nface= _collection->getTopology()->getFaceNumber(idomain); - int * array=new int[nface]; - _collection->getTopology()->getFaceList(idomain,array); - - int nbfacetypes = 0; - const MED_EN::medGeometryElement* facetypes = 0; - if ( _collection->getMesh()[idomain]->getNumberOfElements( constituent_entity, MED_ALL_ELEMENTS)) - { - nbfacetypes = (_collection->getMesh())[idomain]->getNumberOfTypes(constituent_entity); - if (nbfacetypes>0) - facetypes =(_collection->getMesh())[idomain]->getTypes(constituent_entity); - } - for (int itype=0; itypeisDimensionOK(type,_collection->getMeshDimension()-1)) continue; - - int ntype = (_collection->getMesh())[idomain]->getNumberOfElements(constituent_entity,type); - if (ntype==0) continue; - med_2_3::MEDmeshGlobalNumberWr(fid,meshchar, - MED_NO_DT, MED_NO_IT, - med_2_3::MED_CELL, (med_2_3::med_geometry_type)type, - ntype, array+offset ); - offset+=ntype; - } - delete[] array; - } - - - //writing node global numbering - { - int nnode=_collection->getTopology()->getNodeNumber(idomain); - int* array = new int[nnode]; - _collection->getTopology()->getNodeList(idomain,array); - - med_2_3::MEDmeshGlobalNumberWr(fid,meshchar, - MED_NO_DT, MED_NO_IT, - med_2_3::MED_NODE, MED_POINT1, - nnode, array); - delete[] array; - } - - med_2_3::MEDfileClose(fid); - MESSAGE_MED("End of writing"); - -} - -void MESHCollectionDriver::writeElementJoint(medEntityMesh entity , - int icz, - int idomain, - int idistant, - char* mesh_name, - char* joint_name, - med_2_3::med_idt fid ) -{ - ////////////////////////////////////////// - //writing cell/cell correspondency - ////////////////////////////////////////// - int nbcells=(_collection->getCZ())[icz]->getEntityCorrespNumber(entity,entity); - const int* index = (_collection->getCZ())[icz]->getEntityCorrespIndex(entity,entity); - const int* value = (_collection->getCZ())[icz]->getEntityCorrespValue(entity,entity); - if ( nbcells==0 ) return; // e.g. domains have 1 common node - - map , vector > cellmap; - map local_offset; - map distant_offset; - - //definition of the local offsets for the types present on local - //and distant domains - // for a mesh containing 2 triangles and 3 quads - //local_offset[TRIA3]=0 - //local_offset[QUAD4]=2 - - int nb_types_local=(_collection->getMesh())[idomain]-> getNumberOfTypes(entity); - const MED_EN::medGeometryElement* local_types = (_collection->getMesh())[idomain]->getTypes(entity); - const int* local_gni = (_collection->getMesh())[idomain]-> getGlobalNumberingIndex(entity); - for (int i=0; i< nb_types_local; i++) - { - local_offset[local_types[i]]=local_gni[i]-1; - } - - int nb_types_distant=(_collection->getMesh())[idistant]-> getNumberOfTypes(entity); - const MED_EN::medGeometryElement* distant_types = (_collection->getMesh())[idistant]->getTypes(entity); - const int* distant_gni = (_collection->getMesh())[idistant]-> getGlobalNumberingIndex(entity); - for (int i=0; i< nb_types_distant; i++) - { - distant_offset[distant_types[i]]=distant_gni[i]-1; - } - - if (nb_types_local==1 && nb_types_distant==1) - { - MED_EN::medGeometryElement local_type = (_collection->getMesh())[idomain]->getElementType(entity,1); - MED_EN::medGeometryElement distant_type = (_collection->getMesh())[idistant]->getElementType(entity,1); - vector corresp; - for (int i=0; i key - - for (int i=0; igetMesh())[idomain]->getElementType(entity,i+1); - MED_EN::medGeometryElement distant_type = (_collection->getMesh())[idistant]->getElementType(entity,value[icol]); - - cellmap[make_pair(local_type, distant_type)].push_back(i+1-local_offset[local_type]); - cellmap[make_pair(local_type, distant_type)].push_back(value[icol]-distant_offset[distant_type]); - - } - map , vector >::const_iterator iter; - - //going through all the (geom,geom) pairs and writing the joints - for (iter= cellmap.begin(); iter != cellmap.end(); iter++) - { - int size= iter->second.size(); - int *corresp = new int[size]; - for (int ind=0; ind < size; ind++) - corresp[ind]=(iter->second)[ind]; - med_2_3::med_geometry_type local_geo_elem=(med_2_3::med_geometry_type)iter->first.first; - med_2_3::med_geometry_type distant_geo_elem=(med_2_3::med_geometry_type)iter->first.second; - int size_joint=size/2; - //med_2_3::med_err error = - med_2_3::MEDsubdomainCorrespondenceWr(fid, mesh_name, joint_name, - MED_NO_DT, MED_NO_IT, - med_2_3::MED_CELL, local_geo_elem, - med_2_3::MED_CELL, distant_geo_elem, - size_joint, corresp); - delete[] corresp; - } - // MED v 2.3.1 returns an error code when - // writing a joint that is already present in the file. - // Also, it returns an error code if a joint - // concerns 3D elements. - // Until these two items are not - // changed, the following line must be commented out - - //if (error==-1) throw MEDEXCEPTION("Error filling joint"); - - - } -} - -void MESHCollectionDriver::jointSort(int* elems, int nbelems, bool is_first) -{ - //filling an ordered structure with the elem ids - map nodemap; - if (is_first) - for (int i=0; i::const_iterator iter=nodemap.begin(); iter!=nodemap.end(); iter++) - { - if (is_first) - { - *ptr_elems++=iter->first; - *ptr_elems++=iter->second; - } - else - { - *ptr_elems++=iter->second; - *ptr_elems++=iter->first; - } - } -} diff --git a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.hxx b/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.hxx deleted file mode 100644 index 0467dc308..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionDriver.hxx +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2007-2013 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 MESHCOLLECTIONDRIVER_HXX_ -#define MESHCOLLECTIONDRIVER_HXX_ - -#include "MEDSPLITTER.hxx" - -namespace MEDSPLITTER -{ - class MESHCollection; - class ParaDomainSelector; - - class MEDSPLITTER_EXPORT MESHCollectionDriver - { - public: - - MESHCollectionDriver(MESHCollection*); - virtual ~MESHCollectionDriver(){} - - virtual int read(char*, ParaDomainSelector* sel=0)=0; - int readSeq(char*,char*); - - virtual void write(char*, ParaDomainSelector* sel=0)=0; - virtual void readFields (vector *>& filenames, char* fieldname, - int itnumber, int ordernumber) =0; - virtual void readFields (vector *>& filenames, char* fieldname, - int itnumber, int ordernumber) =0; - virtual void writeFields(vector *>& filenames, char* fieldname)=0; - virtual void writeFields(vector *>& filenames, char* fieldname)=0; - - void readFileStruct(vector & field_names,vector& iternumber,vector & ordernumber,vector & types); - - int getFieldType(const std::string& fieldname); - // void exportFamily(vector,MED_EN::medEntityMesh, const string& name); - - void readLoc2GlobCellConnect(int idomain, const set& loc_domains, ParaDomainSelector* ds, - vector & loc2glob_corr); - - int readMeshDimension() const; - - protected: - - void readSubdomain(vector& cellglobal, - vector& faceglobal, - vector& nodeglobal, int idomain); - void writeSubdomain(int idomain,int nbdomain, char*filename, - ParaDomainSelector* domain_selector); - - void writeElementJoint(medEntityMesh entity , - int icz, - int idomain, - int idistant, - char* mesh_name, - char* joint_name, - med_2_3::med_idt fid ); - void jointSort(int* elems, int nbelems, bool is_first); - - - - MESHCollection* _collection; - - std::vector _filename; - std::vector _meshname; - - }; - -} - - -#endif /*MESHCOLLECTIONDRIVER_HXX_*/ diff --git a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedAsciiDriver.H b/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedAsciiDriver.H deleted file mode 100644 index 7157d9f08..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedAsciiDriver.H +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2007-2013 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 MEDSPLITTER_MESHCOLLECTIONMEDASCIIDRIVER_H -#define MEDSPLITTER_MESHCOLLECTIONMEDASCIIDRIVER_H - - -#include -#include -#include -#include - -/*!reads a distributed field - * - * \param fields vector of fields (one field per subdomain) - * \param fieldname name of the field - * \param itnumber number of iteration - * \param ordernumber internal number inside the iteration - * */ -template -void MESHCollectionMedAsciiDriver::_readFields(vector* >& fields,char* fieldname, int itnumber, int ordernumber) -{ - for (unsigned i=0; i<_collection->getMesh().size(); i++) - { - char filename[256]; - strcpy(filename,_filename[i].c_str()); - cout << "maillage : " << filename << " champ : " << fieldname << endl; - // MEDMEM::FIELD* field = new MEDMEM::FIELD(MEDMEM::MED_DRIVER,filename,fieldname,itnumber,ordernumber); - fields.push_back (new MEDMEM::FIELD(MEDMEM::MED_DRIVER,filename,fieldname,itnumber,ordernumber)); - } -} - - -/*!writes a distributed field - * - * \param fields vector of fields (one field per subdomain) - * \param fieldname name of the field - * */ -template -void MESHCollectionMedAsciiDriver::_writeFields(vector* >& fields,char* fieldname) -{ - for (unsigned i=0; i<_collection->getMesh().size(); i++) - { - char filename[256]; - strcpy(filename,_filename[i].c_str()); - int driverid = fields[i]->addDriver(MEDMEM::MED_DRIVER, filename, fieldname); - fields[i]->write(driverid); - } -} - -#endif diff --git a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedAsciiDriver.cxx b/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedAsciiDriver.cxx deleted file mode 100644 index 8a6298ca4..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedAsciiDriver.cxx +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (C) 2007-2013 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 -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#ifndef WIN32 -#include -#endif -//Debug macros -#include "MEDMEM_Utilities.hxx" - -//MEDMEM includes -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_ConnectZone.hxx" - -//MEDSPLITTER includes -#include "MEDSPLITTER_Topology.hxx" -#include "MEDSPLITTER_ParallelTopology.hxx" -#include "MEDSPLITTER_SequentialTopology.hxx" -#include "MEDSPLITTER_MESHCollectionDriver.hxx" -#include "MEDSPLITTER_MESHCollection.hxx" -#include "MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx" -#include "MEDSPLITTER_ParaDomainSelector.hxx" - -using namespace MEDSPLITTER; - -//template inclusion -#include "MEDSPLITTER_MESHCollectionMedAsciiDriver.H" - - -MESHCollectionMedAsciiDriver::MESHCollectionMedAsciiDriver(MESHCollection* collection):MESHCollectionDriver(collection) -{ -} - -/*!reads a MED File v>=2.3 - * and mounts the corresponding meshes in memory - * the connect zones are created from the joints - * - *\param filename ascii file containing the list of MED v2.3 files - * */ - -int MESHCollectionMedAsciiDriver::read(char* filename, ParaDomainSelector* domainSelector) -{ - - const char* LOC = "MEDSPLITTER::MESHCollectionDriver::read()"; - BEGIN_OF_MED(LOC); - - //ditributed meshes - vector cellglobal; - vector nodeglobal; - vector faceglobal; - - int nbdomain; - - // reading ascii master file - try{ - MESSAGE_MED("Start reading"); - ifstream asciiinput(filename); - - if (!asciiinput) - throw MEDEXCEPTION("MEDSPLITTER read - Master File does not exist"); - - char charbuffer[512]; - asciiinput.getline(charbuffer,512); - - while (charbuffer[0]=='#') - { - asciiinput.getline(charbuffer,512); - } - - //reading number of domains - nbdomain=atoi(charbuffer); - cout << "nb domain "<>nbdomain; - _filename.resize(nbdomain); - _meshname.resize(nbdomain); - (_collection->getMesh()).resize(nbdomain); - cellglobal.resize(nbdomain); - nodeglobal.resize(nbdomain); - faceglobal.resize(nbdomain); - - if (nbdomain == 0) - throw MEDEXCEPTION("Empty ASCII master file"); - for (int i=0; i> mesh >> idomain >> _meshname[i] >> host >> _filename[i]; - - //Setting the name of the global mesh (which is the same - //for all the subdomains) - if (i==0) - _collection->setName(mesh); - - if (idomain!=i+1) - { - cerr<<"Error : domain must be written from 1 to N in asciifile descriptor"<isMyDomain(i)) - readSubdomain(cellglobal,faceglobal,nodeglobal, i); - - }//loop on domains - MESSAGE_MED("end of read"); - }//of try - catch(...) - { - cerr << "I/O error reading parallel MED file"<getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal); - _collection->setTopology(aPT); - - for (int i=0; igetMesh().size(); - _filename.resize(nbdomains); - - //loop on the domains - for (int idomain=0; idomainisMyDomain( idomain ) ) - { - if ( !_collection->getMesh()[idomain]->getConnectivityptr() ) continue;//empty domain - - int id=(_collection->getMesh())[idomain]->addDriver(MEDMEM::MED_DRIVER,distfilename,(_collection->getMesh())[idomain]->getName(),MED_EN::WRONLY); - - MESSAGE_MED("Start writing"); - (_collection->getMesh())[idomain]->write(id); - - writeSubdomain(idomain, nbdomains, distfilename, domainSelector); - } - } - - // write master file - if ( !domainSelector || domainSelector->rank() == 0 ) - { - ofstream file(filename); - - file <<"#MED Fichier V 2.3"<<" "<getMesh().size()<<" "<getName() <<" "<< idomain+1 << " " - << (_collection->getMesh())[idomain]->getName() << " localhost " - << _filename[idomain] << " "< *>& filenames, char* fieldname, - int itnumber, int ordernumber) - { - _readFields(filenames,fieldname,itnumber,ordernumber); - } - void readFields(vector *>& filenames, char* fieldname, - int itnumber, int ordernumber) - { - _readFields(filenames,fieldname,itnumber,ordernumber); - } - - void writeFields(vector *>& filenames, char* fieldname) - { - _writeFields( filenames, fieldname); - } - - void writeFields(vector *>& filenames, char* fieldname) - { - _writeFields( filenames, fieldname); - } - - - private : - template void _readFields(vector *>& filenames, char* fieldname, - int itnumber, int ordernumber); - - template - void _writeFields(vector *>& filenames, char* fieldname); - - - - std::string _master_filename; - }; - -} - - -#endif /*MESHCOLLECTIONDRIVER_HXX_*/ diff --git a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.H b/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.H deleted file mode 100644 index 1a9c74f32..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.H +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2007-2013 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 MEDSPLITTER_MESHCOLLECTIONMEDXMLDRIVER_H -#define MEDSPLITTER_MESHCOLLECTIONMEDXMLDRIVER_H - - -#include -#include -#include -#include - - - -/*!reads a distributed field - * - * \param fields vector of fields (one field per subdomain) - * \param fieldname name of the field - * \param itnumber number of iteration - * \param ordernumber internal number inside the iteration - * */ -template -void MESHCollectionMedXMLDriver::_readFields(vector* >& fields,char* fieldname, int itnumber, int ordernumber) -{ - for (unsigned i=0; i<_collection->getMesh().size(); i++) - { - char filename[256]; - strcpy(filename,_filename[i].c_str()); - cout << "maillage : " << filename << " champ : " << fieldname << endl; - // MEDMEM::FIELD* field = new MEDMEM::FIELD(MEDMEM::MED_DRIVER,filename,fieldname,itnumber,ordernumber); - fields.push_back (new MEDMEM::FIELD(MEDMEM::MED_DRIVER,filename,fieldname,itnumber,ordernumber)); - } -} - - -/*!writes a distributed field - * - * \param fields vector of fields (one field per subdomain) - * \param fieldname name of the field - * */ -template -void MESHCollectionMedXMLDriver::_writeFields(vector* >& fields,char* fieldname) -{ - xmlDocPtr master_doc=xmlParseFile(_master_filename.c_str()); - - if (!master_doc) - throw MEDEXCEPTION("MEDSPLITTER writeFields - Master File does not exist"); - - //number of domains - - xmlXPathContextPtr xpathCtx = xmlXPathNewContext(master_doc); - xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(BAD_CAST "//mapping/mesh", xpathCtx); - //assuming there is only one mesh in the XML file - xmlNodePtr mesh_node= xpathObj->nodesetval->nodeTab[0]; - - //adds the field to the master file if necessary - bool exist_field =false; - xpathObj = xmlXPathEvalExpression(BAD_CAST "//mapping/mesh/field", xpathCtx); - //assuming there is only one mesh in the XML file - int field_nr = xpathObj->nodesetval->nodeNr; - for (int i=0; inodesetval->nodeTab[i]->properties->children->content, fieldname)==0) - exist_field = true; - } - - xmlNodePtr field_node; - if (!exist_field) - { - field_node = xmlNewChild(mesh_node, 0, BAD_CAST "field",0); - xmlNewProp(field_node,BAD_CAST "name",BAD_CAST fieldname); - } - - - for (unsigned i=0; i<_collection->getMesh().size(); i++) - { - char filename[256]; - strcpy(filename,_filename[i].c_str()); - int driverid = fields[i]->addDriver(MEDMEM::MED_DRIVER, filename, fieldname); - fields[i]->write(driverid); - - //adds the partition to the master file if the field had not been - //added already - if (!exist_field) - { - xmlNodePtr chunk_node= xmlNewChild(field_node,0,BAD_CAST "chunk",0); - char id[8]; - sprintf(id,"%d",i+1); - xmlNewProp(chunk_node,BAD_CAST "subdomain",BAD_CAST id); - //xmlNewProp(chunk_node,BAD_CAST "name", BAD_CAST fieldname); - //xmlNodePtr fieldname_node= - xmlNewChild(chunk_node,0,BAD_CAST "name", BAD_CAST fieldname); - } - } - //Writing file - xmlKeepBlanksDefault(0); - xmlSaveFormatFileEnc(_master_filename.c_str(), master_doc, "UTF-8", 1); - - //Clean up - xmlXPathFreeContext(xpathCtx); - xmlFreeDoc(master_doc); - //xmlCleanupParser(); - -} - -#endif diff --git a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.cxx b/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.cxx deleted file mode 100644 index 6843dc4b9..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.cxx +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (C) 2007-2013 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 -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#ifndef WIN32 -#include -#else -#include -#include -#endif -//Debug macros -#include "MEDMEM_Utilities.hxx" - -//MEDMEM includes -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_ConnectZone.hxx" - -//MEDSPLITTER includes -#include "MEDSPLITTER_Topology.hxx" -#include "MEDSPLITTER_ParallelTopology.hxx" -#include "MEDSPLITTER_SequentialTopology.hxx" -#include "MEDSPLITTER_MESHCollectionDriver.hxx" -#include "MEDSPLITTER_MESHCollection.hxx" -#include "MEDSPLITTER_MESHCollectionMedXMLDriver.hxx" -#include "MEDSPLITTER_ParaDomainSelector.hxx" - -using namespace MEDSPLITTER; - -//template inclusion -#include "MEDSPLITTER_MESHCollectionMedXMLDriver.H" - -/*!\class MESHCollectionMedXMLDriver - * - *\brief Driver for MED 3.2 files having XML master files - * - * Driver for reading and writing distributed files - * for which the master file is written in an XML format compliant with - * the MED 3.2 specification. - * The reading and writing of the meshes and fields are apart : - * the meshes must always be written/read before the fields. Reading/Writing fields - * is optional and is done field after field. API for reading/writing fields - * is written with a template so that MEDMEM::FIELD and MEDMEM::FIELD - * can be conveniently handled. -*/ - -MESHCollectionMedXMLDriver::MESHCollectionMedXMLDriver(MESHCollection* collection):MESHCollectionDriver(collection) -{ -} - -/*!reads a MED File XML Master File v>=2.3 - * and mounts the corresponding meshes in memory - * the connect zones are created from the joints - * - *\param filename XML file containing the list of MED v2.3 files - * */ - -int MESHCollectionMedXMLDriver::read(char* filename, ParaDomainSelector* domainSelector) -{ - const char* LOC = "MEDSPLITTER::MESHCollectionDriver::read()"; - BEGIN_OF_MED(LOC); - - //ditributed meshes - vector cellglobal; - vector nodeglobal; - vector faceglobal; - - int nbdomain; - - _master_filename=filename; - - // reading ascii master file - try - { - MESSAGE_MED("Start reading"); - - // Setting up the XML tree corresponding to filename - xmlDocPtr master_doc=xmlParseFile(filename); - - if (!master_doc) - throw MEDEXCEPTION("MEDSPLITTER XML read - Master File does not exist o r is not compliant with XML scheme"); - - //////////////////// - //number of domains - //////////////////// - xmlXPathContextPtr xpathCtx = xmlXPathNewContext(master_doc); - xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(BAD_CAST "//splitting/subdomain", xpathCtx); - if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0) - { - xmlXPathFreeObject(xpathObj); - throw MEDEXCEPTION("MEDSPLITTER read - XML Master File does not contain /MED/splitting/subdomain node"); - } - /* as subdomain has only one property which is "number" - * it suffices to take the content of its first child */ - const char* mystring = (const char*)xpathObj->nodesetval->nodeTab[0]->properties->children->content; - sscanf(mystring, "%d", &nbdomain); - - ////////////////// - //mesh name - ////////////////// - xmlXPathFreeObject(xpathObj); - xpathObj = xmlXPathEvalExpression(BAD_CAST "//content/mesh", xpathCtx); - if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0) - { - xmlXPathFreeObject(xpathObj); - throw MEDEXCEPTION("MEDSPLITTER read - XML Master File does not contain /MED/content/mesh node"); - } - _collection->setName( (const char*)xpathObj->nodesetval->nodeTab[0]->properties->children->content); - - cout << "nb domain " << nbdomain << endl; - _filename.resize(nbdomain); - _meshname.resize(nbdomain); - (_collection->getMesh()).resize(nbdomain); - cellglobal.resize(nbdomain); - nodeglobal.resize(nbdomain); - faceglobal.resize(nbdomain); - - - // retrieving the node which contains the file names - const char filechar[]="//files/subfile"; - xmlXPathFreeObject(xpathObj); - xpathObj = xmlXPathEvalExpression(BAD_CAST filechar, xpathCtx); - if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0) - { - xmlXPathFreeObject(xpathObj); - throw MEDEXCEPTION("MEDSPLITTER read - XML Master File does not contain /MED/files/subfile nodes"); - } - int nbfiles = xpathObj->nodesetval ->nodeNr; - - for (int i=0; inodesetval ==0) - throw MEDEXCEPTION("MED XML reader : Error retrieving file name "); - _filename[i]=(const char*)xpathObjfilename->nodesetval->nodeTab[0]->children->content; - - //////////////////////////////// - //reading the local mesh names - //////////////////////////////// - ostringstream mesh_search_string; - mesh_search_string<<"//mapping/mesh/chunk[@subdomain=\""<nodesetval ==0) - throw MEDEXCEPTION("MED XML reader : Error retrieving mesh name "); - _meshname[i]=(const char*)xpathMeshObj->nodesetval->nodeTab[0]->children->content; - - if ( !domainSelector || domainSelector->isMyDomain(i)) - readSubdomain(cellglobal, faceglobal, nodeglobal, i); - xmlXPathFreeObject(xpathObjfilename); - - xmlXPathFreeObject(xpathMeshObj); - }//loop on domains - - // LIBXML cleanup - xmlXPathFreeObject(xpathObj); - xmlXPathFreeContext(xpathCtx); - xmlFreeDoc(master_doc); - - MESSAGE_MED("end of read"); - }//of try - catch(...) - { - throw MEDEXCEPTION("I/O error reading parallel MED file"); - } - - //creation of topology from mesh and connect zones - ParallelTopology* aPT = new ParallelTopology - ((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal); - _collection->setTopology(aPT); - - for (int i=0; itm_year - ,time_asc->tm_mon+1 - ,time_asc->tm_mday); -#else - SYSTEMTIME st; - GetLocalTime ( &st ); - sprintf(date,"%02d%02d%02d", - st.wYear - ,st.wMonth - ,st.wDay); -#endif - - node = xmlNewChild(root_node,0, BAD_CAST "description",0); - - xmlNewProp(node, BAD_CAST "what", BAD_CAST _collection->getDescription().c_str()); - xmlNewProp(node, BAD_CAST "when", BAD_CAST date); - - //Content tag - node =xmlNewChild(root_node,0, BAD_CAST "content",0); - node2 = xmlNewChild(node, 0, BAD_CAST "mesh",0); - xmlNewProp(node2, BAD_CAST "name", BAD_CAST _collection->getName().c_str()); - - //Splitting tag - node=xmlNewChild(root_node,0,BAD_CAST "splitting",0); - node2=xmlNewChild(node,0,BAD_CAST "subdomain",0); - sprintf(buff, "%d", (int)_collection->getMesh().size()); - xmlNewProp(node2, BAD_CAST "number", BAD_CAST buff); - node2=xmlNewChild(node,0,BAD_CAST "global_numbering",0); - xmlNewProp(node2, BAD_CAST "present", BAD_CAST "yes"); - - //Files tag - xmlNodePtr file_node=xmlNewChild(root_node,0,BAD_CAST "files",0); - - //Mapping tag - node = xmlNewChild(root_node,0,BAD_CAST "mapping",0); - xmlNodePtr mesh_node = xmlNewChild(node, 0, BAD_CAST "mesh",0); - xmlNewProp(mesh_node, BAD_CAST "name", BAD_CAST _collection->getName().c_str()); - - int nbdomains= _collection->getMesh().size(); - _filename.resize(nbdomains); - - //loop on the domains - for (int idomain=nbdomains-1; idomain>=0;idomain--) - { - char distfilename[256]; - - ostringstream suffix; - suffix << filename<< idomain+1 <<".med"; - - strcpy(distfilename,suffix.str().c_str()); - - _filename[idomain]=string(distfilename); - - MESSAGE_MED("File name "<isMyDomain( idomain ) ) - { - if ( !_collection->getMesh()[idomain]->getConnectivityptr() ) continue;//empty domain - - int id=(_collection->getMesh())[idomain]->addDriver(MEDMEM::MED_DRIVER,distfilename,(_collection->getMesh())[idomain]->getName(),MED_EN::WRONLY); - - MESSAGE_MED("Start writing"); - (_collection->getMesh())[idomain]->write(id); - (_collection->getMesh())[idomain]->rmDriver(id); - - writeSubdomain(idomain, nbdomains, distfilename, domainSelector); - } - //updating the ascii description file - node = xmlNewChild(file_node, 0, BAD_CAST "subfile",0); - sprintf (buff,"%d",idomain+1); - xmlNewProp(node, BAD_CAST "id", BAD_CAST buff); - xmlNewChild(node,0,BAD_CAST "name",BAD_CAST distfilename); - xmlNewChild(node,0,BAD_CAST "machine",BAD_CAST "localhost"); - - node = xmlNewChild(mesh_node,0, BAD_CAST "chunk",0); - xmlNewProp(node, BAD_CAST "subdomain", BAD_CAST buff); - xmlNewChild(node,0,BAD_CAST "name", BAD_CAST (_collection->getMesh())[idomain]->getName().c_str()); - } - strcat(filename,".xml"); - _master_filename=filename; - if ( !domainSelector || domainSelector->rank() == 0 ) - xmlSaveFormatFileEnc(filename, master_doc, "UTF-8", 1); - xmlFreeDoc(master_doc); - //xmlCleanupParser(); - - END_OF_MED(LOC); -} diff --git a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.hxx b/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.hxx deleted file mode 100644 index 0792b6bcb..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_MESHCollectionMedXMLDriver.hxx +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2007-2013 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 MESHCOLLECTIONMEDXMLDRIVER_HXX_ -#define MESHCOLLECTIONMEDXMLDRIVER_HXX_ - -#include "MEDSPLITTER_MESHCollectionDriver.hxx" - -namespace MEDSPLITTER -{ - class MESHCollection; - - class MESHCollectionMedXMLDriver:public MESHCollectionDriver - { - public: - - MESHCollectionMedXMLDriver(MESHCollection*); - virtual ~MESHCollectionMedXMLDriver(){} - - - int read(char*, ParaDomainSelector* sel=0); - - void write(char*, ParaDomainSelector* sel=0); - - void readFields(vector *>& filenames, char* fieldname, - int itnumber, int ordernumber) - { - _readFields(filenames,fieldname,itnumber,ordernumber); - } - void readFields(vector *>& filenames, char* fieldname, - int itnumber, int ordernumber) - { - _readFields(filenames,fieldname,itnumber,ordernumber); - } - - void writeFields(vector *>& filenames, char* fieldname) - { - _writeFields( filenames, fieldname); - } - void writeFields(vector *>& filenames, char* fieldname) - { - _writeFields( filenames, fieldname); - } - - - - private : - - template void _readFields(vector *>& filenames, char* fieldname, - int itnumber, int ordernumber); - - template - void _writeFields(vector *>& filenames, char* fieldname); - - std::string _master_filename; - }; - -} - - -#endif /*MESHCOLLECTIONDRIVER_HXX_*/ diff --git a/src/MEDSPLITTER/MEDSPLITTER_METISGraph.cxx b/src/MEDSPLITTER/MEDSPLITTER_METISGraph.cxx deleted file mode 100644 index 4dea7ccc0..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_METISGraph.cxx +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (C) 2007-2013 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 -// - -#ifdef MED_ENABLE_PARMETIS -#include -#endif -#ifdef MED_ENABLE_METIS -extern "C" { -#include -} -#endif - -#include "MEDSPLITTER_METISGraph.hxx" -#include "MEDSPLITTER_ParaDomainSelector.hxx" - -using namespace MEDSPLITTER; - -METISGraph::METISGraph():Graph() -{ -} - -METISGraph::METISGraph(MEDMEM::MEDSKYLINEARRAY* graph, int* edgeweight) - :Graph(graph,edgeweight) -{ -} - -METISGraph::~METISGraph() -{ -} - -void METISGraph::partGraph(int ndomain, - const string& options_string, - ParaDomainSelector* parallelizer) -{ - // number of graph vertices - int n = m_graph->getNumberOf(); - - //graph - int * xadj=const_cast(m_graph->getIndex()); - int * adjncy = const_cast(m_graph->getValue()); - //constraints - int * vwgt=m_cellweight; - int * adjwgt=m_edgeweight; - int wgtflag=(m_edgeweight!=0)?1:0+(m_cellweight!=0)?2:0; - - //base 0 or 1 - int base=1; - - //ndomain - int nparts = ndomain; - - //options - int options[5]={0,0,0,0,0}; - - // output parameters - int edgecut; - int* partition = new int[n]; - - if (nparts >1) - { - if ( parallelizer ) - { -#ifdef MED_ENABLE_PARMETIS - // distribution of vertices of the graph among the processors - int * vtxdist = parallelizer ? parallelizer->getNbVertOfProcs() : 0; - MPI_Comm comm = MPI_COMM_WORLD; - - ParMETIS_PartKway( vtxdist, xadj, adjncy, vwgt, adjwgt, &wgtflag, - &base, &nparts, options, &edgecut, partition, &comm ); -#else - throw MED_EXCEPTION("ParMETIS is not available. Check your products, please."); -#endif - } - else - { -#ifdef MED_ENABLE_METIS - if (options_string != "k") - METIS_PartGraphRecursive(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, - &base, &nparts, options, &edgecut, partition); - else - METIS_PartGraphKway(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, - &base, &nparts, options, &edgecut, partition); -#else - throw MED_EXCEPTION("METIS is not available. Check your products, please."); -#endif - } - } - else - { - for (int i=0; i struct TSlice - { - typedef MEDMEM::PointerOf TPtr; - TPtr _pointer; - int _size; - - TSlice(): _size(0) {} - TSlice& operator=(const TSlice& s){_size = s._size; _pointer.set(_size,s._pointer); return *this;} - TSlice(const TSlice& other): _size(other._size),_pointer(other._size, other._pointer){} // copy - void resize(int nb) { _size=nb; _pointer.set(nb); } - void setPtr(int nb, const T* ptr) { _size=nb; _pointer.set(ptr); } // shallowcopy - void copy (int nb, const T* ptr) { _size=nb; _pointer.set(nb,ptr); } // deep copy - void clear() { _size=0; _pointer.set(0); } - T& operator[](const int i) { return _pointer[i]; } - string dumpPtr() const; // debug - }; - template<> string TSlice::dumpPtr() const - { - return _size > 0 ? string(_pointer) : string(""); - } - template string TSlice::dumpPtr() const - { - MEDMEM::STRING res(""); - for ( int i = 0; i < _size && res.size() < 200; ++i ) - res << _pointer[i] << " "; - return res; - } - typedef TSlice TIntSlice; - typedef TSlice TCharSlice; - typedef TSlice TDoubleSlice; - - //================================================================================ - /*! - * \brief Make TCharSlice from string - */ - //================================================================================ - - TCharSlice toCharSlice( const string& str ) - { - TCharSlice slice; - if ( !str.empty() ) - slice.setPtr( str.size() + 1, str.c_str()); - return slice; - } - - //================================================================================ - /*! - * \brief Make string from TCharSlice - */ - //================================================================================ - - string fromCharSlice( TCharSlice& slice ) - { - return slice._size < 1 ? string() : string( slice._pointer ); - } - -#define DEB_OUT(txt) \ -//cout << txt << endl; - //================================================================================ - /*! - * \brief Put list of slices into one array - * \param data - slices of data - * \param buffer - output array - */ - //================================================================================ - template< typename T > - void serialize( vector< TSlice< T > >& data, vector< T >& buffer) - { - // mesure data - int shift = max( 1, int(sizeof(int)/sizeof(T))); // nb of T to store int - int size = shift; // to store nb of slices in data - typename vector< TSlice< T > >::iterator slice = data.begin(); - for ( ; slice != data.end(); ++slice ) - size += slice->_size + shift; // +shift - to store each slice size in the buffer - - // fill in the buffer - - buffer.resize( size ); - T* ptr = & buffer[0]; - // store nb of slices as the first number - *((int*) ptr) = (int) data.size(); - ptr += shift; - - DEB_OUT( "\n *** Nb slices: " << data.size()); - for ( slice = data.begin(); slice != data.end(); ++slice ) - { - *((int*) ptr) = (int) slice->_size; - ptr += shift; - if ( slice->_size ) - memcpy( ptr, slice->_pointer, slice->_size * sizeof(T)); - ptr += slice->_size; - DEB_OUT("#"<< slice - data.begin() << ": \tsize " << slice->_size << " \t" << slice->dumpPtr()); - slice->clear(); - } - data.clear(); - } - //================================================================================ - /*! - * \brief Retrieve data slices from array - * \param data - output slices of data - * \param buffer - data array - * \retval int - zero or slice index (counting from 1) where deserialization failed - */ - //================================================================================ - - template< typename T > - int deserialize( vector< T >& buffer, vector< TSlice< T > >& data ) - { - T* ptr = & buffer[0]; - T* end = ptr + buffer.size(); - - int nb_slices = *((int*) ptr); - data.resize( nb_slices ); - int shift = max( 1, int(sizeof(int)/sizeof(T))); // nb of T to store int - ptr += shift; - - DEB_OUT( "Nb slices: " << data.size()); - for ( int i = 0; i < nb_slices; ++i ) - { - data[i]._size = *((int*) ptr); - ptr += shift; - data[i]._pointer.set( ptr ); - DEB_OUT("#"<< i << ": \tsize " << data[i]._size << " \t" << data[i].dumpPtr()); - if ( data[i]._size < 0 || data[i]._size > end - ptr ) - return i + 1; // error - ptr += data[i]._size; - } - DEB_OUT(" *** END" << endl ) - return 0; - } - - //================================================================================ - /*! - * \brief Return all groups and families of mesh - */ - //================================================================================ - - void getGroupsAndFamilies( MEDMEM::MESH* mesh, - vector< MEDMEM::GROUP*>& groups, - vector< MEDMEM::FAMILY*> & families) - { - medEntityMesh face_entity = mesh->getMeshDimension()==3 ? MED_FACE : MED_EDGE; - - // get all groups - groups = mesh->getGroups( MED_CELL ); - vector< MEDMEM::GROUP* > face_groups = mesh->getGroups( face_entity ); - vector< MEDMEM::GROUP* > node_groups = mesh->getGroups( MED_NODE ); - groups.insert( groups.end(), face_groups.begin(), face_groups.end()); - groups.insert( groups.end(), node_groups.begin(), node_groups.end()); - - // get all families - families = mesh->getFamilies( MED_CELL ); - vector< MEDMEM::FAMILY* > face_families = mesh->getFamilies( face_entity ); - vector< MEDMEM::FAMILY* > node_families = mesh->getFamilies( MED_NODE ); - families.insert( families.end(), face_families.begin(), face_families.end() ); - families.insert( families.end(), node_families.begin(), node_families.end() ); - } - - enum SliceEnum // indices of fixed slices and sub-indices within slices - { - // INT slices - SLC_GENERAL_INFO = 0, - SLC_GEOM_TYPES, - SLC_FAMILY_GEN_DATA, - SLC_FAMILY_GROUP_IDS, - SLC_POLYGON_INDEX, - SLC_POLYHED_INDEX, - SLC_FIRST_STD_CONN, // index of the first of non-fixed int slices: - // - connectivities of std types and - // - elements of families - - // sub-indices of SLC_GENERAL_INFO: - I_SPACEDIM = 0, I_MESHDIM, - I_NB_CELL_TYPES, I_NB_FACE_TYPES, I_NB_NODES, I_NB_GROUPS, - I_NB_CELL_FAMILY, I_NB_FACE_FAMILY, I_NB_NODES_FAMILY, - I_HAD_FAMILIES, - I_MIN_SIZE, // size of SLC_GENERAL_INFO - - // sub-indices repeated within SLC_FAMILY_DATA for each group: - I_FAM_ID = 0, I_NB_FAM_TYPES, I_NB_FAM_GROUPS, - I_FAM_DATA_SIZE, - - // CHAR slices - SLC_MESH_NAME = 0, - SLC_MESH_DESC, - SLC_COORD_SYS, - SLC_FIRST_COORD_NAME // index of the first of non-fixed char slices: - // - coord names - // - coord unites - // - family names - // - group names - }; - enum TagEnum - { - // MPI message tags - TAG_INT = 1032, TAG_COORD = 2064, TAG_CHAR = 3008, - TAG_NODE_NUMS = 4032, TAG_CELL_NUMS = 5032, TAG_FACE_NUMS = 6032, - - // miscellaneous - IS_ON_ALL_FLAG = -1 - }; - - //================================================================================ - /*! - * \brief Enrich MEDMEM::MESHING with addFamily() etc - */ - //================================================================================ - - struct TMESHING : public MEDMEM::MESHING - { - MEDMEM::FAMILY* addFamily(MEDMEM::FAMILY* family, const medEntityMesh& entity) - { - switch ( entity ) { - case MED_CELL: _familyCell.push_back(family); break; - case MED_FACE: _familyFace.push_back(family); break; - case MED_EDGE: _familyEdge.push_back(family); break; - case MED_NODE: _familyNode.push_back(family); break; - default : - throw MED_EXCEPTION(LOCALIZED("Bad Entity !")); - } - family->setMesh( this ); - family->setEntity( entity ); - return family; - } - //================================================================================ - /*! - * \brief Remove all families that prevent correct writting groups that not pass through - * send/recieve as no families exist for them - */ - //================================================================================ - - void clearFamilies() - { - vector< MEDMEM::GROUP*> groups; - vector< MEDMEM::FAMILY*> families; - getGroupsAndFamilies(this, groups, families); - - for ( int i = 0; i < families.size(); ++i ) - { - addReference(); - families[i]->removeReference(); - } - _familyCell.clear(); - _familyFace.clear(); - _familyEdge.clear(); - _familyNode.clear(); - - families.clear(); - for ( int i = 0; i < groups.size(); ++i ) - groups[i]->setNumberOfFamilies(0), groups[i]->setFamilies(families); - } - - //================================================================================ - /*! - * \brief Sets type of coordinate system - */ - //================================================================================ - - void setCoordinatesSystem(const std::string& system) - { - _coordinate->setCoordinatesSystem(system); - } - - //================================================================================ - /*! - * \brief Sets space dimension - */ - //================================================================================ - - void setSpaceDimension( int dim ) - { - _spaceDimension = dim; - } - - //================================================================================ - /*! - * \brief Sets the number of nodes in the mesh - */ - //================================================================================ - - void setNumberOfNodes(const int NumberOfNodes) - { - _numberOfNodes = NumberOfNodes ; - } - }; - - //================================================================================ - /*! - * \brief Set string data to mesh - */ - //================================================================================ - - void setNames( vector< TCharSlice> & char_data, MEDMEM::MESH* mesh ) - { - if ( char_data.size() < SLC_FIRST_COORD_NAME + 2 * mesh->getSpaceDimension() ) - throw MED_EXCEPTION(LOCALIZED("Internal error in MeshSendReceive::recv()")); - - TMESHING* meshing = (TMESHING*) mesh; - - meshing->setName ( fromCharSlice( char_data[ SLC_MESH_NAME ])); - meshing->setDescription ( fromCharSlice( char_data[ SLC_MESH_DESC ])); - meshing->setCoordinatesSystem( fromCharSlice( char_data[ SLC_COORD_SYS ])); - - int char_slice = SLC_FIRST_COORD_NAME; - for ( int ax = 0; ax < meshing->getSpaceDimension(); ++ax ) - { - meshing->setCoordinateName( fromCharSlice( char_data[ char_slice++ ]), ax ); - meshing->setCoordinateUnit( fromCharSlice( char_data[ char_slice++ ]), ax ); - } - - // names of groups and families - - vector< MEDMEM::GROUP* > groups; - vector< MEDMEM::FAMILY*> families; - getGroupsAndFamilies( mesh, groups, families ); - - int group_slice_0 = char_slice + families.size(); - for ( int f = 0; char_slice < char_data.size() && f < families.size(); ++char_slice, ++f ) - { - families[f]->setName ( fromCharSlice( char_data[ char_slice ])); - // group names in families - const string* group_ids = families[f]->getGroupsNames(); - vector< string > group_names( families[f]->getNumberOfGroups() ); - for ( int i = 0; i < families[f]->getNumberOfGroups(); ++i ) - { - int group_id = atoi( group_ids[i].c_str() ); - group_names[i] = fromCharSlice( char_data[ group_slice_0 + group_id ]); - } - families[f]->setGroupsNames( & group_names[0] ); - } - // group names - for ( int g = 0; char_slice < char_data.size() && g < groups.size(); ++char_slice, ++g ) - groups[g]->setName( fromCharSlice( char_data[ char_slice ])); - } - - - //================================================================================ - /*! - * \brief Creates families and groups in the mesh - */ - //================================================================================ - - void makeGroupsAndFamilies ( TMESHING* mesh, vector< TIntSlice >& int_data, int first_elem_slice ) - { - int nb_cell_fams = int_data [ SLC_GENERAL_INFO ][ I_NB_CELL_FAMILY ]; - int nb_face_fams = int_data [ SLC_GENERAL_INFO ][ I_NB_FACE_FAMILY ]; - int nb_node_fams = int_data [ SLC_GENERAL_INFO ][ I_NB_NODES_FAMILY ]; - - medEntityMesh face_entity = mesh->getMeshDimension()==3 ? MED_FACE : MED_EDGE; - - // make families - vector< MEDMEM::FAMILY*> families; - for ( int g = 0; g < nb_cell_fams; ++g ) - families.push_back( mesh->addFamily( new MEDMEM::FAMILY, MED_CELL )); - for ( int g = 0; g < nb_face_fams; ++g ) - families.push_back( mesh->addFamily( new MEDMEM::FAMILY, face_entity )); - for ( int g = 0; g < nb_node_fams; ++g ) - families.push_back( mesh->addFamily( new MEDMEM::FAMILY, MED_NODE )); - - vector< list< MEDMEM::FAMILY* > > fams_of_group( int_data[ SLC_GENERAL_INFO ][ I_NB_GROUPS ]); - - const int* fam_data = int_data [ SLC_FAMILY_GEN_DATA ]._pointer; - const int* fam_groups = int_data [ SLC_FAMILY_GROUP_IDS ]._pointer; - int i_group = 0, fam_elem_slice = first_elem_slice; - - // set family data - for ( int f = 0; f < families.size(); ++f, fam_data += I_FAM_DATA_SIZE ) - { - families[f]->setIdentifier( fam_data[ I_FAM_ID ] ); - // set types and elements - int nb_geom_types = fam_data[ I_NB_FAM_TYPES ]; - families[f]->setNumberOfGeometricType( nb_geom_types ); - if ( nb_geom_types < 1 || int_data[ fam_elem_slice ]._size < 1 ) - { - } - else if ( int_data[ fam_elem_slice ][0] == IS_ON_ALL_FLAG ) - { - families[f]->setAll(true); - families[f]->update(); - } - else - { - vector< medGeometryElement > geom_types( nb_geom_types ); - vector< int > nb_elements( nb_geom_types ); - vector< int > index( nb_geom_types + 1); - index[0] = 1; - for ( int t = 0; t < nb_geom_types; ++t ) - { - if ( families[f]->getEntity() != MED_NODE ) - geom_types[t] = mesh->getElementType( families[f]->getEntity(), - int_data[ fam_elem_slice + t ][0] ); - else - geom_types[t] = MED_NONE; - nb_elements[t] = int_data[ fam_elem_slice ]._size; - index[t+1] = index[t] + nb_elements[t]; - } - families[f]->setGeometricType( &geom_types[0] ); - families[f]->setNumberOfElements( &nb_elements[0] ); - families[f]->setNumber(new MEDMEM::MEDSKYLINEARRAY(nb_geom_types, index[nb_geom_types]-1)); - families[f]->getnumber()->setIndex( & index[0] ); - for ( int t = 0; t < nb_geom_types; ++t ) - families[f]->getnumber()->setI( t+1, int_data[ fam_elem_slice + t ]._pointer ); - } - fam_elem_slice += nb_geom_types; - - // set groups of a family - vector< string > group_names( fam_data[ I_NB_FAM_GROUPS] ); - for ( int g = 0; g < group_names.size(); ++g ) - { - int group_id = fam_groups[ i_group++ ]; - fams_of_group[ group_id ].push_back( families[f] ); - // store group id as string until real names are read - group_names[g] = MEDMEM::STRING( group_id ); - } - families[f]->setNumberOfGroups( group_names.size() ); - families[f]->setGroupsNames( &group_names[0] ); - } - // create groups - - for ( int g = 0; g < fams_of_group.size(); ++g ) - { - MEDMEM::GROUP* group = new MEDMEM::GROUP( "", fams_of_group[ g ]); - mesh->addGroup( *group ); - group->removeReference(); - } - } - - //================================================================================ - /*! - * \brief Restore mesh from received data - */ - //================================================================================ - - MEDMEM::MESH* makeMesh( vector< TIntSlice >& int_data, bool& toClearFamilies ) - { - if ( int_data.empty() || int_data[ SLC_GENERAL_INFO ]._size < I_MIN_SIZE || - int_data[ SLC_GENERAL_INFO ][ I_NB_NODES ] < 1 ) - return 0; - - TMESHING* mesh = new TMESHING(); - // general info - mesh->setSpaceDimension( int_data[ SLC_GENERAL_INFO ][ I_SPACEDIM ]); - mesh->setNumberOfNodes ( int_data[ SLC_GENERAL_INFO ][ I_NB_NODES ]); - int meshDimension = int_data[ SLC_GENERAL_INFO ][ I_MESHDIM ]; - - // nb of types - medEntityMesh face_entity = meshDimension==3 ? MED_FACE : MED_EDGE; - int nb_cell_types = int_data[ SLC_GENERAL_INFO ][ I_NB_CELL_TYPES ]; - int nb_face_types = int_data[ SLC_GENERAL_INFO ][ I_NB_FACE_TYPES ]; - mesh->setNumberOfTypes ( nb_cell_types, MED_CELL ); - mesh->setNumberOfTypes ( nb_face_types, face_entity ); - - // types and nb of elems - vector< medGeometryElement > types( nb_cell_types + nb_face_types ); - vector< int > nbElementsByType( types.size() ) ; - int t = 0, conn_slice = SLC_FIRST_STD_CONN; - for ( ; t < types.size(); ++t ) - { - types[t] = medGeometryElement( int_data[ SLC_GEOM_TYPES ][t] ); - if ( types[t] == MED_POLYGON ) - { - nbElementsByType[t] = int_data[ SLC_POLYGON_INDEX ]._size - 1; - } - else if ( types[t] == MED_POLYHEDRA ) - { - nbElementsByType[t] = int_data[ SLC_POLYHED_INDEX ]._size - 1; - } - else - { - int nn = types[t] % 100; - nbElementsByType[t] = int_data[ conn_slice++ ]._size / nn; - } - } - mesh->setTypes( &types[0], MED_CELL ); - mesh->setTypes( &types[0] + nb_cell_types, face_entity ); - mesh->setNumberOfElements( &nbElementsByType[0], MED_CELL ); - mesh->setNumberOfElements( &nbElementsByType[0] + nb_cell_types, face_entity ); - - // connectivity - const int * index = 0; - for ( t = 0, conn_slice = SLC_FIRST_STD_CONN; t < types.size(); ++t ) - { - if ( types[t] == MED_POLYGON ) - { - index = int_data[ SLC_POLYGON_INDEX ]._pointer; - } - else if ( types[t] == MED_POLYHEDRA ) - { - index = int_data[ SLC_POLYHED_INDEX ]._pointer; - } - - mesh->setConnectivity( t < nb_cell_types ? MED_CELL : face_entity, - types[ t ], - int_data[ conn_slice++ ]._pointer, - index); - } - - // make families and groups - - makeGroupsAndFamilies( mesh, int_data, SLC_FIRST_STD_CONN + types.size() ); - - toClearFamilies = ! int_data[ SLC_GENERAL_INFO ][ I_HAD_FAMILIES ]; - - return mesh; - } - - //================================================================================ - /*! - * \brief Retrieve data of groups and families - * \retval int - number of geom types in all families - */ - //================================================================================ - - int getFamilyData( MEDMEM::MESH* mesh, - vector & families, - vector & groups, - vector & family_gen_data, - vector & family_group_ids ) - { - // get all groups and families of mesh - getGroupsAndFamilies( mesh, groups, families ); - if ( families.empty() ) return 0; - - // assign ids to groups - map < string, int > group_ids; - map < string, int >::iterator name_id; - for ( int id = 0; id < groups.size(); ++id ) - if ( !group_ids.insert( make_pair( groups[id]->getName(), id)).second ) - throw MED_EXCEPTION(LOCALIZED("Equal group names")); - - - family_gen_data.resize( families.size() * I_FAM_DATA_SIZE ); - family_group_ids.clear(); - int nb_fam_types = 0, *fam_data = &family_gen_data[0]; - - for ( int f = 0; f < families.size(); ++f, fam_data += I_FAM_DATA_SIZE ) - { - // sum up number of geom types of families - int nb_types = - families[f]->getEntity() == MED_NODE || families[f]->isOnAllElements() ? - 1 : - families[f]->getNumberOfTypes(); - nb_fam_types += nb_types; - - // fill in family_group_ids - for ( int g = 0; g < families[f]->getNumberOfGroups(); ++g ) - { - name_id = group_ids.find( families[f]->getGroupName( g+1 )); - if ( name_id == group_ids.end() ) - throw MED_EXCEPTION (LOCALIZED(MEDMEM::STRING("Non-exiting group name:>")<< - families[f]->getGroupName( g )<<"<")); - family_group_ids.push_back( name_id->second ); - } - // fill in family_gen_data - fam_data[ I_FAM_ID ] = families[f]->getIdentifier(); - fam_data[ I_NB_FAM_TYPES ] = nb_types; - fam_data[ I_NB_FAM_GROUPS ] = families[f]->getNumberOfGroups(); - } - return nb_fam_types; - } - - //================================================================================ - /*! - * \brief Store mesh as arrayrs of ints, doubles and chars - */ - //================================================================================ - - bool getMeshData(MEDMEM::MESH* mesh, - vector< TIntSlice >& int_data, - vector< TCharSlice >& char_data, - TDoubleSlice& coords) - { - if ( !mesh || mesh->getNumberOfNodes() < 1 ) - return false; - medEntityMesh face_entity = mesh->getMeshDimension()==3 ? MED_FACE : MED_EDGE; - medConnectivity conn = MED_NODAL; - bool have_faces = mesh->existConnectivity( conn, face_entity ); - bool have_families = ( mesh->getNumberOfFamilies( MED_CELL ) + - mesh->getNumberOfFamilies( face_entity ) + - mesh->getNumberOfFamilies( MED_NODE )); - - // create missing families - if ( !have_families && ( mesh->getNumberOfGroups( MED_CELL ) > 0 || - mesh->getNumberOfGroups(face_entity) > 0 || - mesh->getNumberOfGroups( MED_NODE) > 0 )) - mesh->createFamilies(); - - // general info - - int general_info[ I_MIN_SIZE ] = { // SLC_GENERAL_INFO - mesh->getSpaceDimension(), - mesh->getMeshDimension(), - mesh->getNumberOfTypes( MED_CELL ), - have_faces ? mesh->getNumberOfTypes( face_entity ) : 0, - mesh->getNumberOfNodes(), - mesh->getNumberOfGroups( MED_CELL ) - + mesh->getNumberOfGroups( face_entity ) - + mesh->getNumberOfGroups( MED_NODE ), - mesh->getNumberOfFamilies( MED_CELL ), - mesh->getNumberOfFamilies( face_entity ), - mesh->getNumberOfFamilies( MED_NODE ), - int( have_families ) - }; - vector families; - vector groups; - vector family_gen_data, family_group_ids; - int nb_fam_types = getFamilyData( mesh, families, groups, family_gen_data, family_group_ids ); - - // count nb of int data slices taking into account non-fixed slices: - // 1) connectivities of std types and 2) elements per type of family - int nb_int_slices = - SLC_FIRST_STD_CONN + - general_info[ I_NB_CELL_TYPES ] + - general_info[ I_NB_FACE_TYPES ] + - nb_fam_types; - - // nb of char slices (names) - int nb_char_slices = - SLC_FIRST_COORD_NAME + - 2 * general_info[ I_SPACEDIM ] + // coord names + coord unites - families.size() + // family names - groups.size(); // group names - - int_data. resize( nb_int_slices ); - char_data.resize( nb_char_slices ); - - // general info and strings of mesh - - int_data[ SLC_GENERAL_INFO ].copy( I_MIN_SIZE, general_info ); - char_data[ SLC_MESH_NAME ] = toCharSlice( mesh->getName() ); - char_data[ SLC_MESH_DESC ] = toCharSlice( mesh->getDescription() ); - char_data[ SLC_COORD_SYS ] = toCharSlice( mesh->getCoordinatesSystem() ); - int char_slice = SLC_FIRST_COORD_NAME; // next non-filled char slice - for ( int ax = 0; ax < general_info[ I_SPACEDIM ]; ++ax ) - { - char_data[ char_slice++ ] = toCharSlice( mesh->getCoordinatesNames()[ax] ); - char_data[ char_slice++ ] = toCharSlice( mesh->getCoordinatesUnits()[ax] ); - } - int_data[ SLC_FAMILY_GEN_DATA ].copy( family_gen_data.size(), &family_gen_data[0] ); - int_data[ SLC_FAMILY_GROUP_IDS ].copy( family_group_ids.size(), &family_group_ids[0] ); - family_gen_data.clear(); family_group_ids.clear(); - - // geom types and their connectvity - - int_data[ SLC_GEOM_TYPES ].resize( general_info[I_NB_CELL_TYPES] + - general_info[I_NB_FACE_TYPES] ); - int* type_ptr = int_data[ SLC_GEOM_TYPES]._pointer; - int i_slice = SLC_FIRST_STD_CONN; - - const medGeometryElement * cell_types = mesh->getTypes(MED_CELL); - for ( int t = 0; t < general_info[I_NB_CELL_TYPES]; ++t ) - { - *type_ptr++ = cell_types[t]; - int_data[ i_slice++ ].setPtr( mesh->getConnectivityLength( conn, MED_CELL, cell_types[t]), - mesh->getConnectivity ( conn, MED_CELL, cell_types[t])); - } - if ( have_faces ) - { - const medGeometryElement * face_types = mesh->getTypes( face_entity ); - for ( int t = 0; t < general_info[I_NB_FACE_TYPES]; ++t ) - { - *type_ptr++ = face_types[t]; - int_data[ i_slice++ ].setPtr(mesh->getConnectivityLength( conn, face_entity, face_types[t]), - mesh->getConnectivity( conn, face_entity, face_types[t])); - } - } - // polygon connectivity index - - medEntityMesh polygon_entity = mesh->getMeshDimension()==2 ? MED_CELL : MED_FACE; - if ( int nb_polygon = mesh->getNumberOfElements( polygon_entity, MED_POLYGON )) - { - const int nbTypes = mesh->getNumberOfTypes( polygon_entity ); - const int * index = mesh->getConnectivityIndex( conn, polygon_entity ); - index += mesh->getGlobalNumberingIndex( polygon_entity )[ nbTypes-1 ] - 1; - int_data[SLC_POLYGON_INDEX].setPtr( nb_polygon + 1, index ); - } - // polyherdra connectivity index - - if ( int nb_polyhedra = mesh->getNumberOfElements( MED_CELL, MED_POLYHEDRA )) - { - const int nbTypes = mesh->getNumberOfTypes( MED_CELL ); - const int * index = mesh->getConnectivityIndex( conn, MED_CELL ); - index += mesh->getGlobalNumberingIndex( MED_CELL )[ nbTypes-1 ] - 1; - int_data[SLC_POLYHED_INDEX].setPtr( nb_polyhedra + 1, index ); - } - // coordinates - - coords.setPtr( general_info[I_NB_NODES] * general_info[I_SPACEDIM], - mesh->getCoordinates( MED_FULL_INTERLACE )); - - // elements and names of families - - int is_on_all_elements[] = { IS_ON_ALL_FLAG }; - for ( int f = 0; f < families.size(); ++f ) - { - char_data[ char_slice++ ] = toCharSlice( families[f]->getName() ); - - if ( families[f]->isOnAllElements() ) - { - int_data[ i_slice++ ].copy( 1, is_on_all_elements); - } - else - { - bool is_nodal = ( families[f]->getEntity() == MED_NODE ); - int nb_types = is_nodal ? 1 : families[f]->getNumberOfTypes(); - for ( int t = 0; t < nb_types; ++t ) - { - medGeometryElement type = is_nodal ? MED_ALL_ELEMENTS : families[f]->getTypes()[t]; - int_data[ i_slice++ ].setPtr( families[f]->getNumberOfElements( type ), - families[f]->getNumber( type )); - } - } - } - // names of groups - - for ( int g = 0; g < groups.size(); ++g ) - char_data[ char_slice++ ] = toCharSlice( groups[g]->getName() ); - - return true; - } - -} - -//================================================================================ -/*! - * \brief Send mesh to processor irank - * - * WARNING: do NOT delete the mesh until this->isSent()! - */ -//================================================================================ - -void MeshSendReceive::send(int irank, - int idomain, - MEDMEM::MESH* mesh, - const vector& cell_glob_numbers, - const vector& face_glob_numbers, - const vector& node_glob_numbers) -{ - _mesh = mesh; - vector< TIntSlice > int_data; - vector< TCharSlice > char_data; - TDoubleSlice coords; - if ( _mesh && getMeshData( _mesh, int_data, char_data, coords )) - { - serialize( int_data, _int_buf ); - serialize( char_data, _char_buf ); - _node_glob_numbers = node_glob_numbers; - _cell_glob_numbers = cell_glob_numbers; - _face_glob_numbers = face_glob_numbers; - - // sending - MPI_Isend((void*)&_int_buf[0], _int_buf.size(), MPI_INT, irank, - idomain + TAG_INT, MPI_COMM_WORLD, &_int_request); - - MPI_Isend((void*)coords._pointer, coords._size, MPI_DOUBLE, irank, - idomain + TAG_COORD, MPI_COMM_WORLD, &_coord_request); - - MPI_Isend((void*)&_char_buf[0], _char_buf.size(), MPI_CHAR, irank, - idomain + TAG_CHAR, MPI_COMM_WORLD, &_char_request); - - MPI_Isend((void*)&_cell_glob_numbers[0], _cell_glob_numbers.size(), MPI_INT, irank, - idomain + TAG_CELL_NUMS, MPI_COMM_WORLD, &_cell_nums_request); - - MPI_Isend((void*)&_face_glob_numbers[0], _face_glob_numbers.size(), MPI_INT, irank, - idomain + TAG_FACE_NUMS, MPI_COMM_WORLD, &_face_nums_request); - - MPI_Isend((void*)&_node_glob_numbers[0], _node_glob_numbers.size(), MPI_INT, irank, - idomain + TAG_NODE_NUMS, MPI_COMM_WORLD, &_node_nums_request); - } - else - { - // send anything not to block recv() - MPI_Isend((void*)&irank, 1, MPI_INT, irank, - idomain + TAG_INT, MPI_COMM_WORLD, &_int_request); - } -} - -//================================================================================ -/*! - * \brief Receive mesh from irank processor synchronously - */ -//================================================================================ - -MEDMEM::MESH* MeshSendReceive::recv(int irank, int idomain, - vector& cell_glob_numbers, - vector& face_glob_numbers, - vector& node_glob_numbers) -{ - _mesh = 0; - - // receive INT data - - MPI_Status status; - MPI_Probe(irank, idomain + TAG_INT, MPI_COMM_WORLD, &status); // wait for the message - int msg_size = 0; - MPI_Get_count( &status, MPI_INT, &msg_size ); // size of arrived message - _int_buf.resize( msg_size ); - MPI_Recv((void*)&_int_buf[0], _int_buf.size(), MPI_INT, irank, - idomain + TAG_INT, MPI_COMM_WORLD, &status); - if ( msg_size <= I_MIN_SIZE ) - return 0; // mesh not sent - - // receive coordinates - - MPI_Probe(irank, idomain + TAG_COORD, MPI_COMM_WORLD, &status); // wait for the message - MPI_Get_count( &status, MPI_DOUBLE, &msg_size ); // size of arrived message - vector< double > coord_buf( msg_size ); - MPI_Recv((void*)&coord_buf[0], msg_size, MPI_DOUBLE, irank, - idomain + TAG_COORD, MPI_COMM_WORLD, &status); - - // receive chars - - MPI_Probe(irank, idomain + TAG_CHAR, MPI_COMM_WORLD, &status); // wait for the message - MPI_Get_count( &status, MPI_CHAR, &msg_size ); // size of arrived message - _char_buf.resize( msg_size ); - MPI_Recv((void*)&_char_buf[0], _char_buf.size(), MPI_CHAR, irank, - idomain + TAG_CHAR, MPI_COMM_WORLD, &status); - - // receive global cell numbers - - MPI_Probe(irank, idomain + TAG_CELL_NUMS, MPI_COMM_WORLD, &status); // wait for the message - MPI_Get_count( &status, MPI_INT, &msg_size ); // size of arrived message - cell_glob_numbers.resize( msg_size ); - MPI_Recv((void*)&cell_glob_numbers[0], cell_glob_numbers.size(), MPI_INT, irank, - idomain + TAG_CELL_NUMS, MPI_COMM_WORLD, &status); - - // receive global face numbers - - MPI_Probe(irank, idomain + TAG_FACE_NUMS, MPI_COMM_WORLD, &status); // wait for the message - MPI_Get_count( &status, MPI_INT, &msg_size ); // size of arrived message - face_glob_numbers.resize( msg_size ); - MPI_Recv((void*)&face_glob_numbers[0], face_glob_numbers.size(), MPI_INT, irank, - idomain + TAG_FACE_NUMS, MPI_COMM_WORLD, &status); - - // receive global node numbers - - MPI_Probe(irank, idomain + TAG_NODE_NUMS, MPI_COMM_WORLD, &status); // wait for the message - MPI_Get_count( &status, MPI_INT, &msg_size ); // size of arrived message - node_glob_numbers.resize( msg_size ); - MPI_Recv((void*)&node_glob_numbers[0], node_glob_numbers.size(), MPI_INT, irank, - idomain + TAG_NODE_NUMS, MPI_COMM_WORLD, &status); - - // make mesh - - vector< TIntSlice > int_data; - if ( int badSlice = deserialize( _int_buf, int_data )) - throw MED_EXCEPTION(MEDMEM::STRING("MeshSendReceive::recv(")<setCoordinates( _mesh->getSpaceDimension(), - _mesh->getNumberOfNodes(), - &coord_buf[0], "", - MED_EN::MED_FULL_INTERLACE); - coord_buf.clear(); - - // set names - - vector< TCharSlice > char_data; - if ( int badSlice = deserialize( _char_buf, char_data )) - throw MED_EXCEPTION(MEDMEM::STRING("MeshSendReceive::recv(")<clearFamilies(); - - return _mesh; -} - -//======================================================================= -#else // #ifdef HAVE_MPI2 - -MeshSendReceive::MeshSendReceive() {} -MeshSendReceive::~MeshSendReceive() {} -void MeshSendReceive::send(int irank, int idomain, MEDMEM::MESH* mesh, const vector& cell_glob_nums, const vector& face_glob_nums, const vector& node_glob_numbers) {} -MEDMEM::MESH* MeshSendReceive::recv(int irank,int idomain, vector& cell_glob_nums, vector& face_glob_nums, vector& node_glob_numbers) { return 0; } -bool MeshSendReceive::isSent() { return 0; } -void MeshSendReceive::clear() {} - -#endif -//======================================================================= diff --git a/src/MEDSPLITTER/MEDSPLITTER_MeshSendReceive.hxx b/src/MEDSPLITTER/MEDSPLITTER_MeshSendReceive.hxx deleted file mode 100644 index 84f03f21a..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_MeshSendReceive.hxx +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2007-2013 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 -// -// File : MEDSPLITTER_MeshSendReceive.hxx -// Created : Tue Jun 30 19:14:51 2009 -// Author : Edward AGAPOV (eap) - - -#ifndef __MEDSPLITTER_MeshSendReceive_HXX__ -#define __MEDSPLITTER_MeshSendReceive_HXX__ - -#include "MEDSPLITTER.hxx" - -#ifdef HAVE_MPI2 -#include -#else -typedef int MPI_Request; -#endif - -#include - -namespace MEDMEM -{ - class MESH; -} - -namespace MEDSPLITTER -{ - /*! - * \brief Sender-receiver of the mesh. - * - * We also send-receive - * 1) global node ids for the sake of fusing domain parts - * 2) global cell ids for the sake of detecting cell/cell joints using global graph - * 3) global face ids for the sake of not losing face sharing among domains - */ - class MEDSPLITTER_EXPORT MeshSendReceive - { - public: - - MeshSendReceive(); - ~MeshSendReceive(); - - // Sends the mesh of idomain to irank processor asynchronously - // WARNING: do NOT delete the mesh until this->isSent()! - void send(int irank, int idomain, MEDMEM::MESH* mesh, - const std::vector& cell_glob_nums, - const std::vector& face_glob_nums, - const std::vector& node_glob_nums); - - // Receives the mesh of idomain from irank processor synchronously - MEDMEM::MESH* recv(int irank, int idomain, - std::vector& cell_glob_numbers, - std::vector& face_glob_numbers, - std::vector& node_glob_numbers); - - //!< Returns the received or sent mesh. The user is resposible for freeing the received mesh. - MEDMEM::MESH* getMesh() { return _mesh; } - - // Returns true if mesh is already sent - bool isSent(); - - // Frees buffers waiting until isSent() - void clear(); - - private: - - std::vector< int > _int_buf; - std::vector< int > _node_glob_numbers, _cell_glob_numbers, _face_glob_numbers; - std::vector< char> _char_buf; - - MEDMEM::MESH* _mesh; - - MPI_Request _int_request, _coord_request, _char_request; - MPI_Request _node_nums_request, _cell_nums_request, _face_nums_request; - }; -} - - -#endif diff --git a/src/MEDSPLITTER/MEDSPLITTER_ParaDomainSelector.cxx b/src/MEDSPLITTER/MEDSPLITTER_ParaDomainSelector.cxx deleted file mode 100644 index 7ca59e344..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_ParaDomainSelector.cxx +++ /dev/null @@ -1,667 +0,0 @@ -// Copyright (C) 2007-2013 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 -// -// File : MEDSPLITTER_ParaDomainSelector.cxx -// Created : Wed Jun 24 12:39:59 2009 -// Author : Edward AGAPOV (eap) - -#include "MEDSPLITTER_ParaDomainSelector.hxx" - -#include "MEDSPLITTER_UserGraph.hxx" -#include "MEDSPLITTER_JointExchangeData.hxx" - -#include -#include - -#include -#include - -#ifdef HAVE_MPI2 -#include -#endif - -#ifndef WIN32 -#include -#endif - -using namespace MEDSPLITTER; -using namespace MED_EN; -using namespace std; - -//================================================================================ -/*! - * \brief Constructor. Find out my rank and world size - */ -//================================================================================ - -ParaDomainSelector::ParaDomainSelector(bool mesure_memory) - :_rank(0),_world_size(1), _nb_result_domains(-1), _mesure_memory(mesure_memory), - _init_time(0.0), _init_memory(0), _max_memory(0) -{ -#ifdef HAVE_MPI2 - MPI_Comm_size(MPI_COMM_WORLD,&_world_size) ; - MPI_Comm_rank(MPI_COMM_WORLD,&_rank) ; - _init_time = MPI_Wtime(); -#endif - evaluateMemory(); -} - -//================================================================================ -/*! - * \brief Destructor - */ -//================================================================================ - -ParaDomainSelector::~ParaDomainSelector() -{ -} - -//================================================================================ -/*! - * \brief Return true if is running on different hosts - */ -//================================================================================ - -bool ParaDomainSelector::isOnDifferentHosts() const -{ - evaluateMemory(); - if ( _world_size < 2 ) - return false; - -#ifdef HAVE_MPI2 - char name_here[ MPI_MAX_PROCESSOR_NAME+1 ], name_there[ MPI_MAX_PROCESSOR_NAME+1 ]; - int size; - MPI_Get_processor_name( name_here, &size); - - int next_proc = (rank() + 1) % nbProcs(); - int prev_proc = (rank() - 1 + nbProcs()) % nbProcs(); - int tag = 1111111; - - MPI_Status status; - MPI_Sendrecv((void*)&name_here[0], MPI_MAX_PROCESSOR_NAME, MPI_CHAR, next_proc, tag, - (void*)&name_there[0], MPI_MAX_PROCESSOR_NAME, MPI_CHAR, prev_proc, tag, - MPI_COMM_WORLD, &status); - return string(name_here) != string(name_there); -#else - return false; -#endif -} - -//================================================================================ -/*! - * \brief Return true if the domain with domainIndex is to be loaded on this proc - * \param domainIndex - index of mesh domain - * \retval bool - to load or not - */ -//================================================================================ - -bool ParaDomainSelector::isMyDomain(int domainIndex) const -{ - evaluateMemory(); - return (_rank == getProccessorID( domainIndex )); -} - -//================================================================================ -/*! - * \brief Return processor id where the domain with domainIndex resides - * \param domainIndex - index of mesh domain - * \retval int - processor id - */ -//================================================================================ - -int ParaDomainSelector::getProccessorID(int domainIndex) const -{ - evaluateMemory(); - return ( domainIndex % _world_size ); -} - -//================================================================================ -/*! - * \brief Gather info on nb of entities on each processor and return total nb. - * - * Is called - * 1) for MED_CELL to know global id shift for domains at graph construction; - * 2) for sub-entity to know total nb of sub-entities before creating those of joints - */ -//================================================================================ - -int ParaDomainSelector::gatherNbOf(MED_EN::medEntityMesh entity, - const vector& domain_meshes) -{ - evaluateMemory(); - - // get nb of elems of each domain mesh - int nb_domains = domain_meshes.size(); - vector nb_elems( nb_domains, 0 ); - for ( int i = 0; i < nb_domains; ++i ) - if ( domain_meshes[i] ) - nb_elems[i] = domain_meshes[i]->getNumberOfElements(entity, MED_ALL_ELEMENTS); - - // receive nb of elems from other procs - vector all_nb_elems( nb_domains ); -#ifdef HAVE_MPI2 - MPI_Allreduce((void*)&nb_elems[0], (void*)&all_nb_elems[0], nb_domains, - MPI_INT, MPI_SUM, MPI_COMM_WORLD); -#endif - int total_nb = std::accumulate( all_nb_elems.begin(), all_nb_elems.end(), 0 ); - - vector& elem_shift_by_domain - = (entity == MED_CELL) ? _cell_shift_by_domain : _face_shift_by_domain; - - // fill elem_shift_by_domain - - vector< int > ordered_nbs, domain_order( nb_domains ); - ordered_nbs.push_back(0); - for ( int iproc = 0; iproc < nbProcs(); ++iproc ) - for ( int idomain = 0; idomain < nb_domains; ++idomain ) - if ( getProccessorID( idomain ) == iproc ) - { - domain_order[ idomain ] = ordered_nbs.size() - 1; - ordered_nbs.push_back( ordered_nbs.back() + all_nb_elems[idomain] ); - } - elem_shift_by_domain.resize( nb_domains+1, 0 ); - for ( int idomain = 0; idomain < nb_domains; ++idomain ) - elem_shift_by_domain[ idomain ] = ordered_nbs[ domain_order[ idomain ]]; - - elem_shift_by_domain.back() = ordered_nbs.back(); // to know total nb of elements - - if ( entity == MED_CELL ) - { - // fill _nb_vert_of_procs - _nb_vert_of_procs.resize( _world_size+1, 0 ); - for ( int i = 0; i < nb_domains; ++i ) - { - int rank = getProccessorID( i ); - _nb_vert_of_procs[ rank+1 ] += all_nb_elems[ i ]; - } - _nb_vert_of_procs[0] = 1; // base = 1 - for ( int i = 1; i < _nb_vert_of_procs.size(); ++i ) - _nb_vert_of_procs[ i ] += _nb_vert_of_procs[ i-1 ]; // to CSR format - } - else - { - // to compute global ids of faces in joints - //_total_nb_faces = total_nb; - } - -// if ( !_rank) { -// MEDMEM::STRING out("_nb_vert_of_procs :"); -// for ( int i = 0; i < _nb_vert_of_procs.size(); ++i ) -// out << _nb_vert_of_procs[i] << " "; -// std::cout << out << std::endl; -// } -// if ( !_rank) { -// MEDMEM::STRING out("elem_shift_by_domain :"); -// for ( int i = 0; i < elem_shift_by_domain.size(); ++i ) -// out << elem_shift_by_domain[i] << " "; -// std::cout << out << std::endl; -// } - - evaluateMemory(); - - return total_nb; -} - -//================================================================================ -/*! - * \brief Return distribution of the graph vertices among the processors - * \retval int* - array conatining nb of vertices on all processors - * - * gatherNbOf( MED_CELL ) must be called before. - * The result array is to be used as the first arg of ParMETIS_V3_PartKway() and - * is freed by ParaDomainSelector. - */ -//================================================================================ - -#define gatherNbOf_NOT_CALLED(meth) throw MED_EXCEPTION \ -("ParaDomainSelector::" #meth "(): gatherNbOf( MED_CELL ) must be called before") - -int* ParaDomainSelector::getNbVertOfProcs() const -{ - evaluateMemory(); - if ( _nb_vert_of_procs.empty() ) - gatherNbOf_NOT_CALLED(getNbVertOfProcs); - - return (int*) & _nb_vert_of_procs[0]; -} -//================================================================================ -/*! - * \brief Return nb of cells in domains with lower index. - * - * gatherNbOf( MED_CELL ) must be called before. - * Result added to local id on given domain gives id in the whole distributed mesh - */ -//================================================================================ - -int ParaDomainSelector::getDomainShift(int domainIndex) const -{ - evaluateMemory(); - if ( _cell_shift_by_domain.empty() ) - gatherNbOf_NOT_CALLED(getDomainShift); - - return _cell_shift_by_domain[ domainIndex ]; -} - -//================================================================================ -/*! - * \brief Return nb of cells on processors with lower rank. - * - * gatherNbOf( MED_CELL ) must be called before. - * Result added to global id on this processor gives id in the whole distributed mesh - */ -//================================================================================ - -int ParaDomainSelector::getProcShift() const -{ - evaluateMemory(); - if ( _nb_vert_of_procs.empty() ) - gatherNbOf_NOT_CALLED(getProcShift); - - return _nb_vert_of_procs[_rank]-1; -} - -//================================================================================ -/*! - * \brief Gather graphs from all processors into one - */ -//================================================================================ - -auto_ptr ParaDomainSelector::gatherGraph(const Graph* graph) const -{ - Graph* glob_graph = 0; - - evaluateMemory(); -#ifdef HAVE_MPI2 - - // --------------- - // Gather indices - // --------------- - - vector index_size_of_proc( nbProcs() ); // index sizes - 1 - for ( int i = 1; i < _nb_vert_of_procs.size(); ++i ) - index_size_of_proc[i-1] = _nb_vert_of_procs[ i ] - _nb_vert_of_procs[ i-1 ]; - - int index_size = 1 + _cell_shift_by_domain.back(); - int* graph_index = new int[ index_size ]; - const int* index = graph->getGraph()->getIndex(); - int* proc_index_displacement = (int*) & _nb_vert_of_procs[0]; - - MPI_Allgatherv((void*) (index+1), // send local index except first 0 (or 1) - index_size_of_proc[_rank], // index size on this proc - MPI_INT, - (void*) graph_index, // receive indices - & index_size_of_proc[0], // index size on each proc - proc_index_displacement, // displacement of each proc index - MPI_INT, - MPI_COMM_WORLD); - graph_index[0] = index[0]; // it is not overwritten thanks to proc_index_displacement[0]==1 - - // get sizes of graph values on each proc by the got indices of graphs - vector< int > value_size_of_proc( nbProcs() ), proc_value_displacement(1,0); - for ( int i = 0; i < nbProcs(); ++i ) - { - if ( index_size_of_proc[i] > 0 ) - value_size_of_proc[i] = graph_index[ proc_index_displacement[ i+1 ]-1 ] - graph_index[0]; - else - value_size_of_proc[i] = 0; - proc_value_displacement.push_back( proc_value_displacement.back() + value_size_of_proc[i] ); - } - - // update graph_index - for ( int i = 1; i < nbProcs(); ++i ) - { - int shift = graph_index[ proc_index_displacement[i]-1 ]-graph_index[0]; - for ( int j = proc_index_displacement[i]; j < proc_index_displacement[i+1]; ++j ) - graph_index[ j ] += shift; - } - - // -------------- - // Gather values - // -------------- - - int value_size = graph_index[ index_size-1 ] - graph_index[ 0 ]; - int* graph_value = new int[ value_size ]; - const int* value = graph->getGraph()->getValue(); - - MPI_Allgatherv((void*) value, // send local value - value_size_of_proc[_rank], // value size on this proc - MPI_INT, - (void*) graph_value, // receive values - & value_size_of_proc[0], // value size on each proc - & proc_value_displacement[0], // displacement of each proc value - MPI_INT, - MPI_COMM_WORLD); - - // ----------------- - // Gather partition - // ----------------- - - int * partition = new int[ _cell_shift_by_domain.back() ]; - const int* part = graph->getPart(); - - MPI_Allgatherv((void*) part, // send local partition - index_size_of_proc[_rank], // index size on this proc - MPI_INT, - (void*)(partition-1), // -1 compensates proc_index_displacement[0]==1 - & index_size_of_proc[0], // index size on each proc - proc_index_displacement, // displacement of each proc index - MPI_INT, - MPI_COMM_WORLD); - - // ----------- - // Make graph - // ----------- - - MEDMEM::MEDSKYLINEARRAY* array = - new MEDMEM::MEDSKYLINEARRAY( index_size-1, value_size, graph_index, graph_value, true ); - - glob_graph = new UserGraph( array, partition, index_size-1 ); - - evaluateMemory(); - - delete [] partition; - -#endif // HAVE_MPI2 - - return auto_ptr( glob_graph ); -} - -//================================================================================ -/*! - * \brief Sets global numbering for the entity. - * - * This method must be once called for MED_CELL before exchangeJoint() calls - */ -//================================================================================ - -void ParaDomainSelector::gatherEntityTypesInfo(vector& domain_meshes, - MED_EN::medEntityMesh entity) -{ - const list & all_types = meshEntities[ entity ]; - - evaluateMemory(); - - // Put nb of elements of the entity of all domains in one vector - // and by the way find out mesh dimension - - vector nb_of_type( domain_meshes.size() * all_types.size(), 0 ); - int mesh_dim = -1, space_dim = -1; - - for ( int idomain = 0; idomain < domain_meshes.size(); ++idomain ) - { - if ( !isMyDomain(idomain)) continue; - - int* domain_nbs = & nb_of_type[ idomain * all_types.size()]; - - list::const_iterator type = all_types.begin(); - for ( int t = 0; type != all_types.end(); ++t,++type ) - domain_nbs[t] = domain_meshes[idomain]->getNumberOfElements(entity,*type); - - int i_mesh_dim = domain_meshes[idomain]->getMeshDimension(); - int i_space_dim = domain_meshes[idomain]->getSpaceDimension(); - if ( mesh_dim < i_mesh_dim && i_mesh_dim <= 3 ) - mesh_dim = i_mesh_dim; - if ( space_dim < i_space_dim && i_space_dim <= 3 ) - space_dim = i_space_dim; - } - - // Receive nbs from other procs - - vector< int > nb_recv( nb_of_type.size() ); -#ifdef HAVE_MPI2 - MPI_Allreduce((void*)&nb_of_type[0], (void*)&nb_recv[0], nb_of_type.size(), - MPI_INT, MPI_SUM, MPI_COMM_WORLD); -#endif - - // Set info to meshes of distant domains - - for ( int idomain = 0; idomain < domain_meshes.size(); ++idomain ) - { - if ( isMyDomain(idomain)) continue; - - MEDMEM::MESHING* meshing = (MEDMEM::MESHING*) domain_meshes[idomain]; - if ( meshing->getMeshDimension() < mesh_dim ) - { - //meshing->setSpaceDimension( space_dim ); - meshing->setCoordinates( space_dim, /*NumberOfNodes=*/0, 0, "", 0); - } - - vector< medGeometryElement > types; - vector< int > nb_elems; - - int* domain_nbs = & nb_recv[ idomain * all_types.size()]; - - list::const_iterator type = all_types.begin(); - for ( int t = 0; type != all_types.end(); ++t,++type ) - { - if ( domain_nbs[t]==0 ) continue; - types.push_back( *type ); - nb_elems.push_back( domain_nbs[t] ); - } - meshing->setNumberOfTypes( types.size(), entity ); - if ( !types.empty() ) - { - meshing->setTypes ( & types[0], entity ); - meshing->setNumberOfElements( & nb_elems[0], entity ); - } - } - evaluateMemory(); -} - -//================================================================================ -/*! - * \brief Set nb of cell/cell pairs in a joint between domains - */ -//================================================================================ - -void ParaDomainSelector::setNbCellPairs( int nb_cell_pairs, int dist_domain, int loc_domain ) -{ - // This method is needed for further computing global numbers of faces in joint. - // Store if both domains are on this proc else on one of procs only - if ( isMyDomain( dist_domain ) || dist_domain < loc_domain ) - { - if ( _nb_cell_pairs_by_joint.empty() ) - _nb_cell_pairs_by_joint.resize( _nb_result_domains*(_nb_result_domains+1), 0); - - int joint_id = jointId( loc_domain, dist_domain ); - _nb_cell_pairs_by_joint[ joint_id ] = nb_cell_pairs; - } - evaluateMemory(); -} - -//================================================================================ -/*! - * \brief Return nb of cell/cell pairs in a joint between domains on different procs - */ -//================================================================================ - -int ParaDomainSelector::getNbCellPairs( int dist_domain, int loc_domain ) const -{ - evaluateMemory(); - - int joint_id = jointId( loc_domain, dist_domain ); - return _nb_cell_pairs_by_joint[ joint_id ]; -} - -//================================================================================ -/*! - * \brief Gather size of each joint - */ -//================================================================================ - -void ParaDomainSelector::gatherNbCellPairs() -{ - const char* LOC = "MEDSPLITTER::ParaDomainSelector::gatherNbCellPairs(): "; - if ( _nb_cell_pairs_by_joint.empty() ) - _nb_cell_pairs_by_joint.resize( _nb_result_domains*(_nb_result_domains+1), 0); - evaluateMemory(); - - vector< int > send_buf = _nb_cell_pairs_by_joint; -#ifdef HAVE_MPI2 - MPI_Allreduce((void*)&send_buf[0], - (void*)&_nb_cell_pairs_by_joint[0], - _nb_cell_pairs_by_joint.size(), - MPI_INT, MPI_SUM, MPI_COMM_WORLD); -#endif - // check that the set nbs of cell pairs are correct, - // namely that each joint is treated on one proc only - for ( int j = 0; j < _nb_cell_pairs_by_joint.size(); ++j ) - if ( _nb_cell_pairs_by_joint[j] != send_buf[j] && send_buf[j]>0 ) - throw MED_EXCEPTION(MEDMEM::STRING(LOC) << "invalid nb of cell pairs"); -} - -//================================================================================ -/*! - * \brief Send-receive joint data - */ -//================================================================================ - -void ParaDomainSelector::exchangeJoint( JointExchangeData* joint ) const -{ -#ifdef HAVE_MPI2 - vector send_data, recv_data( joint->serialize( send_data )); - - int dest = getProccessorID( joint->distantDomain() ); - int tag = 1001 + jointId( joint->localDomain(), joint->distantDomain() ); - - MPI_Status status; - MPI_Sendrecv((void*)&send_data[0], send_data.size(), MPI_INT, dest, tag, - (void*)&recv_data[0], recv_data.size(), MPI_INT, dest, tag, - MPI_COMM_WORLD, &status); - - joint->deserialize( recv_data ); -#endif -} - -//================================================================================ -/*! - * \brief Return the first global id of sub-entity for the joint - */ -//================================================================================ - -int ParaDomainSelector::getFisrtGlobalIdOfSubentity( int loc_domain, int dist_domain ) const -{ - // total_nb_faces includes faces existing before creation of joint faces - // (got in gatherNbOf( MED_FACE )). - evaluateMemory(); - - int total_nb_faces = _face_shift_by_domain.empty() ? 0 : _face_shift_by_domain.back(); - int id = total_nb_faces + 1; - - if ( _nb_cell_pairs_by_joint.empty() ) - throw MED_EXCEPTION("MEDSPLITTER::ParaDomainSelector::getFisrtGlobalIdOfSubentity(), " - "gatherNbCellPairs() must be called before"); - int joint_id = jointId( loc_domain, dist_domain ); - for ( int j = 0; j < joint_id; ++j ) - id += _nb_cell_pairs_by_joint[ j ]; - - return id; -} - -//================================================================================ -/*! - * \brief Send-receive local ids of joint faces - */ -//================================================================================ - -int* ParaDomainSelector::exchangeSubentityIds( int loc_domain, int dist_domain, - const vector& loc_ids_here ) const -{ - int* loc_ids_dist = new int[ loc_ids_here.size()]; -#ifdef HAVE_MPI2 - int dest = getProccessorID( dist_domain ); - int tag = 2002 + jointId( loc_domain, dist_domain ); - MPI_Status status; - MPI_Sendrecv((void*)&loc_ids_here[0], loc_ids_here.size(), MPI_INT, dest, tag, - (void*) loc_ids_dist, loc_ids_here.size(), MPI_INT, dest, tag, - MPI_COMM_WORLD, &status); - evaluateMemory(); -#endif - - return loc_ids_dist; -} - -//================================================================================ -/*! - * \brief Return identifier for a joint - */ -//================================================================================ - -int ParaDomainSelector::jointId( int local_domain, int distant_domain ) const -{ - evaluateMemory(); - if (_nb_result_domains < 0) - throw MED_EXCEPTION("ParaDomainSelector::jointId(): setNbDomains() must be called before()"); - - if ( local_domain < distant_domain ) - swap( local_domain, distant_domain ); - return local_domain * _nb_result_domains + distant_domain; -} - -//================================================================================ -/*! - * \brief Return domain order so that first go domains on proc 0 and so n - */ -//================================================================================ - -// int ParaDomainSelector::getDomianOrder(int idomain, int nb_domains) const -// { -// return nb_domains / nbProcs() * getProccessorID( idomain ) + idomain / nbProcs(); -// } - -//================================================================================ -/*! - * \brief Return time passed from construction in seconds - */ -//================================================================================ - -double ParaDomainSelector::getPassedTime() const -{ -#ifdef HAVE_MPI2 - return MPI_Wtime() - _init_time; -#else - return 0.0; -#endif -} - -//================================================================================ -/*! - * \brief Evaluate current memory usage and return the maximal one in KB - */ -//================================================================================ - -int ParaDomainSelector::evaluateMemory() const -{ - if ( _mesure_memory ) - { - int used_memory = 0; -#ifndef WIN32 - struct sysinfo si; - int err = sysinfo( &si ); - if ( !err ) - used_memory = - (( si.totalram - si.freeram + si.totalswap - si.freeswap ) * si.mem_unit ) / 1024; -#endif - if ( used_memory > _max_memory ) - ((ParaDomainSelector*) this)->_max_memory = used_memory; - - if ( !_init_memory ) - ((ParaDomainSelector*) this)->_init_memory = used_memory; - } - return _max_memory - _init_memory; -} diff --git a/src/MEDSPLITTER/MEDSPLITTER_ParaDomainSelector.hxx b/src/MEDSPLITTER/MEDSPLITTER_ParaDomainSelector.hxx deleted file mode 100644 index 308d03588..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_ParaDomainSelector.hxx +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (C) 2007-2013 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 -// -// File : MEDSPLITTER_ParaDomainSelector.hxx -// Created : Wed Jun 24 12:18:58 2009 -// Author : Edward AGAPOV (eap) - - -#ifndef __MEDSPLITTER_ParaDomainSelector_HXX__ -#define __MEDSPLITTER_ParaDomainSelector_HXX__ - -#include "MEDSPLITTER.hxx" - -#include - -#include -#include - -namespace MEDMEM -{ - class MESH; -} - -namespace MEDSPLITTER -{ - class Graph; - class JointExchangeData; - -/*! - * \brief Communication helper in parallel mode - */ -class MEDSPLITTER_EXPORT ParaDomainSelector -{ -public: - - ParaDomainSelector(bool mesure_memory=false); - ~ParaDomainSelector(); - - //!< return processor rank - int rank() const { return _rank; } - - //!< return number of processors - int nbProcs() const { return _world_size; } - - // Return true if is running on different hosts - bool isOnDifferentHosts() const; - - // Return true if the domain with domainIndex is to be loaded on this proc - bool isMyDomain(int domainIndex) const; - - // Return processor id where the domain with domainIndex resides - int getProccessorID(int domainIndex) const; - - - //!< Set nb of required domains. (Used to sort joints via jointId()) - void setNbDomains(int nb) { _nb_result_domains = nb; } - - // Return identifier for a joint - int jointId( int local_domain, int distant_domain ) const; - - // Return domain order - //int getDomianOrder(int domainIndex, int nb_domains) const; - - - // Collect nb of entities on procs and return total nb - int gatherNbOf(MED_EN::medEntityMesh entity, const std::vector& domain_meshes); - - // Return distribution of the graph vertices among the processors - int* getNbVertOfProcs() const; - - // Return nb of cells on processors with lower rank - int getProcShift() const; - - // Return nb of cells in domains with lower index - int getDomainShift(int domainIndex) const; - -// // Return nb of sub-entities in domains with lower index -// int getDomainSubentityShift(int domainIndex) const; - - // Gather graphs from all processors into one - std::auto_ptr gatherGraph(const Graph* graph) const; - - // Set types and number of elements of the entity to all meshes - void gatherEntityTypesInfo(std::vector& domain_meshes, - MED_EN::medEntityMesh entity); - - // Set nb of cell/cell pairs in a joint between domains - void setNbCellPairs( int nb_cell_pairs, int dist_domain, int loc_domain ); - - // Gather size of each proc/proc joint - void gatherNbCellPairs(); - - // Return nb of cell/cell pairs in a joint between domains on different procs - int getNbCellPairs( int dist_domain, int loc_domain ) const; - - // Send-receive joint data - void exchangeJoint( JointExchangeData* joint ) const; - - // Return the first global id of sub-entity for the joint - int getFisrtGlobalIdOfSubentity( int loc_domain, int dist_domain ) const; - - // Send-receive local ids of joint faces - int* exchangeSubentityIds( int loc_domain, int dist_domain, - const std::vector& loc_ids_here ) const; - - // Return time passed from construction in seconds - double getPassedTime() const; - - // Evaluate current memory usage and return the maximal one in KB - int evaluateMemory() const; - -private: - - int _rank, _world_size; // my rank and nb of processors - - int _nb_result_domains; // required nb of domains - - //int _total_nb_faces; // nb of faces in the whole mesh without proc/proc joint faces - - std::vector< int > _nb_cell_pairs_by_joint; - - std::vector< int > _nb_vert_of_procs; // graph vertices - std::vector< int > _cell_shift_by_domain; - std::vector< int > _face_shift_by_domain; - - double _init_time; - bool _mesure_memory; - int _init_memory, _max_memory; -}; - -} - -#endif diff --git a/src/MEDSPLITTER/MEDSPLITTER_ParallelTopology.cxx b/src/MEDSPLITTER/MEDSPLITTER_ParallelTopology.cxx deleted file mode 100644 index 85871615c..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_ParallelTopology.cxx +++ /dev/null @@ -1,1174 +0,0 @@ -// Copyright (C) 2007-2013 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 -#include -#include - -#include "InterpKernelHashMap.hxx" - -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_ConnectZone.hxx" -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_MeshFuse.hxx" -#include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_Utilities.hxx" - -#include "MEDSPLITTER_MESHCollection.hxx" -#include "MEDSPLITTER_Topology.hxx" -#include "MEDSPLITTER_Graph.hxx" -#include "MEDSPLITTER_ParallelTopology.hxx" - -using namespace INTERP_KERNEL; - -using namespace MEDSPLITTER; - -//empty constructor -ParallelTopology::ParallelTopology():m_nb_domain(0),m_mesh_dimension(0) -{} - -//!constructing topology according to mesh collection -ParallelTopology::ParallelTopology(const vector& meshes, - const vector& cz, - vector& cellglobal, - vector& nodeglobal, - vector& faceglobal):m_nb_domain(meshes.size())/*,m_mesh_dimension(meshes[0]->getMeshDimension())*/ -{ - - int index_global=0; - int index_node_global=0; - int index_face_global=0; - - m_nb_cells.resize(m_nb_domain); - m_nb_nodes.resize(m_nb_domain); - m_nb_faces.resize(m_nb_domain); - - m_loc_to_glob.resize(m_nb_domain); - m_node_loc_to_glob.resize(m_nb_domain); - m_face_loc_to_glob.resize(m_nb_domain); - - MED_EN::medEntityMesh constituent_entity; - - bool parallel_mode = false; - for (int idomain=0; !parallel_mode && idomaingetMeshDimension(); - constituent_entity = (m_mesh_dimension == 3 ? MED_EN::MED_FACE : MED_EN::MED_EDGE ); - - //creating cell maps - m_nb_cells[idomain]=meshes[idomain]->getNumberOfElements(MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - // cout << "Nb cells (domain "< ("< ("<getNumberOfNodes()); - for (int i=0; igetNumberOfNodes(); i++) - { - m_node_glob_to_loc.insert(make_pair(i+1,make_pair(0,i+1))); - //m_node_loc_to_glob.insert(make_pair(make_pair(0,i+1), i+1)); - m_node_loc_to_glob[0][i]=i+1; - } - m_nb_total_nodes=meshes[idomain]->getNumberOfNodes(); - m_nb_nodes[0]=m_nb_total_nodes; - - // meshes[idomain]->getConnectivity( MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - int nbfaces=meshes[idomain]->getNumberOfElements(constituent_entity,MED_EN::MED_ALL_ELEMENTS); - m_face_loc_to_glob[idomain].resize(nbfaces); - for (int i=0; igetNumberOfNodes(); - INTERP_KERNEL::HashMap > local2distant; - m_node_loc_to_glob[idomain].resize(m_nb_nodes[idomain]); - for (unsigned icz=0; iczgetLocalDomainNumber() == idomain && - cz[icz]->getLocalDomainNumber()>cz[icz]->getDistantDomainNumber()) - { - int nb_node= cz[icz]->getNodeNumber(); - const int* node_corresp=cz[icz]->getNodeCorrespValue(); - int distant_ip = cz[icz]->getDistantDomainNumber(); - for (int i=0; i< nb_node; i++) - { - int local= node_corresp[i*2]; - int distant = node_corresp[i*2+1]; - local2distant.insert(make_pair(local, make_pair(distant_ip,distant))); - } - } - } - // setting mappings for all nodes - if (nodeglobal[idomain]==0) - { - for (int inode=0; inodesecond).first; - int distant = (local2distant.find(inode+1)->second).second; - //int global_number=m_loc_to_glob[make_pair(ip,distant)]; - int global_number=m_loc_to_glob[ip][distant-1]; - m_node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode+1))); - //m_node_loc_to_glob[make_pair(idomain,inode+1)]=global_number; - m_node_loc_to_glob[idomain][inode]=global_number; - } - } - } - //using former node numbering - else - {// cout << "("<"<getConnectivity( MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - m_nb_faces[idomain]=meshes[idomain]->getNumberOfElements(constituent_entity,MED_EN::MED_ALL_ELEMENTS); - MESSAGE_MED ("Nb faces domain " << idomain<getLocalDomainNumber() == idomain && - cz[icz]->getLocalDomainNumber()>cz[icz]->getDistantDomainNumber()) - { - int nb_face= cz[icz]->getFaceNumber(); - const int* face_corresp=cz[icz]->getFaceCorrespValue(); - int distant_ip = cz[icz]->getDistantDomainNumber(); - for (int i=0; i< nb_face; i++) - { - int local= face_corresp[i*2]; - int distant = face_corresp[i*2+1]; - local2distant.insert(make_pair(local, make_pair(distant_ip,distant))); - } - } - } - // setting mappings for all faces - if (faceglobal[idomain]==0) - { - for (int iface=0; ifacesecond).first; - int distant = (local2distant.find(iface+1)->second).second; - //int global_number=m_loc_to_glob[make_pair(ip,distant)]; - int global_number=m_loc_to_glob[ip][distant-1]; - m_face_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,iface+1))); - //m_face_loc_to_glob[make_pair(idomain,iface+1)]=global_number; - m_face_loc_to_glob[idomain][iface]=global_number; - } - } - } - //using former face numbering - else - { - for (int iface=0; iface graph, int nb_domain, int mesh_dimension): - m_nb_domain(nb_domain), - m_mesh_dimension(mesh_dimension), - m_nb_cells(graph->nbVertices()), - m_graph(graph) -{ - m_nb_cells.resize(m_nb_domain); - m_nb_nodes.resize(m_nb_domain); - m_nb_faces.resize(m_nb_domain); - - m_loc_to_glob.resize(m_nb_domain); - m_node_loc_to_glob.resize(m_nb_domain); - m_face_loc_to_glob.resize(m_nb_domain); - - // used in parallel mode only - m_cell_loc_to_glob_fuse.resize(m_nb_domain); - m_face_loc_to_glob_fuse.resize(m_nb_domain); - - for (int i=0; i getPart(); - m_nb_total_cells= graph->nbVertices(); - - for (int icell=0; icell local_node = m_node_glob_to_loc.find(node_list[i])->second; - ip[i]=local_node.first; - local[i]=local_node.second; - } -} - -/*!Converts a list of global node numbers on domain ip - * to a distributed array with local cell numbers. - * - * If a node in the list is represented on several domains, - * only the value with domain ip is returned - * - * */ -void ParallelTopology::convertGlobalNodeList(const int* node_list, int nbnode, int* local, int ip) -{ - if (m_node_glob_to_loc.empty()) - throw MEDMEM::MEDEXCEPTION("convertGlobalNodeList - Node mapping has not yet been built"); - - for (int i=0; i< nbnode; i++) - { - typedef INTERP_KERNEL::HashMultiMap >::iterator mmiter; - pair range=m_node_glob_to_loc.equal_range(node_list[i]); - for (mmiter it=range.first; it !=range.second; it++) - { - int ipfound=(it->second).first; - if (ipfound==ip) - local[i]=(it->second).second; - } - } -} - -/*!Converts a list of global node numbers - * to a distributed array with local cell numbers. - * - * If a node in the list is represented on several domains, - * all the values are put in the array - * */ -void ParallelTopology::convertGlobalNodeListWithTwins(const int* node_list, int nbnode, int*& local, int*& ip,int*& full_array, int& size) -{ - if (m_node_glob_to_loc.empty()) - throw MEDMEM::MEDEXCEPTION("convertGlobalNodeList - Node mapping has not yet been built"); - - size=0; - for (int i=0; i< nbnode; i++) - { - int count= m_node_glob_to_loc.count(node_list[i]); - // if (count > 1) - // cout << "noeud " << node_list[i]<< " doublon d'ordre " << count< >::iterator mmiter; - pair range=m_node_glob_to_loc.equal_range(node_list[i]); - for (mmiter it=range.first; it !=range.second; it++) - { - ip[index]=(it->second).first; - local[index]=(it->second).second; - full_array [index]=node_list[i]; - index++; - } - - } -} - -/*!Converts a list of global face numbers - * to a distributed array with local face numbers. - * - * If a face in the list is represented on several domains, - * all the values are put in the array - * */ -void ParallelTopology::convertGlobalFaceListWithTwins(const int* face_list, int nbface, int*& local, int*& ip, int*& full_array,int& size) -{ - size=0; - for (int i=0; i< nbface; i++) - { - //int count = m_face_glob_to_loc.count(face_list[i]); - //if (count >1) MESSAGE_MED("face en doublon "< >::iterator mmiter; - pair range=m_face_glob_to_loc.equal_range(face_list[i]); - for (mmiter it=range.first; it !=range.second; it++) - { - ip[index]=(it->second).first; - local[index]=(it->second).second; - full_array[index]=face_list[i]; - index++; - } - - } -} - -//!converts a list of global cell numbers -//!to a distributed array with local cell numbers -void ParallelTopology::convertGlobalCellList(const int* cell_list, int nbcell, int* local, int* ip) -{ - for (int i=0; i< nbcell; i++) - { - INTERP_KERNEL::HashMap >::const_iterator iter = m_glob_to_loc.find(cell_list[i]); - ip[i]=(iter->second).first; - local[i]=(iter->second).second; - } -} - -/*!Converts a list of global face numbers - * to a distributed array with local face numbers - */ -void ParallelTopology::convertGlobalFaceList(const int* face_list, int nbface, int* local, int* ip) -{ - for (int i=0; i< nbface; i++) - { - INTERP_KERNEL::HashMap >::const_iterator iter = m_face_glob_to_loc.find(face_list[i]); - if (iter == m_face_glob_to_loc.end()) - { - throw MED_EXCEPTION("convertGlobalFaceList - Face not found"); - } - ip[i]=(iter->second).first; - local[i]=(iter->second).second; - // cout << " in convertGlobalFAceList face global "< ("< >::iterator mmiter; - pair range=m_face_glob_to_loc.equal_range(face_list[i]); - for (mmiter it=range.first; it !=range.second; it++) - { - int ipfound=(it->second).first; - if (ipfound==ip) - local[i]=(it->second).second; - - } - } -} - - -////creating node mapping -void ParallelTopology::createNodeMapping(map& type_connectivity, - map& present_type_numbers, - vector& polygon_conn, - vector& polygon_conn_index, - vector& polyhedron_conn, - vector& polyhedron_conn_index, - vector& polyhedron_face_index, - int idomain) -{ - set local_numbers; - int local_index=0; - - map::const_iterator iter; - for (iter = present_type_numbers.begin(); iter!=present_type_numbers.end();iter++) - { - int type=iter->first; - int nodes_per_type= type%100; - - if (!((type/100==m_mesh_dimension) - ||(type==MED_EN::MED_POLYGON && m_mesh_dimension==2) - ||(type==MED_EN::MED_POLYHEDRA && m_mesh_dimension==3))) continue; - - if (type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) - { - for (int icell=0; icell& globNodes) -{ - // convert global nodes to local in the given domain - set nodes; - set::const_iterator n = globNodes.begin(); - for ( ; n != globNodes.end(); ++n ) - nodes.insert( convertGlobalNode( *n, domain )); - - const MED_EN::medConnectivity connType = MED_EN::MED_NODAL; - const MED_EN::medEntityMesh entity = MED_EN::MED_CELL; - - // loop on all types of cells - const MEDMEM::MESH* mesh = new_collection.getMesh( domain ); - int nbTypes = mesh->getNumberOfTypes( entity ); - const MED_EN::medGeometryElement * types = mesh->getTypes( entity ); - for ( int t = 0; t < nbTypes; ++t ) - { - // get connectivity - if ( !mesh->existConnectivity( connType, entity )) - continue; - int nbCell = mesh->getNumberOfElements( entity, types[t] ); - const int *conn, *index; - conn = mesh->getConnectivity(connType, entity, types[t]); - index = mesh->getConnectivityIndex(connType, entity); - // find a cell containing the first of given nodes, - // then check if the found cell contains all the given nodes - const int firstNode = *nodes.begin(); - for ( int i = 0; i < nbCell; ++i ) - { - for ( int j = index[i]-1; j < index[i+1]-1; ++j ) - if ( conn[j] == firstNode ) - { - unsigned nbSame = 0; - for ( j = index[i]-1; j < index[i+1]-1; ++j ) - nbSame += nodes.count( conn[j] ); - if ( nbSame == nodes.size() ) - return true; - break; - } - } - } - return false; -} - -////creating face mapping -void ParallelTopology::createFaceMapping(const MESHCollection& initial_collection, - const MESHCollection& new_collection) - // map& type_list, - // map& present_type_numbers, - // int idomain - -{ - // containers for the new topology - vector new_counts(m_nb_domain,0); - vector domain_counts(m_nb_domain,0); - const Topology* old_topology=initial_collection.getTopology(); - int nb_domain_old=old_topology->nbDomain(); - int global_index=old_topology->getFaceNumber(); - //cout << "nb faces = " << global_index << endl; - set > > global_treated; - - //definition of the d-1 constituent for the considered mesh dimension - MED_EN::medEntityMesh constituent_entity; - switch (m_mesh_dimension) - { - case 3: - constituent_entity= MED_EN::MED_FACE; - break; - case 2: - constituent_entity = MED_EN::MED_EDGE; - break; - } - - for (int iold=0; ioldgetNumberOfElements(constituent_entity,MED_EN::MED_ALL_ELEMENTS); - SCRUTE_MED(nbtotalface); - const int* face_conn = 0; - const int* face_offset = 0; - if (nbtotalface >0) - { - face_conn = initial_collection.getMesh(iold)->getConnectivity( - MED_EN::MED_NODAL,constituent_entity,MED_EN::MED_ALL_ELEMENTS); - face_offset = initial_collection.getMesh(iold)->getConnectivityIndex(MED_EN::MED_NODAL,constituent_entity); - } - for (int iface=0;ifaceconvertFaceToGlobal(iold,iface+1); - - // int inode = face_offset[iface]; - for (int i=0; i nodes; - int nbnodes; - { - nbnodes=face_offset[iface+1]-face_offset[iface]; - for (int inode= face_offset[iface];inode < face_offset[iface+1]; inode++) - { - int node=face_conn[inode-1]; - - int global = old_topology->convertNodeToGlobal(iold,node); - // cout << "global node "< >::iterator mmiter; - pair range=m_node_glob_to_loc.equal_range(global); - - int ip; - for (mmiter it=range.first; it !=range.second; it++) - { - ip=(it->second).first; - domain_counts[ip]++; - } - } - } - - set::const_iterator iter_node = nodes.begin(); - int numbers[3]; - numbers[2]=0; // for segments - for (int i=0; i > > ::iterator iter_triplets; - pair > triplet = make_pair(numbers[0],make_pair(numbers[1],numbers[2])); - iter_triplets=global_treated.find(triplet); - if (iter_triplets==global_treated.end()) - { - global_treated.insert(triplet); - // int nbnodes=face_offset[iface+1]-face_offset[iface]; - if (global_face_number == -1) - { - global_index++; - global_face_number=global_index; - - } - // SCRUTE_MED(nbnodes); - - for (int inew=0;inew new_counts(m_nb_domain,0); - vector domain_counts(m_nb_domain,0); - const Topology* old_topology=initial_collection.getTopology(); - int nb_domain_old=old_topology->nbDomain(); - //int global_index=old_topology->getFaceNumber(); - // set > > global_treated; - - //definition of the d-1 constituent for the considered mesh dimension - MED_EN::medEntityMesh constituent_entity; - switch (m_mesh_dimension) - { - case 3: - constituent_entity= MED_EN::MED_FACE; - break; - case 2: - constituent_entity = MED_EN::MED_EDGE; - break; - } - - for (int iold=0; ioldgetCellNumber(iold); - - const int* face_conn = initial_collection.getMesh(iold)-> - getConnectivity(MED_EN::MED_DESCENDING,MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - const int* face_offset = initial_collection.getMesh(iold)-> - getConnectivityIndex(MED_EN::MED_DESCENDING,MED_EN::MED_CELL); - MESSAGE_MED("end of connectivity calculation"); - set global_treated; - for (int icell=0; icellconvertCellToGlobal(iold,icell+1); - int inew = getCellDomainNumber(global_cell_number); - - for (int iface = face_offset[icell]; iface < face_offset[icell+1]; iface++) - { - int global_face_number=old_topology->convertFaceToGlobal(iold,abs(face_conn[iface-1])); - if (global_treated.find (global_face_number)==global_treated.end()) - { - new_counts[inew]++; - m_face_glob_to_loc.insert(make_pair(global_face_number,make_pair(inew,new_counts[inew]))); - - //m_face_loc_to_glob.insert(make_pair(make_pair(inew,new_counts[inew]),global_face_number)); - m_face_loc_to_glob[inew].push_back(global_face_number); - global_treated.insert(global_face_number); - - } - } - } - } - - - for (int inew=0;inew& type_connectivity, - map& present_type_numbers, - int idomain, - MED_EN::medEntityMesh entity) -{ - int dimension; - switch (entity) - { - case MED_EN::MED_CELL: - dimension=m_mesh_dimension; - break; - case MED_EN::MED_FACE: - dimension=2; - break; - case MED_EN::MED_EDGE: - dimension=1; - break; - } - - MED_EN::MESH_ENTITIES::const_iterator currentEntity; - list::const_iterator iter; - currentEntity = MED_EN::meshEntities.find(MED_EN::MED_CELL); - - for (iter = (*currentEntity).second.begin();iter != (*currentEntity).second.end(); iter++) - { - MED_EN::medGeometryElement type = (*iter); - if (type/100 != dimension) continue; - for (int inode=0; inodegetGlobal()<<" - "<getGlobal(),make_pair(idomain,ilocal))); - m_face_loc_to_glob[idomain].push_back(face->getGlobal()); - ilocal++; - } - } - m_nb_faces[idomain] =ilocal-1; - } -} - -//================================================================================ -/*! - * \brief Recreating cell and node mapping after send-reveive and fusion of domain meshes - */ -//================================================================================ - -void ParallelTopology::recreateMappingAfterFusion(const vector& meshes) -{ - const char* LOC = "ParallelTopology::recreateMappingAfterFusion(): "; - - m_glob_to_loc.clear(); - m_node_glob_to_loc.clear(); - m_face_glob_to_loc.clear(); - - for (int idomain=0; idomaingetCoordinateptr() ) continue; // empty domian - - //creating cell maps - - m_nb_cells[idomain]=meshes[idomain]->getNumberOfElements(MED_EN::MED_CELL, - MED_EN::MED_ALL_ELEMENTS); - if ( m_cell_loc_to_glob_fuse[idomain].size() != m_nb_cells[idomain] ) - throw MED_EXCEPTION(MEDMEM::STRING(LOC)<<" invalid nb of fused cells"); - - m_loc_to_glob[idomain].swap( m_cell_loc_to_glob_fuse[idomain] ); - - for (int i=0; igetNumberOfNodes(); - m_node_loc_to_glob[idomain] = ((MEDMEM::MeshFuse*)meshes[idomain])->getNodeNumbers(); - if ( m_node_loc_to_glob[idomain].size() != m_nb_nodes[idomain] ) - throw MED_EXCEPTION(MEDMEM::STRING(LOC)<<" invalid nb of fused nodes"); - - // setting mappings for all nodes - for (int inode=0; inodegetNumberOfElements(constituent_entity, - MED_EN::MED_ALL_ELEMENTS); - if ( m_face_loc_to_glob_fuse[idomain].size() != m_nb_faces[idomain] ) - throw MED_EXCEPTION(MEDMEM::STRING(LOC)<<" invalid nb of fused faces of domain "<< idomain - << ": expect " << m_nb_faces[idomain] - << " but have " << m_face_loc_to_glob_fuse[idomain].size()); - - m_face_loc_to_glob[idomain].swap( m_face_loc_to_glob_fuse[idomain] ); - - for (int iface=0; iface -#include "InterpKernelHashMap.hxx" -#include "boost/shared_ptr.hpp" - -#include "MEDSPLITTER_Topology.hxx" - -namespace INTERP_KERNEL -{ - template<> struct hash< pair > - { - size_t operator()( const pair& x ) const - { - return hash< int >()( x.first*1000000+x.second ); - } - }; -} - -namespace MEDSPLITTER { - - class Graph; - class MESHCollection; - class MEDSPLITTER_FaceModel; - - class ParallelTopology:public Topology - { - - public: - - ParallelTopology(); - - ParallelTopology(const std::vector&, - const std::vector&, - std::vector&, - std::vector&, - std::vector&); - - ParallelTopology(boost::shared_ptr graph, int nbdomain, int mesh_dimension); - - ~ParallelTopology(); - //!converts a list of global cell numbers - //!to a distributed array with local cell numbers - void convertGlobalNodeList(const int*, int,int*,int*); - void convertGlobalNodeList(const int*, int,int*,int); - void convertGlobalNodeListWithTwins(const int* face_list, int nbnode, int*& local, int*& ip, int*& full_array, int& size); - - //!converts a list of global node numbers - //!to a distributed array with local cell numbers - void convertGlobalCellList(const int*, int , int*, int *); - - //!converts a list of global face numbers - //!to a distributed array with local face numbers - void convertGlobalFaceList(const int*, int , int*, int *); - void convertGlobalFaceList(const int*, int , int*, int); - void convertGlobalFaceListWithTwins(const int* face_list, int nbface, int*& local, int*& ip, int*& full_array,int& size); - - //!creating node mapping - - void createNodeMapping(std::map& type_connectivity, - std::map& present_type_numbers, - std::vector& conn, - std::vector& conn_index, - std::vector& polyhedron_conn, - std::vector& polyhedron_conn_index, - std::vector& polyhedron_face_index, - int idomain); - - // void createFaceMapping(std::map& type_connectivity, - // std::map& present_type_numbers, - // int idomain); - - void createFaceMapping(const MESHCollection &, const MESHCollection&); - void createFaceMapping2ndversion(const MESHCollection &); - - //!converting node global numberings to local numberings - void convertToLocal(std::map& type_connectivity, - std::map& present_type_numbers, - int idomain, - MED_EN::medEntityMesh entity); - void convertToLocal2ndVersion(int* nodes, int nbnodes, int idomain); - - - - //! computing arrays with node/node correspondencies - void computeNodeNodeCorrespondencies(int nbdomain,vector& ) const; - - //! computing arrays with node/node correspondencies - void computeCellCellCorrespondencies(int nbdomain,vector&, const Graph*) const; - - //! retrieving Graph - // boost::shared_ptr getGraph() const; - - - //!converting node local numbering to global - inline int convertNodeToGlobal(int ip,int icell) const - { - //return m_node_loc_to_glob.find(make_pair(ip,icell))->second; - return icell < 1 ? icell : m_node_loc_to_glob[ip][icell-1]; - } - - //!converting face local numbering to global - inline int convertFaceToGlobal(int ip,int iface) const - { - // if (m_face_loc_to_glob.find(make_pair(ip,icell))==m_face_loc_to_glob.end()) - // return -1; - // else - //return m_face_loc_to_glob.find(make_pair(ip,icell))->second; - return m_face_loc_to_glob[ip][iface-1]; - } - - //converting cell global numbering to local - inline int convertCellToGlobal(int ip,int icell) const - { - // if (m_loc_to_glob.find(make_pair(ip,icell))==m_loc_to_glob.end()) - // return -1; - // else - //return m_loc_to_glob.find(make_pair(ip,icell))->second; - return m_loc_to_glob[ip][icell-1]; - } - - inline void convertNodeToGlobal(int ip, const int* local, int n, int* global)const - { - for (int i=0; isecond; - } - - inline void convertCellToGlobal(int ip, const int* local, int n, int* global)const - { - for (int i=0; isecond; - } - - inline void convertFaceToGlobal(int ip, const int* local, int n, int* global)const - { - for (int i=0; isecond; - } - } - - inline int nbDomain() const - { - return m_nb_domain; - } - - int nbCells() const - { - return m_nb_total_cells; - } - - - inline int nbCells( int idomain) const - { - return m_nb_cells[idomain]; - } - - - - - //!retrieving number of nodes - inline int getNodeNumber(int idomain) const - { - return m_nb_nodes[idomain]; - } - - inline int getNodeNumber() const - { - if (m_node_glob_to_loc.empty()) return 0; - set keys; - for (INTERP_KERNEL::HashMultiMap >::const_iterator iter= m_node_glob_to_loc.begin(); - iter!=m_node_glob_to_loc.end(); - iter++) { - keys.insert(iter->first); - } - return keys.size(); - } - - //!retrieving list of nodes in global numbers - inline void getNodeList(int idomain, int* list) const - { - for (int i=0; isecond; - } - } - - //!< retrieving cell numbers after fusing in parallel mode - std::vector & getFusedCellNumbers(int idomain) - { - return m_cell_loc_to_glob_fuse[idomain]; - } - const std::vector & getFusedCellNumbers(int idomain) const - { - return m_cell_loc_to_glob_fuse[idomain]; - } - - //!< retrieving face numbers after fusing in parallel mode - std::vector & getFusedFaceNumbers(int idomain) - { - return m_face_loc_to_glob_fuse[idomain]; - } - const std::vector & getFusedFaceNumbers(int idomain) const - { - return m_face_loc_to_glob_fuse[idomain]; - } - - - //!retrieving number of nodes - inline int getCellNumber(int idomain) const - { - return m_nb_cells[idomain]; - } - - inline int getCellDomainNumber(int global) const - { - return (m_glob_to_loc.find(global)->second).first; - } - - //!retrieving list of nodes in global numbers - inline void getCellList(int idomain, int* list) const - { - for (int i=0; isecond; - } - - } - - inline int getFaceNumber(int idomain) const - { - return m_nb_faces[idomain]; - } - - inline int getFaceNumber() const - { - if (m_face_glob_to_loc.empty()) return 0; - set keys; - for (INTERP_KERNEL::HashMultiMap >::const_iterator iter= m_face_glob_to_loc.begin(); - iter!=m_face_glob_to_loc.end(); - iter++) { - keys.insert(iter->first); - } - return keys.size(); - } - - - //!retrieving list of faces in global numbers - inline void getFaceList(int idomain, int* list) const - { - for (int i=0; isecond; - } - - } - - //! converting a global cell number to a local representation (domain + local number) - inline std::pair convertGlobalCell(int iglobal) const - { - return m_glob_to_loc.find(iglobal)->second; - } - - inline int convertGlobalFace(int iglobal, int idomain) - { - typedef INTERP_KERNEL::HashMultiMap >::const_iterator MMiter; - pair eq = m_face_glob_to_loc.equal_range(iglobal); - for (MMiter it=eq.first; it != eq.second; it++) - { - SCRUTE_MED (it->second.first); - SCRUTE_MED (idomain); - if (it->second.first == idomain) return it->second.second; - - } - return -1; - } - - inline int convertGlobalNode(int iglobal, int idomain) - { - typedef INTERP_KERNEL::HashMultiMap >::const_iterator MMiter; - pair eq = m_node_glob_to_loc.equal_range(iglobal); - for (MMiter it=eq.first; it != eq.second; it++) - { - if (it->second.first == idomain) return it->second.second; - } - return -1; - } - //!adding a face to the topology - inline void appendFace(int idomain, int ilocal, int iglobal) - { - m_face_loc_to_glob[idomain].push_back(iglobal); - m_face_glob_to_loc.insert(make_pair(iglobal,make_pair(idomain,ilocal))); - } - - //return max global face number - int getMaxGlobalFace() const; - - boost::shared_ptr getGraph() const - { - return m_graph; - } - - //!recreating a face mapping from scratch - void recreateFaceMapping(const TGeom2FacesByDomian& face_map); - - // recreating cell and node mapping after send-reveive and fusion of domain meshes - virtual void recreateMappingAfterFusion(const std::vector& ); - - - - private: - - bool hasCellWithNodes( const MESHCollection&, int dom, const std::set& nodes ); - - - private: - //!mapping global -> local - typedef INTERP_KERNEL::HashMap > TGlob2DomainLoc; - TGlob2DomainLoc m_glob_to_loc; - - // bool is_equal_pair (pair a, pair b){ - // return (a.first==b.first && a.second==b.second); - // } - //!mapping local -> global - //map,int> m_loc_to_glob; - - // - //INTERP_KERNEL::HashMap,int, INTERP_KERNEL::hash > > m_loc_to_glob; - vector > m_loc_to_glob; - //!mapping global -> local - INTERP_KERNEL::HashMultiMap > m_node_glob_to_loc; - - //!mapping local -> global - // map,int> m_node_loc_to_glob; - //INTERP_KERNEL::HashMap,int, INTERP_KERNEL::hash > > m_node_loc_to_glob; - vector > m_node_loc_to_glob; - - // global numbers in parallel mode - vector > m_cell_loc_to_glob_fuse; // glob nums after fusing - vector > m_face_loc_to_glob_fuse; // glob nums after fusing - - - //!mapping global -> local - typedef INTERP_KERNEL::HashMultiMap > TGlob2LocsMap; - TGlob2LocsMap m_face_glob_to_loc; - - //!mapping local -> global - //INTERP_KERNEL::HashMap,int, INTERP_KERNEL::hash > > m_face_loc_to_glob; - vector > m_face_loc_to_glob; - - //map,int> m_face_loc_to_glob; - - vector m_nb_cells; - - vector m_nb_nodes; - - vector m_nb_faces; - - int m_nb_total_cells; - - int m_nb_total_nodes; - - int m_nb_total_faces; - - int m_nb_domain; - - int m_mesh_dimension; - - boost::shared_ptr m_graph; - }; - - -} -#endif /*PARALLELTOPOLOGY_HXX_*/ diff --git a/src/MEDSPLITTER/MEDSPLITTER_SCOTCHGraph.cxx b/src/MEDSPLITTER/MEDSPLITTER_SCOTCHGraph.cxx deleted file mode 100644 index 2268f3657..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_SCOTCHGraph.cxx +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2007-2013 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 -extern "C" { -#define restrict -#include "scotch.h" -} -#include "MEDSPLITTER_Graph.hxx" -#include "MEDSPLITTER_SCOTCHGraph.hxx" - -using namespace MEDSPLITTER; - -SCOTCHGraph::SCOTCHGraph():Graph() -{ -} - -SCOTCHGraph::SCOTCHGraph(MEDMEM::MEDSKYLINEARRAY* graph, int* edgeweight):Graph(graph,edgeweight) -{ -} - -SCOTCHGraph::~SCOTCHGraph() -{ -} - -void SCOTCHGraph::partGraph(int ndomain, const string& options_string, ParaDomainSelector* sel) -{ - // number of graph vertices - int n = m_graph->getNumberOf(); - - //graph - int * xadj=const_cast(m_graph->getIndex()); - int * adjncy = const_cast(m_graph->getValue()); - - //ndomain - int nparts = ndomain; - - // output parameters - int* partition = new int[n+1]; - - SCOTCH_Graph scotch_graph; - - SCOTCH_graphInit(&scotch_graph); - - - SCOTCH_graphBuild(&scotch_graph, - 1, //premier indice 1 - n, // nb of graph nodes - xadj, - 0, - m_cellweight, //graph vertices loads - 0, - xadj[n], // number of edges - adjncy, - m_edgeweight); - - SCOTCH_Strat scotch_strategy; - SCOTCH_stratInit(&scotch_strategy); - - //!user-defined options for the strategy - if (options_string!="") - SCOTCH_stratGraphMap(&scotch_strategy,options_string.c_str()); - - - if (nparts>1) - SCOTCH_graphPart(&scotch_graph,nparts,&scotch_strategy,partition); - else - // partition for 1 subdomain - for (int i=0; i, std::vector){throw MEDEXCEPTION("SequentialTopology - not implemented yet");} - -//!converts a list of global cell numbers -//!to a distributed array with local cell numbers -void SequentialTopology::convertGlobalNodeList(const int*, int,int*,int*){} - -//!converts a list of global node numbers -//!to a distributed array with local cell numbers -void SequentialTopology::convertGlobalCellList(const int*, int , int*, int *){} - -//number of doamins -int SequentialTopology::nbDomain() const -{ - return 0; -} - -//number of cells -int SequentialTopology::nbCells() const -{ - return 0; -} - -//number of cells on a specific domain -int SequentialTopology::nbCells(int idomain) const -{ - return 0; -} - -//!creating node mapping -void SequentialTopology::createNodeMapping(vector type_connectivity,int* present_type_numbers, int idomain){} - -//!converting node global numberings to local numberings -void SequentialTopology::convertToLocal(vector type_connectivity,int* present_type_numbers){} - -//!retrieving number of nodes -int SequentialTopology::getNodeNumber(int idomain) const -{ - return 0; -} - -//!retrieving list of nodes -void SequentialTopology::getNodeList(int idomain, int* list) const{} - -//!retrieving number of cells -int SequentialTopology::getCellNumber(int idomain) const -{ - return 0; -} - -//!retrieving list of cells -void SequentialTopology::getCellList(int idomain, int* list) const{} diff --git a/src/MEDSPLITTER/MEDSPLITTER_SequentialTopology.hxx b/src/MEDSPLITTER/MEDSPLITTER_SequentialTopology.hxx deleted file mode 100644 index 4dae0e338..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_SequentialTopology.hxx +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2007-2013 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 SequentialTOPOLOGY_HXX_ -#define SequentialTOPOLOGY_HXX_ - -#include "MEDSPLITTER.hxx" - -namespace MEDSPLITTER { - class SequentialTopology:public Topology - { - - public: - - SequentialTopology(); - SequentialTopology(std::vector, std::vector); - - //!converts a list of global cell numbers - //!to a distributed array with local cell numbers - void convertGlobalNodeList(const int*, int,int*,int*); - - //!converts a list of global node numbers - //!to a distributed array with local cell numbers - void convertGlobalCellList(const int*, int , int*, int *); - - //number of doamins - int nbDomain() const; - - //number of cells - int nbCells() const; - - //number of cells on a specific domain - int nbCells(int idomain) const; - - //!creating node mapping - void createNodeMapping(vector type_connectivity,int* present_type_numbers, int idomain); - - //!converting node global numberings to local numberings - void convertToLocal(vector type_connectivity,int* present_type_numbers); - - //!retrieving number of nodes - int getNodeNumber(int idomain) const ; - - //!retrieving list of nodes - void getNodeList(int idomain, int* list) const; - - //!retrieving number of cells - int getCellNumber(int idomain) const ; - - //!retrieving list of cells - void getCellList(int idomain, int* list) const; - - private: - //!mapping global -> local - map > m_glob_to_loc; - - //!mapping local -> global - map,int> m_loc_to_glob; - - //!mapping global -> local - multimap > m_node_glob_to_loc; - - //!mapping local -> global - map,int> m_node_loc_to_glob; - - vector m_nb_cells; - - vector m_nb_nodes; - - int m_nb_total_cells; - - int m_nb_total_nodes; - }; -} -#endif /*SequentialTOPOLOGY_HXX_*/ diff --git a/src/MEDSPLITTER/MEDSPLITTER_Topology.hxx b/src/MEDSPLITTER/MEDSPLITTER_Topology.hxx deleted file mode 100644 index df1ad4200..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_Topology.hxx +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright (C) 2007-2013 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 TOPOLOGY_HXX_ -#define TOPOLOGY_HXX_ - -#include "MEDMEM_define.hxx" - -#include "boost/shared_ptr.hpp" - -#include -#include - -namespace MEDMEM -{ - class CONNECTZONE; - class MESH; - class MEDSKYLINEARRAY; -} - -namespace MEDSPLITTER { - - class Graph; - class MESHCollection; - class MEDSPLITTER_FaceModel; - - typedef std::map > TGeom2Faces; - typedef std::vector< TGeom2Faces > TGeom2FacesByDomian; - - class Topology - { - public: - Topology(){} - Topology(std::vector, std::vector){} - - virtual ~Topology(){} - - //!converts a list of global cell numbers - //!to a distributed array with local cell numbers - virtual void convertGlobalNodeList(const int* list, int nb, int* local, int*ip)=0; - virtual void convertGlobalNodeList(const int* list, int nb, int* local, int ip)=0; - //!converts a list of global node numbers - //!to a distributed array with local cell numbers - virtual void convertGlobalCellList(const int*list , int nb, int* local, int*ip)=0; - - //!converts a list of global face numbers - //!to a distributed array with local face numbers - virtual void convertGlobalFaceList(const int*list , int nb, int* local, int*ip)=0; - virtual void convertGlobalFaceList(const int*list , int nb, int* local, int ip)=0; - virtual void convertGlobalFaceListWithTwins(const int* face_list, int nbface, int*& local, int*& ip, int*& full_array, int& size)=0; - virtual void convertGlobalNodeListWithTwins(const int* face_list, int nbnode, int*& local, int*& ip, int*& full_array, int& size)=0; - - - //number of doamins - virtual int nbDomain() const =0; - - //number of cells - virtual int nbCells() const=0; - - - //number of cells on a specific domain - virtual int nbCells(int idomain) const=0; - - ////creating node mapping - virtual void createNodeMapping(std::map& type_connectivity, - std::map& present_type_numbers, - std::vector& polygon_conn, - std::vector& polygon_conn_index, - std::vector& polyhedron_conn, - std::vector& polyhedron_conn_index, - std::vector& polyhedron_face_index, - int domain)=0; - - ////creating face mapping - // virtual void createFaceMapping(std::map& type_connectivity, - // std::map& present_type_numbers,int domain)=0; - // - virtual void createFaceMapping(const MESHCollection&,const MESHCollection&)=0; - - //converting node global numberings to local numberings - virtual void convertToLocal(std::map& type_connectivity, - std::map& present_type_numbers, - int idomain, - MED_EN::medEntityMesh entity)=0; - //converting node global numberings to local numberings - virtual void convertToLocal2ndVersion(int*,int,int)=0; - - virtual int convertNodeToGlobal(int ip,int icell)const=0; - virtual int convertFaceToGlobal(int ip,int icell)const=0; - virtual int convertCellToGlobal(int ip,int icell)const=0; - - virtual void convertNodeToGlobal(int ip,const int* local, int n, int* global)const=0 ; - virtual void convertCellToGlobal(int ip,const int* local, int n, int* global)const=0 ; - virtual void convertFaceToGlobal(int ip,const int* local, int n, int* global)const=0 ; - - //retrieving number of nodes - virtual int getNodeNumber(int idomain) const =0; - virtual int getNodeNumber() const=0; - //retrieving list of nodes - virtual void getNodeList(int idomain, int* list) const =0; - - virtual std::vector & getFusedCellNumbers(int idomain) = 0; - virtual const std::vector & getFusedCellNumbers(int idomain) const = 0; - - virtual std::vector & getFusedFaceNumbers(int idomain) = 0; - virtual const std::vector & getFusedFaceNumbers(int idomain) const = 0; - - //retrieving number of nodes - virtual int getCellNumber(int idomain) const =0; - - //retrieving list of nodes - virtual void getCellList(int idomain, int* list) const =0; - - //retrieving number of faces - virtual int getFaceNumber(int idomain) const =0; - virtual int getFaceNumber()const =0; - - //retrieving list of nodes - virtual void getFaceList(int idomain, int* list) const =0; - - //adding a face to the mapping - virtual void appendFace(int idomain, int ilocal, int iglobal)=0; - - //return max global face number - virtual int getMaxGlobalFace()const=0; - - //return next free global face number - //virtual int nextGlobalFace(int start_num) const=0; - - //!converting a global cell number to a local representation - virtual std::pair convertGlobalCell(int iglobal) const =0; - - //converting a global face number to a local representation - virtual int convertGlobalFace(int iglobal, int idomain)=0; - - //converting a global node number to a local representation - virtual int convertGlobalNode(int iglobal, int idomain)=0; - - //! computing arrays with node/node correspondencies - virtual void computeNodeNodeCorrespondencies(int nbdomain, std::vector&) const =0; - - //! computing arrays with cell/cell correspondencies - virtual void computeCellCellCorrespondencies(int nbdomain, std::vector&, const Graph*) const =0; - - //! retrieving graph - virtual boost::shared_ptr getGraph() const=0; - - //!recreating a face mapping from scratch - virtual void recreateFaceMapping(const TGeom2FacesByDomian& )=0; - - //!recreating cell and node mapping after send-reveive and fusion of domain meshes - virtual void recreateMappingAfterFusion(const std::vector& ) = 0; - }; -} -#endif /*TOPOLOGY_HXX_*/ diff --git a/src/MEDSPLITTER/MEDSPLITTER_UserGraph.cxx b/src/MEDSPLITTER/MEDSPLITTER_UserGraph.cxx deleted file mode 100644 index 8f5fef333..000000000 --- a/src/MEDSPLITTER/MEDSPLITTER_UserGraph.cxx +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2007-2013 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 "MEDSPLITTER_Graph.hxx" -#include "MEDSPLITTER_UserGraph.hxx" - - -using namespace MEDSPLITTER; - -/*! constructor that allows to specify the desired partition - * \param partition as table giving the domain number for each cell - * (domain numbers range from 0 to ndomain-1 - * \param n number of cells in the mesh - */ -UserGraph::UserGraph(MEDMEM::MEDSKYLINEARRAY* array, const int* partition, int n):Graph(array,0) -{ - - int* index=new int [n+1]; - index[0]=1; - for (int i=0; i - -namespace MEDSPLITTER -{ - static std::string trim(std::string& s,const std::string& drop = " ") - { - std::string r=s.erase(s.find_last_not_of(drop)+1); - return r.erase(0,r.find_first_not_of(drop)); - } -} -#endif /*MEDSPLITTER_UTILS_HXX_*/ diff --git a/src/MEDSPLITTER/Makefile.am b/src/MEDSPLITTER/Makefile.am deleted file mode 100644 index 6cb82a79b..000000000 --- a/src/MEDSPLITTER/Makefile.am +++ /dev/null @@ -1,146 +0,0 @@ -# Copyright (C) 2007-2013 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 $(top_srcdir)/adm_local/unix/make_common_starter.am - -# this directory must be recompiled before Test folder - -if CPPUNIT_IS_OK - SUBDIRS=. Test -endif - -lib_LTLIBRARIES= libmedsplitter.la - -salomeinclude_HEADERS= \ -MEDSPLITTER_Topology.hxx \ -MEDSPLITTER_MESHCollection.hxx \ -MEDSPLITTER_MESHCollection.H \ -MEDSPLITTER_MESHCollectionDriver.H \ -MEDSPLITTER_MESHCollectionMedXMLDriver.H \ -MEDSPLITTER_MESHCollectionMedAsciiDriver.H \ -MEDSPLITTER_MESHCollectionDriver.hxx \ -MEDSPLITTER_MESHCollectionMedXMLDriver.hxx \ -MEDSPLITTER_MESHCollectionMedAsciiDriver.hxx \ -MEDSPLITTER_ParallelTopology.hxx \ -MEDSPLITTER_FaceModel.hxx \ -MEDSPLITTER_Graph.hxx\ -MEDSPLITTER_UserGraph.hxx\ -MEDSPLITTER_API.hxx \ -MEDSPLITTER_SequentialTopology.hxx \ -MEDSPLITTER_utils.hxx \ -MEDSPLITTER.hxx \ -MEDSPLITTER_ParaDomainSelector.hxx \ -MEDSPLITTER_MeshSendReceive.hxx \ -MEDSPLITTER_JointExchangeData.hxx - -if MED_ENABLE_METIS - salomeinclude_HEADERS+= MEDSPLITTER_METISGraph.hxx -endif -if MED_ENABLE_SCOTCH - salomeinclude_HEADERS+= MEDSPLITTER_SCOTCHGraph.hxx -endif - -dist_libmedsplitter_la_SOURCES= \ -MEDSPLITTER_MESHCollection.cxx \ -MEDSPLITTER_MESHCollectionDriver.cxx \ -MEDSPLITTER_MESHCollectionMedXMLDriver.cxx \ -MEDSPLITTER_MESHCollectionMedAsciiDriver.cxx \ -MEDSPLITTER_ParallelTopology.cxx \ -MEDSPLITTER_Graph.cxx\ -MEDSPLITTER_UserGraph.cxx\ -MEDSPLITTER_API.cxx \ -MEDSPLITTER_ParaDomainSelector.cxx \ -MEDSPLITTER_MeshSendReceive.cxx \ -MEDSPLITTER_JointExchangeData.cxx - -if MPI_IS_OK -if MED_ENABLE_PARMETIS - dist_libmedsplitter_la_SOURCES+= MEDSPLITTER_METISGraph.cxx -endif -else !MPI_IS_OK -if MED_ENABLE_METIS - dist_libmedsplitter_la_SOURCES+= MEDSPLITTER_METISGraph.cxx -endif -endif -if MED_ENABLE_SCOTCH - dist_libmedsplitter_la_SOURCES+= MEDSPLITTER_SCOTCHGraph.cxx -endif - -libmedsplitter_la_CPPFLAGS= $(MPI_INCLUDES) $(MED3_INCLUDES) $(HDF5_INCLUDES) \ - $(BOOST_CPPFLAGS) $(LIBXML_INCLUDES) \ - -I$(srcdir)/../MEDMEM \ - -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../INTERP_KERNEL/GaussPoints - -libmedsplitter_la_LDFLAGS= -#libmedsplitter_la_LDFLAGS= $(MED3_LIBS_C_ONLY) $(HDF5_LIBS) $(STDLIB) $(LIBXML_LIBS) \ -# ../MEDMEM/libmedmem.la ../MEDWrapper/V2_1/Core/libmed_V2_1.la - -if MPI_IS_OK -if MED_ENABLE_PARMETIS - libmedsplitter_la_CPPFLAGS+= $(PARMETIS_CPPFLAGS) - libmedsplitter_la_LDFLAGS+= $(PARMETIS_LIBS) -endif -else !MPI_IS_OK -if MED_ENABLE_METIS - libmedsplitter_la_CPPFLAGS+= $(METIS_CPPFLAGS) - libmedsplitter_la_LDFLAGS+= $(METIS_LIBS) -endif -endif -if MED_ENABLE_SCOTCH - libmedsplitter_la_CPPFLAGS+= $(SCOTCH_CPPFLAGS) - libmedsplitter_la_LDFLAGS+= $(SCOTCH_LIBS) -endif -if MED_ENABLE_KERNEL - libmedsplitter_la_CPPFLAGS+= $(BOOST_CPPFLAGS) - libmedsplitter_la_LDFLAGS+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace $(BOOST_LIBS) -endif - -libmedsplitter_la_CXXFLAGS = @CXXTMPDPTHFLAGS@ - -libmedsplitter_la_LDFLAGS+= $(MED3_LIBS_C_ONLY) $(HDF5_LIBS) $(STDLIB) $(LIBXML_LIBS) $(MPI_LIBS) \ - ../MEDMEM/libmedmem.la ../INTERP_KERNEL/libinterpkernel.la - -# Executables targets -bin_PROGRAMS= medsplitter - -dist_medsplitter_SOURCES= medsplitter.cxx - -medsplitter_CPPFLAGS= $(libmedsplitter_la_CPPFLAGS) - -medsplitter_LDADD= $(libmedsplitter_la_LDFLAGS) -lm libmedsplitter.la -if MED_ENABLE_KERNEL - medsplitter_LDADD+= -lSALOMEBasics -endif - -if MPI_IS_OK - bin_PROGRAMS+=medsplitter_para - dist_medsplitter_para_SOURCES= medsplitter_para.cxx - medsplitter_para_CPPFLAGS= $(medsplitter_CPPFLAGS) - medsplitter_para_LDADD= $(medsplitter_LDADD) - medsplitter_para_CXXFLAGS=@CXXTMPDPTHFLAGS@ -endif - -medsplitter_CXXFLAGS = @CXXTMPDPTHFLAGS@ - -OBSOLETE_FILES = \ - MEDSPLITTER_SequentialTopology.cxx \ - test_HighLevelAPI.cxx - -EXTRA_DIST += $(OBSOLETE_FILES) diff --git a/src/MEDSPLITTER/Test/CMakeLists.txt b/src/MEDSPLITTER/Test/CMakeLists.txt deleted file mode 100644 index 987a14ea4..000000000 --- a/src/MEDSPLITTER/Test/CMakeLists.txt +++ /dev/null @@ -1,117 +0,0 @@ -# Copyright (C) 2012-2013 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_DIRECTORIES( - ${PARMETIS_INCLUDE_DIRS} - ${METIS_INCLUDE_DIRS} - ${SCOTCH_INCLUDE_DIRS} - ${BOOST_INCLUDE_DIRS} - ${CPPUNIT_INCLUDE_DIRS} - ${LIBXML_INCLUDE_DIRS} - ${MED3_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS} - ${MPI_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR}/.. - ${CMAKE_CURRENT_SOURCE_DIR}/../../MEDMEM - ${CMAKE_CURRENT_SOURCE_DIR}/../../INTERP_KERNELTest # for BasicMainTest.cxx - ${CMAKE_CURRENT_SOURCE_DIR}/../../INTERP_KERNEL - ${CMAKE_CURRENT_SOURCE_DIR}/../../INTERP_KERNEL/Bases - ${CMAKE_CURRENT_SOURCE_DIR}/../../INTERP_KERNEL/Geometric2D - ${CMAKE_CURRENT_SOURCE_DIR}/../../INTERP_KERNEL/ExprEval - ${CMAKE_CURRENT_SOURCE_DIR}/../../INTERP_KERNEL/GaussPoints -) - -SET(MEDSPLITTERTest_HEADERS_HXX - MEDSPLITTERTest.hxx - MEDSPLITTERTest_Utils.hxx - MEDSPLITTERTest_defs.hxx -) - -SET(MEDSPLITTERTest_SOURCES - MEDSPLITTERTest.cxx - MEDSPLITTERTest_MESHCollection.cxx - MEDSPLITTERTest_ParallelTopology.cxx - MEDSPLITTERTest_Utils.cxx -) - -SET(MEDSPLITTERTest_DEFINITIONS "${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${BOOST_DEFINITIONS} ${LIBXML_DEFINITIONS} ${CPPUNIT_DEFINITIONS} ${MPI_DEFINITIONS} ${PLATFORM_DEFINITIONS}") -SET(MEDSPLITTERTest_LDFLAGS ${CPPUNIT_LIBS} ${MED3_LIBS_C_ONLY} medsplittercpp) - -IF(MED_ENABLE_PARMETIS) - SET(MEDSPLITTERTest_SOURCES - ${MEDSPLITTERTest_SOURCES} - ParaMEDSPLITTERTest_MeshSendReceive.cxx - ParaMEDSPLITTERTest_ParaDomainSelector.cxx - ParaMEDSPLITTERTest_medsplitter_para.cxx - ParaMEDSPLITTERTest.hxx - ) - SET(MEDSPLITTERTest_DEFINITIONS "${MEDSPLITTERTest_DEFINITIONS} ${PARMETIS_DEFINITIONS}") - SET(MEDSPLITTERTest_LDFLAGS ${MEDSPLITTERTest_LDFLAGS} ${PARMETIS_LIBS}) -ENDIF(MED_ENABLE_PARMETIS) - -IF(MED_ENABLE_METIS) - SET(MEDSPLITTERTest_DEFINITIONS "${MEDSPLITTERTest_DEFINITIONS} ${METIS_DEFINITIONS}") - SET(MEDSPLITTERTest_LDFLAGS ${MEDSPLITTERTest_LDFLAGS} ${METIS_LIBS}) -ENDIF(MED_ENABLE_METIS) - -IF(MED_ENABLE_KERNEL) - INCLUDE_DIRECTORIES(${KERNEL_ROOT_DIR}/include/salome) - SET(MEDSPLITTERTest_LDFLAGS ${MEDSPLITTERTest_LDFLAGS} ${SALOMELocalTrace}) -ENDIF(MED_ENABLE_KERNEL) - -IF(MED_ENABLE_SCOTCH) - SET(MEDSPLITTERTest_DEFINITIONS "${MEDSPLITTERTest_DEFINITIONS} ${SCOTCH_DEFINITIONS}") - SET(MEDSPLITTERTest_LDFLAGS ${MEDSPLITTERTest_LDFLAGS} ${SCOTCH_LIBS}) -ENDIF(MED_ENABLE_SCOTCH) - -SET(SCRIPTS testMEDSPLITTER.py) - - - -IF(MPI_IS_OK) - IF(MED_ENABLE_PARMETIS) - SET(TestParaMEDSPLITTER_LDFLAGS ${MEDSPLITTERTest_LDFLAGS} MEDSPLITTERTest medmem interpkernel medsplittercpp) - SET(SCRIPTS ${SCRIPTS} testMEDSPLITTER.py) - - ADD_EXECUTABLE(TestParaMEDSPLITTER TestParaMEDSPLITTER.cxx) - SET_TARGET_PROPERTIES(TestParaMEDSPLITTER PROPERTIES COMPILE_FLAGS "${MEDSPLITTERTest_DEFINITIONS}") - TARGET_LINK_LIBRARIES(TestParaMEDSPLITTER ${TestParaMEDSPLITTER_LDFLAGS}) - INSTALL(TARGETS TestParaMEDSPLITTER DESTINATION ${MED_salomebin_BINS}) - ENDIF(MED_ENABLE_PARMETIS) -ELSE(MPI_IS_OK) - IF(MED_ENABLE_METIS) - SET(TestMEDSPLITTER_LDFLAGS ${MEDSPLITTERTest_LDFLAGSS} MEDSPLITTERTest medmem interpkernel medsplittercpp) - IF(MED_ENABLE_KERNEL) - SET(MEDSPLITTERTest_LDFLAGS ${MEDSPLITTERTest_LDFLAGS} ${SALOMEBasics}) - ENDIF(MED_ENABLE_KERNEL) - - ADD_EXECUTABLE(TestMEDSPLITTER TestMEDSPLITTER.cxx) - SET_TARGET_PROPERTIES(TestMEDSPLITTER PROPERTIES COMPILE_FLAGS "${MEDSPLITTERTest_DEFINITIONS}") - TARGET_LINK_LIBRARIES(TestMEDSPLITTER ${TestMEDSPLITTER_LDFLAGS}) - INSTALL(TARGETS TestMEDSPLITTER DESTINATION ${MED_salomebin_BINS}) - ENDIF(MED_ENABLE_METIS) -ENDIF(MPI_IS_OK) - -ADD_LIBRARY(MEDSPLITTERTest SHARED ${MEDSPLITTERTest_SOURCES}) -SET_TARGET_PROPERTIES(MEDSPLITTERTest PROPERTIES COMPILE_FLAGS "${MEDSPLITTERTest_DEFINITIONS}") -TARGET_LINK_LIBRARIES(MEDSPLITTERTest ${MEDSPLITTERTest_LDFLAGS}) -INSTALL(TARGETS MEDSPLITTERTest DESTINATION ${MED_salomelib_LIBS}) - -INSTALL(FILES ${MEDSPLITTERTest_HEADERS_HXX} DESTINATION ${MED_salomeinclude_HEADERS}) -INSTALL(FILES ${SCRIPTS} DESTINATION ${MED_salomebin_BINS}) diff --git a/src/MEDSPLITTER/Test/MEDSPLITTERTest.cxx b/src/MEDSPLITTER/Test/MEDSPLITTERTest.cxx deleted file mode 100644 index ed9b83cf8..000000000 --- a/src/MEDSPLITTER/Test/MEDSPLITTERTest.cxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2007-2013 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 "MEDSPLITTERTest.hxx" -#include - -#include "MEDMEM_STRING.hxx" - -#include -#include -#include -#include -#include - -// ============================================================================ -/*! - * Set up the environment - */ -// ============================================================================ -void MEDSPLITTERTest::setUp() -{ -} - -// ============================================================================ -/*! - * - delete - */ -// ============================================================================ -void MEDSPLITTERTest::tearDown() -{ -} diff --git a/src/MEDSPLITTER/Test/MEDSPLITTERTest.hxx b/src/MEDSPLITTER/Test/MEDSPLITTERTest.hxx deleted file mode 100644 index 4563675ad..000000000 --- a/src/MEDSPLITTER/Test/MEDSPLITTERTest.hxx +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2007-2013 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 _MEDSPLITTERTEST_HXX_ -#define _MEDSPLITTERTEST_HXX_ - -#include "MEDSPLITTERTest_defs.hxx" - -#include - -#include -#include -#include - -namespace MEDSPLITTER { - class MESH; -}; - -class MEDSPLITTERTEST_EXPORT MEDSPLITTERTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( MEDSPLITTERTest ); - CPPUNIT_TEST( testMESHCollection_constructor ); - CPPUNIT_TEST( testMESHCollection_read_seq); - CPPUNIT_TEST( testMESHCollection_read_para); - CPPUNIT_TEST( testMESHCollection_square); - CPPUNIT_TEST( testMESHCollection_square_with_faces); -#ifdef MED_ENABLE_SCOTCH - CPPUNIT_TEST( testMESHCollection_indivisible); -#endif - CPPUNIT_TEST( testMESHCollection_user_partition); - CPPUNIT_TEST( testParallelTopology_graph_constructor); -#ifdef MED_ENABLE_SCOTCH - CPPUNIT_TEST( testMESHCollection_complete_sequence); - CPPUNIT_TEST( testMESHCollection_complete_sequence_with_polygon); -#endif - CPPUNIT_TEST( testMESHCollection_families); -// CPPUNIT_TEST( testMESHCollection_complete_sequence_with_polyhedra); - CPPUNIT_TEST_SUITE_END(); - -public: - - void setUp(); - void tearDown(); - - void testMESHCollection_constructor(); - void testMESHCollection_read_seq(); - void testMESHCollection_read_para(); - void testMESHCollection_square(); - void testMESHCollection_square_with_faces(); - void testMESHCollection_indivisible(); - void testMESHCollection_user_partition(); - void testMESHCollection_complete_sequence(); - void testMESHCollection_complete_sequence_with_polygon(); - void testMESHCollection_complete_sequence_with_polyhedra(); - void testMESHCollection_families(); - void testParallelTopology_graph_constructor(); - - }; - -#endif diff --git a/src/MEDSPLITTER/Test/MEDSPLITTERTest_MESHCollection.cxx b/src/MEDSPLITTER/Test/MEDSPLITTERTest_MESHCollection.cxx deleted file mode 100644 index 0103e55a8..000000000 --- a/src/MEDSPLITTER/Test/MEDSPLITTERTest_MESHCollection.cxx +++ /dev/null @@ -1,1173 +0,0 @@ -// Copyright (C) 2007-2013 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 "MEDSPLITTERTest.hxx" -#include "MEDSPLITTERTest_Utils.hxx" - -#include "MEDMEM_ConnectZone.hxx" -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_GaussLocalization.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDSPLITTER_Graph.hxx" -#include "MEDSPLITTER_Topology.hxx" -#include "MEDSPLITTER_ParallelTopology.hxx" -#include "MEDSPLITTER_SequentialTopology.hxx" -#include "MEDSPLITTER_MESHCollection.hxx" -#include "MEDSPLITTER_MESHCollectionDriver.hxx" - -#include "MEDMEM_Exception.hxx" - -#include -#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 - - -using namespace std; -using namespace MEDSPLITTER; -using namespace MEDMEM; -/*! - * Check methods (33), defined in MEDSPLITTER_MESHCollection.hxx: - * (-) MESHCollection(); - * (-) MESHCollection(const MESHCollection&, Topology*); - * (+) MESHCollection(const std::string& filename); - * (+) MESHCollection(const std::string& filename, const std::string& meshname); - * (-) ~MESHCollection(); - * (+) void write(const std::string& filename); - * (-) MESHCollectionDriver* retrieveDriver(); - * (-) MESHCollectionDriver* getDriver() const; - * (-) void buildCellGraph(MEDMEM::MEDSKYLINEARRAY* & array,int *& edgeweights ); - * (-) void buildCellGraph2ndversion(MEDMEM::MEDSKYLINEARRAY* & array,int *& edgeweights ); - * (+) Topology* createPartition(int nbdomain, Graph::splitter_type type = Graph::METIS, - const string& ="", int* edgeweights=0, int* verticesweights=0); - * (-) Topology* createPartition(const int* partition); - * (-) void getTypeList(int* cell_list,int nb_cells,MED_EN::medEntityMesh entity, - MED_EN::medGeometryElement* type_list) const ; - * (-) void getCoordinates(int* node_list,int nb_nodes, double* coordinates) const ; - * (-) void getNodeConnectivity( const int* cell_list,int nb_cells,MED_EN::medEntityMesh,MED_EN::medGeometryElement type, int* type_connectivity) const ; - * (-) void getFaceConnectivity( const int* cell_list,int nb_cells,MED_EN::medEntityMesh,MED_EN::medGeometryElement type, int* type_connectivity) const ; - * (+) int getMeshDimension() const ; - * (+) int getSpaceDimension() const ; - * (+) std::string getSystem() const; - * (-) std::string getMeshName() const; - * (-) std::vector& getMesh() ; - * (-) MEDMEM::MESH* getMesh(int) const; - * (-) std::vector& getCZ(); - * (-) Topology* getTopology() const ; - * (-) void setTopology(Topology* topology); - * (+) string getName() const {return m_name;} - * (+) void setName(const string& name) {m_name=name;} - * (-) void castFamilies(const MESHCollection& old_collection); - * (-) void castSupport(const MESHCollection& old_collection, std::vector old_support, std::vector new_support); - * (-) void castAllFields(const MESHCollection& old_collection); - * (-) void castField(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber); - * (+) void setIndivisibleGroup(const string& a); - * (-) void buildConnectZones(int idomain); - */ - - -void MEDSPLITTERTest::testMESHCollection_constructor() -{ - string filename_rd = MEDSPLITTERTest_Utils::getResourceFile("carre_en_quad4.med"); - string fileNotExist_rd = "notExist22.med"; - string emptyfilename = ""; - - - //--------------------------Test READ ONLY part------------------------------// - - ///////////////////////////////////////////////////////////// - // TEST1a: Open not existing sequential and parallel file // - ///////////////////////////////////////////////////////////// - string meshname="non_existent"; - - CPPUNIT_ASSERT_THROW(MESHCollection mc1(fileNotExist_rd, meshname), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(MESHCollection mc2(fileNotExist_rd), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(MESHCollection mc3(filename_rd, meshname), MEDEXCEPTION); - - // ////////////////////////////////////////////// - // // TEST1b: Open file with empty file name /// - // ////////////////////////////////////////////// - // - CPPUNIT_ASSERT_THROW(MESHCollection mc4(emptyfilename, meshname), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(MESHCollection mc5(emptyfilename), MEDEXCEPTION); - -} - - -//! Testing basic manipulation for a sequential file -void MEDSPLITTERTest::testMESHCollection_read_seq() -{ - string filename_rd = MEDSPLITTERTest_Utils::getResourceFile("pointe.med"); - string filename_seq_wr = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_seq_pointe22"); - string filename_seq_med = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_seq_pointe221.med"); - - // To remove tmp files from disk - MEDSPLITTERTest_TmpFilesRemover aRemover; - aRemover.Register(filename_seq_wr); - aRemover.Register(filename_seq_med); - - //--------------------------Test READ ONLY part------------------------------// - - // ///////////////////////////////////////////// - // // TEST2: Manipulation of a single MED file - // ///////////////////////////////////////////// - string meshname="maa1"; - MESHCollection collection(filename_rd,meshname); - collection.setDriverType(MEDSPLITTER::MedAscii); - CPPUNIT_ASSERT_EQUAL(meshname,collection.getName()); - string newname = "New_name"; - collection.setName(newname); - CPPUNIT_ASSERT_EQUAL(newname,collection.getName()); - string systemname="CARTESIAN"; - CPPUNIT_ASSERT_EQUAL(systemname,collection.getSystem()); - CPPUNIT_ASSERT_EQUAL(3,collection.getMeshDimension()); - CPPUNIT_ASSERT_EQUAL(3,collection.getSpaceDimension()); - - collection.write(filename_seq_wr); - - //Reading from the master file - MESHCollection collection2(filename_seq_wr); - CPPUNIT_ASSERT_EQUAL(collection.getName(),collection2.getName()); - - //Reading from the med file - MESHCollection collection3(filename_seq_med,meshname); - CPPUNIT_ASSERT_EQUAL(meshname,collection3.getName()); - -} - -//! Testing basic manipulation for a parallel file - -void MEDSPLITTERTest::testMESHCollection_read_para() -{ - string filename_rd = MEDSPLITTERTest_Utils::getResourceFile("pointe.med"); - string filename_para_wr = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para_pointe22_"); - string filename_xml = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para_pointe22_.xml"); - string filename_para_med0 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para_pointe22_1.med"); - string filename_para_med1 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para_pointe22_2.med"); - - - // To remove tmp files from disk - MEDSPLITTERTest_TmpFilesRemover aRemover; - aRemover.Register(filename_xml); - aRemover.Register(filename_para_med0); - aRemover.Register(filename_para_med1); - - string meshname="maa1"; - MESHCollection collection(filename_rd,meshname); - Topology* topo=0; - CPPUNIT_ASSERT_THROW(topo=collection.createPartition(0,Graph::METIS),MEDEXCEPTION); - if (topo!=0) delete topo; -#ifdef MED_ENABLE_METIS - CPPUNIT_ASSERT_NO_THROW(topo=collection.createPartition(2,Graph::METIS)); -#else - CPPUNIT_ASSERT_THROW(topo=collection.createPartition(2,Graph::METIS), MEDEXCEPTION); - CPPUNIT_FAIL("METIS is not available, further test execution is not possible."); -#endif - MESHCollection new_collection(collection, topo); - new_collection.write(filename_para_wr); - - CPPUNIT_ASSERT_EQUAL(meshname,new_collection.getName()); - MESHCollection new_collection2(filename_xml); - CPPUNIT_ASSERT_EQUAL(collection.getName(),new_collection2.getName()); - - MESHCollection new_collection3(filename_para_med0,"maa1_1"); - CPPUNIT_ASSERT_EQUAL(collection.getName()+"_1",new_collection3.getName()); - delete topo; -} - -//!Testing a normal scheme - -/* - * test_SPLITTER_square - * - * computes a partitioning for the following geometry - * - * - * - * 7------------8------------9 - * | | | - * | | | - * | 3 | 4 | - * | | | - * | | | - * 4------------5------------6 - * | | | - * | | | - * | 1 | 2 | - * | | | - * | | | - * 1------------2------------3 - * - * Result of the 2 domain split : - * - * 5------------6 5------------6 - * | | | | - * | | | | - * | 2 | | 2 | - * | | | | - * | | | | - * 1------------2 1------------2 - * | | | | - * | | | | - * | 1 | | 1 | - * | | | | - * | | | | - * 4------------3 4------------3 - */ - - -void MEDSPLITTERTest::testMESHCollection_square() -{ - string filename_rd = MEDSPLITTERTest_Utils::getResourceFile("carre_en_quad4.med"); - string filename_wr = MEDSPLITTERTest_Utils::makeTmpFile("carre_split"); - string filename_wr_1 = MEDSPLITTERTest_Utils::makeTmpFile("carre_split1.med"); - string filename_wr_2 = MEDSPLITTERTest_Utils::makeTmpFile("carre_split2.med"); - - // To remove tmp files from disk - MEDSPLITTERTest_TmpFilesRemover aRemover; - aRemover.Register(filename_wr); - aRemover.Register(filename_wr+".xml"); - aRemover.Register(filename_wr_1); - aRemover.Register(filename_wr_2); - - char meshname[20] = "carre_en_quad4"; - char meshname1[20] = "carre_en_quad4_1"; - char meshname2[20] = "carre_en_quad4_2"; - - MESHCollection collection(filename_rd,meshname); - MEDSPLITTER::Topology* topo; -#ifdef MED_ENABLE_METIS - CPPUNIT_ASSERT_NO_THROW(topo = collection.createPartition(2,Graph::METIS)); -#else - CPPUNIT_ASSERT_THROW(topo = collection.createPartition(2,Graph::METIS), MEDEXCEPTION); - CPPUNIT_FAIL("METIS is not available, further test execution is not possible."); -#endif - MESHCollection new_collection(collection, topo); - - //collection.write("/export/home/test_splitter"); - new_collection.write(filename_wr); - new_collection.castAllFields(collection); - - MEDMEM::MESH mesh1(MEDMEM::MED_DRIVER, filename_wr_1, meshname1); - MEDMEM::MESH mesh2(MEDMEM::MED_DRIVER, filename_wr_2, meshname2); - - // testing number of elements for each partition - int nbelem1=mesh1.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - int nbelem2=mesh2.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - - CPPUNIT_ASSERT_EQUAL(nbelem1,2); - CPPUNIT_ASSERT_EQUAL(nbelem2,2); - - - //testing number of joints - med_2_3::med_idt fid1 = med_2_3::MEDfileOpen(filename_wr_1.c_str(),med_2_3::MED_ACC_RDONLY); - med_2_3::med_idt fid2 = med_2_3::MEDfileOpen(filename_wr_2.c_str(),med_2_3::MED_ACC_RDONLY); - int nj1= med_2_3::MEDnSubdomainJoint(fid1, meshname1); - int nj2= med_2_3::MEDnSubdomainJoint(fid2, meshname2); - CPPUNIT_ASSERT_EQUAL(nj1,1); - CPPUNIT_ASSERT_EQUAL(nj2,1); - - //testing distant domains - - char desc1[MED_COMMENT_SIZE+1]; - char maa_dist1[MED_NAME_SIZE+1], jn1[MED_NAME_SIZE+1]; - char desc2[MED_COMMENT_SIZE+1], maa_dist2[MED_NAME_SIZE+1], jn2[MED_NAME_SIZE+1]; - int dom1, dom2; - int nstep,nocstp; - med_2_3::MEDsubdomainJointInfo(fid1, meshname1, 1, jn1, desc1, &dom1, maa_dist1, &nstep, &nocstp); - med_2_3::MEDsubdomainJointInfo(fid2, meshname2, 1, jn2, desc2, &dom2, maa_dist2, &nstep, &nocstp); - CPPUNIT_ASSERT(strcmp(jn1,"joint_2")==0); - CPPUNIT_ASSERT(strcmp(jn2,"joint_1")==0); - CPPUNIT_ASSERT_EQUAL(dom1,1); - CPPUNIT_ASSERT_EQUAL(dom2,0); - - // testing node-node correspondency - med_2_3::med_entity_type typ_ent_loc=med_2_3::MED_NODE; - med_2_3::med_entity_type typ_ent_dist=med_2_3::MED_NODE; - med_2_3::med_geometry_type typ_geo_loc= MED_POINT1; - med_2_3::med_geometry_type typ_geo_dist= MED_POINT1; - - int n1; - med_2_3::MEDsubdomainCorrespondenceSize(fid1,meshname1,jn1,MED_NO_DT, MED_NO_IT, typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist, &n1); - med_2_3::med_int* tab = new med_2_3::med_int[2*n1]; - - med_2_3::MEDsubdomainCorrespondenceRd(fid1,meshname1,jn1,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist, tab); - - med_2_3::med_int tabreference1[6] = {2,1,3,4,6,5}; - for (int i=0; i<2*n1; i++) - CPPUNIT_ASSERT_EQUAL(tab[i],tabreference1[i]); - - delete[] tab; - - int n2; - med_2_3::MEDsubdomainCorrespondenceSize(fid2,meshname2,jn2,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,&n2); - tab = new med_2_3::med_int[2*n2]; - - med_2_3::MEDsubdomainCorrespondenceRd(fid2,meshname2,jn2,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,tab); - - med_2_3::med_int tabreference2[] = {1,2,4,3,5,6}; - for (int i=0; i<2*n1; i++) - CPPUNIT_ASSERT_EQUAL(tab[i],tabreference2[i]); - delete[] tab; - - //testing nodes global numbering - med_2_3::med_int* num = new med_2_3::med_int[6]; - cout << "Reading global " << MEDmeshGlobalNumberRd(fid1, meshname1, MED_NO_DT, MED_NO_IT, typ_ent_loc, typ_geo_loc, num) << endl; - - med_2_3::med_int globnoderef1[] = {4,5,2,1,7,8}; - - for (int i=0; i<6; i++) - CPPUNIT_ASSERT_EQUAL(num[i],globnoderef1[i]); - delete[] num; - - //testing nodes global numbering - num = new med_2_3::med_int[6]; - MEDmeshGlobalNumberRd(fid2, meshname2, MED_NO_DT, MED_NO_IT, typ_ent_loc, typ_geo_loc, num); - med_2_3::med_int globnoderef2[] = {5,6,3,2,8,9}; - for (int i=0; i<6; i++) - CPPUNIT_ASSERT_EQUAL(num[i],globnoderef2[i]); - delete[] num; - - //testing cell-cell correspondency - typ_ent_loc=med_2_3::MED_CELL; - typ_ent_dist=med_2_3::MED_CELL; - typ_geo_loc= MED_QUAD4; - typ_geo_dist= MED_QUAD4; - //joint1 - med_2_3::MEDsubdomainCorrespondenceSize(fid1,meshname1,jn1,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,&n1); - CPPUNIT_ASSERT_EQUAL(n1,2); - tab = new med_2_3::med_int[2*n1]; - med_2_3::MEDsubdomainCorrespondenceRd(fid1,meshname1,jn1,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,tab); - - med_2_3::med_int tabreferencecell1[4] = {1,1,2,2}; - for (int i=0; i<2*n1; i++) - CPPUNIT_ASSERT_EQUAL(tab[i],tabreferencecell1[i]); - - med_2_3::MEDsubdomainCorrespondenceSize(fid2,meshname2,jn2,MED_NO_DT, MED_NO_IT, typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist, &n2); - CPPUNIT_ASSERT_EQUAL(n2,2); - delete[] tab; - //joint2 - tab = new med_2_3::med_int[2*n2]; - med_2_3::MEDsubdomainCorrespondenceRd(fid2,meshname2,jn2,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,tab); - - med_2_3::med_int tabreferencecell2[4] = {1,1,2,2}; - for (int i=0; icreatePartition(2,Graph::METIS); - MESHCollection* new_collection = new MESHCollection (*collection, topo); - new_collection->setSubdomainBoundaryCreates(true); - - //collection.write("/export/home/test_splitter"); - new_collection->write(filename_wr); - new_collection->castAllFields(*collection); - - MEDMEM::MESH mesh1(MEDMEM::MED_DRIVER, filename_wr_1, meshname1); - MEDMEM::MESH mesh2(MEDMEM::MED_DRIVER, filename_wr_2, meshname2); - - // testing number of elements for each partition - int nbelem1=mesh1.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - int nbelem2=mesh2.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - - CPPUNIT_ASSERT_EQUAL(nbelem1,2); - CPPUNIT_ASSERT_EQUAL(nbelem2,2); - - - //testing number of joints - med_2_3::med_idt fid1 = med_2_3::MEDfileOpen(filename_wr_1.c_str(),med_2_3::MED_ACC_RDONLY); - med_2_3::med_idt fid2 = med_2_3::MEDfileOpen(filename_wr_2.c_str(),med_2_3::MED_ACC_RDONLY); - int nj1= med_2_3::MEDnSubdomainJoint(fid1, meshname1); - int nj2= med_2_3::MEDnSubdomainJoint(fid2, meshname2); - CPPUNIT_ASSERT_EQUAL(nj1,1); - CPPUNIT_ASSERT_EQUAL(nj2,1); - - //testing distant domains - - char desc1[MED_COMMENT_SIZE+1]; - char maa_dist1[MED_NAME_SIZE+1], jn1[MED_NAME_SIZE+1]; - char desc2[MED_COMMENT_SIZE+1], maa_dist2[MED_NAME_SIZE+1], jn2[MED_NAME_SIZE+1]; - int dom1, dom2; - int nstep,nocstp; - med_2_3::MEDsubdomainJointInfo(fid1, meshname1, 1, jn1, desc1, &dom1, maa_dist1, &nstep, &nocstp); - med_2_3::MEDsubdomainJointInfo(fid2, meshname2, 1, jn2, desc2, &dom2, maa_dist2, &nstep, &nocstp); - CPPUNIT_ASSERT_EQUAL(dom1,1); - CPPUNIT_ASSERT_EQUAL(dom2,0); - - // testing node-node correspondency - med_2_3::med_entity_type typ_ent_loc=med_2_3::MED_NODE; - med_2_3::med_entity_type typ_ent_dist=med_2_3::MED_NODE; - med_2_3::med_geometry_type typ_geo_loc= MED_POINT1; - med_2_3::med_geometry_type typ_geo_dist= MED_POINT1; - - int n1; - med_2_3::MEDsubdomainCorrespondenceSize(fid1,meshname1,jn1, MED_NO_DT, MED_NO_IT, typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist, &n1); - CPPUNIT_ASSERT_EQUAL(3,n1); - med_2_3::med_int* tab = new med_2_3::med_int[2*n1]; - - med_2_3::MEDsubdomainCorrespondenceRd(fid1,meshname1,jn1, MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist, tab); - - med_2_3::med_int tabreference1[6] = {2,1,3,4,6,5}; - for (int i=0; i<2*n1; i++) - CPPUNIT_ASSERT_EQUAL(tab[i],tabreference1[i]); - - delete[] tab; - - int n2; - med_2_3::MEDsubdomainCorrespondenceSize(fid2,meshname2,jn2, MED_NO_DT, MED_NO_IT, typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,&n2); - tab = new med_2_3::med_int[2*n2]; - - med_2_3::MEDsubdomainCorrespondenceRd(fid2,meshname2,jn2,MED_NO_DT, MED_NO_IT, typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,tab); - - med_2_3::med_int tabreference2[]={1,2,4,3,5,6}; - for (int i=0; i<2*n1; i++) - CPPUNIT_ASSERT_EQUAL(tab[i],tabreference2[i]); - delete[] tab; - - //testing nodes global numbering - med_2_3::med_int* num = new med_2_3::med_int[6]; - cout << "Reading global " << MEDmeshGlobalNumberRd(fid1, meshname1, MED_NO_DT, MED_NO_IT, typ_ent_loc, typ_geo_loc, num) << endl; - - med_2_3::med_int globnoderef1[]={4,5,2,1,7,8}; - - for (int i=0; i<6; i++) - CPPUNIT_ASSERT_EQUAL(num[i],globnoderef1[i]); - delete[] num; - - //testing nodes global numbering - num = new med_2_3::med_int[6]; - MEDmeshGlobalNumberRd(fid2, meshname2, MED_NO_DT, MED_NO_IT, typ_ent_loc, typ_geo_loc, num); - med_2_3::med_int globnoderef2[]={5,6,3,2,8,9}; - for (int i=0; i<6; i++) - CPPUNIT_ASSERT_EQUAL(num[i],globnoderef2[i]); - delete[] num; - - //testing cell-cell correspondency - typ_ent_loc=med_2_3::MED_CELL; - typ_ent_dist=med_2_3::MED_CELL; - typ_geo_loc= MED_QUAD4; - typ_geo_dist= MED_QUAD4; - //joint1 - med_2_3::MEDsubdomainCorrespondenceSize(fid1,meshname1,jn1,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,&n1); - CPPUNIT_ASSERT_EQUAL(n1,2); - tab = new med_2_3::med_int[2*n1]; - med_2_3::MEDsubdomainCorrespondenceRd(fid1,meshname1,jn1,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,tab); - - med_2_3::med_int tabreferencecell1[4]={1,1,2,2}; - for (int i=0; i<2*n1; i++) - CPPUNIT_ASSERT_EQUAL(tab[i],tabreferencecell1[i]); - - med_2_3::MEDsubdomainCorrespondenceSize(fid2,meshname2,jn2,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,&n2); - CPPUNIT_ASSERT_EQUAL(n2,2); - delete[] tab; - //joint2 - tab = new med_2_3::med_int[2*n2]; - med_2_3::MEDsubdomainCorrespondenceRd(fid2,meshname2,jn2,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,tab); - - med_2_3::med_int tabreferencecell2[4]={1,1,2,2}; - for (int i=0; icreatePartition(partition); - MESHCollection* new_collection = new MESHCollection (*collection, topo); - new_collection->write(filename_wr); - new_collection->castAllFields(*collection); - - MEDMEM::MESH mesh1(MEDMEM::MED_DRIVER, filename_wr_1, meshname1); - MEDMEM::MESH mesh2(MEDMEM::MED_DRIVER, filename_wr_2, meshname2); - - // testing number of elements for each partition - - int nbelem1=mesh1.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - int nbelem2=mesh2.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - CPPUNIT_ASSERT_EQUAL(nbelem1,2); - CPPUNIT_ASSERT_EQUAL(nbelem2,2); - - //testing number of joints - med_2_3::med_idt fid1 = med_2_3::MEDfileOpen(filename_wr_1.c_str(),med_2_3::MED_ACC_RDONLY); - med_2_3::med_idt fid2 = med_2_3::MEDfileOpen(filename_wr_2.c_str(),med_2_3::MED_ACC_RDONLY); - - int nj1= med_2_3::MEDnSubdomainJoint(fid1, meshname1); - int nj2= med_2_3::MEDnSubdomainJoint(fid2, meshname2); - CPPUNIT_ASSERT_EQUAL(nj1,1); - CPPUNIT_ASSERT_EQUAL(nj2,1); - - //testing distant domains - - char desc1[MED_COMMENT_SIZE+1]; - char maa_dist1[MED_NAME_SIZE+1], jn1[MED_NAME_SIZE+1]; - char desc2[MED_COMMENT_SIZE+1]; - char maa_dist2[MED_NAME_SIZE+1], jn2[MED_NAME_SIZE+1]; - //int dom1, dom2; - med_2_3::med_int dom1, dom2; - int nstep,nocstp; - med_2_3::MEDsubdomainJointInfo(fid1, meshname1, 1, jn1, desc1, &dom1, maa_dist1, &nstep, &nocstp); - med_2_3::MEDsubdomainJointInfo(fid2, meshname2, 1, jn2, desc2, &dom2, maa_dist2, &nstep, &nocstp); - CPPUNIT_ASSERT_EQUAL(dom1,1); - CPPUNIT_ASSERT_EQUAL(dom2,0); - - // testing node-node correspondency - med_2_3::med_entity_type typ_ent_loc=med_2_3::MED_NODE; - med_2_3::med_entity_type typ_ent_dist=med_2_3::MED_NODE; - med_2_3::med_geometry_type typ_geo_loc= MED_POINT1; - med_2_3::med_geometry_type typ_geo_dist= MED_POINT1; - - int n1; - med_2_3::MEDsubdomainCorrespondenceSize(fid1,meshname1,jn1,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,&n1); - CPPUNIT_ASSERT_EQUAL(5,n1); - med_2_3::med_int* tab = new med_2_3::med_int[2*n1]; - - med_2_3::MEDsubdomainCorrespondenceRd(fid1,meshname1,jn1,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,tab); - - med_2_3::med_int tabreference1[10] = {1,7,2,1,3,4,5,6,7,2}; - for (int i=0; i<2*n1; i++) - CPPUNIT_ASSERT_EQUAL(tab[i],tabreference1[i]); - delete[] tab; - int n2; - med_2_3::MEDsubdomainCorrespondenceSize(fid2,meshname2,jn2,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,&n2); - tab = new med_2_3::med_int[2*n2]; - - med_2_3::MEDsubdomainCorrespondenceRd(fid2,meshname2,jn2,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,tab); - - med_2_3::med_int tabreference2[10] = {1,2,2,7,4,3,6,5,7,1}; - for (int i=0; i<2*n2; i++) - CPPUNIT_ASSERT_EQUAL(tab[i],tabreference2[i]); - delete[] tab; - - //testing nodes global numbering - med_2_3::med_int* num = new med_2_3::med_int[7]; - cout << "Reading global " << MEDmeshGlobalNumberRd(fid1, meshname1, MED_NO_DT, MED_NO_IT, typ_ent_loc, typ_geo_loc, num) << endl; - med_2_3::med_int globnoderef1[7] = {4,5,2,1,8,9,6}; - - for (int i=0; i<7; i++) - CPPUNIT_ASSERT_EQUAL(num[i],globnoderef1[i]); - - delete[] num; - - //testing nodes global numbering - num = new med_2_3::med_int[7]; - MEDmeshGlobalNumberRd(fid2, meshname2, MED_NO_DT, MED_NO_IT, typ_ent_loc, typ_geo_loc, num); - med_2_3::med_int globnoderef2[7] = {5,6,3,2,7,8,4}; - for (int i=0; i<7; i++) - CPPUNIT_ASSERT_EQUAL(num[i],globnoderef2[i]); - delete[] num; - - //testing cell-cell correspondency - typ_ent_loc=med_2_3::MED_CELL; - typ_ent_dist=med_2_3::MED_CELL; - typ_geo_loc= MED_QUAD4; - typ_geo_dist= MED_QUAD4; - //joint1 - med_2_3::MEDsubdomainCorrespondenceSize(fid1,meshname1,jn1,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist, &n1); - tab = new med_2_3::med_int[2*n1]; - med_2_3::MEDsubdomainCorrespondenceRd(fid1,meshname1,jn1,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,tab); - - med_2_3::med_int tabreferencecell1[8] = {1,1,1,2,2,1,2,2}; - for (int i=0; i<2*n1; i++) - CPPUNIT_ASSERT_EQUAL(tab[i],tabreferencecell1[i]); - - med_2_3::MEDsubdomainCorrespondenceSize(fid1,meshname1,jn1,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist,&n2); - delete[] tab; - //joint2 - tab = new med_2_3::med_int[2*n2]; - med_2_3::MEDsubdomainCorrespondenceRd(fid2,meshname2,jn2,MED_NO_DT, MED_NO_IT,typ_ent_loc, typ_geo_loc,typ_ent_dist, typ_geo_dist, tab); - - med_2_3::med_int tabreferencecell2[8] = {1,1,1,2,2,1,2,2}; - for (int i=0; inbCells(),topo2->nbCells()); - new_collection3.setDriverType(MEDSPLITTER::MedAscii); - new_collection3.write(filename_para2_wr); - - MESHCollection new_collection4(filename_para2_wr); - Topology* topo1=new_collection4.createPartition(1,Graph::METIS); - - MESHCollection new_collection_seq(new_collection4,topo1); - new_collection_seq.write(filename_seq_wr); - MEDMEM::MESH* mesh_after = new_collection_seq.getMesh(0); - MEDMEM::MESH* mesh_before = collection.getMesh(0); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS), mesh_after->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfElements(MED_FACE, MED_ALL_ELEMENTS), mesh_after->getNumberOfElements(MED_FACE, MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS), mesh_after->getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfNodes(), mesh_after->getNumberOfNodes()); - delete topo2; - delete topo3; - delete topo1; -} - -/*! Testing a complex scenario to involve several shared pointers - * on similar structures - */ - -void MEDSPLITTERTest::testMESHCollection_complete_sequence_with_polygon() -{ - string filename_rd = MEDSPLITTERTest_Utils::getResourceFile("recoll_bord.med"); - string filename_para_wr = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para_recoll_"); - string filename_para_med1 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para_recoll_1.med"); - string filename_para_med2 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para_recoll_2.med"); - string filename_para2_wr = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para2_recoll_"); - string filename_para2_med1 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para2_recoll_1.med"); - string filename_para2_med2 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para2_recoll_2.med"); - string filename_para2_med3 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para2_recoll_3.med"); - string filename_seq_wr = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_seq_recoll_"); - string filename_seq_med = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_seq_recoll_1.med"); - - - // To remove tmp files from disk - MEDSPLITTERTest_TmpFilesRemover aRemover; - aRemover.Register(filename_para_wr); - aRemover.Register(filename_para_med1); - aRemover.Register(filename_para_med2); - aRemover.Register(filename_para2_wr); - aRemover.Register(filename_para2_med1); - aRemover.Register(filename_para2_med2); - aRemover.Register(filename_para2_med3); - aRemover.Register(filename_seq_wr); - aRemover.Register(filename_seq_wr+".xml"); - aRemover.Register(filename_seq_med); - - - string meshname="Bord"; - MESHCollection collection(filename_rd,meshname); - Topology* topo2=collection.createPartition(2,Graph::METIS); - MESHCollection new_collection(collection, topo2); - new_collection.setDriverType(MEDSPLITTER::MedAscii); - new_collection.write(filename_para_wr); - - MESHCollection new_collection2(filename_para_wr); - CPPUNIT_ASSERT_EQUAL(collection.getName(),new_collection2.getName()); - Topology* topo3=new_collection2.createPartition(3,Graph::SCOTCH); - MESHCollection new_collection3(new_collection2,topo3); - CPPUNIT_ASSERT_EQUAL(topo3->nbCells(),topo2->nbCells()); - new_collection3.setDriverType(MEDSPLITTER::MedAscii); - new_collection3.write(filename_para2_wr); - - MESHCollection new_collection4(filename_para2_wr); - Topology* topo1; -#ifdef MED_ENABLE_METIS - CPPUNIT_ASSERT_NO_THROW(topo1 = new_collection4.createPartition(1,Graph::METIS)); -#else - CPPUNIT_ASSERT_THROW(topo1 = new_collection4.createPartition(1,Graph::METIS), MEDEXCEPTION); - CPPUNIT_FAIL("METIS is not available, further test execution is not possible."); -#endif - - MESHCollection new_collection_seq(new_collection4,topo1); - new_collection_seq.write(filename_seq_wr); - MEDMEM::MESH* mesh_after = new_collection_seq.getMesh(0); - MEDMEM::MESH* mesh_before = collection.getMesh(0); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS), - mesh_after->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfElements(MED_FACE, MED_ALL_ELEMENTS), - mesh_after->getNumberOfElements(MED_FACE, MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS), - mesh_after->getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfNodes(), mesh_after->getNumberOfNodes()); - delete topo2; - delete topo3; - delete topo1; -} - -/*! Testing a complex scenario to involve several shared pointers - * on similar structures - */ - -void MEDSPLITTERTest::testMESHCollection_complete_sequence_with_polyhedra() -{ - string filename_rd = MEDSPLITTERTest_Utils::getResourceFile("poly3D.med"); - string filename_para_wr = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para_poly3D_"); - string filename_para_med1 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para_poly3D_1.med"); - string filename_para_med2 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para_poly3D_2.med"); - string filename_para2_wr = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para2_poly3D_"); - string filename_para2_med1 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para2_poly3D_1.med"); - string filename_para2_med2 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para2_poly3D_2.med"); - string filename_para2_med3 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_para2_poly3D_3.med"); - string filename_seq_wr = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_seq_poly3D_"); - string filename_seq_med = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_seq_poly3D_1.med"); - - - // To remove tmp files from disk - MEDSPLITTERTest_TmpFilesRemover aRemover; - aRemover.Register(filename_para_wr); - aRemover.Register(filename_para_med1); - aRemover.Register(filename_para_med2); - aRemover.Register(filename_para2_wr); - aRemover.Register(filename_para2_med1); - aRemover.Register(filename_para2_med2); - aRemover.Register(filename_para2_med3); - aRemover.Register(filename_seq_wr); - aRemover.Register(filename_seq_med); - - - string meshname="poly3D"; - MESHCollection collection(filename_rd,meshname); - Topology* topo2=collection.createPartition(2,Graph::METIS); - MESHCollection new_collection(collection, topo2); - new_collection.setDriverType(MEDSPLITTER::MedAscii); - new_collection.write(filename_para_wr); - - MESHCollection new_collection2(filename_para_wr); - CPPUNIT_ASSERT_EQUAL(collection.getName(),new_collection2.getName()); - Topology* topo3=new_collection2.createPartition(3,Graph::SCOTCH); - MESHCollection new_collection3(new_collection2,topo3); - CPPUNIT_ASSERT_EQUAL(topo3->nbCells(),topo2->nbCells()); - new_collection3.setDriverType(MEDSPLITTER::MedAscii); - new_collection3.write(filename_para2_wr); - - MESHCollection new_collection4(filename_para2_wr); - Topology* topo1=new_collection4.createPartition(1,Graph::METIS); - - MESHCollection new_collection_seq(new_collection4,topo1); - new_collection_seq.write(filename_seq_wr); - MEDMEM::MESH* mesh_after = new_collection_seq.getMesh(0); - MEDMEM::MESH* mesh_before = collection.getMesh(0); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS), mesh_after->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfElements(MED_FACE, MED_ALL_ELEMENTS), mesh_after->getNumberOfElements(MED_FACE, MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS), mesh_after->getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(mesh_before->getNumberOfNodes(), mesh_after->getNumberOfNodes()); - delete topo2; - delete topo3; - delete topo1; -} - -/*! Testing a TRIO_U scenario with subzones defined as families - - - */ - -void MEDSPLITTERTest::testMESHCollection_families() -{ - string filename_rd = MEDSPLITTERTest_Utils::getResourceFile("trio_2D.med"); - string filename_wr = MEDSPLITTERTest_Utils::makeTmpFile("trio_split_faces"); - string filename_wr_1 = MEDSPLITTERTest_Utils::makeTmpFile("trio_split_faces1.med"); - string filename_wr_2 = MEDSPLITTERTest_Utils::makeTmpFile("trio_split_faces2.med"); - - // To remove tmp files from disk - MEDSPLITTERTest_TmpFilesRemover aRemover; - aRemover.Register(filename_wr); - aRemover.Register(filename_wr+".xml"); - aRemover.Register(filename_wr_1); - aRemover.Register(filename_wr_2); - - char meshname[30] = "dom"; - char meshname1[30] = "dom_1"; - char meshname2[30] = "dom_2"; - - - MESHCollection* collection = new MESHCollection (filename_rd,meshname); - MEDSPLITTER::Topology* topo = collection->createPartition(2,Graph::METIS); - MESHCollection* new_collection = new MESHCollection (*collection, topo, true, true); - new_collection->setSubdomainBoundaryCreates(true); - //collection.write("/export/home/test_splitter"); - new_collection->write(filename_wr); - new_collection->castAllFields(*collection); - - delete topo; - delete collection; - delete new_collection; - - MEDMEM::MESH mesh1(MEDMEM::MED_DRIVER, filename_wr_1, meshname1); - MEDMEM::MESH mesh2(MEDMEM::MED_DRIVER, filename_wr_2, meshname2); - - // testing number of elements for each partition - int nbelem1=mesh1.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - int nbelem2=mesh2.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - - CPPUNIT_ASSERT_EQUAL(nbelem1+nbelem2,2020); - - - - //testing number of joints - med_2_3::med_idt fid1 = med_2_3::MEDfileOpen(filename_wr_1.c_str(),med_2_3::MED_ACC_RDONLY); - med_2_3::med_idt fid2 = med_2_3::MEDfileOpen(filename_wr_2.c_str(),med_2_3::MED_ACC_RDONLY); - int nj1= med_2_3::MEDnSubdomainJoint(fid1, meshname1); - int nj2= med_2_3::MEDnSubdomainJoint(fid2, meshname2); - CPPUNIT_ASSERT_EQUAL(nj1,1); - CPPUNIT_ASSERT_EQUAL(nj2,1); - - //testing distant domains - - char desc1[MED_COMMENT_SIZE+1]; - char maa_dist1[MED_NAME_SIZE+1], jn1[MED_NAME_SIZE+1]; - char desc2[MED_COMMENT_SIZE+1], maa_dist2[MED_NAME_SIZE+1], jn2[MED_NAME_SIZE+1]; - int dom1, dom2; - int nstep,nocstp; - med_2_3::MEDsubdomainJointInfo(fid1, meshname1, 1, jn1, desc1, &dom1, maa_dist1, &nstep, &nocstp); - med_2_3::MEDsubdomainJointInfo(fid2, meshname2, 1, jn2, desc2, &dom2, maa_dist2, &nstep, &nocstp); - CPPUNIT_ASSERT_EQUAL(dom1,1); - CPPUNIT_ASSERT_EQUAL(dom2,0); - - - int nbEdgesFamilies1= med_2_3::MEDnFamily(fid1, meshname1); - int nbEdgesFamilies2= med_2_3::MEDnFamily(fid2, meshname2); - - CPPUNIT_ASSERT_EQUAL(nbEdgesFamilies1,7); // six initial families + a joint - CPPUNIT_ASSERT_EQUAL(nbEdgesFamilies2,7); // six initial families + a joint - - // EAP 16 Apr 2012: order of families is actually unpredictable - // string fam_name = mesh1.getFamily(MED_EN::MED_EDGE,1)->getName(); - // char test_name[MED_NAME_SIZE+1]="Sortie"; - // CPPUNIT_ASSERT(strcmp(fam_name.c_str(),test_name)==0); - -} diff --git a/src/MEDSPLITTER/Test/MEDSPLITTERTest_ParallelTopology.cxx b/src/MEDSPLITTER/Test/MEDSPLITTERTest_ParallelTopology.cxx deleted file mode 100644 index d39f3cb6d..000000000 --- a/src/MEDSPLITTER/Test/MEDSPLITTERTest_ParallelTopology.cxx +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright (C) 2007-2013 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 "MEDSPLITTERTest.hxx" -#include "MEDSPLITTERTest_Utils.hxx" - -#include "MEDMEM_ConnectZone.hxx" -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_GaussLocalization.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDSPLITTER_Graph.hxx" -#include "MEDSPLITTER_Topology.hxx" -#include "MEDSPLITTER_ParallelTopology.hxx" -#include "MEDSPLITTER_SequentialTopology.hxx" -#include "MEDSPLITTER_MESHCollection.hxx" -#include "MEDSPLITTER_MESHCollectionDriver.hxx" - -#ifdef MED_ENABLE_METIS -#include "MEDSPLITTER_METISGraph.hxx" -#endif -//#include "MEDSPLITTER_SCOTCHGraph.hxx" - -#include "MEDMEM_Exception.hxx" - -#include -#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 - - -using namespace std; -using namespace MEDSPLITTER; -using namespace MEDMEM; - -/* - * Check methods defined in ParallelTopology.hxx - * - ParallelTopology(); - ParallelTopology(vector, vector,vector&, vector&, vector&); - (+) ParallelTopology(boost::shared_ptr graph, int nbdomain, int mesh_dimension); - ~ParallelTopology(); - (+) void convertGlobalNodeList(const int*, int,int*,int*); - (+) void convertGlobalNodeList(const int*, int,int*,int); - (+) void convertGlobalNodeListWithTwins(const int* face_list, int nbnode, int*& local, int*& ip, int*& full_array, int& size); - (+) void convertGlobalCellList(const int*, int , int*, int *); - void convertGlobalFaceList(const int*, int , int*, int *); - void convertGlobalFaceList(const int*, int , int*, int); - void convertGlobalFaceListWithTwins(const int* face_list, int nbface, int*& local, int*& ip, int*& full_array,int& size); - void createNodeMapping(std::map& type_connectivity, - std::map& present_type_numbers, - int idomain); - void createFaceMapping(const MESHCollection &); - void createFaceMapping2ndversion(const MESHCollection &); - void convertToLocal(std::map& type_connectivity, - std::map& present_type_numbers, - int idomain, - MED_EN::medEntityMesh entity); - void computeNodeNodeCorrespondencies(int nbdomain,vector& ) const; - void computeCellCellCorrespondencies(int nbdomain,vector&, const Graph* ) const; - inline int convertNodeToGlobal(int ip,int icell) const - inline int convertFaceToGlobal(int ip,int icell) const - inline int convertCellToGlobal(int ip,int icell) const - inline void convertNodeToGlobal(int ip, const int* local, int n, int* global)const - (+)inline void convertCellToGlobal(int ip, const int* local, int n, int* global)const - inline void convertFaceToGlobal(int ip, const int* local, int n, int* global)const - (+) inline int nbDomain() const - int nbCells() const - (+) inline int nbCells( int idomain) const - (+) inline int getNodeNumber(int idomain) const - inline int getNodeNumber() const - inline void getNodeList(int idomain, int* list) const - (+) inline int getCellNumber(int idomain) const - inline int getCellDomainNumber(int global) const - inline void getCellList(int idomain, int* list) const - inline int getFaceNumber(int idomain) const - inline int getFaceNumber() const - inline void getFaceList(int idomain, int* list) const - boost::shared_ptr getGraph() const -*/ - -void MEDSPLITTERTest::testParallelTopology_graph_constructor() -{ -#ifndef MED_ENABLE_METIS - CPPUNIT_FAIL("METIS is not available. Please, check your compilation."); -#else - string filename_rd = MEDSPLITTERTest_Utils::getResourceFile("carre_en_quad4.med"); - string filename_para_wr = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_seq_pointe22_"); - string filename_para_med0 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_seq_pointe22_1.med"); - string filename_para_med1 = MEDSPLITTERTest_Utils::makeTmpFile("myWrField_seq_pointe22_2.med"); - - string meshname="carre_en_quad4"; - MESHCollection collection(filename_rd,meshname); - - MEDMEM::MEDSKYLINEARRAY* array=0; - int* edgeweights=0; - - collection.buildCellGraph(array,edgeweights); - - boost::shared_ptr cell_graph=boost::shared_ptr(new METISGraph(array,edgeweights)); - - cell_graph->partGraph(2,""); - - //cell_graph is a shared pointer - Topology* topology = new ParallelTopology (cell_graph, 2, collection.getMeshDimension()); - - - /* - * test_SPLITTER_square - * - * computes a partitioning for the following geometry - * - * - * - * 7------------8------------9 - * | | | - * | | | - * | 3 | 4 | - * | | | - * | | | - * 4------------5------------6 - * | | | - * | | | - * | 1 | 2 | - * | | | - * | | | - * 1------------2------------3 - * - * Result of the 2 domain split : - * - * 5------------6 5------------6 - * | | | | - * | | | | - * | 2 | | 2 | - * | | | | - * | | | | - * 1------------2 1------------2 - * | | | | - * | | | | - * | 1 | | 1 | - * | | | | - * | | | | - * 4------------3 4------------3 - */ - - int iglobal[3]={1,2,3}; - int* iloc=new int[3]; - int* iproc=new int[3]; - int iloc_answer[3]={1,1,2}; - int iproc_answer[3]={0,1,0}; - topology->convertGlobalCellList(iglobal,3,iloc,iproc); - for(int i=0; i<3; i++) - { - CPPUNIT_ASSERT_EQUAL(iloc_answer[i], iloc[i]); - CPPUNIT_ASSERT_EQUAL(iproc_answer[i],iproc[i]); - } - int* global_2 = new int[3]; - topology->convertCellToGlobal(0,iloc,3,global_2); - int global_answer[3]={1,1,3}; - for (int i=0; i<3; i++) - { - CPPUNIT_ASSERT_EQUAL(global_answer[i],global_2[i]); - } - - CPPUNIT_ASSERT_EQUAL(topology->getCellNumber(0),2); - CPPUNIT_ASSERT_EQUAL(topology->getCellNumber(1),2); - - - CPPUNIT_ASSERT_EQUAL(topology->nbCells(0),2); - CPPUNIT_ASSERT_EQUAL(topology->nbCells(1),2); - - CPPUNIT_ASSERT_EQUAL(topology->nbDomain(),2); - //node and face lists have not yet been computed - CPPUNIT_ASSERT_THROW(topology->convertGlobalNodeList(iglobal,3,iloc,iproc),MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(topology->convertGlobalFaceList(iglobal,3,iloc,iproc),MEDEXCEPTION); - - MESHCollection new_collection(collection, topology); - - CPPUNIT_ASSERT_EQUAL(topology->getNodeNumber(0),6); - CPPUNIT_ASSERT_EQUAL(topology->getNodeNumber(1),6); - - topology->convertGlobalNodeList(iglobal,3,iloc,iproc); - - int iloc_node_answer[3]={4,3,3}; - int iproc_node_answer[3]={0,0,1}; - for(int i=0; i<3; i++) - { - CPPUNIT_ASSERT_EQUAL(iloc_node_answer[i], iloc[i]); - CPPUNIT_ASSERT_EQUAL(iproc_node_answer[i],iproc[i]); - } - int* local_nodes; - int* ip_nodes; - int* full_array; - int size; - topology->convertGlobalNodeListWithTwins(iglobal, 3, local_nodes, ip_nodes, full_array, size); - CPPUNIT_ASSERT_EQUAL(size,4); - int iloc_node_wt_answer[4]={4,3,4,3}; - int iproc_node_wt_answer[4]={0,0,1,1}; - for(int i=0; i<4; i++) - { - CPPUNIT_ASSERT_EQUAL(iloc_node_wt_answer[i], local_nodes[i]); - CPPUNIT_ASSERT_EQUAL(iproc_node_wt_answer[i],ip_nodes[i]); - } - delete topology; - delete[] iloc; - delete[]iproc; - delete[] global_2; - delete[] local_nodes; - delete[] ip_nodes; - delete[] full_array; -#endif // MED_ENABLE_METIS -} diff --git a/src/MEDSPLITTER/Test/MEDSPLITTERTest_Utils.cxx b/src/MEDSPLITTER/Test/MEDSPLITTERTest_Utils.cxx deleted file mode 100644 index 692ea76ff..000000000 --- a/src/MEDSPLITTER/Test/MEDSPLITTERTest_Utils.cxx +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (C) 2007-2013 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 -// -// File : MEDSPLITTERTest_TmpFilesRemover.hxx -// Created : Mon Jul 6 14:08:12 2009 -// Author : Edward AGAPOV (eap) - -#include "MEDSPLITTERTest_Utils.hxx" - -#include - -#include -#include -#include - -#ifdef WIN32 -#include -#else -#include -#endif - -using namespace std; - -namespace MEDSPLITTERTest_Utils -{ - -string getResourceFile( const string& filename ) -{ - string resourceFile = ""; - - if ( getenv("top_srcdir") ) { - // we are in 'make check' step - resourceFile = getenv("top_srcdir"); - resourceFile += "/resources/"; - } - else if ( getenv("MED_ROOT_DIR") ) { - // use MED_ROOT_DIR env.var - resourceFile = getenv("MED_ROOT_DIR"); - resourceFile += "/share/salome/resources/med/"; - } - resourceFile += filename; -#ifndef WIN32 - if (access(resourceFile.data(), F_OK) != 0) -#else - if ( GetFileAttributes ( resourceFile.c_str() ) == 0xFFFFFFFF ) - if ( GetLastError () == ERROR_FILE_NOT_FOUND ) -#endif - CPPUNIT_FAIL(MEDMEM::STRING("Resource file ")<< filename << " not found"); - - return resourceFile; -} - - -//================================================================================ -/*! - * \brief Returns writable temporary directory - */ -//================================================================================ - -string getTmpDirectory() -{ - string path; - - list dirs; - if ( getenv("TMP") ) dirs.push_back( getenv("TMP" )); - if ( getenv("TMPDIR") ) dirs.push_back( getenv("TMPDIR" )); - dirs.push_back( "/tmp" ); -#ifndef WIN32 - for ( list::iterator dir = dirs.begin(); dir != dirs.end(); ++dir ) - if ( access( dir->data(), W_OK ) == 0 ) - return *dir; -#endif - - CPPUNIT_FAIL("Can't find writable temporary directory. Set TMP environment variable correctly"); - return ""; -} - - -//================================================================================ -/*! - * \brief Creates a copy of source file (if source file is specified) - * in the temporary directory and returns a path to the tmp file - * - * \param tmpfile name of the temporary file (without path) - * \param srcfile source file - * \return path to the temporary file - */ -//================================================================================ -std::string makeTmpFile( const std::string& tmpfile, const std::string& srcfile ) -{ - std::string tmpf = getTmpDirectory() + "/" + tmpfile; - if ( srcfile != "" ) { - std::string cmd = "cp " + srcfile + " " + tmpf + " ; chmod +w " + tmpf; - system( cmd.c_str() ); - } - return tmpf; -} -} - -// to automatically remove temporary files from disk -bool MEDSPLITTERTest_TmpFilesRemover::Register(const string theTmpFile, const bool and_remove) -{ -// if ( and_remove && access( theTmpFile.data(), F_OK ) == 0 ) -// remove(theTmpFile.data()); - return (myTmpFiles.insert(theTmpFile)).second; -} - -MEDSPLITTERTest_TmpFilesRemover::~MEDSPLITTERTest_TmpFilesRemover() -{ - set< string>::iterator it = myTmpFiles.begin(); - for (; it != myTmpFiles.end(); it++) { -#ifndef WIN32 - if (access((*it).data(), F_OK) == 0) -#else - -#endif - remove((*it).data()); - - } - myTmpFiles.clear(); -} - diff --git a/src/MEDSPLITTER/Test/MEDSPLITTERTest_Utils.hxx b/src/MEDSPLITTER/Test/MEDSPLITTERTest_Utils.hxx deleted file mode 100644 index 26d6a5f42..000000000 --- a/src/MEDSPLITTER/Test/MEDSPLITTERTest_Utils.hxx +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2007-2013 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 -// -// File : MEDSPLITTERTest_TmpFilesRemover.hxx -// Created : Mon Jul 6 14:08:12 2009 -// Author : Edward AGAPOV (eap) - -#ifndef __MEDSPLITTERTest_UTILS_HXX__ -#define __MEDSPLITTERTest_UTILS_HXX__ - -#include -#include -#include -#include - -// to automatically remove temporary files from disk -class MEDSPLITTERTest_TmpFilesRemover -{ -public: - - MEDSPLITTERTest_TmpFilesRemover() {} - bool Register(const std::string theTmpFile, const bool and_remove=true); - ~MEDSPLITTERTest_TmpFilesRemover(); - -private: - std::set myTmpFiles; -}; - -namespace MEDSPLITTERTest_Utils -{ - std::string getResourceFile( const std::string& ); - std::string getTmpDirectory(); - std::string makeTmpFile( const std::string&, const std::string& = "" ); -} - -#endif diff --git a/src/MEDSPLITTER/Test/MEDSPLITTERTest_defs.hxx b/src/MEDSPLITTER/Test/MEDSPLITTERTest_defs.hxx deleted file mode 100755 index 29212af3d..000000000 --- a/src/MEDSPLITTER/Test/MEDSPLITTERTest_defs.hxx +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2007-2013 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 _MEDSPLITTERTEST_DEFS_HXX_ -#define _MEDSPLITTERTEST_DEFS_HXX_ - - -#ifdef WIN32 -# if defined MEDSPLITTERTEST_EXPORTS || defined MEDSPLITTERTest_EXPORTS -# define MEDSPLITTERTEST_EXPORT __declspec( dllexport ) -# else -# define MEDSPLITTERTEST_EXPORT __declspec( dllimport ) -# endif -#else -# define MEDSPLITTERTEST_EXPORT -#endif - -#endif //_MEDSPLITTERTEST_DEFS_HXX_ diff --git a/src/MEDSPLITTER/Test/Makefile.am b/src/MEDSPLITTER/Test/Makefile.am deleted file mode 100644 index 29db22244..000000000 --- a/src/MEDSPLITTER/Test/Makefile.am +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright (C) 2007-2013 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 - -# SALOMELocalTrace : log on local machine - -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -lib_LTLIBRARIES = libMEDSPLITTERTest.la - - -dist_libMEDSPLITTERTest_la_SOURCES= \ - MEDSPLITTERTest.cxx \ - MEDSPLITTERTest_MESHCollection.cxx \ - MEDSPLITTERTest_ParallelTopology.cxx \ - MEDSPLITTERTest_Utils.cxx - -if MED_ENABLE_PARMETIS - dist_libMEDSPLITTERTest_la_SOURCES+= \ - ParaMEDSPLITTERTest_MeshSendReceive.cxx \ - ParaMEDSPLITTERTest_ParaDomainSelector.cxx \ - ParaMEDSPLITTERTest_medsplitter_para.cxx \ - ParaMEDSPLITTERTest.hxx -endif - -salomeinclude_HEADERS = \ - MEDSPLITTERTest.hxx \ - MEDSPLITTERTest_Utils.hxx \ - MEDSPLITTERTest_defs.hxx - -libMEDSPLITTERTest_la_CPPFLAGS= $(MPI_INCLUDES) @CPPUNIT_INCLUDES@ $(MED3_INCLUDES) \ - $(HDF5_INCLUDES) $(BOOST_CPPFLAGS) $(LIBXML_CXXFLAGS) \ - -I$(srcdir)/.. -I$(srcdir)/../../MEDMEM \ - -I$(srcdir)/../../MEDMEMCppTest -I$(srcdir)/../../INTERP_KERNEL/Bases \ - -I$(srcdir)/../../INTERP_KERNEL/GaussPoints \ - -I$(srcdir)/../../INTERP_KERNEL -libMEDSPLITTERTest_la_LDFLAGS= $(MED3_LIBS_C_ONLY) @CPPUNIT_LIBS@ ../libmedsplitter.la - -if MED_ENABLE_KERNEL - libMEDSPLITTERTest_la_CPPFLAGS+= ${KERNEL_CXXFLAGS} - libMEDSPLITTERTest_la_LDFLAGS+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace -endif - -if MED_ENABLE_PARMETIS - libMEDSPLITTERTest_la_CPPFLAGS+= $(PARMETIS_CPPFLAGS) - libMEDSPLITTERTest_la_LDFLAGS+= $(PARMETIS_LIBS) -endif -if MED_ENABLE_METIS - libMEDSPLITTERTest_la_CPPFLAGS+= $(METIS_CPPFLAGS) - libMEDSPLITTERTest_la_LDFLAGS+= $(METIS_LIBS) -endif -if MED_ENABLE_SCOTCH - libMEDSPLITTERTest_la_CPPFLAGS+= $(SCOTCH_CPPFLAGS) - libMEDSPLITTERTest_la_LDFLAGS+= $(SCOTCH_LIBS) -endif -libMEDSPLITTERTest_la_CXXFLAGS = @CXXTMPDPTHFLAGS@ - -dist_salomescript_DATA = testMEDSPLITTER.py - -# parallel exe -if MPI_IS_OK -if MED_ENABLE_PARMETIS - PARA_BIN_TEST_PROGS = TestParaMEDSPLITTER - TestParaMEDSPLITTER_SOURCES= TestParaMEDSPLITTER.cxx - TestParaMEDSPLITTER_CPPFLAGS = $(TestMEDSPLITTER_CPPFLAGS) $(MPI_INCLUDES) $(CPPUNIT_INCLUDES) - TestParaMEDSPLITTER_CXXFLAGS = @CXXTMPDPTHFLAGS@ - TestParaMEDSPLITTER_LDADD = $(MED3_LIBS_C_ONLY) $(libMEDSPLITTERTest_la_LDFLAGS) -lm \ - libMEDSPLITTERTest.la \ - ../../MEDMEM/libmedmem.la ../../INTERP_KERNEL/libinterpkernel.la \ - ../libmedsplitter.la $(HDF5_LIBS) $(MPI_LIBS) @CPPUNIT_LIBS@ - dist_salomescript_DATA += testParaMEDSPLITTER.py -# TESTS = TestParaMEDSPLITTER - UNIT_TEST_PROG = TestParaMEDSPLITTER -endif -else !MPI_IS_OK -if MED_ENABLE_METIS -# Executables targets - -BIN_TEST_PROGRS = TestMEDSPLITTER - -TestMEDSPLITTER_SOURCES= TestMEDSPLITTER.cxx - -TestMEDSPLITTER_CPPFLAGS= $(libMEDSPLITTERTest_la_CPPFLAGS) -TestMEDSPLITTER_CXXFLAGS = @CXXTMPDPTHFLAGS@ -TestMEDSPLITTER_LDADD= $(MED3_LIBS_C_ONLY) $(libMEDSPLITTERTest_la_LDFLAGS) -lm \ - libMEDSPLITTERTest.la \ - ../../MEDMEM/libmedmem.la ../../INTERP_KERNEL/libinterpkernel.la \ - ../libmedsplitter.la -# TESTS = TestMEDSPLITTER - UNIT_TEST_PROG = TestMEDSPLITTER -if MED_ENABLE_KERNEL - TestMEDSPLITTER_LDADD+= -lSALOMEBasics -endif -endif -endif - -bin_PROGRAMS = $(PARA_BIN_TEST_PROGS) $(BIN_TEST_PROGRS) - -check: tests - -clean-local: - rm -f UnitTestsResult* diff --git a/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest.hxx b/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest.hxx deleted file mode 100644 index 9226c4e44..000000000 --- a/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest.hxx +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2007-2013 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 _ParaMEDSPLITTERTest_HXX_ -#define _ParaMEDSPLITTERTest_HXX_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -class ParaMEDSPLITTERTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( ParaMEDSPLITTERTest ); - - CPPUNIT_TEST( testMeshSendReceive ); - CPPUNIT_TEST( testMeshFuse ); - - CPPUNIT_TEST( testParaDomainSelector_gatherGraph ); - CPPUNIT_TEST( testParaDomainSelector_gatherNbOf ); - CPPUNIT_TEST( testParaDomainSelector_gatherEntityTypesInfo ); - CPPUNIT_TEST( testParaDomainSelector_gatherNbCellPairs ); - CPPUNIT_TEST( testParaDomainSelector_exchangeJoint ); - CPPUNIT_TEST( testParaDomainSelector_exchangeSubentityIds ); - - // CPPUNIT_TEST( functional_validation ); -> For the moment bug into ConnectZone - - CPPUNIT_TEST_SUITE_END(); - -public: - - void testMeshSendReceive(); - void testMeshFuse(); - - void testParaDomainSelector_gatherGraph(); - void testParaDomainSelector_gatherNbOf (); - void testParaDomainSelector_gatherEntityTypesInfo (); - void testParaDomainSelector_gatherNbCellPairs (); - void testParaDomainSelector_exchangeJoint (); - void testParaDomainSelector_exchangeSubentityIds (); - - void functional_validation(); - void test_medsplitter_para( const std::string& med_file, const std::string& mesh ); -}; - -#endif diff --git a/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_MeshSendReceive.cxx b/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_MeshSendReceive.cxx deleted file mode 100644 index 037b51341..000000000 --- a/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_MeshSendReceive.cxx +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (C) 2007-2013 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 -// -// File : ParaMEDSPLITTERTest_MeshSendReceive.cxx -// Created : Mon Jul 6 14:14:29 2009 -// Author : Edward AGAPOV (eap) - -#include "ParaMEDSPLITTERTest.hxx" -#include "MEDSPLITTERTest_Utils.hxx" - -#include "MEDSPLITTER_MESHCollection.hxx" -#include "MEDSPLITTER_MeshSendReceive.hxx" -#include "MEDSPLITTER_Topology.hxx" - -#include "MEDMEM_MeshFuse.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_DriverFactory.hxx" - -using namespace std; -using namespace MEDSPLITTER; -using namespace MED_EN; - -//================================================================================ -/*! - * \brief Test intended to run on one proc - */ -//================================================================================ - -void ParaMEDSPLITTERTest::testMeshSendReceive() -{ - MEDMEM::STRING filename = MEDSPLITTERTest_Utils::getResourceFile("pointe.med"); - MEDMEM::MESH* meshSent = 0; - MEDMEM::MESH* meshRecv = 0; - - int size, rank; - MPI_Comm_size(MPI_COMM_WORLD, &size); - MPI_Comm_rank(MPI_COMM_WORLD, &rank) ; - - MeshSendReceive sender, receiver; - vector nums_sent_1(3,7), nums_sent_2(4,8), nums_sent_3(5,9); - vector nums_recv_1, nums_recv_2, nums_recv_3; - - if ( rank == 0 ) - { - meshSent = new MEDMEM::MESH; - MEDMEM::MED_MESH_RDONLY_DRIVER drv(filename, meshSent ); - drv.setMeshName( "maa1" ); - drv.desactivateFacesComputation(); - drv.open(); - drv.read(); - drv.close(); - CPPUNIT_ASSERT_NO_THROW( sender.send( size-1, 1,meshSent,nums_sent_1,nums_sent_2,nums_sent_3)); - } - if ( rank == size-1 ) - { - CPPUNIT_ASSERT_NO_THROW( meshRecv = receiver.recv( 0, 1, nums_recv_1,nums_recv_2,nums_recv_3)); - CPPUNIT_ASSERT( meshRecv ); - // test by printing that minimally needed data is present - MEDMEM::STRING out; - CPPUNIT_ASSERT_NO_THROW( out << *meshRecv ); - } - if ( size == 1 ) - { - CPPUNIT_ASSERT( nums_recv_1 == nums_sent_1 ); - CPPUNIT_ASSERT( nums_recv_2 == nums_sent_2 ); - CPPUNIT_ASSERT( nums_recv_3 == nums_sent_3 ); - - if ( ! meshSent->deepCompare( *meshRecv ) ) - { -#ifdef _DEBUG_ - MEDMEM::STRING outfilename("/tmp/pointe"); - outfilename << (void*) meshRecv << ".med"; - int drv = meshRecv->addDriver(MEDMEM::MED_DRIVER, outfilename, meshRecv->getName() ); - meshRecv->write( drv ); - CPPUNIT_FAIL( MEDMEM::STRING("received mesh differs from the sent one ") << filename << - ", check the received mesh in " << outfilename); -#else - CPPUNIT_FAIL( "received mesh differs from the sent one "); -#endif - } - } - - delete meshRecv; - delete meshSent; -} - -//================================================================================ -/*! - * \brief Split pointe.med and fuse back - */ -//================================================================================ - -void ParaMEDSPLITTERTest::testMeshFuse() -{ - string filename = MEDSPLITTERTest_Utils::getResourceFile("pointe.med"); - string meshname = "maa1"; - - // Splitting - - MESHCollection collection(filename,meshname); - - vector partition; - partition.reserve( collection.getMesh()[0]->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)); - for ( int i = 0; i < partition.capacity()/2; ++i ) - partition.push_back( 0 ); - while ( partition.size() < partition.capacity() ) - partition.push_back( 1 ); - - Topology* new_topo = collection.createPartition( &partition[0] ); - MESHCollection new_collection(collection, new_topo); - - // test splits of the mesh by printing - MEDMEM::STRING out; - CPPUNIT_ASSERT_NO_THROW( out << *(new_collection.getMesh()[0])); - CPPUNIT_ASSERT_NO_THROW( out << *(new_collection.getMesh()[1])); - - // global numbers - vector glob_nb_left ( new_topo->getNodeNumber(0) ); - vector glob_nb_right( new_topo->getNodeNumber(1) ); - new_topo->getNodeList( 0, & glob_nb_left[0] ); - new_topo->getNodeList( 1, & glob_nb_right[0] ); - - // Fusion - - // test that minimally needed data present by printing - MEDMEM::MeshFuse fusion; - fusion.concatenate(new_collection.getMesh()[0], glob_nb_left); - CPPUNIT_ASSERT_NO_THROW( out << ( (const MEDMEM::MESH &) fusion )); - fusion.concatenate(new_collection.getMesh()[1], glob_nb_right); - CPPUNIT_ASSERT_NO_THROW( out << ( (const MEDMEM::MESH &) fusion )); - - // compare - MEDMEM::MESH init_mesh( MEDMEM::MED_DRIVER, filename, meshname); - if ( !init_mesh.deepCompare( fusion )) - { -// fusion.addDriver( MEDMEM::MED_DRIVER, "/tmp/fusion.med", fusion.getName() ); -// fusion.write(); - -// new_collection.getMesh()[0]->addDriver( MEDMEM::MED_DRIVER,"/tmp/split_1.med", "maa1"); -// new_collection.getMesh()[1]->addDriver( MEDMEM::MED_DRIVER,"/tmp/split_2.med", "maa1"); -// new_collection.getMesh()[0]->write(); -// new_collection.getMesh()[1]->write(); -// new_collection.write( "/tmp/split" ); - - //CPPUNIT_ASSERT( init_mesh.getName() == fusion.getName() ); - CPPUNIT_ASSERT( init_mesh.getSpaceDimension() == fusion.getSpaceDimension() ); - CPPUNIT_ASSERT( init_mesh.getMeshDimension() == fusion.getMeshDimension() ); - CPPUNIT_ASSERT( init_mesh.getIsAGrid() == fusion.getIsAGrid() ); - CPPUNIT_ASSERT( init_mesh.getNumberOfNodes() == fusion.getNumberOfNodes() ); - //CPPUNIT_ASSERT( init_mesh.getCoordinatesSystem() == fusion.() ); - CPPUNIT_ASSERT( init_mesh.getNumberOfTypes(MED_CELL) == fusion.getNumberOfTypes(MED_CELL) ); - for ( int i = 0; i < init_mesh.getNumberOfTypes(MED_CELL); ++i ) - CPPUNIT_ASSERT( init_mesh.getTypes(MED_CELL)[i] == fusion.getTypes(MED_CELL)[i] ); - CPPUNIT_ASSERT( init_mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) - == fusion.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) ); - -// CPPUNIT_ASSERT( init_mesh.() == fusion.() ); -// CPPUNIT_ASSERT( init_mesh.() == fusion.() ); -// CPPUNIT_ASSERT( init_mesh.() == fusion.() ); -// CPPUNIT_ASSERT( init_mesh.() == fusion.() ); -// CPPUNIT_ASSERT( init_mesh.() == fusion.() ); -// CPPUNIT_ASSERT( init_mesh.() == fusion.() ); - } - - delete new_topo; - -} diff --git a/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_ParaDomainSelector.cxx b/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_ParaDomainSelector.cxx deleted file mode 100644 index 4ff17cad1..000000000 --- a/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_ParaDomainSelector.cxx +++ /dev/null @@ -1,516 +0,0 @@ -// Copyright (C) 2007-2013 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 -// -// File : ParaMEDSPLITTERTest_ParaDomainSelector.cxx -// Created : Tue Jul 21 16:25:50 2009 -// Author : Edward AGAPOV (eap) - -#include "ParaMEDSPLITTERTest.hxx" -#include "MEDSPLITTERTest_Utils.hxx" - -#include "MEDSPLITTER_ParaDomainSelector.hxx" -#include "MEDSPLITTER_UserGraph.hxx" -#include "MEDSPLITTER_JointExchangeData.hxx" -#include "MEDSPLITTER_FaceModel.hxx" - -#include -#include -#include - -#include -#include - -using namespace std; -using namespace MEDSPLITTER; -using namespace MED_EN; - -//================================================================================ -/*! - * \brief Test ParaDomainSelector::gatherGraph( graph ) - */ -//================================================================================ - -void ParaMEDSPLITTERTest::testParaDomainSelector_gatherGraph() -{ - int world_size; - MPI_Comm_size(MPI_COMM_WORLD,&world_size); - - if ( world_size != 2 ) - return; - - // Combine two equal graphs: - // index: [ 1, 3, 6 ] - // value: [ 1, 2, 1, 2, 3] - // partition: [ 0, 1 ] - // - // Expect to get: - // index: [ 1, 3, 6, 8, 11 ] - // value: [ 1, 2, 1, 2, 3, 1, 2, 1, 2, 3] - // partition: [ 0, 1, 0, 1 ] - - ParaDomainSelector dom_sel; - CPPUNIT_ASSERT_NO_THROW( dom_sel.isOnDifferentHosts() ); -#ifdef _DEBUG_ - cout << "On different hosts = " << dom_sel.isOnDifferentHosts() << endl; -#endif - - // Let ParaDomainSelector know domain sizes - - MEDMEM::MESHING meshing; - int nb_elems[] = { 2 }; medGeometryElement type = MED_POINT1; - meshing.setNumberOfTypes ( 1, MED_CELL ); - meshing.setTypes ( &type, MED_CELL ); - meshing.setNumberOfElements( nb_elems, MED_CELL ); - - vector domain_meshes(2, (MEDMEM::MESH*)0); - domain_meshes[ dom_sel.rank() ] = &meshing; - dom_sel.gatherNbOf( MED_CELL, domain_meshes ); - - // Make the graph - - int index[] = { 1, 3, 6 }; - int value[] = { 1, 2, 1, 2, 3 }; - int* partition = new int[2]; - partition[0]=0; partition[1] = 1; - MEDMEM::MEDSKYLINEARRAY* array = new MEDMEM::MEDSKYLINEARRAY( 2, 5, index, value); - auto_ptr graph( new UserGraph( array, partition, 2 )); - - // Gather graphs - - auto_ptr glob_graph( dom_sel.gatherGraph( graph.get() )); - - const int* ind = glob_graph->getGraph()->getIndex(); - const int* val = glob_graph->getGraph()->getValue(); - const int* part= glob_graph->getPart(); - - CPPUNIT_ASSERT_EQUAL( 4, glob_graph->getGraph()->getNumberOf() ); - CPPUNIT_ASSERT_EQUAL( index[0], ind[0] ); - CPPUNIT_ASSERT_EQUAL( index[1], ind[1] ); - CPPUNIT_ASSERT_EQUAL( index[2], ind[2] ); - CPPUNIT_ASSERT_EQUAL( index[2]+ind[1]-ind[0], ind[3] ); - CPPUNIT_ASSERT_EQUAL( index[2]+ind[2]-ind[0], ind[4] ); - - CPPUNIT_ASSERT_EQUAL( 10, glob_graph->getGraph()->getLength() ); - CPPUNIT_ASSERT_EQUAL( value[0], val[0] ); - CPPUNIT_ASSERT_EQUAL( value[1], val[1] ); - CPPUNIT_ASSERT_EQUAL( value[2], val[2] ); - CPPUNIT_ASSERT_EQUAL( value[3], val[3] ); - CPPUNIT_ASSERT_EQUAL( value[4], val[4] ); - CPPUNIT_ASSERT_EQUAL( value[0], val[5] ); - CPPUNIT_ASSERT_EQUAL( value[1], val[6] ); - CPPUNIT_ASSERT_EQUAL( value[2], val[7] ); - CPPUNIT_ASSERT_EQUAL( value[3], val[8] ); - CPPUNIT_ASSERT_EQUAL( value[4], val[9] ); - - CPPUNIT_ASSERT_EQUAL( partition[0], part[0] ); - CPPUNIT_ASSERT_EQUAL( partition[1], part[1] ); - CPPUNIT_ASSERT_EQUAL( partition[0], part[2] ); - CPPUNIT_ASSERT_EQUAL( partition[1], part[3] ); -} - -//================================================================================ -/*! - * \brief test ParaDomainSelector::gatherNbOf( entity, domain_meshes ) - */ -//================================================================================ - -void ParaMEDSPLITTERTest::testParaDomainSelector_gatherNbOf () -{ - int world_size; - MPI_Comm_size(MPI_COMM_WORLD,&world_size); - - if ( world_size != 2 ) - return; - - string filename = MEDSPLITTERTest_Utils::getResourceFile("square1_split1.med"); - string meshname = "Mesh_2_1"; - - ParaDomainSelector dom_sel; - - MEDMEM::MESH mesh_full( MEDMEM::MED_DRIVER, filename, meshname); - MEDMEM::MESH mesh_empty; - - vector meshes(2); - meshes[0] = & mesh_full; - meshes[1] = & mesh_empty; - if ( dom_sel.rank() > 0 ) - swap( meshes[0], meshes[1] ); - - // test gatherNbOf( MED_CELL ) - int nb_cells, init_nb_cells = mesh_full.getNumberOfElements( MED_CELL, MED_ALL_ELEMENTS ); - CPPUNIT_ASSERT_NO_THROW( nb_cells = dom_sel.gatherNbOf( MED_CELL, meshes )); - CPPUNIT_ASSERT_EQUAL( 2 * init_nb_cells, nb_cells ); - - // test gatherNbOf( MED_EDGE ) - int nb_edges, init_nb_edges = mesh_full.getNumberOfElements( MED_EDGE, MED_ALL_ELEMENTS ); - CPPUNIT_ASSERT_NO_THROW( nb_edges = dom_sel.gatherNbOf( MED_EDGE, meshes )); - CPPUNIT_ASSERT_EQUAL( 2 * init_nb_edges, nb_edges ); - - // test getNbVertOfProcs() - int* nb_cell_by_proc; - CPPUNIT_ASSERT_NO_THROW( nb_cell_by_proc = dom_sel.getNbVertOfProcs() ); - CPPUNIT_ASSERT_EQUAL( init_nb_cells, nb_cell_by_proc[1]-nb_cell_by_proc[0] ); - CPPUNIT_ASSERT_EQUAL( init_nb_cells, nb_cell_by_proc[2]-nb_cell_by_proc[1] ); - - // test getProcShift() - if ( dom_sel.rank() == 0 ) - CPPUNIT_ASSERT_EQUAL( 0, dom_sel.getProcShift() ); - else - CPPUNIT_ASSERT_EQUAL( init_nb_cells, dom_sel.getProcShift() ); - - CPPUNIT_ASSERT_EQUAL( 0, dom_sel.getDomainShift(0) ); - CPPUNIT_ASSERT_EQUAL( init_nb_cells, dom_sel.getDomainShift(1) ); -} - -//================================================================================ -/*! - * \brief Test ParaDomainSelector::gatherEntityTypesInfo( domain_meshes, entity ) - */ -//================================================================================ - -void ParaMEDSPLITTERTest::testParaDomainSelector_gatherEntityTypesInfo () -{ - int world_size; - MPI_Comm_size(MPI_COMM_WORLD,&world_size); - - if ( world_size != 2 ) - return; - - string filename = MEDSPLITTERTest_Utils::getResourceFile("square1_split1.med"); - string meshname = "Mesh_2_1"; - - ParaDomainSelector dom_sel; - - MEDMEM::MESH mesh_full( MEDMEM::MED_DRIVER, filename, meshname); - MEDMEM::MESH mesh_empty; - - vector meshes(2); - meshes[0] = & mesh_full; - meshes[1] = & mesh_empty; - if ( dom_sel.rank() > 0 ) - swap( meshes[0], meshes[1] ); - - // --------------- - // test for cells - // --------------- - - const medGeometryElement * init_cell_types = mesh_full.getTypes (MED_CELL); - const int * init_cell_nb_index = mesh_full.getGlobalNumberingIndex(MED_CELL); - int nb_init_cell_types = mesh_full.getNumberOfTypes (MED_CELL); - - // pass info on cell types from mesh_full on other proc to mesh_empty on this proc - CPPUNIT_ASSERT_NO_THROW( dom_sel.gatherEntityTypesInfo( meshes, MED_CELL )); - - const medGeometryElement * got_cell_types = mesh_empty.getTypes (MED_CELL); - const int * got_cell_nb_index = mesh_empty.getGlobalNumberingIndex(MED_CELL); - int nb_got_cell_types = mesh_empty.getNumberOfTypes (MED_CELL); - - // check that we got the same info - CPPUNIT_ASSERT_EQUAL( nb_init_cell_types, nb_got_cell_types); - CPPUNIT_ASSERT_EQUAL( nb_init_cell_types, mesh_full.getNumberOfTypes(MED_CELL)); - CPPUNIT_ASSERT_EQUAL( init_cell_types, mesh_full.getTypes (MED_CELL)); - for ( int i = 0; i < nb_got_cell_types; ++i ) - { - CPPUNIT_ASSERT_EQUAL( init_cell_types[i], got_cell_types[i] ); - CPPUNIT_ASSERT_EQUAL( mesh_full.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS ), - mesh_empty.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS )); - CPPUNIT_ASSERT_EQUAL( init_cell_nb_index[ i+1 ], got_cell_nb_index[ i+1 ]); - } - - // test for faces - there are no faces - CPPUNIT_ASSERT_THROW( dom_sel.gatherEntityTypesInfo( meshes, MED_FACE ), MED_EXCEPTION); - - // --------------- - // test for edges - // --------------- - - const medGeometryElement * init_edge_types = mesh_full.getTypes (MED_EDGE); - const int * init_edge_nb_index = mesh_full.getGlobalNumberingIndex(MED_EDGE); - int nb_init_edge_types = mesh_full.getNumberOfTypes (MED_EDGE); - - // pass info on edge types from mesh_full on other proc to mesh_empty on this proc - CPPUNIT_ASSERT_NO_THROW( dom_sel.gatherEntityTypesInfo( meshes, MED_EDGE )); - - const medGeometryElement * got_edge_types = mesh_empty.getTypes (MED_EDGE); - const int * got_edge_nb_index = mesh_empty.getGlobalNumberingIndex(MED_EDGE); - int nb_got_edge_types = mesh_empty.getNumberOfTypes (MED_EDGE); - - // check that we got the same info - CPPUNIT_ASSERT_EQUAL( nb_init_edge_types, nb_got_edge_types); - CPPUNIT_ASSERT_EQUAL( nb_init_edge_types, mesh_full.getNumberOfTypes(MED_EDGE)); - CPPUNIT_ASSERT_EQUAL( init_edge_types, mesh_full.getTypes (MED_EDGE)); - for ( int i = 0; i < nb_got_edge_types; ++i ) - { - CPPUNIT_ASSERT_EQUAL( init_edge_types[i], got_edge_types[i] ); - CPPUNIT_ASSERT_EQUAL( mesh_full.getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS ), - mesh_empty.getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS )); - CPPUNIT_ASSERT_EQUAL( init_edge_nb_index[ i+1 ], got_edge_nb_index[ i+1 ]); - } -} - -void ParaMEDSPLITTERTest::testParaDomainSelector_gatherNbCellPairs () -{ - int world_size; - MPI_Comm_size(MPI_COMM_WORLD,&world_size); - - if ( world_size != 2 ) - return; - - ParaDomainSelector dom_sel; - CPPUNIT_ASSERT_EQUAL( 2, dom_sel.nbProcs() ); - - // imagine we have 5 domains - const int nb_domains = 5; - dom_sel.setNbDomains(nb_domains); - - // ---------------------------------------- - // test isMyDomain() and getProccessorID() - // ---------------------------------------- - set doms_here; - for ( int idomain = 0; idomain < nb_domains; ++idomain ) - if ( dom_sel.isMyDomain( idomain )) - { - doms_here.insert( idomain ); - CPPUNIT_ASSERT_EQUAL( dom_sel.getProccessorID( idomain ), dom_sel.rank() ); - } - CPPUNIT_ASSERT( doms_here.size() == 2 || doms_here.size() == 3 ); - - // --------------- - // test jointId() - // --------------- - set joint_ids; - set< pair< int, int> > dom_pairs; - for ( int idom1 = 0; idom1 < nb_domains; ++idom1 ) - for ( int idom2 = 0; idom2 < nb_domains; ++idom2 ) - if ( idom1 != idom2 ) - { - joint_ids.insert( dom_sel.jointId( idom1, idom2 )); - dom_pairs.insert( idom1 < idom2 ? make_pair( idom1, idom2 ) : make_pair( idom2, idom1 )); - } - CPPUNIT_ASSERT_EQUAL( dom_pairs.size(), joint_ids.size() ); - - // ------------------------- - // test gatherNbCellPairs() - // ------------------------- - joint_ids.clear(); - int nb_interproc_pairs = 0, nb_local_pairs = 0, total_joint_size = 0; - for ( int idom1 = 0; idom1 < nb_domains; ++idom1 ) - for ( int idom2 = idom1+1; idom2 < nb_domains; ++idom2 ) - { - // gather data for further checks - int nb_doms_here = doms_here.count( idom1 ) + doms_here.count( idom2 ); - bool is_inter_proc = ( nb_doms_here == 1 ); - bool is_local = ( nb_doms_here%2 == 0 ); - int nb_pairs = dom_sel.jointId( idom1, idom2 ); - total_joint_size += nb_pairs; - if ( is_inter_proc ) nb_interproc_pairs += nb_pairs; - if ( is_local ) nb_local_pairs += nb_pairs; - if ( nb_doms_here == 0 || idom1 == idom2 ) continue; - // set data to ParaDomainSelector - if ( is_inter_proc && doms_here.count( idom1 ) || - is_local && nb_doms_here == 2 ) - { - dom_sel.setNbCellPairs( nb_pairs, idom1, idom2 ); - } - } - dom_sel.gatherNbCellPairs(); - //CPPUNIT_ASSERT_EQUAL( nb_local_pairs, dom_sel.getNbSubentitiesWithoutProcJoints() ); - - for ( int idom1 = 0; idom1 < nb_domains; ++idom1 ) - for ( int idom2 = 0; idom2 < nb_domains; ++idom2 ) - { - //int nb_doms_here = doms_here.count( idom1 ) + doms_here.count( idom2 ); - int nb_pairs_expect = dom_sel.jointId( idom1, idom2 ); - if ( int nb_pairs = dom_sel.getNbCellPairs( idom1, idom2 )) - { - CPPUNIT_ASSERT_EQUAL( nb_pairs_expect, nb_pairs ); - int fisrt_id = dom_sel.getFisrtGlobalIdOfSubentity( idom1, idom2 ); - CPPUNIT_ASSERT(0 < fisrt_id && fisrt_id <= total_joint_size); - } - } -} - -//================================================================================ -/*! - * \brief Test work of JointExchangeData and of ParaDomainSelector::exchangeJoint(joint) - */ -//================================================================================ - -void ParaMEDSPLITTERTest::testParaDomainSelector_exchangeJoint () -{ - int world_size; - MPI_Comm_size(MPI_COMM_WORLD,&world_size); - - if ( world_size != 2 ) - return; - - ParaDomainSelector dom_sel; - - // Exchange a joint between two grids with following global ids - // 5 6 6 9 - // *-----* *-----* - // | | | | - // | 2 | | 4 | - // |3 |4 |4 |8 - // *-----* *-----* - // | | | | - // | 1 | | 3 | - // |1 |2 |2 |7 - // *-----* *-----* - - // make grids; actually we make one grid as their connectivities are same and - // coordinates doesn't matter here - const MEDMEM::MESH* grid = 0; - { - const int dim = 2; - vector > xyz_array(dim); - vector coord_name(dim,"coo"); - vector unit(dim,"m"); - - xyz_array[0].resize(2, 0.); - xyz_array[1].resize(3, 0.); - MEDMEM::GRID tmpGrid( xyz_array, coord_name, unit ); - grid = tmpGrid.convertInMESH(); - } - - // global ids - int cells1[] = { 1, 2 }; - int cells2[] = { 3, 4 }; - int nodes1[] = { 1, 2, 3, 4, 5, 6 }; - int nodes2[] = { 2, 7, 4, 8, 6, 9 }; - int* cells_here = dom_sel.rank() ? cells2 : cells1; - int* cells_dist = dom_sel.rank() ? cells2 : cells1; - int* nodes_here = dom_sel.rank() ? nodes2 : nodes1; - //int* nodes_dist = dom_sel.rank() ? nodes2 : nodes1; - - int dom_here = dom_sel.isMyDomain( 0 ) ? 0 : 1; - int dom_dist = 1 - dom_here; - - // store cell/cell correspondencies - JointExchangeData joint; - joint.addCellCorrespondence( grid, dom_dist, dom_here, cells_dist[0], cells_here[0], 1 ); - joint.addCellCorrespondence( grid, dom_dist, dom_here, cells_dist[1], cells_here[1], 2 ); - CPPUNIT_ASSERT_EQUAL( 2, joint.nbCellPairs()); - - // prepare to exchangeJoint() - joint.setMeshes( dom_dist, grid, dom_here, grid ); - CPPUNIT_ASSERT_EQUAL( dom_dist, joint.distantDomain() ); - CPPUNIT_ASSERT_EQUAL( dom_here, joint.localDomain() ); - - joint.setConnectivity( nodes_here ); - // in general case we woul need to call dom_sel.gatherEntityTypesInfo() but grid - // knows nb of elements without connectivity initialization - CPPUNIT_ASSERT_THROW( dom_sel.exchangeJoint( & joint ), MED_EXCEPTION); - dom_sel.setNbDomains( 2 ); - dom_sel.setNbCellPairs( 2, dom_dist, dom_here ); - dom_sel.gatherNbCellPairs(); - CPPUNIT_ASSERT_NO_THROW( dom_sel.exchangeJoint( & joint )); - - // get CONNECTZONE - const int joint_edge_glob_id = 100; - joint.setFisrtGlobalIdOfSubentity( joint_edge_glob_id ); - TGeom2FacesByDomian face_map(2); - auto_ptr cz( joint.makeConnectZone(face_map)); - CPPUNIT_ASSERT( cz.get() ); - - // --------- - // check cz - // --------- - - CPPUNIT_ASSERT_EQUAL( dom_dist, cz->getDistantDomainNumber() ); - CPPUNIT_ASSERT_EQUAL( dom_here, cz->getLocalDomainNumber() ); - - CPPUNIT_ASSERT_EQUAL( long(grid), long(cz->getLocalMesh()) ); - CPPUNIT_ASSERT_EQUAL( long(grid), long(cz->getDistantMesh()) ); - - CPPUNIT_ASSERT( cz->isEntityCorrespPresent(MED_CELL, MED_CELL) ); - CPPUNIT_ASSERT( !cz->isEntityCorrespPresent(MED_NODE, MED_NODE) ); - CPPUNIT_ASSERT( !cz->isEntityCorrespPresent(MED_EDGE, MED_EDGE) ); - CPPUNIT_ASSERT( !cz->isEntityCorrespPresent(MED_FACE, MED_FACE) ); - - CPPUNIT_ASSERT_EQUAL( 3, cz->getNodeNumber() ); - CPPUNIT_ASSERT_EQUAL( 2, cz->getEntityCorrespNumber(MED_CELL,MED_CELL)); - - const int * node_index = cz->getNodeCorrespIndex(); - CPPUNIT_ASSERT(node_index); - for ( int i = 0; i < 4; ++i ) - CPPUNIT_ASSERT_EQUAL( i + 1, node_index[ i ]); - - const int * node_value = cz->getNodeCorrespValue(); - CPPUNIT_ASSERT(node_value); - int val[2][6] = {{ 2, 1, 4, 3, 6, 5 }, - { 1, 2, 3, 4, 5, 6 }}; // local ids of neighbouring domain - for ( int i = 0; i < 6; ++i ) - CPPUNIT_ASSERT_EQUAL( val[ dom_sel.rank()][ i ], node_value[ i ]); - - const int * cell_index = cz->getEntityCorrespIndex(MED_CELL, MED_CELL); - CPPUNIT_ASSERT(cell_index); - for ( int i = 0; i < 3; ++i ) - CPPUNIT_ASSERT_EQUAL( i + 1, cell_index[ i ]); - - const int * cell_value = cz->getEntityCorrespValue(MED_CELL, MED_CELL); - CPPUNIT_ASSERT(cell_value); - CPPUNIT_ASSERT_EQUAL( 1, cell_value[ 0 ]); - CPPUNIT_ASSERT_EQUAL( 2, cell_value[ 1 ]); - - CPPUNIT_ASSERT_EQUAL( 1, int( face_map[ dom_sel.rank() ].size() )); - CPPUNIT_ASSERT_EQUAL( 0, int( face_map[ 1 - dom_sel.rank() ].size() )); - CPPUNIT_ASSERT_EQUAL( MED_SEG2, face_map[ dom_sel.rank() ].begin()->first ); - - vector< MEDSPLITTER_FaceModel* >& faces = face_map[ dom_sel.rank() ][ MED_SEG2 ]; - CPPUNIT_ASSERT_EQUAL( 2, int( faces.size() )); - CPPUNIT_ASSERT_EQUAL( MED_SEG2, faces[0]->getType()); - CPPUNIT_ASSERT_EQUAL( joint_edge_glob_id+0, faces[0]->getGlobal()); - CPPUNIT_ASSERT_EQUAL( joint_edge_glob_id+1, faces[1]->getGlobal()); - // edge connectivity - CPPUNIT_ASSERT_EQUAL( dom_sel.rank() ? 1 : 4, (*faces[0])[0]); - CPPUNIT_ASSERT_EQUAL( dom_sel.rank() ? 3 : 2, (*faces[0])[1]); - CPPUNIT_ASSERT_EQUAL( dom_sel.rank() ? 3 : 6, (*faces[1])[0]); - CPPUNIT_ASSERT_EQUAL( dom_sel.rank() ? 5 : 4, (*faces[1])[1]); - - grid->removeReference(); -} - -//================================================================================ -/*! - * \brief Test ParaDomainSelector::exchangeSubentityIds() -*/ -//================================================================================ - -void ParaMEDSPLITTERTest::testParaDomainSelector_exchangeSubentityIds () -{ - int world_size; - MPI_Comm_size(MPI_COMM_WORLD,&world_size); - - if ( world_size != 2 ) - return; - - ParaDomainSelector dom_sel; - vector loc_ids_here(3, -373); - int* got_ids; - CPPUNIT_ASSERT_THROW - ( dom_sel.exchangeSubentityIds( dom_sel.rank(), 1-dom_sel.rank(), loc_ids_here),MED_EXCEPTION); - dom_sel.setNbDomains( 2 ); - CPPUNIT_ASSERT_NO_THROW - ( got_ids = dom_sel.exchangeSubentityIds( dom_sel.rank(), 1-dom_sel.rank(), loc_ids_here)); - CPPUNIT_ASSERT_EQUAL( loc_ids_here[0], got_ids[0] ); - CPPUNIT_ASSERT_EQUAL( loc_ids_here[1], got_ids[1] ); - CPPUNIT_ASSERT_EQUAL( loc_ids_here[2], got_ids[2] ); - delete [] got_ids; -} - diff --git a/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_medsplitter_para.cxx b/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_medsplitter_para.cxx deleted file mode 100644 index 8d3dbb714..000000000 --- a/src/MEDSPLITTER/Test/ParaMEDSPLITTERTest_medsplitter_para.cxx +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (C) 2007-2013 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 -// -// File : ParaMEDSPLITTERTest_medsplitter_para.cxx -// Created : Fri Jul 31 12:35:44 2009 -// Author : Edward AGAPOV (eap) -// - -#include "ParaMEDSPLITTERTest.hxx" -#include "MEDSPLITTERTest_Utils.hxx" - -#include "MEDSPLITTER_ParaDomainSelector.hxx" -#include "MEDSPLITTER_MESHCollection.hxx" -#include "MEDSPLITTER_ParaDomainSelector.hxx" -#include "MEDSPLITTER_Topology.hxx" -//#include "MEDSPLITTER_API.hxx" - -#include -#include - -using namespace std; -using namespace MEDSPLITTER; -using namespace MED_EN; - -//================================================================================ -/*! - * \brief call test_medsplitter_para with 2 files: blade.med et pointe.med - */ -//================================================================================ - -void ParaMEDSPLITTERTest::functional_validation() -{ - //test_medsplitter_para( "/dn25/salome/eap/salome/misc/tmp/meshing_REsplit1.med", "meshing_1"); - test_medsplitter_para( MEDSPLITTERTest_Utils::getResourceFile("TimeStamps.med"), "dom"); - test_medsplitter_para( MEDSPLITTERTest_Utils::getResourceFile("square1.med"), "Mesh_2"); - test_medsplitter_para( MEDSPLITTERTest_Utils::getResourceFile("pointe.med"), "maa1"); -} - -//================================================================================ -/*! - * \brief La validation consistera à prendre un maillage, à le découper en deux, - * à passer de deux à trois sous-domaines, puis à revenir vers un sous-domaine. - */ -//================================================================================ - -void ParaMEDSPLITTERTest::test_medsplitter_para( const string& med_file, const string& meshname ) -{ - ParaDomainSelector dom_sel; - - string tmp_dir = MEDSPLITTERTest_Utils::getTmpDirectory(); - // if splitter is running on different hosts, assure tmp_dir to be accessible from all procs - bool diff_hosts = dom_sel.isOnDifferentHosts(); - if ( diff_hosts ) - if ( getenv("HOME")) - tmp_dir = getenv("HOME"); - - string file_2 = tmp_dir + "/test_medsplitter_para_2" ; - string file_3 = tmp_dir + "/test_medsplitter_para_3" ; - string file_1 = tmp_dir + "/test_medsplitter_para_1" ; - string file_3c= tmp_dir + "/test_medsplitter_para_3c" ; - MEDMEM::STRING rm_cmd("rm "); rm_cmd << tmp_dir << "/test_medsplitter_para_*"; - - MPI_Barrier( MPI_COMM_WORLD ); // avoid removing files being read - - // remove all old (master and med) files - if ( dom_sel.rank() == 0 ) - system( rm_cmd ); - - // découper en deux - if ( dom_sel.rank() == 0 ) - { - MESHCollection collection_1(med_file,meshname); - auto_ptr new_topo_2( collection_1.createPartition( 2, Graph::SCOTCH )); - - MESHCollection collection_2w( collection_1, new_topo_2.get()); - collection_2w.setDriverType(MEDSPLITTER::MedAscii); - collection_2w.write( file_2 ); - } - MPI_Barrier( MPI_COMM_WORLD ); // wait for master file_2 - - // passer de deux à trois sous-domaines - MESHCollection collection_2r(file_2,dom_sel); - auto_ptr new_topo_3( collection_2r.createPartition( 3, Graph::METIS )); - - MESHCollection collection_3w( collection_2r, new_topo_3.get()); - collection_3w.setDriverType(MEDSPLITTER::MedAscii); - collection_3w.write( file_3 ); - - // check global face numbers of collection_3w - { - int total_nb_faces = 0; - for ( int idomain=0; idomain < collection_3w.getMesh().size(); ++idomain ) - total_nb_faces += collection_3w.getMesh()[idomain]->getNumberOfElements(collection_3w.getSubEntity(), MED_ALL_ELEMENTS ); - - for ( int idomain=0; idomain < collection_3w.getMesh().size(); ++idomain ) - { - int nb_dom_faces = new_topo_3->getFaceNumber(idomain); - MEDMEM::PointerOf glob_ids( nb_dom_faces ); - new_topo_3->getFaceList(idomain, glob_ids); - for ( int i = 0; i < nb_dom_faces; ++i ) - if ( glob_ids[i] < 1 || glob_ids[i] > total_nb_faces ) - CPPUNIT_FAIL(MEDMEM::STRING("Invalid global face id: ")<< glob_ids[i]); - } - } - - MPI_Barrier( MPI_COMM_WORLD ); // wait for master file_3 - - // revenir vers un sous-domaine - MESHCollection collection_3r(file_3,dom_sel); - auto_ptr new_topo_1( collection_3r.createPartition( 1, Graph::METIS )); - - MESHCollection collection_1w( collection_3r, new_topo_1.get()); - collection_1w.setDriverType(MEDSPLITTER::MedAscii); - collection_1w.write( file_1 ); - - // compare initial and final mesh - - if ( dom_sel.getProccessorID(0) == dom_sel.rank() ) - { - MEDMEM::MESH init_mesh( MEDMEM::MED_DRIVER, med_file, meshname); - MEDMEM::MESH& res_mesh = * collection_1w.getMesh()[0]; - - // nb nodes - int i_nb_nodes = init_mesh.getNumberOfNodes(); - int r_nb_nodes = res_mesh.getNumberOfNodes(); - CPPUNIT_ASSERT_EQUAL( i_nb_nodes, r_nb_nodes ); - - // coord - string i_coo_sys = init_mesh.getCoordinatesSystem(); - string r_coo_sys = res_mesh.getCoordinatesSystem(); - CPPUNIT_ASSERT_EQUAL( i_coo_sys, r_coo_sys ); - - // types and nb elements - int i_nb_types = init_mesh.getNumberOfTypes(MED_CELL); - int r_nb_types = res_mesh.getNumberOfTypes(MED_CELL); - CPPUNIT_ASSERT_EQUAL( i_nb_types, r_nb_types ); - { - const medGeometryElement* i_types = init_mesh.getTypes(MED_CELL); - const medGeometryElement* r_types = res_mesh.getTypes(MED_CELL); - for ( int i=0; i -namespace po=boost::program_options; -#endif - -#include -#include - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDSPLITTER_Graph.hxx" -#include "MEDSPLITTER_MESHCollection.hxx" -#include "MEDSPLITTER_Topology.hxx" - -using namespace std; - - - -int main(int argc, char** argv) -{ -#ifndef MED_ENABLE_METIS -#ifndef MED_ENABLE_SCOTCH - cout << "Sorry, no one split method is available. Please, compile with METIS or SCOTCH."<(),"name of the input MED file") - ("output-file",po::value(),"name of the resulting file") - ("meshname",po::value(),"name of the input mesh") -#ifdef MED_ENABLE_METIS -#ifdef MED_ENABLE_SCOTCH - ("split-method",po::value(&library)->default_value("metis"),"name of the splitting library (metis,scotch)") -#endif -#endif - ("ndomains",po::value(&ndomains)->default_value(1),"number of subdomains in the output file") - ("plain-master","creates a plain masterfile instead of an XML file") - ("creates-boundary-faces","creates the necessary faces so that faces joints are created in the output files") - ("family-splitting","preserves the family names instead of focusing on the groups") - ("empty-groups","creates empty groups in zones that do not contain a group from the original domain"); - - po::variables_map vm; - po::store(po::parse_command_line(argc,argv,desc),vm); - po::notify(vm); - - if (vm.count("help")) - { - cout<(); - if (!vm.count("input-file") || !vm.count("output-file")) - { - cout << "input-file and output-file names must be specified"<(); - output = vm["output-file"].as(); - - if (vm.count("mesh-only")) - mesh_only=true; - - if (vm.count("distributed")) - is_sequential=false; - - if (is_sequential) - meshname = vm["meshname"].as(); - - if (vm.count("plain-master")) - xml_output_master=false; - - if (vm.count("creates-boundary-faces")) - creates_boundary_faces=true; - - if (vm.count("split-families")) - split_families=true; - - if (vm.count("empty-groups")) - empty_groups=true; - -#else // BOOST_PROGRAM_OPTIONS_LIB - - // Primitive parsing of command-line options - - string desc ("Available options:\n" - "\t--help : produces this help message\n" - "\t--mesh-only : do not create the fields contained in the original file(s)\n" - "\t--distributed : specifies that the input file is distributed\n" - "\t--input-file= : name of the input MED file\n" - "\t--output-file= : name of the resulting file\n" - "\t--meshname= : name of the input mesh (not used with --distributed option)\n" - "\t--ndomains= : number of subdomains in the output file, default is 1\n" -#ifdef MED_ENABLE_METIS -#ifdef MED_ENABLE_SCOTCH - "\t--split-method=: name of the splitting library (metis/scotch), default is metis\n" -#endif -#endif - "\t--plain-master : creates a plain masterfile instead of an XML file\n" - "\t--creates-boundary-faces: creates the necessary faces so that faces joints are created in the output files\n" - "\t--family-splitting : preserves the family names instead of focusing on the groups\n" - "\t--empty-groups : creates empty groups in zones that do not contain a group from the original domain" - ); - - if (argc < 4) { - cout << desc.c_str() << endl; - return 1; - } - - for (int i = 1; i < argc; i++) { - if (strlen(argv[i]) < 3) { - cout << desc.c_str() << endl; - return 1; - } - - if (strncmp(argv[i],"--m",3) == 0) { - if (strcmp(argv[i],"--mesh-only") == 0) { - mesh_only = true; - cout << "\tmesh-only = " << mesh_only << endl; // tmp - } - else if (strlen(argv[i]) > 11) { // "--meshname=" - meshname = (argv[i] + 11); - cout << "\tmeshname = " << meshname << endl; // tmp - } - } - else if (strncmp(argv[i],"--d",3) == 0) { - is_sequential = false; - cout << "\tis_sequential = " << is_sequential << endl; // tmp - } - else if (strncmp(argv[i],"--i",3) == 0) { - if (strlen(argv[i]) > 13) { // "--input-file=" - input = (argv[i] + 13); - cout << "\tinput-file = " << input << endl; // tmp - } - } - else if (strncmp(argv[i],"--o",3) == 0) { - if (strlen(argv[i]) > 14) { // "--output-file=" - output = (argv[i] + 14); - cout << "\toutput-file = " << output << endl; // tmp - } - } - else if (strncmp(argv[i],"--s",3) == 0) { - if (strlen(argv[i]) > 15) { // "--split-method=" - library = (argv[i] + 15); - cout << "\tsplit-method = " << library << endl; // tmp - } - } - else if (strncmp(argv[i],"--f",3) == 0) { //"--family-splitting" - split_families=true; - cout << "\tfamily-splitting true" << endl; // tmp - } - else if (strncmp(argv[i],"--n",3) == 0) { - if (strlen(argv[i]) > 11) { // "--ndomains=" - ndomains = atoi(argv[i] + 11); - cout << "\tndomains = " << ndomains << endl; // tmp - } - } - else if (strncmp(argv[i],"--p",3) == 0) { // "--plain-master" - xml_output_master = false; - cout << "\txml_output_master = " << xml_output_master << endl; // tmp - } - else if (strncmp(argv[i],"--c",3) == 0) { // "--creates-boundary-faces" - creates_boundary_faces = true; - cout << "\tcreates_boundary_faces = " << creates_boundary_faces << endl; // tmp - } - else if (strncmp(argv[i],"--e",3) == 0) { // "--empty-groups" - empty_groups = true; - cout << "\tempty_groups = true" << endl; // tmp - } - else { - cout << desc.c_str() << endl; - return 1; - } - } - - if (is_sequential && meshname.empty()) { - cout << "Mesh name must be given for sequential(not distributed) input file." << endl; - cout << desc << endl; - return 1; - } - -#endif // BOOST_PROGRAM_OPTIONS_LIB - - - //testing whether it is possible to write a file at the specified location - string outputtest = output + ".testioms."; - ofstream testfile (outputtest.c_str()); - if (testfile.fail()) - { - cout << "MEDSPLITTER : output-file directory does not exist or is in read-only access" << endl; - return 1; - }; - //deletes test file - remove(outputtest.c_str()); - - // Beginning of the computation - - // Loading the mesh collection - MEDSPLITTER::MESHCollection* collection; - cout << "MEDSPLITTER - reading input files "<createPartition(ndomains,MEDSPLITTER::Graph::METIS); - else - new_topo = collection->createPartition(ndomains,MEDSPLITTER::Graph::SCOTCH); - - cout << "MEDSPLITTER - creating new meshes"< - -#include - -#ifdef BOOST_PROGRAM_OPTIONS_LIB -#include -namespace po=boost::program_options; -#endif - -using namespace std; - - - -int main(int argc, char** argv) -{ -#ifndef MED_ENABLE_PARMETIS -#ifndef ENABLE_PTSCOTCH - cout << "Sorry, no one split method is available. Please, compile with ParMETIS or PT-SCOTCH."<(),"name of the input MED file") - ("output-file",po::value(),"name of the resulting file") - //("meshname",po::value(),"name of the input mesh") -#ifdef MED_ENABLE_PARMETIS -#ifdef ENABLE_PTSCOTCH - ("split-method",po::value(&library)->default_value("metis"),"name of the splitting library (metis,scotch)") -#endif -#endif - ("ndomains",po::value(&ndomains)->default_value(1),"number of subdomains in the output file") - ("plain-master","creates a plain masterfile instead of an XML file") - ("creates-boundary-faces","creates the necessary faces so that faces joints are created in the output files") - ("family-splitting","preserves the family names instead of focusing on the groups") - ("empty-groups","creates empty groups in zones that do not contain a group from the original domain") - ("dump-cpu-memory","dumps passed CPU time and maximal increase of used memory"); - - po::variables_map vm; - po::store(po::parse_command_line(argc,argv,desc),vm); - po::notify(vm); - - if (vm.count("help")) - { - cout<(); - if (!vm.count("input-file") || !vm.count("output-file")) - { - cout << "input-file and output-file names must be specified"<(); - output = vm["output-file"].as(); - -// if (vm.count("mesh-only")) -// mesh_only=true; - -// if (vm.count("distributed")) -// is_sequential=false; - -// if (is_sequential) -// meshname = vm["meshname"].as(); - - if (vm.count("plain-master")) - xml_output_master=false; - - if (vm.count("creates-boundary-faces")) - creates_boundary_faces=true; - - if (vm.count("split-families")) - split_family=true; - - if (vm.count("empty-groups")) - empty_groups=true; - - if (vm.count("dump-cpu-memory")) - mesure_memory=true; - -#else // BOOST_PROGRAM_OPTIONS_LIB - - // Primitive parsing of command-line options - - string desc ("Available options:\n" - "\t--help : produces this help message\n" - //"\t--mesh-only : do not create the fields contained in the original file(s)\n" - //"\t--distributed : specifies that the input file is distributed\n" - "\t--input-file= : name of the input MED file\n" - "\t--output-file= : name of the resulting file\n" - //"\t--meshname= : name of the input mesh (not used with --distributed option)\n" - "\t--ndomains= : number of subdomains in the output file, default is 1\n" -#ifdef MED_ENABLE_PARMETIS -#ifdef ENABLE_PTSCOTCH - "\t--split-method= : name of the splitting library (metis/scotch), default is metis\n" -#endif -#endif - "\t--plain-master : creates a plain masterfile instead of an XML file\n" - "\t--creates-boundary-faces: creates the necessary faces so that faces joints are created in the output files\n" - "\t--family-splitting : preserves the family names instead of focusing on the groups\n" - "\t--dump-cpu-memory : dumps passed CPU time and maximal increase of used memory\n" - ); - - if (argc < 4) { - cout << desc.c_str() << endl; - return 1; - } - - for (int i = 1; i < argc; i++) { - if (strlen(argv[i]) < 3) { - cout << desc.c_str() << endl; - return 1; - } - -/* if (strncmp(argv[i],"--m",3) == 0) { - if (strcmp(argv[i],"--mesh-only") == 0) { - mesh_only = true; - cout << "\tmesh-only = " << mesh_only << endl; // tmp - } - else if (strlen(argv[i]) > 11) { // "--meshname=" - meshname = (argv[i] + 11); - cout << "\tmeshname = " << meshname << endl; // tmp - } - } - else if (strncmp(argv[i],"--d",3) == 0) { - is_sequential = false; - cout << "\tis_sequential = " << is_sequential << endl; // tmp - } - else */if (strncmp(argv[i],"--i",3) == 0) { - if (strlen(argv[i]) > 13) { // "--input-file=" - input = (argv[i] + 13); - cout << "\tinput-file = " << input << endl; // tmp - } - } - else if (strncmp(argv[i],"--o",3) == 0) { - if (strlen(argv[i]) > 14) { // "--output-file=" - output = (argv[i] + 14); - cout << "\toutput-file = " << output << endl; // tmp - } - } - else if (strncmp(argv[i],"--s",3) == 0) { - if (strlen(argv[i]) > 15) { // "--split-method=" - library = (argv[i] + 15); - cout << "\tsplit-method = " << library << endl; // tmp - } - } - else if (strncmp(argv[i],"--f",3) == 0) { //"--family-splitting" - split_family=true; - cout << "\tfamily-splitting true" << endl; // tmp - } - else if (strncmp(argv[i],"--n",3) == 0) { - if (strlen(argv[i]) > 11) { // "--ndomains=" - ndomains = atoi(argv[i] + 11); - cout << "\tndomains = " << ndomains << endl; // tmp - } - } - else if (strncmp(argv[i],"--p",3) == 0) { // "--plain-master" - xml_output_master = false; - cout << "\txml_output_master = " << xml_output_master << endl; // tmp - } - else if (strncmp(argv[i],"--c",3) == 0) { // "--creates-boundary-faces" - creates_boundary_faces = true; - cout << "\tcreates_boundary_faces = " << creates_boundary_faces << endl; // tmp - } - else if (strncmp(argv[i],"--e",3) == 0) { // "--empty-groups" - empty_groups = true; - cout << "\tempty_groups = true" << endl; // tmp - } - else if (strncmp(argv[i],"--d",3) == 0) { // "--dump-cpu-memory" - mesure_memory = true; - cout << "\tdump-cpu-memory = true" << endl; // tmp - } - else { - cout << desc.c_str() << endl; - return 1; - } - } - -// if (is_sequential && meshname.empty()) { -// cout << "Mesh name must be given for sequential(not distributed) input file." << endl; -// cout << desc << endl; -// return 1; -// } - -#endif // BOOST_PROGRAM_OPTIONS_LIB - - - //testing whether it is possible to write a file at the specified location - string outputtest = output + ".testioms."; - ofstream testfile (outputtest.c_str()); - if (testfile.fail()) - { - cout << "MEDSPLITTER : output-file directory does not exist or is in read-only access" << endl; - return 1; - } - //deletes test file - remove(outputtest.c_str()); - - // Beginning of the computation - - MPI_Init(&argc,&argv); - - - // Loading the mesh collection - cout << "MEDSPLITTER - reading input files "< - -using namespace std; -int main() -{ - string testname="MEDSPLITTER - test #3 -"; - - char filename[100] = "../../share/salome/resources/med/carre_en_quad4.med"; - char meshname[20] = "carre_en_quad4"; - char output[100]="./tests/API_test"; - int is_distributed=0; - int nprocs=4; - int meshonly=0; - int method=0; - return medsplitter(filename, - meshname, - output, - is_distributed, - nprocs, - method, - meshonly); -} - diff --git a/src/MEDSPLITTER_Swig/CMakeLists.txt b/src/MEDSPLITTER_Swig/CMakeLists.txt deleted file mode 100644 index 27e0470c4..000000000 --- a/src/MEDSPLITTER_Swig/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2012-2013 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 -# - -FIND_PACKAGE(SWIG REQUIRED) -INCLUDE(${SWIG_USE_FILE}) - -SET_SOURCE_FILES_PROPERTIES(libMEDSPLITTER_Swig.i PROPERTIES CPLUSPLUS ON) -SET_SOURCE_FILES_PROPERTIES(libMEDSPLITTER_Swig.i PROPERTIES SWIG_DEFINITIONS "-shadow") - -INCLUDE_DIRECTORIES( - ${PYTHON_INCLUDE_DIRS} - ${MED3_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS} - ${BOOST_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDSPLITTER - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDMEM - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDMEM_SWIG - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Geometric2D - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/ExprEval - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints - ) - -SWIG_ADD_MODULE(libMEDSPLITTER_Swig python libMEDSPLITTER_Swig.i) -SWIG_LINK_LIBRARIES(libMEDSPLITTER_Swig ${PYTHON_LIBS} medsplittercpp) -SET_TARGET_PROPERTIES(_libMEDSPLITTER_Swig PROPERTIES COMPILE_FLAGS "${BOOST_DEFINITIONS} ${PLATFORM_DEFINITIONS}") -IF(${MACHINE} STREQUAL WINDOWS) - SET_TARGET_PROPERTIES(_libMEDSPLITTER_Swig PROPERTIES DEBUG_OUTPUT_NAME _libMEDSPLITTER_Swig_d) -ENDIF(${MACHINE} STREQUAL WINDOWS) -INSTALL(TARGETS _libMEDSPLITTER_Swig DESTINATION ${MED_salomepythondir}) -INSTALL(FILES libMEDSPLITTER_Swig.i DESTINATION ${MED_salomeinclude_HEADERS}) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libMEDSPLITTER_Swig.py DESTINATION ${MED_salomepythondir}) -INSTALL(FILES MEDSPLITTER.py test_MEDSPLITTER.py DESTINATION ${MED_salomescript_DATA}) - diff --git a/src/MEDSPLITTER_Swig/MEDSPLITTER.py b/src/MEDSPLITTER_Swig/MEDSPLITTER.py deleted file mode 100644 index 9ba974943..000000000 --- a/src/MEDSPLITTER_Swig/MEDSPLITTER.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 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 -# - -from libMEDSPLITTER_Swig import * diff --git a/src/MEDSPLITTER_Swig/Makefile.am b/src/MEDSPLITTER_Swig/Makefile.am deleted file mode 100644 index 74d6acdb7..000000000 --- a/src/MEDSPLITTER_Swig/Makefile.am +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright (C) 2007-2013 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 -# - -# MED MEDMEM_SWIG : binding of C++ implementation and Python -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -salomepython_PYTHON = libMEDSPLITTER_Swig.py -salomepyexec_LTLIBRARIES = _libMEDSPLITTER_Swig.la - -salomeinclude_HEADERS = \ - libMEDSPLITTER_Swig.i - -SWIG_DEF = libMEDSPLITTER_Swig.i - -SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../MEDMEM_SWIG - -dist__libMEDSPLITTER_Swig_la_SOURCES = libMEDSPLITTER_Swig.i -nodist__libMEDSPLITTER_Swig_la_SOURCES = libMEDSPLITTER_Swig_wrap.cxx -libMEDSPLITTER_Swig.py: libMEDSPLITTER_Swig_wrap.cxx - -libMEDSPLITTER_Swig_wrap.cxx: $(SWIG_DEF) - $(SWIG) $(SWIG_FLAGS) -o $@ $< - -_libMEDSPLITTER_Swig_la_CPPFLAGS = $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) $(PYTHON_INCLUDES) \ - $(MED3_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ $(BOOST_CPPFLAGS) \ - -I$(srcdir)/../MEDMEM -I$(srcdir)/../MEDWrapper/V2_1/Core -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../MEDSPLITTER -I$(srcdir)/../INTERP_KERNEL/Bases - -_libMEDSPLITTER_Swig_la_LDFLAGS = -module $(MED3_LIBS_C_ONLY) $(HDF5_LIBS) $(PYTHON_LIBS) $(BOOST_LIBS) \ - ../MEDMEM/libmedmem.la ../INTERP_KERNEL/libinterpkernel.la \ - ../MEDSPLITTER/libmedsplitter.la - -if MED_ENABLE_KERNEL - _libMEDSPLITTER_Swig_la_CPPFLAGS += ${KERNEL_CXXFLAGS} - _libMEDSPLITTER_Swig_la_LDFLAGS += ${KERNEL_LDFLAGS} -lSALOMELocalTrace -endif - -CLEANFILES = libMEDSPLITTER_Swig_wrap.cxx libMEDSPLITTER_Swig.py - -dist_salomescript_DATA = MEDSPLITTER.py test_MEDSPLITTER.py diff --git a/src/MEDSPLITTER_Swig/libMEDSPLITTER_Swig.i b/src/MEDSPLITTER_Swig/libMEDSPLITTER_Swig.i deleted file mode 100644 index 91b70dcac..000000000 --- a/src/MEDSPLITTER_Swig/libMEDSPLITTER_Swig.i +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -%module libMEDSPLITTER_Swig - -%{ -#include "MEDMEM_Mesh.hxx" -#include -#include - -using namespace MEDSPLITTER; - -typedef enum {METIS,SCOTCH} splitter_type; -%} - -typedef enum {METIS,SCOTCH} splitter_type; -typedef enum{MedAscii, MedXML, Undefined} DriverType; - -%include "my_typemap.i" - -%typecheck(SWIG_TYPECHECK_POINTER) const int* { - $1 = PyList_Check($input) ? 1 : 0; -} - -namespace MEDSPLITTER { -class Graph { -public: - typedef enum {METIS,SCOTCH} splitter_type; - %extend { - Graph() {return 0;} - } -}; -} - -class MESHCollection { -public: - MESHCollection(const MESHCollection&, MEDSPLITTER::Topology*, - bool family_splitting=false, bool create_empty_groups=false); - MESHCollection(const char* filename); - MESHCollection(const char* filename, char* meshname); - - MEDSPLITTER::Topology* createPartition(int nbdomain, - MEDSPLITTER::Graph::splitter_type splitter_type = METIS, - const char* theStr=0); - MEDSPLITTER::Topology* createPartition(const int* partition); - - void setDriverType(::DriverType type); - void setSubdomainBoundaryCreates(bool flag); - - void write(const char* filename); - void castAllFields(const MESHCollection& old_collection); - void castFamilies(const MESHCollection& old_collection); - void castField(const MESHCollection& old_collection, const char* fieldname, - int itnumber, int ordernumber); - - void setIndivisibleGroup(const std::string& a); -}; diff --git a/src/MEDSPLITTER_Swig/test_MEDSPLITTER.py b/src/MEDSPLITTER_Swig/test_MEDSPLITTER.py deleted file mode 100644 index 83294c963..000000000 --- a/src/MEDSPLITTER_Swig/test_MEDSPLITTER.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 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 -# - -from MEDSPLITTER import * -import os - -#Beginning of the computation - -#Loading the mesh collection -print "reading files" - -data_dir = os.getenv("MED_ROOT_DIR") -filename_rd = os.path.join( data_dir, "share/salome/resources/med/pointe.med") -meshname="maa1" - -collection = MESHCollection(filename_rd,meshname) - -print "MEDSPLITTER - computing partition " - - -new_topo = collection.createPartition(4,METIS); - -# Creating a new mesh collection from the partitioning -new_collection = MESHCollection(collection, new_topo, 1, 1); - - -new_collection.setSubdomainBoundaryCreates(1); - -print "MEDSPLITTER - writing output files " -new_collection.write("/tmp/myOutput.med") - -# Casting the fields on the new collection -new_collection.castAllFields(collection); -