Salome HOME
Copyright update 2020
[tools/medcoupling.git] / src / ParaMEDMEM / ParaMESH.hxx
1 // Copyright (C) 2007-2020  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 #pragma once
21
22 #include "MEDCouplingPointSet.hxx"
23 #include "ProcessorGroup.hxx"
24 #include "MEDCouplingMemArray.hxx"
25
26 #include <string>
27 #include <vector>
28
29 namespace MEDCoupling
30 {
31   class Topology;
32   class BlockTopology;
33   class DataArrayInt;
34
35   /*!
36    * \anchor ParaMESH-det
37    *
38    * Parallel representation of an unstructured mesh.
39    *
40    * This class is very specific to the requirement of parallel code computations.
41    * Two main constructors are available:
42    * - the most simple one, taking directly a \ref meshes "MEDCoupling mesh" object
43    * - the second one (for an advanced usage), which can be used to specify an explicit topology
44    * in a parallel computation.
45    */
46   class ParaMESH
47   {
48   public:
49     ParaMESH( MEDCouplingPointSet *mesh,
50               const ProcessorGroup& proc_group, const std::string& name);
51     ParaMESH( MEDCouplingPointSet *subdomain_mesh,
52               MEDCouplingPointSet *subdomain_face,
53               DataArrayIdType *CorrespElt_local2global,
54               DataArrayIdType *CorrespFace_local2global,
55               DataArrayIdType *CorrespNod_local2global,
56               const ProcessorGroup& proc_group ) ;
57
58     virtual ~ParaMESH();
59     void setNodeGlobal(DataArrayIdType *nodeGlobal);
60     void setCellGlobal(DataArrayIdType *cellGlobal);
61     Topology* getTopology() const { return _explicit_topology; }
62     bool isStructured() const { return _cell_mesh->isStructured(); }
63     MEDCouplingPointSet *getCellMesh() const { return _cell_mesh.iAmATrollConstCast(); }
64     MEDCouplingPointSet *getFaceMesh() const { return _face_mesh.iAmATrollConstCast(); }
65     BlockTopology* getBlockTopology() const { return _block_topology; }
66
67     DataArrayIdType* getGlobalNumberingNodeDA() const { return _node_global.retnConstCast(); }
68     DataArrayIdType* getGlobalNumberingFaceDA() const { return _face_global.retnConstCast(); }
69     DataArrayIdType* getGlobalNumberingCellDA() const { return _cell_global.retnConstCast(); }
70     const mcIdType* getGlobalNumberingNode() const { if(_node_global) return _node_global->getConstPointer(); return nullptr; }
71     const mcIdType* getGlobalNumberingFace() const { if(_face_global) return _face_global->getConstPointer(); return nullptr; }
72     const mcIdType* getGlobalNumberingCell() const { if(_cell_global) return _cell_global->getConstPointer(); return nullptr; }
73
74   private:
75     //mesh object underlying the ParaMESH object
76     MCAuto<MEDCouplingPointSet> _cell_mesh ;
77     MCAuto<MEDCouplingPointSet> _face_mesh ;
78
79     //id of the local grid
80     int _my_domain_id;
81
82     //global topology of the cells
83     MEDCoupling::BlockTopology* _block_topology;
84     Topology*  _explicit_topology;
85     // pointers to global numberings
86     MCAuto<DataArrayIdType> _node_global;
87     MCAuto<DataArrayIdType> _face_global;
88     MCAuto<DataArrayIdType> _cell_global;
89   };
90 }