14#include "arcane/utils/ArcanePrecomp.h"
16#include "arcane/utils/NotSupportedException.h"
17#include "arcane/utils/ArgumentException.h"
19#include "arcane/mesh/TiedInterfaceExchanger.h"
20#include "arcane/mesh/DynamicMesh.h"
21#include "arcane/mesh/TiedInterface.h"
22#include "arcane/mesh/FaceFamily.h"
24#include "arcane/core/SerializeBuffer.h"
25#include "arcane/core/IParallelMng.h"
26#include "arcane/core/ItemPrinter.h"
27#include "arcane/core/ItemFamilySerializeArgs.h"
57 nb_items.add(nb_tied_node);
58 nb_items.add(nb_tied_face);
59 for (
Integer z = 0; z < nb_tied_node; ++z) {
67 for (
Integer z = 0; z < nb_tied_face; ++z) {
94 info() <<
"DESERIALIZE_INFO rank=" << m_rank <<
" nb_face=" << uids.largeSize();
98 info() <<
"NODES: " << slaves_node_uid;
100 info() <<
"FACES: " << slaves_face_uid;
131 , m_face_family(
mesh->faceFamily())
132 , m_node_family(
mesh->nodeFamily())
168 info(4) <<
"BUILD_AFTER_DESERIALIZE_INFO rank=" << sdi->m_rank <<
" nb_face=" << nb_uid;
169 for (
Integer i = 0; i < nb_uid; ++i) {
170 Int64 uid = sdi->uids[i];
171 Integer nb_slave_node = sdi->nb_items[i * 2];
172 Integer nb_slave_face = sdi->nb_items[(i * 2) + 1];
174 m_index_map.insert(std::make_pair(uid,
FaceInfo(sdi, i, face_index, node_index)));
175 face_index += nb_slave_face;
176 node_index += nb_slave_node;
178 m_sdi_array.add(sdi);
181 void convertUniqueIds()
183 for (
Integer z = 0, n = m_sdi_array.size(); z < n; ++z) {
186 Integer nb_total_slave_face = sdi->slaves_face_uid.
size();
187 info(4) <<
"CONVERT_UID nb_slave_face=" << nb_total_slave_face;
191 Integer nb_total_slave_node = sdi->slaves_node_uid.
size();
192 info(4) <<
"CONVERT_UID nb_slave_node=" << nb_total_slave_node;
198 const FaceInfo& _getInfo(
Int64 uid)
200 std::map<Int64, FaceInfo>::const_iterator iter = m_index_map.find(uid);
201 if (iter == m_index_map.end())
202 throw ArgumentException(A_FUNCINFO, String::format(
"Can not find uid '{0}'", uid));
208 const FaceInfo& fi = _getInfo(uid);
209 Integer face_index = fi.face_index;
210 *nb_node = fi.sd_info->nb_items[face_index * 2];
211 *nb_face = fi.sd_info->nb_items[(face_index * 2) + 1];
214 virtual void fillTiedInfos(Face face,
219 const FaceInfo& fi = _getInfo(face.uniqueId());
220 OneSubDomainInfo* sdi = fi.sd_info;
223 Integer face_index = fi.face_index;
224 Integer nb_node = sdi->nb_items[face_index * 2];
225 Integer nb_face = sdi->nb_items[(face_index * 2) + 1];
229 tied_nodes_lid.copy(nodes_lid);
230 tied_faces_lid.copy(faces_lid);
231 for (
Integer z = 0; z < nb_node; ++z)
232 tied_nodes_isos[z] = Real2(isos[(z * 2)], isos[(z * 2) + 1]);
237 IItemFamily* m_face_family;
238 IItemFamily* m_node_family;
239 std::map<Int64, FaceInfo> m_index_map;
240 UniqueArray<OneSubDomainInfo*> m_sdi_array;
249TiedInterfaceExchanger::
251: TraceAccessor(mesh->traceMng())
253, m_sub_domain(mesh->subDomain())
254, m_deserialized_info(new DeserializedInfo(mesh, traceMng()))
255, m_my_rank(mesh->parallelMng()->commRank())
262TiedInterfaceExchanger::
263~TiedInterfaceExchanger()
265 for (SubDomainInfoMap::const_iterator iter(m_infos.begin()); iter != m_infos.end(); ++iter)
267 delete m_deserialized_info;
273inline TiedInterfaceExchanger::OneSubDomainInfo* TiedInterfaceExchanger::
276 SubDomainInfoMap::const_iterator iter = m_infos.find(rank);
277 if (iter != m_infos.end())
280 m_infos.insert(std::make_pair(rank, sdi));
307 FaceFamily& face_family = m_mesh->trueFaceFamily();
309 for (
Integer i = 0, n = tied_interfaces.
size(); i < n; ++i) {
312 TiedInterfaceNodeList tied_nodes = ti->
tiedNodes();
313 TiedInterfaceFaceList tied_faces = ti->
tiedFaces();
317 Int32 owner = new_owners[iface];
322 sdi->addOne(face, face_tied_nodes, face_tied_faces);
346 switch (buf->
mode()) {
347 case ISerializer::ModeReserve:
348 sdi->serializeReserve(buf);
351 sdi->serializePut(buf);
354 sdi->deserialize(buf);
355 m_deserialized_info->buildAfterDeserializeInfo(sdi);
373 m_deserialized_info->buildAfterDeserializeInfo(sdi);
378 m_deserialized_info->convertUniqueIds();
387 FaceFamily& face_family = m_mesh->trueFaceFamily();
388 for (
Integer i = 0, n = tied_interfaces.
size(); i < n; ++i) {
392 nb_slave_nodes.
resize(nb_master_face);
393 nb_slave_faces.
resize(nb_master_face);
400 m_deserialized_info->getNbSlave(face.
uniqueId(), &nb_node, &nb_face);
401 nb_slave_nodes[index] = nb_node;
402 nb_slave_faces[index] = nb_face;
405 ti->rebuild(m_deserialized_info, nb_slave_nodes, nb_slave_faces);
417 return m_mesh->faceFamily();
Integer size() const
Number of elements in the vector.
Exception when an argument is invalid.
void resize(Int64 s)
Changes the number of elements in the array to s.
Constant view of an array of type T.
constexpr ConstArrayView< T > subView(Integer abegin, Integer asize) const noexcept
Sub-view (constant) starting from element abegin and containing asize elements.
constexpr Integer size() const noexcept
Number of elements in the array.
constexpr ConstArrayView< T > subConstView(Integer abegin, Integer asize) const noexcept
Sub-view (constant) starting from element abegin and containing asize elements.
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.
virtual void putArray(Span< const Real > values)=0
Save the number of elements and the values elements.
virtual void reserveArray(Span< const Real > values)=0
Reserve to save the number of elements and the values elements.
virtual void getArray(Array< Real > &values)=0
Resize and fill values.
@ ModePut
The serializer expects reserve().
@ ModeGet
The serializer expects get().
virtual eMode mode() const =0
Current operating mode.
Arguments for the serialization callbacks of entity families.
Int32 rank() const
Rank of the source or destination.
ISerializer * serializer() const
Associated serializer.
Integer size() const
Number of elements in the group.
ItemUniqueId uniqueId() const
Unique identifier across all domains.
Class managing a 2-dimensional real vector.
constexpr __host__ __device__ Real2 & add(Real2 b)
Adds b to the pair.
Semi-conforming mesh face.
Face face() const
Welded face.
Semi-conformal mesh node.
Node node() const
Tied node.
Real2 isoCoordinates() const
Iso-barycentric coordinates of the node.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessage info() const
Flow for an information message.
ITraceMng * traceMng() const
Trace manager.
Implementation of a mesh.
void applyTiedInterface(ITiedInterface *interface)
Sets the information related to the tied interface interface.
void removeTiedInterface(ITiedInterface *interface)
Removes the information related to the tied interface interface.
VariableItemInt32 & itemsNewOwner() override
Variable containing the number of the new subdomain owning the entity.
void buildAfterDeserializeInfo(OneSubDomainInfo *sdi)
Constructs the info after deserialization.
Int32UniqueArray slaves_node_local_id
Only after deserialization, contains the localId() of each entity in slaves_node_uid.
Int32UniqueArray slaves_face_local_id
Only after deserialization, contains the localId() of each entity in slaves_face_uid.
IItemFamily * family() const override
Associated family.
void initialize() override
Initializes the instance before the start of exchanges.
void serialize(const ItemFamilySerializeArgs &args) override
Serializes the faces into the buffer buf.
void finalize() override
Performs end-of-exchange processing.
Information on mesh semi-conformities.
virtual TiedInterfaceFaceList tiedFaces() const
List of information about the slave faces of a master face.
virtual FaceGroup masterInterface() const
Group containing the master faces.
virtual TiedInterfaceNodeList tiedNodes() const
List of information about the slave nodes of a master face.
ItemGroupT< Face > FaceGroup
Group of faces.
ItemVariableScalarRefT< Int32 > VariableItemInt32
32-bit integer type quantity
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.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
UniqueArray< Real > RealUniqueArray
Dynamic 1D array of reals.
ArrayView< Real2 > Real2ArrayView
C equivalent of a 1D array of Real2.
UniqueArray< Integer > IntegerUniqueArray
Dynamic 1D array of integers.
std::int32_t Int32
Signed integer type of 32 bits.
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.
Real y
second component of the pair
Real x
first component of the pair
Integer slave_node_index
Index in isos and slaves_node_uid of the first slave node.
Integer slave_face_index
Index in slaves_face_uid of the first slave face.
OneSubDomainInfo * sd_info
Instance containing the info.
Integer face_index
Index of the face in the uid array.