Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
AsyncParticleExchanger.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* AsyncParticleExchanger.h (C) 2000-2021 */
9/* Author : Hugo Taboada */
10/*---------------------------------------------------------------------------*/
11
12#include "arcane/mesh/BasicParticleExchanger.h"
13
14#include "arcane/core/IAsyncParticleExchanger.h"
15
16/*---------------------------------------------------------------------------*/
17/*---------------------------------------------------------------------------*/
18
19namespace Arcane::mesh
20{
21
22class AsyncParticleExchanger
23: public BasicService
24, public IParticleExchanger
26{
27
28 //Constructors and destructors
29 public:
30
31 explicit AsyncParticleExchanger(const ServiceBuildInfo& sbi);
32 ~AsyncParticleExchanger() override;
33
34 //IParticleExchanger.h interface
35 public:
36
37 void build() override;
38 void initialize(IItemFamily* item_family) override;
39 void beginNewExchange(Integer nb_particule) override;
40 bool exchangeItems(Integer nb_particle_finish_exchange,
41 Int32ConstArrayView local_ids,
42 Int32ConstArrayView sub_domains_to_send,
43 ItemGroup item_group,
44 IFunctor* functor) override;
45 bool exchangeItems(Integer nb_particle_finish_exchange,
46 Int32ConstArrayView local_ids,
47 Int32ConstArrayView sub_domains_to_send,
48 Int32Array* new_particle_local_ids,
49 IFunctor* functor) override;
50 void sendItems(Integer nb_particle_finish_exchange,
51 Int32ConstArrayView local_ids,
52 Int32ConstArrayView sub_domains_to_send) override;
53 bool waitMessages(Integer nb_pending_particles,
54 Int32Array* new_particle_local_ids,
55 IFunctor* functor) override;
56 void addNewParticles(Integer nb_particle) override;
57 IItemFamily* itemFamily() override;
58 void setVerboseLevel(Integer level) override;
59 Integer verboseLevel() const override;
61
62 //IAsyncParticleExchanger.h interface
63 public:
64
65 bool exchangeItemsAsync(Integer nb_particle_finish_exchange,
66 Int32ConstArrayView local_ids,
67 Int32ConstArrayView sub_domains_to_send,
68 Int32Array* new_particle_local_ids,
69 IFunctor* functor,
70 bool has_local_flying_particles) override;
71
72 //Private member variables including bpe that is a composition with BasicParticleExchanger class.
73 private:
74
76 Integer m_nb_particle_send_before_reduction = 0;
77 Integer m_nb_particle_send_before_reduction_tmp = 0;
78 Integer m_sum_of_nb_particle_sent = 0; //Sum of particles sent calculated in the stopping condition of asynchronous mode
79 UniqueArray<Parallel::Request> m_reduce_requests; //This array should only have one request at a time
80
81 //Private functions used by internal implementation of AsyncParticleExchanger
82 private:
83
84 void _generateSendItemsAsync(Int32ConstArrayView local_ids, Int32ConstArrayView sub_domains_to_send);
85 //bool _waitSomeMessages(Integer nb_pending_particles, ItemGroup item_group, Int32Array* new_particle_local_ids);
86 bool _waitSomeMessages(ItemGroup item_group, Int32Array* new_particle_local_ids);
87};
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
92} // namespace Arcane::mesh
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
Interface of an asynchronous particle exchanger.
Interface of an entity family.
Definition IItemFamily.h:83
Interface of a particle exchanger.
Mesh entity group.
Definition ItemGroup.h:51
Structure containing the information to create a service.
1D data vector with value semantics (STL style).
bool waitMessages(Integer nb_pending_particles, Int32Array *new_particle_local_ids, IFunctor *functor) override
void setVerboseLevel(Integer level) override
Sets the verbosity level (0 for no messages).
void sendItems(Integer nb_particle_finish_exchange, Int32ConstArrayView local_ids, Int32ConstArrayView sub_domains_to_send) override
void initialize(IItemFamily *item_family) override
Initializes the exchanger for the item_family item_family.
IAsyncParticleExchanger * asyncParticleExchanger() override
Asynchronism management (returns nullptr if functionality is not available).
void build() override
Build-level construction of the service.
void beginNewExchange(Integer nb_particule) override
Starts a new particle exchange.
void addNewParticles(Integer nb_particle) override
Adds nb_particle to the current exchange.
bool exchangeItems(Integer nb_particle_finish_exchange, Int32ConstArrayView local_ids, Int32ConstArrayView sub_domains_to_send, ItemGroup item_group, IFunctor *functor) override
Exchanges particles between sub-domains.
Integer verboseLevel() const override
Verbosity level.
IItemFamily * itemFamily() override
Associated family.
Basic particle exchanger (uses blocking reduction).
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
Definition UtilsTypes.h:127