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 "ComponentTopology.hxx"
20 #include "InterpolationUtils.hxx"
24 /* Generic constructor for \a nb_comp components equally parted
25 * in \a nb_blocks blocks
27 ComponentTopology::ComponentTopology(int nb_comp, ProcessorGroup* group):_proc_group(group)
29 int nb_blocks=group->size();
31 if (nb_blocks>nb_comp)
32 throw INTERP_KERNEL::Exception("ComponentTopology Number of components must be larger than number of blocks");
34 _component_array.resize(nb_blocks+1);
35 _component_array[0]=0;
36 for (int i=1; i<=nb_blocks; i++)
38 _component_array[i]=_component_array[i-1]+nb_comp/nb_blocks;
39 if (i<=nb_comp%nb_blocks)
40 _component_array[i]++;
44 /* Generic constructor for \a nb_comp components equally parted
45 * in \a nb_blocks blocks
47 ComponentTopology::ComponentTopology(int nb_comp, int nb_blocks):_proc_group(0)
49 if (nb_blocks>nb_comp)
50 throw INTERP_KERNEL::Exception("ComponentTopology Number of components must be larger than number of blocks");
52 _component_array.resize(nb_blocks+1);
53 _component_array[0]=0;
54 for (int i=1; i<=nb_blocks; i++)
56 _component_array[i]=_component_array[i-1]+nb_comp/nb_blocks;
57 if (i<=nb_comp%nb_blocks)
58 _component_array[i]++;
63 //!Constructor for one block of \a nb_comp components
64 ComponentTopology::ComponentTopology(int nb_comp):_proc_group(0)
67 _component_array.resize(2);
68 _component_array[0]=0;
69 _component_array[1]=nb_comp;
73 //! Constructor for one component
74 ComponentTopology::ComponentTopology():_proc_group(0)
76 _component_array.resize(2);
77 _component_array[0]=0;
78 _component_array[1]=1;
82 ComponentTopology::~ComponentTopology()
86 int ComponentTopology::nbLocalComponents() const
89 return nbComponents();
92 int myrank = _proc_group->myRank();
94 nbcomp = _component_array[myrank+1]-_component_array[myrank];
100 int ComponentTopology::firstLocalComponent() const
106 int myrank = _proc_group->myRank();
108 icomp = _component_array[myrank];