1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D
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 #include "CommInterface.hxx"
21 #include "ProcessorGroup.hxx"
22 #include "MPIProcessorGroup.hxx"
23 #include "ParaMESH.hxx"
24 #include "Topology.hxx"
25 #include "ExplicitTopology.hxx"
26 #include "BlockTopology.hxx"
27 #include "ComponentTopology.hxx"
36 ExplicitTopology::ExplicitTopology():
37 _proc_group(NULL), _nb_elems(0), _nb_components(0),
38 _loc2glob(NULL), _glob2loc()
41 ExplicitTopology::ExplicitTopology(const ParaMESH& paramesh ):
42 _proc_group(paramesh.getBlockTopology()->getProcGroup()),
45 _nb_elems=paramesh.getCellMesh()->getNumberOfCells();
46 const int* global=paramesh.getGlobalNumberingCell();
47 _loc2glob=new int[_nb_elems];
49 for (int i=0; i<_nb_elems; i++)
51 _loc2glob[i]=global[i];
52 _glob2loc[global[i]]=i;
56 ExplicitTopology::ExplicitTopology(const ExplicitTopology& topo, int nb_components)
58 _proc_group = topo._proc_group;
59 _nb_elems = topo._nb_elems;
60 _nb_components = nb_components;
61 _loc2glob=new int[_nb_elems];
62 for (int i=0; i<_nb_elems; i++)
64 _loc2glob[i]=topo._loc2glob[i];
66 _glob2loc=topo._glob2loc;
70 ExplicitTopology::~ExplicitTopology()
72 if (_loc2glob != 0) delete[] _loc2glob;
76 /*! Serializes the data contained in the Explicit Topology
77 * for communication purposes*/
78 void ExplicitTopology::serialize(int* & serializer, int& size) const
82 buffer.push_back(_nb_elems);
83 for (int i=0; i<_nb_elems; i++)
85 buffer.push_back(_loc2glob[i]);
88 serializer=new int[buffer.size()];
90 copy(buffer.begin(), buffer.end(), serializer);
93 /*! Unserializes the data contained in the Explicit Topology
94 * after communication. Uses the same structure as the one used for serialize()
97 void ExplicitTopology::unserialize(const int* serializer,const CommInterface& comm_interface)
99 const int* ptr_serializer=serializer;
100 cout << "unserialize..."<<endl;
101 _nb_elems=*ptr_serializer++;
102 cout << "nbelems "<<_nb_elems<<endl;
103 _loc2glob=new int[_nb_elems];
104 for (int i=0; i<_nb_elems; i++)
106 _loc2glob[i]=*ptr_serializer;
107 _glob2loc[*ptr_serializer]=i;