1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfPartitioner.hpp */
/* */
/* Author: */
/* Kenneth Leiter */
/* kenneth.leiter@arl.army.mil */
/* US Army Research Laboratory */
/* Aberdeen Proving Ground, MD */
/* */
/* Copyright @ 2011 US Army Research Laboratory */
/* All Rights Reserved */
/* See Copyright.txt for details */
/* */
/* This software is distributed WITHOUT ANY WARRANTY; without */
/* even the implied warranty of MERCHANTABILITY or FITNESS */
/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
/* for more information. */
/* */
/*****************************************************************************/
#ifndef XDMFPARTITIONER_HPP_
#define XDMFPARTITIONER_HPP_
#ifdef __cplusplus
// Forward Declarations
class XdmfGraph;
class XdmfGridCollection;
class XdmfHeavyDataWriter;
class XdmfSet;
class XdmfUnstructuredGrid;
// Includes
#include <set>
#include "XdmfUtils.hpp"
#include "XdmfSharedPtr.hpp"
/**
* @brief XdmfPartitioner partitions an XdmfGrid using the metis
* library.
*
* XdmfPartitioner uses the metis library to partition XdmfGrids.
*/
class XDMFUTILS_EXPORT XdmfPartitioner {
public:
enum MetisScheme {
DUAL_GRAPH = 0,
NODAL_GRAPH = 1
};
/**
* Create a new XdmfPartitioner.
*
* @return constructed XdmfPartitioner.
*/
static shared_ptr<XdmfPartitioner> New();
virtual ~XdmfPartitioner();
/**
* Ignore set when partitioning. Set is not partitioned or added to
* resulting grid.
*
* @param set the set to ignore when partitioning.
*/
void ignore(const shared_ptr<const XdmfSet> set);
void ignore(const XdmfSet *);
/**
* Partitions an XdmfGraph using the metis library. An attribute
* named "Partition" is added to the XdmfGraph that contains
* partition numbers for each graph vertex.
*
* @param graphToPartition an XdmfGraph to partition.
* @param numberOfPartitions the number of pieces to partition the
* graph into.
*/
void
partition(const shared_ptr<XdmfGraph> graphToPartition,
const unsigned int numberOfPartitions) const;
/**
* Partitions an XdmfUnstructuredGrid using the metis library.
*
* The partitioner splits the XdmfGridUnstructured and all attached
* XdmfAttributes and XdmfSets into their proper partition. An
* XdmfAttribute named "GlobalNodeId" is added to each partitioned
* grid to map partitioned node ids to their original unpartitioned
* id. An XdmfMap is added to each partitioned grid mapping shared
* nodes to other processors. All arrays attached to the passed
* gridToPartition are read from disk if not initialized.
*
* @param gridToPartition an XdmfGridUnstructured to partition.
* @param numberOfPartitions the number of pieces to partition the grid into.
* @param heavyDataWriter an XdmfHDF5Writer to write the partitioned mesh to.
* If no heavyDataWriter is specified, all partitioned data will remain in
* memory.
*
* @return a spatial collection containing partitioned grids.
*/
shared_ptr<XdmfGridCollection>
partition(const shared_ptr<XdmfUnstructuredGrid> gridToPartition,
const unsigned int numberOfPartitions,
const MetisScheme metisScheme = DUAL_GRAPH,
const shared_ptr<XdmfHeavyDataWriter> heavyDataWriter = shared_ptr<XdmfHeavyDataWriter>()) const;
/**
* Unpartitions an XdmfGridCollection of unstructured grids into a single
* XdmfUnstructuredGrid.
*
* @param gridToPartition an XdmfGridUnstructured to partition.
*
* @return a unstructured grid containing the unpartitioned grid.
*/
shared_ptr<XdmfUnstructuredGrid>
unpartition(const shared_ptr<XdmfGridCollection> gridToUnPartition) const;
XdmfPartitioner(const XdmfPartitioner & partitioner);
protected:
XdmfPartitioner();
private:
void operator=(const XdmfPartitioner & partitioner); // Not implemented.
std::set<const XdmfSet * > mIgnoredSets;
};
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define XDMF_PARTITIONER_SCHEME_DUAL_GRAPH 500
#define XDMF_PARTITIONER_SCHEME_NODAL_GRAPH 501
// C wrappers go here
struct XDMFPARTITIONER; // Simply as a typedef to ensure correct typing
typedef struct XDMFPARTITIONER XDMFPARTITIONER;
XDMFUTILS_EXPORT XDMFPARTITIONER * XdmfPartitionerNew();
XDMFUTILS_EXPORT void XdmfPartitionerIgnore(XDMFPARTITIONER * partitioner,
XDMFSET * set);
XDMFUTILS_EXPORT void XdmfPartitionerPartitionGraph(XDMFPARTITIONER * partitioner,
XDMFGRAPH * graphToPartition,
unsigned int numberOfPartitions);
XDMFUTILS_EXPORT XDMFGRIDCOLLECTION * XdmfPartitionerPartitionUnstructuredGrid(XDMFPARTITIONER * partitioner,
XDMFUNSTRUCTUREDGRID * gridToPartition,
unsigned int numberOfPartitions,
int metisScheme,
XDMFHEAVYDATAWRITER * heavyDataWriter);
XDMFUTILS_EXPORT XDMFUNSTRUCTUREDGRID * XdmfPartitionerUnpartition(XDMFPARTITIONER * partitioner,
XDMFGRIDCOLLECTION * gridToUnPartition);
XDMFUTILS_EXPORT void XdmfPartitionerFree(XDMFPARTITIONER * partitioner);
#ifdef __cplusplus
}
#endif
#endif /* XDMFPARTITIONER_HPP_ */
|