Skip to content

Commit

Permalink
[arcane,cea] Corrige dans 'SplitSDMeshPartitioner' une division par z…
Browse files Browse the repository at this point in the history
…éro si on utilise le nombre de mailles comme poids.

En effet dans ce cas le tableau retourné par
MeshPartitionerBase::cellsWeightsWithConstraints() ne contient que des
zéros et donc la somme des poids est nulle.
  • Loading branch information
grospelliergilles committed Oct 7, 2024
1 parent 9cff884 commit c0d329d
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions arcane/ceapart/src/arcane/cea/SplitSDMeshPartitioner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ initPoids(bool initial_partition)

/* récupération du poids aux mailles pour qu'il suivent les cellules */
IMesh* mesh = this->mesh();
IParallelMng* pm = mesh->parallelMng();
CellGroup own_cells = mesh->ownCells();
// if (initial_partition || m_cells_weight.empty())
// ENUMERATE_CELL(iitem,own_cells){
Expand All @@ -165,10 +166,24 @@ initPoids(bool initial_partition)
// else{
// Integer nb_weight = nbCellWeight();
SharedArray<float> cell_weights = cellsWeightsWithConstraints(1, true); // 1 poids seulement

Real max_weight = 0.0;
ENUMERATE_CELL(iitem,own_cells){
m_poids_aux_mailles[iitem] = cell_weights[iitem.index()];
Real weight = cell_weights[iitem.index()];
m_poids_aux_mailles[iitem] = weight;
max_weight = math::max(weight, max_weight);
}
Real global_max_weight = pm->reduce(Parallel::ReduceMax, max_weight);
// Si zéro, cela signifie que tous les poids sont nuls.
// Dans ce cas, cela signifie qu'on utilise le nombre de mailles comme poids
// et donc on met 1 partout.
if (global_max_weight == 0.0) {
ENUMERATE_CELL (iitem, own_cells) {
m_poids_aux_mailles[iitem] = 1.0;
}
}
}

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
void SplitSDMeshPartitioner::
Expand Down Expand Up @@ -1804,23 +1819,34 @@ AfficheEquilMaillage(StrucMaillage* Maillage)
info()<<" AfficheEquilMaillage(...)";

double poidsMin = 0.0;
double poidsMax = 0.0;
double poidsMax = 0.0;
const double weight = Maillage->Poids;

if (Maillage->ListeDomaines) {
const int nb_domain_max = Maillage->NbDomainesMax;
if (nb_domain_max == 0)
ARCANE_FATAL("NbDomainesMax is zero", nb_domain_max);
const double weight_divide_nb_domain_max = weight / static_cast<double>(nb_domain_max);
info() << "weight=" << weight;
info() << "weight_divide_nb_domain_max=" << weight_divide_nb_domain_max;
if (weight == 0.0)
ARCANE_FATAL("Mesh weight is zero", weight);
if (weight_divide_nb_domain_max == 0.0)
ARCANE_FATAL("Null weight sum");

if(Maillage->ListeDomaines != NULL){

poidsMin = Maillage->ListeDomaines[0].Poids;

for (int i=0; i<Maillage->NbDomainesMax; i++){
double poidsDom = Maillage->ListeDomaines[i].Poids;

if (poidsDom > poidsMax)
poidsMax = poidsDom;
poidsMax = poidsDom;
if (poidsDom < poidsMin)
poidsMin = poidsDom;
poidsMin = poidsDom;
}

info()<<" INFO equilibrage / noeuds : max : "<<poidsMax<<", min : "<<poidsMin
<<", max/moy = "<<poidsMax/(Maillage->Poids/(double)Maillage->NbDomainesMax);
<< ", max/moy = " << poidsMax / weight_divide_nb_domain_max;
}
else{
info()<<"AfficheEquilMaillage : Maillage->ListeDomaines == NULL";
Expand Down

0 comments on commit c0d329d

Please sign in to comment.