MOAB: Mesh Oriented datABase  (version 5.2.1)
MetisPartitioner.hpp
Go to the documentation of this file.
00001 /**
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  *
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007  * retains certain rights in this software.
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  */
00015 
00016 // Contributed by Lorenzo Alessio Botti (SpaFEDTe)
00017 // This implementation is mostly borrowed from the mbzoltan MOAB partitioning tool
00018 
00019 #ifndef __metispartitioner_hpp__
00020 #define __metispartitioner_hpp__
00021 
00022 #include <stdlib.h>
00023 #include "moab/PartitionerBase.hpp"
00024 #include "metis.h"
00025 
00026 namespace moab
00027 {
00028 
00029 class Interface;
00030 class Range;
00031 }  // namespace moab
00032 
00033 using namespace moab;
00034 
00035 class MetisPartitioner : public PartitionerBase< idx_t >
00036 {
00037 
00038   public:
00039     MetisPartitioner( Interface* impl = NULL, const bool use_coords = false );
00040 
00041     virtual ~MetisPartitioner();
00042 
00043     virtual ErrorCode partition_mesh_and_geometry( const double part_geom_mesh_size, const idx_t nparts,
00044                                                    const char* zmethod, const char* other_method, double imbal_tol,
00045                                                    const int part_dim = 3, const bool write_as_sets = true,
00046                                                    const bool write_as_tags = false, const int obj_weight = 0,
00047                                                    const int edge_weight = 0, const bool part_surf = false,
00048                                                    const bool ghost = false, const int projection_type = 0, const bool recompute_rcb_box = false,
00049                                                    const bool print_time = false );
00050 
00051     virtual ErrorCode partition_mesh( const idx_t nparts, const char* method, const int part_dim = 3,
00052                                       const bool write_as_sets = true, const bool write_as_tags = false,
00053                                       const bool partition_tagged_sets = false,
00054                                       const bool partition_tagged_ents = false, const char* aggregating_tag = NULL,
00055                                       const bool print_time = false );
00056 
00057     virtual ErrorCode write_partition( const idx_t nparts, Range& elems, const idx_t* assignment,
00058                                        const bool write_as_sets, const bool write_as_tags );
00059 
00060     ErrorCode write_aggregationtag_partition( const idx_t nparts, Range& elems, const idx_t* assignment,
00061                                               const bool write_as_sets, const bool write_as_tags );
00062 
00063     // put closure of entities in the part sets too
00064     virtual ErrorCode include_closure();
00065 
00066     // virtual ErrorCode write_file(const char *filename, const char *out_file);
00067 
00068   private:
00069     ErrorCode assemble_graph( const int dimension, std::vector< double >& coords, std::vector< idx_t >& moab_ids,
00070                               std::vector< idx_t >& adjacencies, std::vector< idx_t >& length, Range& elems );
00071 
00072     ErrorCode assemble_taggedsets_graph( const int dimension, std::vector< double >& coords,
00073                                          std::vector< idx_t >& moab_ids, std::vector< idx_t >& adjacencies,
00074                                          std::vector< idx_t >& length, Range& elems, const char* aggregating_tag );
00075 
00076     ErrorCode assemble_taggedents_graph( const int dimension, std::vector< double >& coords,
00077                                          std::vector< idx_t >& moab_ids, std::vector< idx_t >& adjacencies,
00078                                          std::vector< idx_t >& length, Range& elems, const char* aggregating_tag );
00079 };
00080 
00081 // Inline functions
00082 
00083 inline ErrorCode MetisPartitioner::partition_mesh_and_geometry( const double, const idx_t nparts, const char* zmethod,
00084                                                                 const char*, double, const int part_dim,
00085                                                                 const bool write_as_sets, const bool write_as_tags,
00086                                                                 const int, const int, const bool, const bool,
00087                                                                 const int, const bool, const bool print_time )
00088 {
00089     // Only partition the mesh - no geometric partition available
00090     return partition_mesh( nparts, zmethod, part_dim, write_as_sets, write_as_tags, false, false, NULL, print_time );
00091 }
00092 
00093 inline ErrorCode MetisPartitioner::include_closure()
00094 {
00095     return MB_NOT_IMPLEMENTED;
00096 }
00097 
00098 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines