Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MapCoordToUid.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* MapCoordToUid.cc (C) 2000-2024 */
9/* */
10/* Recherche d'entités à partir de ses coordonnées. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MESH_MAPCOORDTOUID_H
13#define ARCANE_MESH_MAPCOORDTOUID_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/ITraceMng.h"
18#include "arcane/utils/TraceAccessor.h"
19#include "arcane/utils/Real3.h"
20#include "arcane/utils/Math.h"
21
22#include "arcane/core/SharedVariable.h"
24
25#include "arcane/mesh/MeshGlobal.h"
26#include "arcane/mesh/DynamicMeshKindInfos.h"
27
28#include <map>
29#include <unordered_map>
30#include <unordered_set>
31#include "arcane/utils/PerfCounterMng.h"
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36namespace Arcane::mesh
37{
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
47{
48 public:
49
50 typedef std::unordered_multimap<Int32, std::pair<const Real3, Int64>> map_type;
51 // typedef std::unordered_multimap<Int64, std::pair<const Real3,Int64> > map_type; // This (needed !) correction introduces a bug in a IFPEN application...investigation in progress (Scarab Arc356@IFPEN)
52 typedef std::unordered_set<Int64> set_type;
53 static const Real TOLERANCE;
54
55 class Box
56 {
57 public:
58
59 Box();
60 virtual ~Box() {}
61 void init(IMesh* mesh);
62 void init2(IMesh* mesh);
63 Real3 m_lower_bound;
64 Real3 m_upper_bound;
65 Real3 m_size;
66 };
67
68#ifdef ACTIVATE_PERF_COUNTER
69 struct PerfCounter
70 {
71 typedef enum
72 {
73 Clear,
74 Fill,
75 Fill2,
76 Insert,
77 Find,
78 Key,
80 } eType;
81
82 static const std::string m_names[NbCounters];
83 };
84#endif
85 MapCoordToUid(IMesh* mesh);
86
87 void setBox(Box* box)
88 {
89 m_box = box;
90 }
91
92 void clear() { m_map.clear(); }
93 void _clear();
94
95 void updateNodeData(ArrayView<ItemInternal*> coarsen_cells);
96 void updateFaceData(ArrayView<ItemInternal*> coarsen_cells);
97
98 void clearNodeData(ArrayView<ItemInternal*> coarsen_cells);
99 void clearFaceData(ArrayView<ItemInternal*> coarsen_cells);
100
101 Int64 insert(const Real3, const Int64, const Real tol = TOLERANCE);
102 void erase(const Real3, const Real tol = TOLERANCE);
103
104 bool empty() const { return m_map.empty(); }
105
106 Int64 find(const Real3, const Real tol = TOLERANCE);
107
108 bool areClose(Real3 const& p1, Real3 const& p2, Real tol)
109 {
110 return Arcane::math::abs(p1.x - p2.x) +
111 Arcane::math::abs(p1.y - p2.y) +
112 Arcane::math::abs(p1.z - p2.z) <=
113 tol;
114 }
115
116#ifdef ACTIVATE_PERF_COUNTER
117 PerfCounterMng<PerfCounter>& getPerfCounter()
118 {
119 return m_perf_counter;
120 }
121#endif
122 protected:
123
124 Int64 key(const Real3);
125
126 protected:
127
128 IMesh* m_mesh;
129 map_type m_map;
130 Box* m_box;
131 VariableNodeReal3& m_nodes_coords;
132#ifdef ACTIVATE_PERF_COUNTER
133 PerfCounterMng<PerfCounter> m_perf_counter;
134#endif
135};
136
137/*---------------------------------------------------------------------------*/
138/*---------------------------------------------------------------------------*/
139
141: public MapCoordToUid
142{
143 public:
144
145 typedef MapCoordToUid BaseType;
147 : MapCoordToUid(mesh)
148 {}
149 void init();
150 void check();
151
152 bool insert(const Real3 center, const Int64 uid, const Real tol = TOLERANCE)
153 {
154 return BaseType::insert(center, uid, tol) != uid;
155 }
156
157 void init2();
158 void check2();
159
161 void updateData(ArrayView<ItemInternal*> refine_cells);
162
163 inline bool isItemToSuppress(Node node, const Int64 parent_uid) const;
164
165 protected:
166
167 void fill();
168 void fill2();
169};
170
171/*---------------------------------------------------------------------------*/
172/*---------------------------------------------------------------------------*/
173
175{
176 public:
177
178 typedef MapCoordToUid BaseType;
180 : MapCoordToUid(mesh)
181 , m_face_center(VariableBuildInfo(mesh, "AMRFaceCenter"))
182 {}
183 void init();
184 void check();
185
186 void init2();
187 void check2();
188
189 bool insert(const Real3& center, const Int64& uid, const Real tol = TOLERANCE)
190 {
191 Int64 old_uid = BaseType::insert(center, uid, tol);
192 if (uid != old_uid) {
193 m_new_uids.insert(uid);
194 return true;
195 }
196 return false;
197 }
198
199 void clearNewUids()
200 {
201 m_new_uids.clear();
202 }
203
204 bool isNewUid(Int64 uid)
205 {
206 return m_new_uids.find(uid) != m_new_uids.end();
207 }
208
210 void updateData(ArrayView<ItemInternal*> refine_cells);
211
212 void initFaceCenter();
213 void updateFaceCenter(ArrayView<ItemInternal*> refine_cells);
214
215 protected:
216
217 void fill();
218 void fill2();
219
220 Real3 faceCenter(Face face) const;
221 bool isItemToSuppress(Face face) const;
222
223 private:
224
225 VariableFaceReal3 m_face_center;
226 set_type m_new_uids;
227};
228/*---------------------------------------------------------------------------*/
229/*---------------------------------------------------------------------------*/
230
231} // namespace Arcane::mesh
232
233/*---------------------------------------------------------------------------*/
234/*---------------------------------------------------------------------------*/
235
236#endif /* MapCoordToUid_H_ */
Fonctions mathématiques diverses.
Face d'une maille.
Definition Item.h:932
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Noeud d'un maillage.
Definition Dom.h:204
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Paramètres nécessaires à la construction d'une variable.
structure de recherche d'un noeud à partir de ses coords La clef de hashage est la position geometriq...
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.