Salome HOME
ParaMEDMEM: DisjointDEC
[tools/medcoupling.git] / src / ParaMEDMEM / ParaMESH.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __PARAMESH_HXX__
21 #define __PARAMESH_HXX__
22
23 #include "MEDCouplingPointSet.hxx"
24 #include "ProcessorGroup.hxx"
25 #include "MEDCouplingMemArray.hxx"
26
27 #include <string>
28 #include <vector>
29
30 namespace MEDCoupling
31 {
32   class Topology;
33   class BlockTopology;
34   class DataArrayInt;
35
36   /*!
37    * \anchor ParaMESH-det
38    *
39    * Parallel representation of an unstructured mesh.
40    *
41    * This class is very specific to the requirement of parallel code computations.
42    * Two main constructors are available:
43    * - the most simple one, taking directly a \ref meshes "MEDCoupling mesh" object
44    * - the second one (for an advanced usage), which can be used to specify an explicit topology
45    * in a parallel computation.
46    */
47   class ParaMESH
48   {
49   public:
50     ParaMESH( MEDCouplingPointSet *mesh,
51               const ProcessorGroup& proc_group, const std::string& name);
52     ParaMESH( MEDCouplingPointSet *subdomain_mesh,
53               MEDCouplingPointSet *subdomain_face,
54               DataArrayInt *CorrespElt_local2global,
55               DataArrayInt *CorrespFace_local2global,
56               DataArrayInt *CorrespNod_local2global,
57               const ProcessorGroup& proc_group ) ;
58
59     virtual ~ParaMESH();
60     void setNodeGlobal(DataArrayInt *nodeGlobal);
61     void setCellGlobal(DataArrayInt *cellGlobal);
62     Topology* getTopology() const { return _explicit_topology; }
63     bool isStructured() const { return _cell_mesh->isStructured(); }
64     MEDCouplingPointSet *getCellMesh() const { return _cell_mesh; }
65     MEDCouplingPointSet *getFaceMesh() const { return _face_mesh; }
66     BlockTopology* getBlockTopology() const { return _block_topology; }
67
68     DataArrayInt* getGlobalNumberingNodeDA() const { if(_node_global) _node_global->incrRef(); return _node_global; }
69     DataArrayInt* getGlobalNumberingFaceDA() const { if(_face_global) _face_global->incrRef(); return _face_global; }
70     DataArrayInt* getGlobalNumberingCellDA() const { if(_cell_global) _cell_global->incrRef(); return _cell_global; }
71     const int* getGlobalNumberingNode() const { if(_node_global) return _node_global->getConstPointer(); return 0; }
72     const int* getGlobalNumberingFace() const { if(_face_global) return _face_global->getConstPointer(); return 0; }
73     const int* getGlobalNumberingCell() const { if(_cell_global) return _cell_global->getConstPointer(); return 0; }
74
75   private:
76     //mesh object underlying the ParaMESH object
77     MEDCouplingPointSet *_cell_mesh ;
78     MEDCouplingPointSet *_face_mesh ;
79
80     //id of the local grid
81     int _my_domain_id;
82
83     //global topology of the cells
84     MEDCoupling::BlockTopology* _block_topology;
85     Topology*  _explicit_topology;
86     // pointers to global numberings
87     DataArrayInt* _node_global;
88     DataArrayInt* _face_global;
89     DataArrayInt* _cell_global;
90   };
91 }
92
93 #endif