00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __PARTITION_H
00034 #define __PARTITION_H
00035
00036 #include <stdlib.h>
00037 #include <math.h>
00038 #include <string>
00039
00040 #include <iostream>
00041 using std::cout;
00042 using std::ostream;
00043 using std::endl;
00044
00045 #include <iomanip>
00046 using std::setw;
00047
00048 #include "OFELI_Config.h"
00049 #include "Mesh.h"
00050 #include "output.h"
00051
00052 #define WITH_METIS
00053
00054 #ifdef WITH_METIS
00055 #ifdef __cplusplus
00056 extern "C"
00057 {
00058 #include "metis.h"
00059 }
00060 #endif
00061 #endif
00062
00063
00064 namespace OFELI {
00065
00066 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00067 struct ErrorInPartition {
00068 void Message(const char *file, size_t line, int code, int p1=0, int p2=0);
00069 };
00070 #endif
00071
00083 class Partition
00084 {
00085
00086 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00087 typedef struct { size_t side1, sd, side; } Interface;
00088 #endif
00089
00090 public:
00091
00092
00093
00096 Partition(Mesh &mesh, char *file);
00097
00099 Partition(Mesh &mesh, size_t n);
00100
00102 ~Partition();
00103
00104
00105
00107 size_t getNbSubMeshes() const { return _nb_submesh; }
00108
00110 size_t getNbNodes(size_t i) const { return _theSubMesh[i]->getNbNodes(); }
00111
00113 size_t getNbElements(size_t i) const { return _theSubMesh[i]->getNbElements(); }
00114
00116 Mesh &getMesh(size_t i) const { return *_theSubMesh[i]; }
00117
00119 size_t getNodeLabelInSubMesh(size_t sm, size_t label) const { return _m2sm_node[sm][label-1]; }
00120
00122 size_t getElementLabelInSubMesh(size_t sm, size_t label) const { return _m2sm_element[sm][label-1]; }
00123
00125 size_t getNodeLabelInMesh(size_t sm, size_t label) const { return _sm2m_node[sm][label-1]; }
00126
00128 size_t getElementLabelInMesh(size_t sm, size_t label) const { return _sm2m_element[sm][label-1]; }
00129
00131 size_t getNbInterfaceSides(size_t sm) const { return _nb_interface_sides[sm]; }
00132
00134 size_t getFirstSideLabel(size_t sm, size_t i) const { return _interface_side[sm][i-1].side1; }
00135
00137 size_t getSubMesh(size_t sm, size_t i) const { return _interface_side[sm][i-1].sd; }
00138
00140 size_t getSecondSideLabel(size_t sm, size_t i) const { return _interface_side[sm][i-1].side; }
00141
00143 void setVerbose(size_t verb) { _verbose = verb; }
00144
00146 void Put(size_t n, char *file) const { _theSubMesh[n]->Put(file); }
00147
00149 void BPut(size_t n, char *file) const { _theSubMesh[n]->BPut(file); }
00150
00151
00152
00154 void Init(int *epart);
00155
00156
00157
00159 friend ostream & operator<<(ostream& s, const Partition &p);
00160
00161 protected:
00162 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00163 int _nb_submesh, _verbose;
00164 #endif
00165
00166 private:
00167 Mesh *_theMesh, *_theSubMesh[MAX_NB_SUBMESHES];
00168 vector<size_t> _nb_interface_sides;
00169 size_t _max_nb_meshes;
00170 size_t **_sm2m_node, **_m2sm_node, **_sm2m_element, **_m2sm_element;
00171 Interface **_interface_side;
00172 bool EqualSides(size_t sm1, const Side *sd1, size_t sm2, const Side *sd2);
00173 ErrorInPartition _e;
00174 };
00175
00176 }
00177
00178 #endif