Back to index

salome-med  6.5.0
MEDSPLITTER_MESHCollection.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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     //Default constructor
00054     MESHCollection();
00055 
00056     //Constructing from an existing mesh and a new topology
00057     MESHCollection(const MESHCollection&, Topology*, bool family_splitting=false, bool create_empty_groups=false);
00058 
00059     //Constructing the mesh collection from a file
00060     MESHCollection(const std::string& filename);
00061 
00062     //Constructing the mesh collection from a file
00063     MESHCollection(const std::string& filename, ParaDomainSelector& domainSelector);
00064 
00065     //Constructing the mesh collection from a file
00066     MESHCollection(const std::string& filename, const std::string& meshname);
00067 
00068     ~MESHCollection();
00069         
00070     bool isParallelMode() const { return _domain_selector; }
00071         
00072     //writing to a distributed file
00073     void write(const std::string& filename);
00074 
00075     //getting the driver
00076     MESHCollectionDriver* retrieveDriver();
00077     MESHCollectionDriver* getDriver() const;
00078     void setDriverType(MEDSPLITTER::DriverType type) {_driver_type=type;}
00079 
00080     //creation of the cell graph
00081     void buildCellGraph(MEDMEM::MEDSKYLINEARRAY* & array,int *& edgeweights );
00082 
00083     //creation and partition of the associated graph
00084     Topology* createPartition(int nbdomain, Graph::splitter_type type = Graph::METIS,
00085                               const string& ="", int* edgeweights=0, int* verticesweights=0);
00086 
00087     //creation of a user specified partition
00088     Topology* createPartition(const int* partition);
00089 
00090     //retrieving list of types
00091     void getTypeList(int* cell_list,int nb_cells,MED_EN::medEntityMesh entity,
00092                      MED_EN::medGeometryElement* type_list) const ;
00093 
00094     //getting list of coordinates
00095     void getCoordinates(int* node_list,int nb_nodes, double* coordinates) const ;
00096 
00097     //getting connectivities
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/*, vector<int>& face_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     //void getFaceConnectivity( const int*  cell_list,int nb_cells,MED_EN::medGeometryElement type, int* type_connectivity) const ;
00107 
00108     //getting mesh dimension
00109     int getMeshDimension() const ;
00110 
00111     //getting space dimension
00112     int getSpaceDimension() const ;
00113 
00114     //getting system of coordinates
00115     std::string getSystem() const;
00116 
00117     //getting name of the mesh
00118     std::string getMeshName() const;
00119 
00120     //return constituent entity
00121     MED_EN::medEntityMesh getSubEntity() const;
00122 
00123     //getting a reference to mesh vector
00124     std::vector<MEDMEM::MESH*>& getMesh() ;
00125 
00126     //getting a reference to a domain mesh
00127     MEDMEM::MESH* getMesh(int) const;
00128 
00129     //getting a reference to connect zones vector
00130     std::vector<MEDMEM::CONNECTZONE*>& getCZ();
00131 
00132     //getting a pointer to topology
00133     Topology* getTopology() const ;
00134 
00135 
00136     //settig a new topology
00137     void setTopology(Topology* topology);
00138 
00139     //getting/setting the name of the global mesh (as opposed 
00140     //to the name of a subdomain \a nn, which is name_nn) 
00141     string getName() const {return _name;}
00142     void setName(const string& name) {_name=name;}
00143 
00144     //getting/setting the description of the global mesh
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     //choosing a group to be indivisible
00160     void setIndivisibleGroup(const string& a);
00161 
00163     // void buildConnectZones(int idomain);
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 }//of namespace
00253 
00254 #endif /*MESHCOLLECTION_*/