Salome HOME
extract medtool doc from MED
[modules/med.git] / medtool / src / ParaMEDMEM / BlockTopology.hxx
1 // Copyright (C) 2007-2015  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 __BLOCKTOPOLOGY_HXX__
21 #define __BLOCKTOPOLOGY_HXX__
22
23 #include "Topology.hxx"
24 #include "ProcessorGroup.hxx"
25
26 #include <vector>
27
28 namespace ParaMEDMEM
29 {
30   class ComponentTopology;
31   class MEDCouplingCMesh;
32
33   typedef enum{Block,Cycle} CYCLE_TYPE; 
34
35   class BlockTopology : public Topology
36   {
37   public:
38     BlockTopology() { }
39     BlockTopology(const ProcessorGroup& group, MEDCouplingCMesh *grid); 
40     BlockTopology(const BlockTopology& geom_topo, const ComponentTopology& comp_topo);
41     BlockTopology(const ProcessorGroup& group, int nb_elem);
42     virtual ~BlockTopology();
43     //!Retrieves the number of elements for a given topology
44     int getNbElements()const { return _nb_elems; }
45     int getNbLocalElements() const;
46     const ProcessorGroup* getProcGroup()const { return _proc_group; }
47     std::pair<int,int> globalToLocal (const int) const ;
48     int localToGlobal (const std::pair<int,int>) const;
49     std::vector<std::pair<int,int> > getLocalArrayMinMax() const ;
50     int getDimension() const { return _dimension; }
51     void serialize(int* & serializer, int& size) const ;
52     void unserialize(const int* serializer, const CommInterface& comm_interface);
53   private:
54     //dimension : 2 or 3
55     int _dimension;
56     //proc array
57     std::vector<int> _nb_procs_per_dim;
58     //stores the offsets vector  
59     std::vector<std::vector<int> > _local_array_indices;
60     //stores the cycle type (block or cyclic)
61     std::vector<CYCLE_TYPE> _cycle_type;
62     //Processor group
63     const ProcessorGroup* _proc_group;
64     //nb of elements
65     int _nb_elems;
66     bool _owns_processor_group;
67   };
68 }
69
70 #endif