14#include "arcane/mesh/ParticleFamily.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/PlatformUtils.h"
19#include "arcane/core/ISubDomain.h"
20#include "arcane/core/IMesh.h"
21#include "arcane/core/IVariableMng.h"
22#include "arcane/core/Properties.h"
23#include "arcane/core/ItemPrinter.h"
25#include "arcane/mesh/ItemsExchangeInfo2.h"
26#include "arcane/mesh/DynamicMesh.h"
27#include "arcane/mesh/ItemConnectivitySelector.h"
28#include "arcane/mesh/DynamicMeshKindInfos.h"
40ParticleFamily(IMesh* mesh,
const String& name)
42, m_particle_type_info(nullptr)
43, m_particle_shared_info(nullptr)
44, m_sub_domain_id(NULL_SUB_DOMAIN_ID)
45, m_enable_ghost_items(false)
46, m_cell_connectivity(nullptr)
65 ItemTypeMng* itm = m_mesh->itemTypeMng();
66 m_particle_type_info = itm->typeFromId(IT_NullType);
67 m_sub_domain_id = subDomain()->subDomainId();
70 if (!platform::getEnvironmentVariable(
"ARCANE_PARTICLE_NO_UNIQUE_ID_MAP").null()) {
71 pwarning() <<
"TEMPORARY: suppress particule uniqueId map";
72 setHasUniqueIdMap(
false);
75 bool has_unique_id_map = !m_properties->getBool(
"no-unique-id-map");
76 _setHasUniqueIdMap(has_unique_id_map);
79 m_cell_connectivity =
new CellConnectivity(
this, mesh()->cellFamily(),
"ParticleCell");
81 _addConnectivitySelector(m_cell_connectivity);
83 _buildConnectivitySelectors();
86 m_cell_connectivity->setPreAllocatedSize(1);
90 auto network = m_mesh->itemFamilyNetwork();
92 network->addDependency(
this, mesh()->cellFamily(), m_cell_connectivity->customConnectivity(),
false);
102inline void ParticleFamily::
105 _allocateInfos(
particle, uid, m_particle_shared_info);
118 ii->setUniqueId(uid);
120 _initializeNewlyAllocatedParticle(
ii, uid);
123 ii->setOwner(m_sub_domain_id, m_sub_domain_id);
131_findOrAllocParticle(Int64 uid,
bool&
is_alloc)
135 _initializeNewlyAllocatedParticle(
ii, uid);
167 m_cell_connectivity->replaceItem(
particle, 0, cell);
179 Integer n = items.
size();
180 for (Integer i = 0; i < n; ++i) {
194 m_need_prepare_dump =
true;
205 for (Integer i = 0, n =
particle_ids.size(); i < n; ++i)
207 m_need_prepare_dump =
true;
222 for (Integer i = 0; i <
nb_item; ++i) {
225 items[i] =
ii->localId();
228 m_need_prepare_dump =
true;
236addItems(Int64ConstArrayView unique_ids, Int32ConstArrayView owners, Int32ArrayView items)
238 Integer nb_item = unique_ids.size();
241 preAllocate(nb_item);
243 if (!hasUniqueIdMap())
244 ARCANE_FATAL(
"Can not add particles with owners when hasUniqueIdMap()==false family={0}",
247 bool need_alloc =
false;
248 for (Integer i = 0; i < nb_item; ++i) {
249 Int64 uid = unique_ids[i];
250 ItemInternal* ii = _findOrAllocParticle(uid, need_alloc);
251 ii->setOwner(owners[i], m_sub_domain_id);
253 items[i] = ii->localId();
256 m_need_prepare_dump =
true;
257 _printInfos(nb_item);
267 ex.computeExchangeItems();
268 ex.computeExchangeInfos();
270 ex.processExchange();
271 ex.removeSentItems();
272 ex.readAndAllocItems();
273 notifyItemsOwnerChanged();
305 auto network = m_mesh->itemFamilyNetwork();
309 for (Integer i = 0, n =
local_ids.size(); i < n; ++i) {
315 for (
auto parent_connectivity : m_mesh->itemFamilyNetwork()->getParentConnectivities(
this)) {
331 for (Integer i = 0, n =
local_ids.size(); i < n; ++i) {
339 m_need_prepare_dump =
true;
358 info(4) <<
"ParticleFamily::prepareForDump: " << name()
360 ItemFamily::prepareForDump();
369 ItemFamily::readFromDump();
380 Integer
nb_hash = itemsMap().nbBucket();
390setHasUniqueIdMap(
bool v)
392 _setHasUniqueIdMap(v);
393 m_properties->setBool(
"no-unique-id-map", !v);
400hasUniqueIdMap()
const
402 return _infos().hasUniqueIdMap();
411 m_particle_shared_info = _findSharedInfo(m_particle_type_info);
418checkValidConnectivity()
420 ItemFamily::checkValidConnectivity();
427removeNeedRemoveMarkedItems()
429 if (getEnableGhostItems()) {
435 Integer f = item.
itemBase().flags();
436 if (f & ItemFlags::II_NeedRemove) {
443 info() <<
"Number of particles of family " << name() <<
" to remove: " <<
lids_to_remove.size();
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Gère la récupération des informations de connectivité.
Flags pour les caractéristiques des entités.
Structure interne d'une entité de maillage.
Index d'un Item dans une variable.
Vue sur un tableau typé d'entités.
Classe de base d'un élément de maillage.
impl::MutableItemBase mutableItemBase() const
Partie interne modifiable de l'entité.
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
impl::ItemBase itemBase() const
Partie interne de l'entité.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Tableau associatif de ItemInternal.
Informations pour échanger des entités d'une famille donnée et leur caractéristiques.
Vue modifiable d'un tableau d'un type T.
constexpr Integer size() const noexcept
Retourne la taille du tableau.
Vue constante d'un tableau de type T.
@ IK_Particle
Entité de maillage de genre particule.
InternalConnectivityPolicy
Politique d'utilisation des connectivités.