Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
DoFFamily.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/* DoFFamily.h (C) 2000-2024 */
9/* */
10/* Degree of Freedom Family (DoF) */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MESH_DOFFAMILY_H
13#define ARCANE_MESH_DOFFAMILY_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18#include "arcane/core/IMesh.h"
19#include "arcane/core/IParallelMng.h"
20#include "arcane/core/IDoFFamily.h"
21
22#include "arcane/mesh/ItemFamily.h"
23
24// can be removed, used only for ENUMERATE_ITEM_INTERNAL_MAP_DATA macro...
25#include "arcane/mesh/DynamicMeshIncrementalBuilder.h"
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30namespace Arcane::mesh
31{
32class DynamicMesh;
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37class ARCANE_MESH_EXPORT DoFUids
38{
42 public:
43
44 // item with one dof
45 static Int64 uid(Int64 connected_item_uid) { return connected_item_uid; } // Trivial.
46
47 // item with several dof
48 static Int64 uid(Int64 max_dof_family_uid,
49 Int64 max_connected_item_family_uid,
50 Int64 connected_item_uid,
51 Int32 dof_index_in_item)
52 {
53 return connected_item_uid + (max_connected_item_family_uid + 1) * dof_index_in_item + max_dof_family_uid + 1;
54 } // very temporary solution...
55
56 // utilities
57 static Int64 getMaxItemUid(IItemFamily* family);
58};
59
60/*---------------------------------------------------------------------------*/
61/*---------------------------------------------------------------------------*/
62
63class ARCANE_MESH_EXPORT DoFFamily
64: public ItemFamily
66, public IDoFFamily
67{
68 private:
69
72 DoFFamily(IMesh* mesh, const String& name);
73
74 public:
75
76 // Implementation of IDoFFamily
77 String name() const override { return ItemFamily::name(); }
78 String fullName() const override { return ItemFamily::fullName(); }
79 Integer nbItem() const override { return ItemFamily::nbItem(); }
80 ItemGroup allItems() const override { return ItemFamily::allItems(); }
81 void endUpdate() override { return ItemFamily::endUpdate(); }
82 IItemFamily* itemFamily() override { return this; }
83
84 public:
85
87 {
88 return _allocDoF(uid);
89 }
90
91 ItemInternal* allocOne(Int64 uid)
92 {
93 return _allocDoF(uid);
94 }
95
96 // IItemFamilyModifier interface
97 Item findOrAllocOne(Int64 uid, ItemTypeId, MeshInfos&, bool& is_alloc) override
98 {
99 auto dof = _findOrAllocDoF(uid, is_alloc);
100 return dof;
101 }
102
103 ItemInternal* findOrAllocOne(Int64 uid, bool& is_alloc)
104 {
105 return _findOrAllocDoF(uid, is_alloc);
106 }
107
108 // IItemFamilyModifier interface
109 IItemFamily* family() override { return this; }
110
111 IDoFFamily* toDoFFamily() override { return this; }
112
114 DoFVectorView addDoFs(Int64ConstArrayView dof_uids, Int32ArrayView dof_lids) override;
115
117 DoFVectorView addGhostDoFs(Int64ConstArrayView dof_uids, Int32ArrayView dof_lids, Int32ConstArrayView owners) override;
118
120 void computeSynchronizeInfos() override;
121
122 DoFGroup allDoFs() { return ItemFamily::allItems(); }
123 DoFGroup ownDoFs() { return ItemFamily::allItems().own(); }
124 DoFGroup ghostDoFs() { return ItemFamily::allItems().ghost(); }
125
126 void removeDoFs(Int32ConstArrayView items_local_id) override;
127
128 private:
129
130 void build() override;
131 void _addItems(Int64ConstArrayView unique_ids, Int32ArrayView items);
132 void addGhostItems(Int64ConstArrayView unique_ids, Int32ArrayView items, Int32ConstArrayView owners) override;
133 void _removeItems(Int32ConstArrayView local_ids, bool keep_ghost = false) { internalRemoveItems(local_ids, keep_ghost); };
134 void internalRemoveItems(Int32ConstArrayView local_ids, bool keep_ghost = false) override;
135 // void compactItems(bool do_sort) {m_need_prepare_dump = false;} //! Overrides ItemFamily::compactItems because there is no compaction for DoFs for now.
136
137 // FOR DEBUG
138 void _printInfos(Integer nb_added);
139
140 private:
141
142 void preAllocate(Integer nb_item);
143 ItemInternal* _allocDoF(const Int64 uid);
144 ItemInternal* _allocDoFGhost(const Int64 uid, const Int32 owner);
145 ItemInternal* _findOrAllocDoF(const Int64 uid, bool& is_alloc);
146
147 ItemSharedInfoWithType* m_shared_info;
148
149 friend class DynamicMesh;
150};
151
152/*---------------------------------------------------------------------------*/
153/*---------------------------------------------------------------------------*/
154
155} // namespace Arcane::mesh
156
157/*---------------------------------------------------------------------------*/
158/*---------------------------------------------------------------------------*/
159
160#endif
Declarations of types on entities.
Interface of a DoF family.
Definition IDoFFamily.h:34
Interface for modifying a family.
Interface of an entity family.
Definition IItemFamily.h:83
Mesh entity group.
Definition ItemGroup.h:51
Internal structure of a mesh entity.
Type of an entity (Item).
Definition ItemTypeId.h:33
Base class for a mesh element.
Definition Item.h:84
void endUpdate() override
Notifies the end of modification of the entity list.
Definition DoFFamily.h:81
DoFFamily(IMesh *mesh, const String &name)
The family cannot be created directly; the DoFManager must be used.
Definition DoFFamily.cc:51
String fullName() const override
Full family name (with the mesh's name).
Definition DoFFamily.h:78
Integer nbItem() const override
Number of entities.
Definition DoFFamily.h:79
ItemGroup allItems() const override
Group of all entities.
Definition DoFFamily.h:80
IDoFFamily * toDoFFamily() override
Returns the interface of the particle family for this family.
Definition DoFFamily.h:111
Item allocOne(Int64 uid, ItemTypeId, MeshInfos &) override
Allocates an element in the family and updates the corresponding mesh_info.
Definition DoFFamily.h:86
String name() const override
Family name.
Definition DoFFamily.h:77
static Int64 uid(Int64 connected_item_uid)
Definition DoFFamily.h:45
Implementation of a mesh.
Definition DynamicMesh.h:98
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.
String name() const override
Family name.
Definition ItemFamily.h:140
Class containing mesh information.
Definition MeshInfos.h:36
ItemVectorViewT< DoF > DoFVectorView
View over a vector of degrees of freedom.
Definition ItemTypes.h:316
ItemGroupT< DoF > DoFGroup
Group of Degrees of Freedom.
Definition ItemTypes.h:194
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.