00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __MEDSPLITTER_MESHCOLLECTION_HXX__
00020 #define __MEDSPLITTER_MESHCOLLECTION_HXX__
00021
00022 #include "MEDSPLITTER.hxx"
00023
00024 #include "MEDSPLITTER_Graph.hxx"
00025 #include "MEDSPLITTER_FaceModel.hxx"
00026 #include "boost/shared_ptr.hpp"
00027 #include <vector>
00028 #include <map>
00029
00030
00031 namespace MEDMEM
00032 {
00033 class MESH;
00034 class CONNECTZONE;
00035 class MEDSKYLINEARAY;
00036 class SUPPORT;
00037 }
00038
00039 namespace MEDSPLITTER
00040 {
00041
00042 class Topology;
00043 class MESHCollectionDriver;
00044 class ParaDomainSelector;
00045
00046 typedef enum{MedAscii, MedXML, Undefined} DriverType;
00047
00048 class MEDSPLITTER_EXPORT MESHCollection
00049 {
00050
00051 public:
00052
00053
00054 MESHCollection();
00055
00056
00057 MESHCollection(const MESHCollection&, Topology*, bool family_splitting=false, bool create_empty_groups=false);
00058
00059
00060 MESHCollection(const std::string& filename);
00061
00062
00063 MESHCollection(const std::string& filename, ParaDomainSelector& domainSelector);
00064
00065
00066 MESHCollection(const std::string& filename, const std::string& meshname);
00067
00068 ~MESHCollection();
00069
00070 bool isParallelMode() const { return _domain_selector; }
00071
00072
00073 void write(const std::string& filename);
00074
00075
00076 MESHCollectionDriver* retrieveDriver();
00077 MESHCollectionDriver* getDriver() const;
00078 void setDriverType(MEDSPLITTER::DriverType type) {_driver_type=type;}
00079
00080
00081 void buildCellGraph(MEDMEM::MEDSKYLINEARRAY* & array,int *& edgeweights );
00082
00083
00084 Topology* createPartition(int nbdomain, Graph::splitter_type type = Graph::METIS,
00085 const string& ="", int* edgeweights=0, int* verticesweights=0);
00086
00087
00088 Topology* createPartition(const int* partition);
00089
00090
00091 void getTypeList(int* cell_list,int nb_cells,MED_EN::medEntityMesh entity,
00092 MED_EN::medGeometryElement* type_list) const ;
00093
00094
00095 void getCoordinates(int* node_list,int nb_nodes, double* coordinates) const ;
00096
00097
00098 void getNodeConnectivity( const int* cell_list,int nb_cells,MED_EN::medEntityMesh,MED_EN::medGeometryElement type, int* type_connectivity) const ;
00099 void getPolygonNodeConnectivity(const int* cell_list,int nb_cells,MED_EN::medEntityMesh entity,
00100 vector<int>& type_connectivity, vector<int>& connectivity_index) const;
00101 void getPolyhedraNodeConnectivity(const int* cell_list,int nb_cells,MED_EN::medEntityMesh entity,
00102 vector<int>& type_connectivity, vector<int>& connectivity_index) const;
00103
00104 void getFaceConnectivity( const int* cell_list,int nb_cells,MED_EN::medEntityMesh,MED_EN::medGeometryElement type, int* type_connectivity) const ;
00105
00106
00107
00108
00109 int getMeshDimension() const ;
00110
00111
00112 int getSpaceDimension() const ;
00113
00114
00115 std::string getSystem() const;
00116
00117
00118 std::string getMeshName() const;
00119
00120
00121 MED_EN::medEntityMesh getSubEntity() const;
00122
00123
00124 std::vector<MEDMEM::MESH*>& getMesh() ;
00125
00126
00127 MEDMEM::MESH* getMesh(int) const;
00128
00129
00130 std::vector<MEDMEM::CONNECTZONE*>& getCZ();
00131
00132
00133 Topology* getTopology() const ;
00134
00135
00136
00137 void setTopology(Topology* topology);
00138
00139
00140
00141 string getName() const {return _name;}
00142 void setName(const string& name) {_name=name;}
00143
00144
00145 string getDescription() const {return _description;}
00146 void setDescription(const string& name) { _description=name;}
00147
00149 void castFamilies(const MESHCollection& old_collection);
00150
00151 void castSupport(const MESHCollection& old_collection, std::vector<const MEDMEM::SUPPORT*>& old_support, std::vector<MEDMEM::SUPPORT*>& new_support);
00152
00154 void castAllFields(const MESHCollection& old_collection);
00155
00157 void castField(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber);
00158
00159
00160 void setIndivisibleGroup(const string& a);
00161
00163
00164 void buildConnectZones();
00165 void buildConnectZonesBetweenProcs(std::vector <std::map <MED_EN::medGeometryElement, std::vector<MEDSPLITTER_FaceModel*> > > &, map< pair<int,int>, MEDMEM::MEDSKYLINEARRAY*> & local_cell_cell_correspondency);
00166
00167 void addJointGroup(const std::vector<int>&, int idomain, int idistant);
00168
00169 static bool isDimensionOK(MED_EN::medGeometryElement type, int dim)
00170 {
00171 return ((type/100 == dim) || (dim==2 && type == MED_EN::MED_POLYGON) || (dim==3 && type == MED_EN::MED_POLYHEDRA));
00172 }
00173 void setSubdomainBoundaryCreates(bool flag) { _subdomain_boundary_creates=flag;}
00174 bool getSubdomainBoundaryCreates(){return _subdomain_boundary_creates;}
00175
00176 void setFamilySplitting(bool flag){_family_splitting=flag;}
00177 bool getFamilySplitting(){return _family_splitting;}
00178
00179 void setCreateEmptyGroups(bool flag){_create_empty_groups=flag;}
00180 bool getCreateEmptyGroups(){return _create_empty_groups;}
00181
00182
00183 private:
00184
00186 void createNodalConnectivity(const MESHCollection & initial_collection, int idomain, MED_EN::medEntityMesh entity);
00187
00189 void treatIndivisibleRegions(int* tag);
00190
00193 template <class T>
00194 void castFields(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber);
00195
00196 void getFaces(int idomain, std::map<MED_EN::medGeometryElement, std::vector<MEDSPLITTER_FaceModel*> >&);
00197
00198 MEDSPLITTER_FaceModel* getCommonFace(int ip1,int ilocal1,int ip2,int ilocal2,int face_index);
00199
00200 template<class TID2CONN>
00201 void fillGlobalConnectivity(TID2CONN & node2cell, TID2CONN & cell2node );
00202
00204 Topology* _topology;
00205
00207 bool _owns_topology;
00208
00210 boost::shared_ptr<Graph> _cell_graph;
00211
00213 MESHCollectionDriver* _driver;
00214
00216 ParaDomainSelector* _domain_selector;
00217
00219 std::vector<MEDMEM::MESH*> _mesh;
00220
00222 int _i_non_empty_mesh;
00223
00225 std::vector<MEDMEM::CONNECTZONE*> _connect_zones;
00226
00228 std::vector<std::string> _indivisible_regions;
00229
00231 string _name;
00232
00234 string _description;
00235
00237 DriverType _driver_type;
00238
00241 bool _subdomain_boundary_creates;
00242
00245 bool _family_splitting;
00246
00249 bool _create_empty_groups;
00250 };
00251
00252 }
00253
00254 #endif