1 // Copyright (C) 2007-2008 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.
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
19 #include "CommInterface.hxx"
20 #include "ProcessorGroup.hxx"
21 #include "MPIProcessorGroup.hxx"
22 #include "ParaMESH.hxx"
23 #include "Topology.hxx"
24 #include "ExplicitTopology.hxx"
25 #include "BlockTopology.hxx"
26 #include "ComponentTopology.hxx"
35 ExplicitTopology::ExplicitTopology(const ParaMESH& paramesh ):
36 _proc_group(paramesh.getBlockTopology()->getProcGroup()),
39 _nb_elems=paramesh.getCellMesh()->getNumberOfCells();
40 const int* global=paramesh.getGlobalNumberingCell();
41 _loc2glob=new int[_nb_elems];
43 for (int i=0; i<_nb_elems; i++)
45 _loc2glob[i]=global[i];
46 _glob2loc[global[i]]=i;
50 ExplicitTopology::ExplicitTopology(const ExplicitTopology& topo, int nb_components)
52 _proc_group = topo._proc_group;
53 _nb_elems = topo._nb_elems;
54 _nb_components = nb_components;
55 _loc2glob=new int[_nb_elems];
56 for (int i=0; i<_nb_elems; i++)
58 _loc2glob[i]=topo._loc2glob[i];
60 _glob2loc=topo._glob2loc;
64 ExplicitTopology::~ExplicitTopology()
66 if (_loc2glob != 0) delete[] _loc2glob;
70 /*! Serializes the data contained in the Explicit Topology
71 * for communication purposes*/
72 void ExplicitTopology::serialize(int* & serializer, int& size) const
76 buffer.push_back(_nb_elems);
77 for (int i=0; i<_nb_elems; i++)
79 buffer.push_back(_loc2glob[i]);
82 serializer=new int[buffer.size()];
84 copy(buffer.begin(), buffer.end(), serializer);
87 /*! Unserializes the data contained in the Explicit Topology
88 * after communication. Uses the same structure as the one used for serialize()
91 void ExplicitTopology::unserialize(const int* serializer,const CommInterface& comm_interface)
93 const int* ptr_serializer=serializer;
94 cout << "unserialize..."<<endl;
95 _nb_elems=*ptr_serializer++;
96 cout << "nbelems "<<_nb_elems<<endl;
97 _loc2glob=new int[_nb_elems];
98 for (int i=0; i<_nb_elems; i++)
100 _loc2glob[i]=*ptr_serializer;
101 _glob2loc[*ptr_serializer]=i;