Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
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 <cstdlib> 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, 00044 const idx_t nparts, 00045 const char* zmethod, 00046 const char* other_method, 00047 double imbal_tol, 00048 const int part_dim = 3, 00049 const bool write_as_sets = true, 00050 const bool write_as_tags = false, 00051 const int obj_weight = 0, 00052 const int edge_weight = 0, 00053 const bool part_surf = false, 00054 const bool ghost = false, 00055 const int projection_type = 0, 00056 const bool recompute_rcb_box = false, 00057 const bool print_time = false ); 00058 00059 virtual ErrorCode partition_mesh( const idx_t nparts, 00060 const char* method, 00061 const int part_dim = 3, 00062 const bool write_as_sets = true, 00063 const bool write_as_tags = false, 00064 const bool partition_tagged_sets = false, 00065 const bool partition_tagged_ents = false, 00066 const char* aggregating_tag = NULL, 00067 const bool print_time = false ); 00068 00069 virtual ErrorCode write_partition( const idx_t nparts, 00070 Range& elems, 00071 const idx_t* assignment, 00072 const bool write_as_sets, 00073 const bool write_as_tags ); 00074 00075 ErrorCode write_aggregationtag_partition( const idx_t nparts, 00076 Range& elems, 00077 const idx_t* assignment, 00078 const bool write_as_sets, 00079 const bool write_as_tags ); 00080 00081 // put closure of entities in the part sets too 00082 virtual ErrorCode include_closure(); 00083 00084 // virtual ErrorCode write_file(const char *filename, const char *out_file); 00085 00086 private: 00087 ErrorCode assemble_graph( const int dimension, 00088 std::vector< double >& coords, 00089 std::vector< idx_t >& moab_ids, 00090 std::vector< idx_t >& adjacencies, 00091 std::vector< idx_t >& length, 00092 Range& elems ); 00093 00094 ErrorCode assemble_taggedsets_graph( const int dimension, 00095 std::vector< double >& coords, 00096 std::vector< idx_t >& moab_ids, 00097 std::vector< idx_t >& adjacencies, 00098 std::vector< idx_t >& length, 00099 Range& elems, 00100 const char* aggregating_tag ); 00101 00102 ErrorCode assemble_taggedents_graph( const int dimension, 00103 std::vector< double >& coords, 00104 std::vector< idx_t >& moab_ids, 00105 std::vector< idx_t >& adjacencies, 00106 std::vector< idx_t >& length, 00107 Range& elems, 00108 const char* aggregating_tag ); 00109 }; 00110 00111 // Inline functions 00112 00113 inline ErrorCode MetisPartitioner::partition_mesh_and_geometry( const double, 00114 const idx_t nparts, 00115 const char* zmethod, 00116 const char*, 00117 double, 00118 const int part_dim, 00119 const bool write_as_sets, 00120 const bool write_as_tags, 00121 const int, 00122 const int, 00123 const bool, 00124 const bool, 00125 const int, 00126 const bool, 00127 const bool print_time ) 00128 { 00129 // Only partition the mesh - no geometric partition available 00130 return partition_mesh( nparts, zmethod, part_dim, write_as_sets, write_as_tags, false, false, NULL, print_time ); 00131 } 00132 00133 inline ErrorCode MetisPartitioner::include_closure() 00134 { 00135 return MB_NOT_IMPLEMENTED; 00136 } 00137 00138 #endif