Mesh Oriented datABase  (version 5.5.1)
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 int projection_type = 0,
54  const bool recompute_rcb_box = false,
55  const bool print_time = false );
56 
57  virtual ErrorCode partition_mesh( const idx_t nparts,
58  const char* method,
59  const int part_dim = 3,
60  const bool write_as_sets = true,
61  const bool write_as_tags = false,
62  const bool partition_tagged_sets = false,
63  const bool partition_tagged_ents = false,
64  const char* aggregating_tag = NULL,
65  const bool print_time = false );
66 
67  virtual ErrorCode write_partition( const idx_t nparts,
68  Range& elems,
69  const idx_t* assignment,
70  const bool write_as_sets,
71  const bool write_as_tags );
72 
73  ErrorCode write_aggregationtag_partition( const idx_t nparts,
74  Range& elems,
75  const idx_t* assignment,
76  const bool write_as_sets,
77  const bool write_as_tags );
78 
79  // put closure of entities in the part sets too
80  virtual ErrorCode include_closure();
81 
82  // virtual ErrorCode write_file(const char *filename, const char *out_file);
83 
84  private:
85  ErrorCode assemble_graph( const int dimension,
86  std::vector< double >& coords,
87  std::vector< idx_t >& moab_ids,
88  std::vector< idx_t >& adjacencies,
89  std::vector< idx_t >& length,
90  Range& elems );
91 
92  ErrorCode assemble_taggedsets_graph( const int dimension,
93  std::vector< double >& coords,
94  std::vector< idx_t >& moab_ids,
95  std::vector< idx_t >& adjacencies,
96  std::vector< idx_t >& length,
97  Range& elems,
98  const char* aggregating_tag );
99 
100  ErrorCode assemble_taggedents_graph( const int dimension,
101  std::vector< double >& coords,
102  std::vector< idx_t >& moab_ids,
103  std::vector< idx_t >& adjacencies,
104  std::vector< idx_t >& length,
105  Range& elems,
106  const char* aggregating_tag );
107 };
108 
109 // Inline functions
110 
112  const idx_t nparts,
113  const char* zmethod,
114  const char*,
115  double,
116  const int part_dim,
117  const bool write_as_sets,
118  const bool write_as_tags,
119  const int,
120  const int,
121  const int,
122  const bool,
123  const bool print_time )
124 {
125  // Only partition the mesh - no geometric partition available
126  return partition_mesh( nparts, zmethod, part_dim, write_as_sets, write_as_tags, false, false, NULL, print_time );
127 }
128 
130 {
131  return MB_NOT_IMPLEMENTED;
132 }
133 
134 #endif