1 // Copyright (C) 2007-2023 CEA, EDF
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef __BLOCKTOPOLOGY_HXX__
21 #define __BLOCKTOPOLOGY_HXX__
23 #include "Topology.hxx"
24 #include "ProcessorGroup.hxx"
30 class ComponentTopology;
31 class MEDCouplingCMesh;
33 typedef enum{Block,Cycle} CYCLE_TYPE;
36 * \anchor BlockTopology-det
38 * A BlockTopology typically represents the split of a *structured* mesh among the processors of
39 * a common ProcessorGroup. Each processor gets a contiguous part of the cells in the mesh (a block).
41 * A BlockTopology can also be used to split a structured domain among the various components of a field.
43 * \sa ExplicitTopology
45 class BlockTopology : public Topology
49 BlockTopology(const ProcessorGroup& group, MEDCouplingCMesh *grid);
50 BlockTopology(const BlockTopology& geom_topo, const ComponentTopology& comp_topo);
51 BlockTopology(const ProcessorGroup& group, mcIdType nb_elem);
52 virtual ~BlockTopology();
55 //!Retrieves the number of elements for a given topology
56 mcIdType getNbElements()const { return _nb_elems; }
57 mcIdType getNbLocalElements() const;
58 const ProcessorGroup* getProcGroup()const { return _proc_group; }
59 std::pair<int,mcIdType> globalToLocal (const mcIdType) const ;
60 mcIdType localToGlobal (const std::pair<int,mcIdType>) const;
61 std::vector<std::pair<int,mcIdType> > getLocalArrayMinMax() const ;
62 int getDimension() const { return _dimension; }
63 void serialize(mcIdType* & serializer, mcIdType& size) const ;
64 void unserialize(const mcIdType* serializer, const CommInterface& comm_interface);
69 std::vector<int> _nb_procs_per_dim;
70 //stores the offsets vector
71 std::vector<std::vector<mcIdType> > _local_array_indices;
72 //stores the cycle type (block or cyclic)
73 std::vector<CYCLE_TYPE> _cycle_type;
75 const ProcessorGroup* _proc_group;
78 bool _owns_processor_group;