1 // Copyright (C) 2007-2023 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 "ComponentTopology.hxx"
21 #include "ProcessorGroup.hxx"
22 #include "InterpolationUtils.hxx"
26 /* Generic constructor for \a nb_comp components equally parted
27 * in \a nb_blocks blocks
29 ComponentTopology::ComponentTopology(int nb_comp, ProcessorGroup* group):_proc_group(group)
31 int nb_blocks=group->size();
33 if (nb_blocks>nb_comp)
34 throw INTERP_KERNEL::Exception("ComponentTopology Number of components must be larger than number of blocks");
36 _component_array.resize(nb_blocks+1);
37 _component_array[0]=0;
38 for (int i=1; i<=nb_blocks; i++)
40 _component_array[i]=_component_array[i-1]+nb_comp/nb_blocks;
41 if (i<=nb_comp%nb_blocks)
42 _component_array[i]++;
46 /* Generic constructor for \a nb_comp components equally parted
47 * in \a nb_blocks blocks
49 ComponentTopology::ComponentTopology(int nb_comp, int nb_blocks):_proc_group(0)
51 if (nb_blocks>nb_comp)
52 throw INTERP_KERNEL::Exception("ComponentTopology Number of components must be larger than number of blocks");
54 _component_array.resize(nb_blocks+1);
55 _component_array[0]=0;
56 for (int i=1; i<=nb_blocks; i++)
58 _component_array[i]=_component_array[i-1]+nb_comp/nb_blocks;
59 if (i<=nb_comp%nb_blocks)
60 _component_array[i]++;
65 //!Constructor for one block of \a nb_comp components
66 ComponentTopology::ComponentTopology(int nb_comp):_proc_group(0)
69 _component_array.resize(2);
70 _component_array[0]=0;
71 _component_array[1]=nb_comp;
75 //! Constructor for one component
76 ComponentTopology::ComponentTopology():_proc_group(0)
78 _component_array.resize(2);
79 _component_array[0]=0;
80 _component_array[1]=1;
84 ComponentTopology::~ComponentTopology()
88 int ComponentTopology::nbLocalComponents() const
91 return nbComponents();
94 int myrank = _proc_group->myRank();
96 nbcomp = _component_array[myrank+1]-_component_array[myrank];
102 int ComponentTopology::firstLocalComponent() const
108 int myrank = _proc_group->myRank();
110 icomp = _component_array[myrank];