14#include "arcane/core/ISerializer.h"
15#include "arcane/core/ItemPrinter.h"
16#include "arcane/core/IMesh.h"
17#include "arcane/core/IParallelMng.h"
19#include "arcane/mesh/ParticleFamilySerializer.h"
20#include "arcane/mesh/ParticleFamily.h"
31ParticleFamilySerializer::
33: TraceAccessor(family->traceMng())
41void ParticleFamilySerializer::
47 switch (sbuf->
mode()) {
48 case ISerializer::ModeReserve:
57 for (
Integer z = 0; z < nb_item; ++z) {
58 particle_unique_ids[z] = items_internal.
uniqueId(local_ids[z]).asInt64();
60 sbuf->
putSpan(particle_unique_ids);
64 for (
Integer z = 0; z < nb_item; ++z) {
65 Particle item(items_internal[local_ids[z]]);
67 particles_cell_uid[z] = (has_cell) ? item.
cell().
uniqueId() : NULL_ITEM_UNIQUE_ID;
69 sbuf->
putSpan(particles_cell_uid);
81void ParticleFamilySerializer::
94 particles_uid.
resize(nb_item);
96 cells_unique_id.
resize(nb_item);
97 cells_local_id.
resize(nb_item);
100 Int32Array* particles_local_id = (local_ids) ? local_ids : &temporary_particles_local_id;
101 particles_local_id->
resize(nb_item);
112 if (!m_family->getEnableGhostItems()) {
113 m_family->addParticles(particles_uid, local_ids_view);
116 particles_owner.
resize(nb_item);
117 for (
Integer zz = 0; zz < nb_item; ++zz) {
118 Int32 cell_lid = cells_local_id[zz];
119 if (cell_lid != NULL_ITEM_LOCAL_ID) {
120 Cell c = internal_cells[cell_lid];
121 particles_owner[zz] = c.
owner();
124 particles_owner[zz] = NULL_SUB_DOMAIN_ID;
127 m_family->addParticles2(particles_uid, particles_owner, local_ids_view);
132 for (
Integer zz = 0; zz < nb_item; ++zz) {
133 Particle p = internal_particles[local_ids_view[zz]];
134 Int32 cell_lid = cells_local_id[zz];
135 if (cell_lid != NULL_ITEM_LOCAL_ID) {
136 Cell c = internal_cells[cell_lid];
137 m_family->setParticleCell(p, c);
140 m_family->setParticleCell(p,
Cell());
void resize(Int64 s)
Changes the number of elements in the array to s.
ArrayView< T > view() const
Mutable view of this array.
View of cell information.
constexpr Integer size() const noexcept
Number of elements in the array.
Interface of an entity family.
virtual void itemsUniqueIdToLocalId(Int32ArrayView local_ids, Int64ConstArrayView unique_ids, bool do_fatal=true) const =0
Converts an array of unique numbers to local numbers.
void reserveInt64(Int64 n)
Reserve for n Int64.
@ ModePut
The serializer expects reserve().
@ ModeGet
The serializer expects get().
virtual Int64 getInt64()=0
Retrieve a size.
virtual void putSpan(Span< const Real > values)
Add the array values.
virtual eMode mode() const =0
Current operating mode.
virtual void getSpan(Span< Real > values)
Retrieve the array values.
virtual void reserveSpan(eBasicDataType dt, Int64 n)=0
Reserves memory for n values of dt.
virtual void putInt64(Int64 value)=0
Add the integer value.
__host__ __device__ ItemUniqueId uniqueId(Int32 local_id) const
uniqueId() of the entity with local ID local_id
View of a list to obtain information about entities.
Int32 owner() const
Owner subdomain number of the entity.
ItemUniqueId uniqueId() const
Unique identifier across all domains.
bool hasCell() const
True if the particle is in a mesh cell.
Cell cell() const
Cell to which the particle belongs. You must call setCell() before calling this function....
void deserializeItems(ISerializer *buf, Int32Array *local_ids) override
Deserializes the entities of the family family() from buf.
UniqueArray< Int64 > Int64UniqueArray
Dynamic 1D array of 64-bit integers.
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.
@ Int64
64-bit integer data type
ConstArrayView< ItemInternal * > ItemInternalList
Type of the internal list of entities.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
std::int32_t Int32
Signed integer type of 32 bits.