Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions arcane/src/arcane/mesh/MeshExchange.cc
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@
/*---------------------------------------------------------------------------*/

void MeshExchange::
_computeItemsToSend(bool send_dof)

Check failure on line 562 in arcane/src/arcane/mesh/MeshExchange.cc

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 28 to the 25 allowed.

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AaFi1txXfhNg41uNmy_A&open=AaFi1txXfhNg41uNmy_A&pullRequest=2838
{
for (const auto& iter : m_items_to_send)
iter.second->resize(m_nb_rank);
Expand Down Expand Up @@ -609,7 +609,10 @@
if (particle_family && particle_family->getEnableGhostItems() == true) {
ArrayView<std::set<Int32>> to_send = _getItemsToSend(family);
ENUMERATE_PARTICLE (iparticle, particle_family->allItems().own()) {
_addItemToSend(to_send, iparticle->localId(), iparticle->cell().localId(), use_itemfamily_network);
Cell cell = iparticle->cell();
// Do not send the particle if it has no cell.
if (!cell.null())

Check failure on line 614 in arcane/src/arcane/mesh/MeshExchange.cc

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AaFi1txXfhNg41uNmy_B&open=AaFi1txXfhNg41uNmy_B&pullRequest=2838
_addItemToSend(to_send, iparticle->localId(), cell.localId(), use_itemfamily_network);
}
}
if (send_dof && family->itemKind() == IK_DoF) {
Expand Down Expand Up @@ -1416,13 +1419,16 @@
{
for (IItemFamily* family : m_mesh->itemFamilies()) {
IParticleFamily* particle_family = family->toParticleFamily();
if (particle_family && particle_family->getEnableGhostItems() == true) {
if (particle_family && particle_family->getEnableGhostItems()) {
mesh::NewItemOwnerBuilder owner_builder;

ENUMERATE_PARTICLE (iparticle, particle_family->allItems()) {
Particle particle = *iparticle;
Cell cell = owner_builder.connectedCellOfItem(particle);
particle.mutableItemBase().setFlags(cell.itemBase().flags());
// NOTE GG: 10/2026. This code is very strange
// I think we should only modify some flags (II_NeedRemove?)
if (!cell.null())

Check failure on line 1430 in arcane/src/arcane/mesh/MeshExchange.cc

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this code to not nest more than 3 if|for|do|while|switch statements.

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AaFi1txXfhNg41uNmy_C&open=AaFi1txXfhNg41uNmy_C&pullRequest=2838
particle.mutableItemBase().setFlags(cell.itemBase().flags());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion arcane/src/arcane/mesh/MeshExchanger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ computeExchangeInfos()
// of ghost items, this list has already been determined during the call to
// mesh_exchange.computeInfos().
IParticleFamily* particle_family = family->toParticleFamily();
if (particle_family && particle_family->getEnableGhostItems() == false)
if (particle_family && !particle_family->getEnableGhostItems())
exchanger->computeExchangeItems();
else
exchanger->setExchangeItems(mesh_exchange.getItemsToSend(family));
Expand Down
7 changes: 6 additions & 1 deletion arcane/src/arcane/mesh/UnstructuredMeshUtilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ changeOwnersFromCells()
VariableItemInt32& particles_owner(family->itemsNewOwner());
ENUMERATE_PARTICLE (i_particle, family->allItems()) {
Particle particle = *i_particle;
particles_owner[particle] = cells_owner[particle.cell()];
Cell pcell = particle.cell();
if (!pcell.null())
particles_owner[particle] = cells_owner[pcell];
else
// If the particle has no cell, its new owner is the current owner.
particles_owner[particle] = particle.owner();
}
}

Expand Down
19 changes: 14 additions & 5 deletions arcane/src/arcane/tests/ParallelTesterModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* ParallelTesterModule.cc (C) 2000-2024 */
/* ParallelTesterModule.cc (C) 2000-2026 */
/* */
/* Parallelism test module. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -174,8 +174,8 @@ class ParticleFamilyTester
Integer particle_per_cell = 12;
info() << " BuildParticleFamily increment=" << particle_per_cell
<< " nb_particle=" << m_family->nbItem();
Int64UniqueArray uids;
Int32UniqueArray cells_lid;
UniqueArray<Int64> uids;
UniqueArray<Int32> cells_lid;
IParallelMng* pm = m_family->parallelMng();
CellGroup own_cells = m_family->mesh()->ownCells();
Integer nb_own_cell = own_cells.size();
Expand All @@ -191,7 +191,16 @@ class ParticleFamilyTester
++first_uid;
}
}

// To check load-balance with particles with no cells, make sure some
// particles have no cells.
// NOTE: Having particles without cells is not supported when using
// graph network.
if (!m_family->mesh()->itemFamilyNetwork()) {
Int32 nb_particle_to_add = uids.size();
for (Int32 i = 0; i < nb_particle_to_add; ++i)
if ((i % 10) == 0)
cells_lid[i] = ItemLocalId{};
}
m_first_uid = m_first_uid + uid_increment * comm_size;

info() << "Create " << uids.size() << " particles";
Expand All @@ -202,7 +211,7 @@ class ParticleFamilyTester
m_family->partialEndUpdateVariable(m_values1.variable());
ENUMERATE_PARTICLE (ipart, particles) {
Particle particle = *ipart;
m_values1[ipart] = (Real)(particle.uniqueId().asInt64());
m_values1[ipart] = static_cast<Real>(particle.uniqueId().asInt64());
}
m_family->endUpdate();
}
Expand Down
Loading