1 // Copyright (C) 2007-2014 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(const ParaMESH& paramesh ):
37 _proc_group(paramesh.getBlockTopology()->getProcGroup()),
40 _nb_elems=paramesh.getCellMesh()->getNumberOfCells();
41 const int* global=paramesh.getGlobalNumberingCell();
42 _loc2glob=new int[_nb_elems];
44 for (int i=0; i<_nb_elems; i++)
46 _loc2glob[i]=global[i];
47 _glob2loc[global[i]]=i;
51 ExplicitTopology::ExplicitTopology(const ExplicitTopology& topo, int nb_components)
53 _proc_group = topo._proc_group;
54 _nb_elems = topo._nb_elems;
55 _nb_components = nb_components;
56 _loc2glob=new int[_nb_elems];
57 for (int i=0; i<_nb_elems; i++)
59 _loc2glob[i]=topo._loc2glob[i];
61 _glob2loc=topo._glob2loc;
65 ExplicitTopology::~ExplicitTopology()
67 if (_loc2glob != 0) delete[] _loc2glob;
71 /*! Serializes the data contained in the Explicit Topology
72 * for communication purposes*/
73 void ExplicitTopology::serialize(int* & serializer, int& size) const
77 buffer.push_back(_nb_elems);
78 for (int i=0; i<_nb_elems; i++)
80 buffer.push_back(_loc2glob[i]);
83 serializer=new int[buffer.size()];
85 copy(buffer.begin(), buffer.end(), serializer);
88 /*! Unserializes the data contained in the Explicit Topology
89 * after communication. Uses the same structure as the one used for serialize()
92 void ExplicitTopology::unserialize(const int* serializer,const CommInterface& comm_interface)
94 const int* ptr_serializer=serializer;
95 cout << "unserialize..."<<endl;
96 _nb_elems=*ptr_serializer++;
97 cout << "nbelems "<<_nb_elems<<endl;
98 _loc2glob=new int[_nb_elems];
99 for (int i=0; i<_nb_elems; i++)
101 _loc2glob[i]=*ptr_serializer;
102 _glob2loc[*ptr_serializer]=i;