Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
MetisPartitioner.hpp
Go to the documentation of this file.
1 /**
2  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
3  * storing and accessing finite element mesh data.
4  *
5  * Copyright 2004 Sandia Corporation. Under the terms of Contract
6  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7  * retains certain rights in this software.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  */
15 
16 // Contributed by Lorenzo Alessio Botti (SpaFEDTe)
17 // This implementation is mostly borrowed from the mbzoltan MOAB partitioning tool
18 
19 #ifndef __metispartitioner_hpp__
20 #define __metispartitioner_hpp__
21 
22 #include <cstdlib>
23 #include "moab/PartitionerBase.hpp"
24 #include "metis.h"
25 
26 namespace moab
27 {
28 
29 class Interface;
30 class Range;
31 } // namespace moab
32 
33 using namespace moab;
34 
35 class MetisPartitioner : public PartitionerBase< idx_t >
36 {
37 
38  public:
39  MetisPartitioner( Interface* impl = NULL, const bool use_coords = false );
40 
41  virtual ~MetisPartitioner();
42 
43  virtual ErrorCode partition_mesh_and_geometry( const double part_geom_mesh_size,
44  const idx_t nparts,
45  const char* zmethod,
46  const char* other_method,
47  double imbal_tol,
48  const int part_dim = 3,
49  const bool write_as_sets = true,
50  const bool write_as_tags = false,
51  const int obj_weight = 0,
52  const int edge_weight = 0,
53  const bool part_surf = false,
54  const bool ghost = false,
55  const int projection_type = 0,
56  const bool recompute_rcb_box = false,
57  const bool print_time = false );
58 
59  virtual ErrorCode partition_mesh( const idx_t nparts,
60  const char* method,
61  const int part_dim = 3,
62  const bool write_as_sets = true,
63  const bool write_as_tags = false,
64  const bool partition_tagged_sets = false,
65  const bool partition_tagged_ents = false,
66  const char* aggregating_tag = NULL,
67  const bool print_time = false );
68 
69  virtual ErrorCode write_partition( const idx_t nparts,
70  Range& elems,
71  const idx_t* assignment,
72  const bool write_as_sets,
73  const bool write_as_tags );
74 
75  ErrorCode write_aggregationtag_partition( const idx_t nparts,
76  Range& elems,
77  const idx_t* assignment,
78  const bool write_as_sets,
79  const bool write_as_tags );
80 
81  // put closure of entities in the part sets too
82  virtual ErrorCode include_closure();
83 
84  // virtual ErrorCode write_file(const char *filename, const char *out_file);
85 
86  private:
87  ErrorCode assemble_graph( const int dimension,
88  std::vector< double >& coords,
89  std::vector< idx_t >& moab_ids,
90  std::vector< idx_t >& adjacencies,
91  std::vector< idx_t >& length,
92  Range& elems );
93 
94  ErrorCode assemble_taggedsets_graph( const int dimension,
95  std::vector< double >& coords,
96  std::vector< idx_t >& moab_ids,
97  std::vector< idx_t >& adjacencies,
98  std::vector< idx_t >& length,
99  Range& elems,
100  const char* aggregating_tag );
101 
102  ErrorCode assemble_taggedents_graph( const int dimension,
103  std::vector< double >& coords,
104  std::vector< idx_t >& moab_ids,
105  std::vector< idx_t >& adjacencies,
106  std::vector< idx_t >& length,
107  Range& elems,
108  const char* aggregating_tag );
109 };
110 
111 // Inline functions
112 
114  const idx_t nparts,
115  const char* zmethod,
116  const char*,
117  double,
118  const int part_dim,
119  const bool write_as_sets,
120  const bool write_as_tags,
121  const int,
122  const int,
123  const bool,
124  const bool,
125  const int,
126  const bool,
127  const bool print_time )
128 {
129  // Only partition the mesh - no geometric partition available
130  return partition_mesh( nparts, zmethod, part_dim, write_as_sets, write_as_tags, false, false, NULL, print_time );
131 }
132 
134 {
135  return MB_NOT_IMPLEMENTED;
136 }
137 
138 #endif