~ubuntu-branches/ubuntu/saucy/rheolef/saucy

« back to all changes in this revision

Viewing changes to nfem/plib/geo_mpi_partition_scotch.cc

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Saramito
  • Date: 2011-03-23 11:14:26 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110323111426-cjvhey7lxt6077ty
Tags: 5.93-1
* New upstream release (minor changes):
  - some extra warning message deleted in heap_allocator
  - graphic output with mayavi2 fixed
  - add doc refman in .info and .pdf format

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
///
 
2
/// This file is part of Rheolef.
 
3
///
 
4
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
 
5
///
 
6
/// Rheolef is free software; you can redistribute it and/or modify
 
7
/// it under the terms of the GNU General Public License as published by
 
8
/// the Free Software Foundation; either version 2 of the License, or
 
9
/// (at your option) any later version.
 
10
///
 
11
/// Rheolef is distributed in the hope that it will be useful,
 
12
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
/// GNU General Public License for more details.
 
15
///
 
16
/// You should have received a copy of the GNU General Public License
 
17
/// along with Rheolef; if not, write to the Free Software
 
18
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
/// 
 
20
/// =========================================================================
 
21
#include "rheolef/config.h"
 
22
#ifdef _RHEOLEF_HAVE_MPI
 
23
// mesh partition 
 
24
#include "rheolef/distributed.h"
 
25
 
 
26
#include "geo_partition_scotch.h"
 
27
 
 
28
namespace rheolef {
 
29
using namespace std;
 
30
 
 
31
void geo_dual (
 
32
        my_idxtype *elmdist,
 
33
        my_idxtype *eptr,
 
34
        vector<my_idxtype>& eind, 
 
35
        int *ncommonnodes,
 
36
        vector<my_idxtype>& xadj, 
 
37
        vector<my_idxtype>& adjncy, 
 
38
        const mpi::communicator& comm);
 
39
 
 
40
extern "C" {
 
41
void ParMETIS_V3_PartKway (const int * const, int * const, int * const, int * const, int * const, const int * const, const int * const, const int * const, const int * const, const float * const, const float * const, const int * const, int * const, int * const, MPI_Comm * const);
 
42
}
 
43
// -------------------------------------------------------------------------------------
 
44
// This function is the entry point of the distributed k-way multilevel mesh partitionioner
 
45
// This function assumes nothing about the mesh distribution.
 
46
// It is the general case.
 
47
// -------------------------------------------------------------------------------------
 
48
void geo_partition_scotch (
 
49
        my_idxtype *elmdist,
 
50
        my_idxtype *eptr, 
 
51
        vector<my_idxtype>& eind,
 
52
        my_idxtype *elmwgt, 
 
53
        int *ncon,
 
54
        int *ncommonnodes,
 
55
        int *nparts, 
 
56
        float *tpwgts,
 
57
        float *ubvec,
 
58
        int *edgecut,
 
59
        my_idxtype *part, 
 
60
        const mpi::communicator& comm)
 
61
{
 
62
  if (eind.size() == 0) {
 
63
    error_macro ("empty sizes not supported");
 
64
  }
 
65
  // Try and take care bad inputs
 
66
  if (elmdist == NULL || eptr == NULL ||
 
67
      ncon == NULL || ncommonnodes == NULL || nparts == NULL ||
 
68
      tpwgts == NULL || ubvec == NULL || edgecut == NULL || 
 
69
      part == NULL) {
 
70
    error_macro ("one or more required parameters is NULL");
 
71
  }
 
72
  comm.barrier();
 
73
 
 
74
  vector<my_idxtype> xadj;
 
75
  vector<my_idxtype> adjncy;
 
76
  geo_dual (
 
77
        elmdist,
 
78
        eptr,
 
79
        eind,
 
80
        ncommonnodes,
 
81
        xadj,
 
82
        adjncy,
 
83
        comm);
 
84
 
 
85
  comm.barrier();
 
86
 
 
87
  // Partition the graph
 
88
  MPI_Comm raw_comm = comm;
 
89
  int options[10];
 
90
  options[0] = 1;
 
91
  options[PMV3_OPTION_DBGLVL] = 0; // otherwise: timming print to stdout...
 
92
  options[PMV3_OPTION_SEED] = 0;
 
93
  int numflag = 0;
 
94
  int wgtflag = 0;
 
95
  ParMETIS_V3_PartKway(
 
96
        elmdist, 
 
97
        xadj.begin().operator->(),
 
98
        adjncy.begin().operator->(),
 
99
        elmwgt, 
 
100
        NULL, 
 
101
        &wgtflag, 
 
102
        &numflag, 
 
103
        ncon, 
 
104
        nparts,
 
105
        tpwgts,
 
106
        ubvec,
 
107
        options,
 
108
        edgecut,
 
109
        part,
 
110
        &raw_comm);
 
111
 
 
112
  comm.barrier();
 
113
}
 
114
 
 
115
} // namespace rheolef
 
116
#endif // _RHEOLEF_HAVE_MPI