Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ParticleFamily.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/* ParticleFamily.h (C) 2000-2021 */
9/* */
10/* Particle family. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MESH_PARTICLEFAMILY_H
13#define ARCANE_MESH_PARTICLEFAMILY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/MultiBuffer.h"
18
19#include "arcane/core/VariableTypes.h"
20#include "arcane/core/IParticleFamily.h"
21
22#include "arcane/mesh/ItemFamily.h"
23#include "arcane/mesh/ItemInternalConnectivityIndex.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane::mesh
29{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
39class ARCANE_MESH_EXPORT ParticleFamily
40: public ItemFamily
41, public IParticleFamily
42{
43 private:
44
46 typedef ItemFamily BaseClass;
47
48 public:
49
50 static String const defaultFamilyName()
51 {
52 return "Particle";
53 }
54
55 ParticleFamily(IMesh* mesh, const String& name);
56 virtual ~ParticleFamily(); //<! Releases resources
57
58 public:
59
60 virtual void build() override;
61
62 void setEnableGhostItems(bool value) override
63 {
64 m_enable_ghost_items = value;
65 }
66 bool getEnableGhostItems() const override
67 {
68 return m_enable_ghost_items;
69 }
70
72 String name() const override { return BaseClass::name(); }
73 String fullName() const override { return BaseClass::fullName(); }
74 Integer nbItem() const override { return BaseClass::nbItem(); }
75 ItemGroup allItems() const override { return BaseClass::allItems(); }
76
77 ParticleVectorView addParticles(Int64ConstArrayView unique_ids,
78 Int32ArrayView items) override;
79 ParticleVectorView addParticles2(Int64ConstArrayView unique_ids,
81 Int32ArrayView items) override;
82
83 ParticleVectorView addParticles(Int64ConstArrayView unique_ids,
84 Int32ConstArrayView cells_local_id,
85 Int32ArrayView items_local_id) override;
86 void removeParticles(Int32ConstArrayView items_local_id) override;
87
88 void addItems(Int64ConstArrayView unique_ids, Int32ConstArrayView owners, Int32ArrayView items);
89
90 void internalRemoveItems(Int32ConstArrayView local_ids, bool keep_ghost) override;
91 void exchangeParticles() override;
92
93 void setParticleCell(Particle particle, Cell new_cell) override;
94 void setParticlesCell(ParticleVectorView particles, CellVectorView new_cells) override;
95
96 void endUpdate() override { ItemFamily::endUpdate(); }
97
98 public:
99
100 void preAllocate(Integer nb_item);
101
102 public:
103
104 void prepareForDump() override;
105 void readFromDump() override;
106
107 public:
108
109 void setHasUniqueIdMap(bool v) override;
110 bool hasUniqueIdMap() const override;
111
112 public:
113
115 {
116 if (m_enable_ghost_items)
118 }
119 IItemFamily* itemFamily() override { return this; }
120 IParticleFamily* toParticleFamily() override { return this; }
121
122 void checkValidConnectivity() override;
123 void removeNeedRemoveMarkedItems() override;
124
125 private:
126
127 ItemTypeInfo* m_particle_type_info;
128 ItemSharedInfoWithType* m_particle_shared_info;
129 Int32 m_sub_domain_id;
130 bool m_enable_ghost_items;
131 CellConnectivity* m_cell_connectivity;
132
133 inline ItemInternal* _allocParticle(Int64 uid, bool& need_alloc);
134 inline ItemInternal* _findOrAllocParticle(Int64 uid, bool& is_alloc);
135
136 void _printInfos(Integer nb_added);
137 void _setSharedInfo();
138 inline void _setCell(ItemLocalId particle, ItemLocalId cell);
139 inline void _initializeNewlyAllocatedParticle(ItemInternal* particle, Int64 uid);
140 void _addItems(Int64ConstArrayView unique_ids, Int32ArrayView items);
141};
142
143/*---------------------------------------------------------------------------*/
144/*---------------------------------------------------------------------------*/
145
146} // End namespace Arcane::mesh
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/
150
151#endif
Cell of a mesh.
Definition Item.h:1300
Interface of an entity family.
Definition IItemFamily.h:83
Interface of a particle family.
Mesh entity group.
Definition ItemGroup.h:51
Internal structure of a mesh entity.
Index of an Item in a variable.
Definition ItemLocalId.h:42
Info on a mesh entity type.
Particle.
Definition Item.h:1529
Selection between historical and on-demand connectivities.
IMesh * mesh() const override
Associated mesh.
String fullName() const override
Full family name (with the mesh's name).
Definition ItemFamily.h:141
void endUpdate() override
Notifies the end of modification of the entity list.
ItemGroup allItems() const override
Group of all entities.
Integer nbItem() const override
Number of entities.
void computeSynchronizeInfos() override
Constructs the structures necessary for synchronization.
String name() const override
Family name.
Definition ItemFamily.h:140
Temporary class to hold an ItemSharedInfo and an entity type.
IItemFamily * itemFamily() override
Interface on the family.
Integer nbItem() const override
Number of entities.
String name() const override
Family name.
String fullName() const override
Full family name (with the mesh's name).
void endUpdate() override
Notifies the end of modification of the entity list.
void setEnableGhostItems(bool value) override
Sets the flag to manage ghost particles for the family.
bool getEnableGhostItems() const override
Retrieves the flag to manage ghost particles for the family.
IParticleFamily * toParticleFamily() override
Returns the interface of the particle family for this family.
void computeSynchronizeInfos() override
Constructs the structures necessary for synchronization.
ItemGroup allItems() const override
Group of all entities.
ItemVectorViewT< Cell > CellVectorView
View over a vector of cells.
Definition ItemTypes.h:305
ItemVectorViewT< Particle > ParticleVectorView
View over a vector of particles.
Definition ItemTypes.h:310
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:480
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:453
std::int32_t Int32
Signed integer type of 32 bits.