Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
MapCoordToUid.cc
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/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/Real3.h"
15#include "arcane/utils/ITraceMng.h"
16
17#include "arcane/core/IMesh.h"
18#include "arcane/core/SharedVariable.h"
19#include "arcane/core/IParallelMng.h"
20
21#include "arcane/mesh/DynamicMesh.h"
22#include "arcane/mesh/MapCoordToUid.h"
23
24#include <limits>
25#include <utility>
26#include <set>
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Arcane::mesh
32{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37const Real MapCoordToUid::TOLERANCE = 1.e-6;
38
39//--------------------------------------------------------------------------
40namespace
41{
42 // 10 bits per coordinate, to work with 32+ bit machines
43 const unsigned int chunkmax = 1024;
44 const unsigned long chunkmax2 = 1048576;
45 const Real chunkfloat = 1024.0;
46}
47
48#ifdef ACTIVATE_PERF_COUNTER
49const std::string MapCoordToUid::PerfCounter::m_names[] =
50 {
51 "Clear",
52 "Fill",
53 "Fill2",
54 "Insert",
55 "Find",
56 "Key"
57 };
58#endif
59
60/*---------------------------------------------------------------------------*/
61/*---------------------------------------------------------------------------*/
62
63MapCoordToUid::Box::
64Box()
65{
66 m_lower_bound = std::numeric_limits<Real>::max();
67 m_upper_bound = -std::numeric_limits<Real>::max();
68}
69
70/*---------------------------------------------------------------------------*/
71/*---------------------------------------------------------------------------*/
72
73void MapCoordToUid::Box::
74init(IMesh* mesh)
75{
76 m_lower_bound = std::numeric_limits<Real>::max();
77 m_upper_bound = -std::numeric_limits<Real>::max();
78 // bounding box
79 SharedVariableNodeReal3 nodes_coords(mesh->sharedNodesCoordinates());
80
81 ENUMERATE_NODE(i_item,mesh->allNodes()){
82 m_lower_bound[0] = std::min(m_lower_bound[0],nodes_coords[i_item].x);
83 m_lower_bound[1] = std::min(m_lower_bound[1],nodes_coords[i_item].y);
84 m_lower_bound[2] = std::min(m_lower_bound[2],nodes_coords[i_item].z);
85 m_upper_bound[0] = std::max(m_upper_bound[0],nodes_coords[i_item].x);
86 m_upper_bound[1] = std::max(m_upper_bound[1],nodes_coords[i_item].y);
87 m_upper_bound[2] = std::max(m_upper_bound[2],nodes_coords[i_item].z);
88 }
89 // la box du maillage entier
90 if (mesh->parallelMng()->isParallel()){
91 mesh->parallelMng()->reduce(Parallel::ReduceMin,m_lower_bound);
92 mesh->parallelMng()->reduce(Parallel::ReduceMax,m_upper_bound);
93 }
94 m_size = m_upper_bound - m_lower_bound;
95}
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99
100void MapCoordToUid::Box::
101init2(IMesh* mesh)
102{
103 // bounding box
104 m_lower_bound = std::numeric_limits<Real>::max();
105 m_upper_bound = -std::numeric_limits<Real>::max();
106
107 SharedVariableNodeReal3 nodes_coords(mesh->sharedNodesCoordinates());
108 DynamicMesh* dmesh = ARCANE_CHECK_POINTER(dynamic_cast<DynamicMesh*>(mesh));
109 ItemInternalMap& nodes_map = dmesh->nodesMap();
110
111 nodes_map.eachItem([&](Node node) {
112 Int64 uid = node.uniqueId().asInt64();
113 if(uid == NULL_ITEM_ID)
114 return;
115 m_lower_bound[0] = std::min(m_lower_bound[0],nodes_coords[node].x);
116 m_lower_bound[1] = std::min(m_lower_bound[1],nodes_coords[node].y);
117 m_lower_bound[2] = std::min(m_lower_bound[2],nodes_coords[node].z);
118 m_upper_bound[0] = std::max(m_upper_bound[0],nodes_coords[node].x);
119 m_upper_bound[1] = std::max(m_upper_bound[1],nodes_coords[node].y);
120 m_upper_bound[2] = std::max(m_upper_bound[2],nodes_coords[node].z);
121 });
122 // la box du maillage entier
123 if (mesh->parallelMng()->isParallel()) {
124 mesh->parallelMng()->reduce(Parallel::ReduceMin,m_lower_bound);
125 mesh->parallelMng()->reduce(Parallel::ReduceMax,m_upper_bound);
126 }
127 m_size = m_upper_bound - m_lower_bound ;
128}
129
130/*---------------------------------------------------------------------------*/
131/*---------------------------------------------------------------------------*/
132
133MapCoordToUid::
134MapCoordToUid(IMesh* mesh)
135: m_mesh(mesh)
136, m_box(NULL)
137, m_nodes_coords(mesh->nodesCoordinates())
138{
139#ifdef ACTIVATE_PERF_COUNTER
140 m_perf_counter.init() ;
141#endif
142}
143
144/*---------------------------------------------------------------------------*/
145/*---------------------------------------------------------------------------*/
146
147void NodeMapCoordToUid::
148init()
149{
150 _clear();
151 fill();
152}
153
154/*---------------------------------------------------------------------------*/
155/*---------------------------------------------------------------------------*/
156
157void FaceMapCoordToUid::
158init()
159{
160 _clear() ;
161 fill();
162 clearNewUids();
163}
164
165/*---------------------------------------------------------------------------*/
166/*---------------------------------------------------------------------------*/
167
168void NodeMapCoordToUid::
169init2()
170{
171 _clear();
172 this->fill2();
173}
174
175
176/*---------------------------------------------------------------------------*/
177/*---------------------------------------------------------------------------*/
178
179bool NodeMapCoordToUid::
180isItemToSuppress(Node node, const Int64 parent_uid) const
181{
182 for( Cell cell : node.cells() )
183 if (cell.isActive() || cell.uniqueId()==parent_uid)
184 return false;
185 return true;
186}
187
188/*---------------------------------------------------------------------------*/
189/*---------------------------------------------------------------------------*/
190
191void FaceMapCoordToUid::
192init2()
193{
194 _clear() ;
195 this->fill2();
196}
197
198/*---------------------------------------------------------------------------*/
199/*---------------------------------------------------------------------------*/
200
201Real3 FaceMapCoordToUid::
202faceCenter(Face face) const
203{
204 Real3 pfc = Real3::null();
205 for( Node node : face.nodes() )
206 pfc += m_nodes_coords[node];
207 pfc /= static_cast<Real> (face.nbNode());
208 return pfc ;
209}
210
211/*---------------------------------------------------------------------------*/
212/*---------------------------------------------------------------------------*/
213
214bool FaceMapCoordToUid::
215isItemToSuppress(Face face) const
216{
217 if (face.nbCell()==1)
218 return ! face.cell(0).isActive() ;
219 else{
220 Cell cell0 = face.cell(0);
221 Cell cell1 = face.cell(1);
222 Integer level0 = cell0.level();
223 Integer level1 = cell1.level();
224 if(level0==level1)
225 return ! (cell0.isActive() || cell1.isActive()) ;
226 if(level0>level1)
227 return ! cell0.isActive() ;
228 else
229 return ! cell1.isActive() ;
230 }
231}
232
233/*---------------------------------------------------------------------------*/
234/*---------------------------------------------------------------------------*/
235
236void MapCoordToUid::
237_clear()
238{
239 CHECKPERF( m_perf_counter.start(PerfCounter::Clear) )
240
241 for(map_type::iterator iter = m_map.begin();iter != m_map.end();++iter){
242 iter->second.second = NULL_ITEM_ID ;
243 }
244 CHECKPERF( m_perf_counter.stop(PerfCounter::Clear) )
245}
246
247/*---------------------------------------------------------------------------*/
248/*---------------------------------------------------------------------------*/
249
250void NodeMapCoordToUid::
251clearData(ArrayView<ItemInternal*> coarsen_cells)
252{
253 typedef std::set<Int64> set_type;
254 typedef std::pair<set_type::iterator,bool> insert_return_type;
255 set_type node_list;
256 for (Integer icell = 0; icell < coarsen_cells.size(); icell++){
257 Cell parent(coarsen_cells[icell]);
258 for (UInt32 i = 0, nc = parent.nbHChildren(); i < nc; i++){
259 Cell child = parent.hChild(i);
260 for( Node node : child.nodes() ){
261 Int64 uid = node.uniqueId() ;
262 insert_return_type value = node_list.insert(uid) ;
263 if(value.second){
264 if(isItemToSuppress(node, parent.uniqueId())){
265 m_mesh->traceMng()->debug(Trace::Highest)<<"SUPPRESS NODE : "<<uid<<" "<<m_nodes_coords[node] ;
266 erase(m_nodes_coords[node]) ;
267 //++count ;
268 }
269 }
270 }
271 }
272 }
273 //cout<<"NUMBER OF SUPPRESSED NODES : "<<count<<endl ;
274}
275
276/*---------------------------------------------------------------------------*/
277/*---------------------------------------------------------------------------*/
278
279void FaceMapCoordToUid::
280clearData(ArrayView<ItemInternal*> coarsen_cells)
281{
282 typedef std::set<Int64> set_type;
283 typedef std::pair<set_type::iterator,bool> insert_return_type;
284 set_type face_list;
285 for(Integer icell=0;icell<coarsen_cells.size();++icell){
286 Cell cell(coarsen_cells[icell]);
287 for (UInt32 i = 0, nc = cell.nbHChildren(); i < nc; i++){
288 Cell child = cell.hChild(i) ;
289 for( Face face : child.faces() ){
290 Int64 uid = face.uniqueId() ;
291 insert_return_type value = face_list.insert(uid) ;
292 if(value.second){
293 //cout<<" test face "<<uid<<" " ;
294 //for(int ic=0;ic<iface->nbCell();++ic)
295 // cout<<" c["<<iface->cell(ic)->uniqueId()<<" "<<iface->cell(ic)->isActive()<<" "<<iface->cell(ic)->nbHChildren();
296 //cout<<endl ;
297 if(isItemToSuppress(face)){
298 //Real3 fc = faceCenter(*iface) ;
299 //cout<<"SUPPRESS FACE : "<<uid<<" "<<m_face_center[iface]<<endl ;
300 erase(m_face_center[face]) ;
301 }
302 }
303 }
304 }
305 }
306}
307
308/*---------------------------------------------------------------------------*/
309/*---------------------------------------------------------------------------*/
310
311void NodeMapCoordToUid::
312updateData(ArrayView<ItemInternal*> refine_cells)
313{
314 typedef std::set<Int64> set_type;
315 typedef std::pair<set_type::iterator,bool> insert_return_type;
316 set_type node_list;
317 std::size_t count = 0;
318 for (Integer icell = 0; icell < refine_cells.size(); icell++){
319 Cell parent=refine_cells[icell];
320 for (UInt32 i = 0, nc = parent.nbHChildren(); i < nc; i++){
321 Cell child = parent.hChild(i) ;
322 for( Node node : child.nodes() ){
323 Int64 uid = node.uniqueId() ;
324 insert_return_type value = node_list.insert(uid) ;
325 if (value.second){
326 bool is_new = insert(m_nodes_coords[node],uid) ;
327 if(is_new){
328 m_mesh->traceMng()->debug(Trace::Highest)<<"INSERT NODE : "<<uid<<" "<<m_nodes_coords[node] ;
329 ++count;
330 }
331 }
332 }
333 }
334 }
335 m_mesh->traceMng()->debug(Trace::Highest)<<"NUMBER OF ADDED NODES : "<<count ;
336 //check() ;
337}
338
339/*---------------------------------------------------------------------------*/
340/*---------------------------------------------------------------------------*/
341
342void FaceMapCoordToUid::
343updateData(ArrayView<ItemInternal*> refine_cells)
344{
345 typedef std::set<Int64> set_type;
346 typedef std::pair<set_type::iterator,bool> insert_return_type;
347 set_type face_list ;
348 for(Integer icell=0;icell<refine_cells.size();++icell){
349 Cell cell = refine_cells[icell] ;
350 for (UInt32 i = 0, nc = cell.nbHChildren(); i < nc; i++){
351 Cell child = cell.hChild(i) ;
352 for( Face face : child.faces() ){
353 Int64 uid = face.uniqueId() ;
354 insert_return_type value = face_list.insert(uid);
355 if(value.second){
356 Real3 fc = faceCenter(face);
357 m_face_center[face] = fc;
358 insert(fc,uid) ;
359 }
360 }
361 }
362 }
363}
364
365/*---------------------------------------------------------------------------*/
366/*---------------------------------------------------------------------------*/
367
368Int64 MapCoordToUid::
369insert(const Real3 p,const Int64 uid,Real tol)
370{
371 CHECKPERF( m_perf_counter.start(PerfCounter::Insert) )
372 //this->m_map.insert(std::make_pair(this->key(p), std::make_pair(p,uid)));
373 Int64 pointkey = this->key(p);
374
375 // Look for the exact key first
376 std::pair<map_type::iterator,map_type::iterator>
377 pos = m_map.equal_range(pointkey);
378 map_type::iterator iter = pos.first ;
379 while (iter != pos.second){
380 if ( areClose(p,iter->second.first,tol)){
381 Int64 old_uid = iter->second.second;
382 iter->second.second = uid ;
383 CHECKPERF( m_perf_counter.stop(PerfCounter::Insert) )
384 return old_uid ;
385 }
386 else
387 ++iter;
388 }
389 // Look for neighboring bins' keys next
390 for (int xoffset = -1; xoffset != 2; ++xoffset)
391 for (int yoffset = -1; yoffset != 2; ++yoffset)
392 for (int zoffset = -1; zoffset != 2; ++zoffset) {
393 std::pair<map_type::iterator,map_type::iterator>
394 pos2 = m_map.equal_range(pointkey +
395 xoffset*chunkmax2 +
396 yoffset*chunkmax +
397 zoffset);
398 map_type::iterator iter2 = pos2.first ;
399 while (iter2 != pos2.second){
400 if ( areClose(p,iter2->second.first,tol)){
401 Int64 old_uid = iter2->second.second ;
402 iter2->second.second = uid ;
403 CHECKPERF( m_perf_counter.stop(PerfCounter::Insert) )
404 return old_uid;
405 }
406 else
407 ++iter2;
408 }
409 }
410 m_map.insert(pos.first,std::make_pair(pointkey, std::make_pair(p,uid)));
411 CHECKPERF( m_perf_counter.stop(PerfCounter::Insert) )
412 return NULL_ITEM_ID ;
413}
414
415/*---------------------------------------------------------------------------*/
416/*---------------------------------------------------------------------------*/
417
418Int64 MapCoordToUid::
419find(const Real3 p,const Real tol)
420{
421 CHECKPERF( m_perf_counter.start(PerfCounter::Find) )
422
423 // Look for a likely key in the multimap
424 Int64 pointkey = this->key(p);
425
426 // Look for the exact key first
427 std::pair<map_type::iterator,map_type::iterator>
428 pos = m_map.equal_range(pointkey);
429
430 while (pos.first != pos.second)
431 if ( areClose(p,pos.first->second.first,tol)){
432 //debug() << "find(),MapCoordToUid";
433 return pos.first->second.second;
434 }
435 else
436 ++pos.first;
437
438 // Look for neighboring bins' keys next
439 for (int xoffset = -1; xoffset != 2; ++xoffset)
440 for (int yoffset = -1; yoffset != 2; ++yoffset)
441 for (int zoffset = -1; zoffset != 2; ++zoffset){
442 std::pair<map_type::iterator,map_type::iterator>
443 pos = m_map.equal_range(pointkey +
444 xoffset*chunkmax2 +
445 yoffset*chunkmax +
446 zoffset);
447 while (pos.first != pos.second){
448 if ( areClose(p,pos.first->second.first,tol)){
449 return pos.first->second.second;
450 }
451 else
452 ++pos.first;
453 }
454 }
455
456 CHECKPERF( m_perf_counter.stop(PerfCounter::Find) )
457 return NULL_ITEM_ID;
458}
459
460/*---------------------------------------------------------------------------*/
461/*---------------------------------------------------------------------------*/
462
463void MapCoordToUid::
464erase(const Real3 p,const Real tol)
465{
466 ARCANE_UNUSED(tol);
467 // Look for a likely key in the multimap
468 insert(p,NULL_ITEM_ID);
469}
470
471/*---------------------------------------------------------------------------*/
472/*---------------------------------------------------------------------------*/
473
474Int64 MapCoordToUid::
475key(const Real3 p)
476{
477 CHECKPERF( m_perf_counter.start(PerfCounter::Key) )
478 Real xscaled = (p.x - m_box->m_lower_bound.x) / (m_box->m_size.x),
479 yscaled = (p.y - m_box->m_lower_bound.y) / (m_box->m_size.y),
480 zscaled = (m_box->m_upper_bound.z != m_box->m_lower_bound.z)
481 ? ((p.z - m_box->m_lower_bound.z)/(m_box->m_size.z)) : p.z;
482#ifndef NO_USER_WARNING
483#warning [MapCoordToUid::key] 2D m_box->m_upper_bound.z==m_box->m_lower_bound.z
484#endif
485 Int64 n0 = static_cast<Int64> (chunkfloat * xscaled),
486 n1 = static_cast<Int64> (chunkfloat * yscaled),
487 n2 = static_cast<Int64> (chunkfloat * zscaled);
488
489 CHECKPERF( m_perf_counter.stop(PerfCounter::Key) )
490 return chunkmax2*n0 + chunkmax*n1 + n2;
491}
492
493/*---------------------------------------------------------------------------*/
494/*---------------------------------------------------------------------------*/
495
496void NodeMapCoordToUid::
497fill()
498{
499 // Populate the nodes map
500 CHECKPERF( m_perf_counter.start(PerfCounter::Fill) )
501 m_mesh->traceMng()->debug(Trace::Highest)<<"[MapCoordToUid::fill] nb allNodes="<<m_mesh->allNodes().size();
502 ENUMERATE_NODE(i_item,m_mesh->allNodes()){
503 Node node = *i_item;
504 Int64 uid = node.uniqueId().asInt64();
505 this->insert(m_nodes_coords[i_item],uid);
506 }
507 CHECKPERF( m_perf_counter.stop(PerfCounter::Fill) )
508}
509
510/*---------------------------------------------------------------------------*/
511/*---------------------------------------------------------------------------*/
512
513void NodeMapCoordToUid::
514check()
515{
516 m_mesh->traceMng()->debug(Trace::Highest)<<"[NODE MapCoordToUid::fill] nb allNodes="<<m_mesh->allNodes().size();
517 // Populate the nodes map
518 std::set<Int64> set;
519 ENUMERATE_NODE(i_item,m_mesh->allNodes()){
520 Node node = *i_item;
521 Int64 uid = node.uniqueId().asInt64();
522 m_mesh->traceMng()->debug(Trace::Highest)<<"\t[NODE MapCoordToUid::fill] node_"<<node.localId()<<", uid="<<uid<<" "<<m_nodes_coords[i_item];
523 Int64 map_uid = find(m_nodes_coords[i_item]);
524 set.insert(uid) ;
525 if(uid!=map_uid){
526 m_mesh->traceMng()->error()<<"MAP NODE ERROR : uid = "<<uid<<" coords="<<m_nodes_coords[i_item];
527 m_mesh->traceMng()->fatal()<<"MAP NODE ERROR : "<<map_uid<<" found, expected uid "<<uid;
528 }
529 }
530 {
531 Integer count = 0 ;
532 for(map_type::iterator iter = m_map.begin();iter!=m_map.end();++iter)
533 if(iter->second.second!=NULL_ITEM_ID){
534 ++count ;
535 if(set.find(iter->second.second)==set.end()){
536 m_mesh->traceMng()->fatal()<<"MAP NODE ERROR : node "<<iter->second.second<<" "<<iter->second.first<<" does not exist";
537 }
538 }
539 if(count !=m_mesh->allNodes().size())
540 m_mesh->traceMng()->fatal()<<"MAP NODE ERROR : map size"<<count<<" != "<<m_mesh->allNodes().size();
541 }
542}
543
544/*---------------------------------------------------------------------------*/
545/*---------------------------------------------------------------------------*/
546
547void FaceMapCoordToUid::
548fill()
549{
550 CHECKPERF( m_perf_counter.start(PerfCounter::Fill) )
551 m_mesh->traceMng()->debug(Trace::Highest)<<"[MapCoordToUid::fill] nb allFaces="<<m_mesh->allFaces().size();
552 ENUMERATE_FACE(iface,m_mesh->allFaces()){
553 this->insert(m_face_center[iface],iface->uniqueId());
554 }
555 CHECKPERF( m_perf_counter.stop(PerfCounter::Fill) )
556}
557
558/*---------------------------------------------------------------------------*/
559/*---------------------------------------------------------------------------*/
560
561void FaceMapCoordToUid::
562check()
563{
564 m_mesh->traceMng()->debug(Trace::Highest)<<"[FACE MapCoordToUid::fill] nb allFaces="<<m_mesh->allFaces().size();
565 std::set<Int64> set;
566 ENUMERATE_FACE(iface,m_mesh->allFaces()){
567 Int64 uid = iface->uniqueId() ;
568 m_mesh->traceMng()->debug(Trace::Highest)<<"\t[FACE MapCoordToUid::fill] face_"<<iface->localId()<<", uid="<<uid;
569 for( Node inode : iface->nodes() ){
570 m_mesh->traceMng()->debug(Trace::Highest)<<"\t\t[FACE MapCoordToUid::fill] node_"<<inode.localId();
571 }
572 Int64 map_uid = find(m_face_center[iface]);
573 set.insert(uid) ;
574 if(uid!=map_uid){
575 m_mesh->traceMng()->fatal()<<"MAP FACE ERROR : "<<map_uid<<" found, expected uid "<<uid;
576 }
577 }
578 {
579 Integer count = 0;
580 for(map_type::iterator iter = m_map.begin();iter!=m_map.end();++iter)
581 if(iter->second.second!=NULL_ITEM_ID){
582 ++count;
583 if(set.find(iter->second.second)==set.end()){
584 m_mesh->traceMng()->fatal()<<"MAP FACE ERROR : node "<<iter->second.second<<" "<<iter->second.first<<" does not exist";
585 }
586 }
587 if(count !=m_mesh->allFaces().size())
588 m_mesh->traceMng()->fatal()<<"MAP FACE ERROR : map size"<<count<<" != "<<m_mesh->allNodes().size();
589 }
590}
591
592/*---------------------------------------------------------------------------*/
593/*---------------------------------------------------------------------------*/
594
595void NodeMapCoordToUid::
596fill2()
597{
598 CHECKPERF( m_perf_counter.start(PerfCounter::Fill2) )
599 // Populate the nodes map
600 DynamicMesh* dmesh = ARCANE_CHECK_POINTER(dynamic_cast<DynamicMesh*>(m_mesh));
601 ItemInternalMap& nodes_map = dmesh->nodesMap();
602 nodes_map.eachItem([&](Node node) {
603 Int64 uid = node.uniqueId().asInt64();
604 if(uid == NULL_ITEM_ID)
605 return;
606 this->insert(m_nodes_coords[node],uid);
607 });
608 CHECKPERF( m_perf_counter.stop(PerfCounter::Fill2) )
609}
610
611/*---------------------------------------------------------------------------*/
612/*---------------------------------------------------------------------------*/
613
614void NodeMapCoordToUid::
615check2()
616{
617 // Populate the nodes map
618 DynamicMesh* dmesh = ARCANE_CHECK_POINTER(dynamic_cast<DynamicMesh*>(m_mesh));
619 ItemInternalMap& nodes_map = dmesh->nodesMap();
620 nodes_map.eachItem([&](Node node) {
621 Int64 uid = node.uniqueId().asInt64();
622 Int64 map_uid = find(m_nodes_coords[node]);
623 if(uid!=map_uid)
624 ARCANE_FATAL("MAP NODE ERROR : '{0}' found, expected uid '{1}'",map_uid,uid);
625 });
626}
627
628/*---------------------------------------------------------------------------*/
629/*---------------------------------------------------------------------------*/
630
631void FaceMapCoordToUid::
632fill2()
633{
634 CHECKPERF( m_perf_counter.stop(PerfCounter::Fill2) )
635 DynamicMesh* dmesh = ARCANE_CHECK_POINTER(dynamic_cast<DynamicMesh*>(m_mesh));
636 ItemInternalMap& faces_map = dmesh->facesMap();
637 faces_map.eachItem([&](Face face) {
638 Int64 face_uid = face.uniqueId().asInt64();
639 if(face_uid == NULL_ITEM_ID)
640 return;
641 this->insert(faceCenter(face),face_uid);
642 });
643 CHECKPERF( m_perf_counter.stop(PerfCounter::Fill2) )
644}
645
646/*---------------------------------------------------------------------------*/
647/*---------------------------------------------------------------------------*/
648
649void FaceMapCoordToUid::
650check2()
651{
652 DynamicMesh* dmesh = ARCANE_CHECK_POINTER(dynamic_cast<DynamicMesh*>(m_mesh));
653 ItemInternalMap& faces_map = dmesh->facesMap();
654 faces_map.eachItem([&](Face face) {
655 Int64 face_uid = face.uniqueId().asInt64();
656 Int64 map_uid = find(faceCenter(face));
657 if (face_uid != map_uid)
658 ARCANE_FATAL("MAP NODE ERROR : '{0}' found, expected uid '{1}'",map_uid,face_uid);
659 });
660}
661
662/*---------------------------------------------------------------------------*/
663/*---------------------------------------------------------------------------*/
664
665void FaceMapCoordToUid::
666initFaceCenter()
667{
668 ENUMERATE_FACE(iface,m_mesh->allFaces()){
669 m_face_center[iface] = faceCenter(*iface);
670 }
671}
672
673/*---------------------------------------------------------------------------*/
674/*---------------------------------------------------------------------------*/
675
676void FaceMapCoordToUid::
677updateFaceCenter(ArrayView<ItemInternal*> refine_cells)
678{
679 typedef std::set<Int64> set_type ;
680 typedef std::pair<set_type::iterator,bool> insert_return_type;
681 set_type face_list ;
682 for(Integer icell=0;icell<refine_cells.size();++icell){
683 Cell cell = refine_cells[icell] ;
684 for (UInt32 i = 0, nc = cell.nbHChildren(); i<nc; ++i ){
685 Cell child = cell.hChild(i) ;
686 for( Face face : child.faces() ){
687 Int64 uid = face.uniqueId() ;
688 insert_return_type value = face_list.insert(uid);
689 if (value.second){
690 Real3 fc = faceCenter(face);
691 m_face_center[face] = fc;
692 }
693 }
694 }
695 }
696}
697
698/*---------------------------------------------------------------------------*/
699/*---------------------------------------------------------------------------*/
700
701} // End namespace Arcane::mesh
702
703/*---------------------------------------------------------------------------*/
704/*---------------------------------------------------------------------------*/
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
#define ENUMERATE_FACE(name, group)
Enumérateur générique d'un groupe de faces.
#define ENUMERATE_NODE(name, group)
Enumérateur générique d'un groupe de noeuds.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
SharedMeshVariableScalarRefT< Node, Real3 > SharedVariableNodeReal3
Grandeur au noeud de type coordonnées.
Int32 Integer
Type représentant un entier.