From: vbd Date: Fri, 22 Jul 2011 07:22:32 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: MEDPartitioner_first_compilable_version~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=de29854978d24ef79299cf1f8c90a32bddfc80fa;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.hxx b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.hxx index 10d28ab8b..3d6e7f418 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.hxx @@ -16,8 +16,8 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef PARALLELTOPOLOGY_HXX_ -#define PARALLELTOPOLOGY_HXX_ +#ifndef __PARALLELTOPOLOGY_HXX__ +#define __PARALLELTOPOLOGY_HXX__ #include #include diff --git a/src/MEDPartitioner/Makefile.am b/src/MEDPartitioner/Makefile.am index d9e732f07..56326d10e 100644 --- a/src/MEDPartitioner/Makefile.am +++ b/src/MEDPartitioner/Makefile.am @@ -26,7 +26,7 @@ if CPPUNIT_IS_OK SUBDIRS=. endif -lib_LTLIBRARIES= libmedsplitter.la +lib_LTLIBRARIES= libmedpartitioner.la salomeinclude_HEADERS= \ MEDPARTITIONER_MESHCollection.hxx \ @@ -52,7 +52,7 @@ if MED_ENABLE_SCOTCH salomeinclude_HEADERS+= MEDPARTITIONER_SCOTCHGraph.hxx endif -dist_libmedsplitter_la_SOURCES= \ +dist_libmedpartitioner_la_SOURCES= \ MEDPARTITIONER_MESHCollection.cxx \ MEDPARTITIONER_MESHCollectionDriver.cxx \ MEDPARTITIONER_MESHCollectionMedXMLDriver.cxx \ @@ -66,58 +66,58 @@ MEDPARTITIONER_SkyLineArray.cxx \ MEDPARTITIONER_ConnectZone.cxx if MED_ENABLE_METIS - dist_libmedsplitter_la_SOURCES+= MEDPARTITIONER_METISGraph.cxx + dist_libmedpartitioner_la_SOURCES+= MEDPARTITIONER_METISGraph.cxx endif if MED_ENABLE_SCOTCH - dist_libmedsplitter_la_SOURCES+= MEDPARTITIONER_SCOTCHGraph.cxx + dist_libmedpartitioner_la_SOURCES+= MEDPARTITIONER_SCOTCHGraph.cxx endif -libmedsplitter_la_CPPFLAGS= $(MPI_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \ +libmedpartitioner_la_CPPFLAGS= $(MPI_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \ $(BOOST_CPPFLAGS) $(LIBXML_INCLUDES) \ -I$(srcdir)/../MEDMEM -I$(srcdir)/../MEDWrapper/V2_1/Core \ -I$(srcdir)/../INTERP_KERNEL/Bases -I$(srcdir)/../MEDCoupling \ -I$(srcdir)/../MEDLoader -I$(srcdir)/../INTERP_KERNEL -libmedsplitter_la_LDFLAGS= -#libmedsplitter_la_LDFLAGS= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) $(LIBXML_LIBS) \ +libmedpartitioner_la_LDFLAGS= +#libmedpartitioner_la_LDFLAGS= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) $(LIBXML_LIBS) \ # ../MEDMEM/libmedmem.la ../MEDWrapper/V2_1/Core/libmed_V2_1.la if MED_ENABLE_PARMETIS - libmedsplitter_la_CPPFLAGS+= $(PARMETIS_CPPFLAGS) - libmedsplitter_la_LDFLAGS+= $(PARMETIS_LIBS) + libmedpartitioner_la_CPPFLAGS+= $(PARMETIS_CPPFLAGS) + libmedpartitioner_la_LDFLAGS+= $(PARMETIS_LIBS) endif if MED_ENABLE_METIS - libmedsplitter_la_CPPFLAGS+= $(METIS_CPPFLAGS) - libmedsplitter_la_LDFLAGS+= $(METIS_LIBS) + libmedpartitioner_la_CPPFLAGS+= $(METIS_CPPFLAGS) + libmedpartitioner_la_LDFLAGS+= $(METIS_LIBS) endif if MED_ENABLE_SCOTCH - libmedsplitter_la_CPPFLAGS+= $(SCOTCH_CPPFLAGS) - libmedsplitter_la_LDFLAGS+= $(SCOTCH_LIBS) + libmedpartitioner_la_CPPFLAGS+= $(SCOTCH_CPPFLAGS) + libmedpartitioner_la_LDFLAGS+= $(SCOTCH_LIBS) endif if MED_ENABLE_KERNEL - libmedsplitter_la_CPPFLAGS+= ${KERNEL_CXXFLAGS} - libmedsplitter_la_LDFLAGS+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace + libmedpartitioner_la_CPPFLAGS+= ${KERNEL_CXXFLAGS} + libmedpartitioner_la_LDFLAGS+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace endif -libmedsplitter_la_LDFLAGS+= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) $(LIBXML_LIBS) $(MPI_LIBS) \ +libmedpartitioner_la_LDFLAGS+= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) $(LIBXML_LIBS) $(MPI_LIBS) \ ../MEDMEM/libmedmem.la ../INTERP_KERNEL/libinterpkernel.la ../MEDCoupling/libmedcoupling.la ../MEDLoader/libmedloader.la # Executables targets -bin_PROGRAMS= medsplitter +bin_PROGRAMS= medpartitioner -dist_medsplitter_SOURCES= medsplitter.cxx +dist_medpartitioner_SOURCES= medpartitioner.cxx -medsplitter_CPPFLAGS= $(libmedsplitter_la_CPPFLAGS) -medsplitter_LDADD= $(libmedsplitter_la_LDFLAGS) -lm $(BOOST_LIBS) libmedsplitter.la +medpartitioner_CPPFLAGS= $(libmedpartitioner_la_CPPFLAGS) +medpartitioner_LDADD= $(libmedpartitioner_la_LDFLAGS) -lm $(BOOST_LIBS) libmedpartitioner.la if MED_ENABLE_KERNEL - medsplitter_LDADD+= -lSALOMEBasics + medpartitioner_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) + bin_PROGRAMS+=medpartitioner_para + dist_medpartitioner_para_SOURCES= medpartitioner_para.cxx + medpartitioner_para_CPPFLAGS= $(medpartitioner_CPPFLAGS) + medpartitioner_para_LDADD= $(medpartitioner_LDADD) endif OBSOLETE_FILES = \ diff --git a/src/MEDPartitioner/medpartitioner.cxx b/src/MEDPartitioner/medpartitioner.cxx new file mode 100644 index 000000000..fa6c5de9c --- /dev/null +++ b/src/MEDPartitioner/medpartitioner.cxx @@ -0,0 +1,315 @@ +// Copyright (C) 2007-2010 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 medsplitter : tool to split n MED files into p separate +// MED files with a partitioning specified +// by an external tool +// File : medsplitter.cxx +// Author : Vincent BERGEAUD (CEA-DEN/DANS/DM2S/SFME/LGLS) +// Module : MED +// +#ifdef BOOST_PROGRAM_OPTIONS_LIB +#include +namespace po=boost::program_options; +#endif + +#include +#include +#include +#include +#include + +#include "MEDPARTITIONER_Graph.hxx" +#include "MEDPARTITIONER_MESHCollection.hxx" +#include "MEDPARTITIONER_Topology.hxx" + +using namespace std; + + + +int main(int argc, char** argv) +{ +#ifndef ENABLE_METIS +#ifndef 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 ENABLE_METIS +#ifdef 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 ENABLE_METIS +#ifdef 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 << "MEDPARTITIONER : 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 + MEDPARTITIONER::MESHCollection* collection; + cout << "MEDPARTITIONER - reading input files "<createPartition(ndomains,MEDPARTITIONER::Graph::METIS); + else + new_topo = collection->createPartition(ndomains,MEDPARTITIONER::Graph::SCOTCH); + + cout << "MEDPARTITIONER - creating new meshes"< + +#ifdef HAVE_MPI2 +#include +#endif + +#include + +#ifdef BOOST_PROGRAM_OPTIONS_LIB +#include +namespace po=boost::program_options; +#endif + +using namespace std; + + + +int main(int argc, char** argv) +{ +#ifndef 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 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 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 << "MEDPARTITIONER : 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 << "MEDPARTITIONER - reading input files "< -namespace po=boost::program_options; -#endif - -#include -#include - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDPARTITIONER_Graph.hxx" -#include "MEDPARTITIONER_MESHCollection.hxx" -#include "MEDPARTITIONER_Topology.hxx" - -using namespace std; - - - -int main(int argc, char** argv) -{ -#ifndef ENABLE_METIS -#ifndef 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 ENABLE_METIS -#ifdef 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 ENABLE_METIS -#ifdef 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 << "MEDPARTITIONER : 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 - MEDPARTITIONER::MESHCollection* collection; - cout << "MEDPARTITIONER - reading input files "<createPartition(ndomains,MEDPARTITIONER::Graph::METIS); - else - new_topo = collection->createPartition(ndomains,MEDPARTITIONER::Graph::SCOTCH); - - cout << "MEDPARTITIONER - creating new meshes"< - -#ifdef HAVE_MPI2 -#include -#endif - -#include - -#ifdef BOOST_PROGRAM_OPTIONS_LIB -#include -namespace po=boost::program_options; -#endif - -using namespace std; - - - -int main(int argc, char** argv) -{ -#ifndef 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 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 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 << "MEDPARTITIONER : 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 << "MEDPARTITIONER - reading input files "<