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