270 m_internal->corefinementTimer.start();
271 m_internal->migrationTimer.start();
273 pinfo() <<
"Surface infos berfore migration "
274 << m_master_group.name() <<
"(" << m_master_group.size() <<
") and "
275 << m_slave_group.name() <<
"(" << m_slave_group.size() <<
")";
277 IParallelMng * parallel_mng = subDomain()->parallelMng();
285 master_lower_left(maxValue,maxValue,maxValue),
286 master_upper_right(-maxValue,-maxValue,-maxValue),
287 slave_lower_left(maxValue,maxValue,maxValue),
288 slave_upper_right(-maxValue,-maxValue,-maxValue);
294 for (
Node node : iface->nodes()) {
295 master_lower_left =
math::min(master_lower_left, nodesCoordinates[node]);
296 master_upper_right =
math::max(master_upper_right, nodesCoordinates[node]);
300 for (
Node node : iface->nodes()) {
301 master_lower_left =
math::min(master_lower_left, nodesCoordinates[node]);
302 master_upper_right =
math::max(master_upper_right, nodesCoordinates[node]);
308 for (
Node node : iface->nodes()) {
309 slave_lower_left =
math::min(slave_lower_left, nodesCoordinates[node]);
310 slave_upper_right =
math::max(slave_upper_right, nodesCoordinates[node]);
315 master_lower_left.subSame(m_box_tolerance);
316 master_upper_right.addSame(m_box_tolerance);
317 slave_lower_left.subSame(m_box_tolerance);
318 slave_upper_right.
addSame(m_box_tolerance);
320 <<
" M= " << master_lower_left <<
" - " << master_upper_right
321 <<
" S= " << slave_lower_left <<
" - " << slave_upper_right;
326 myBox.
add(master_lower_left);
327 myBox.
add(master_upper_right);
328 myBox.
add(slave_lower_left);
329 myBox.
add(slave_upper_right);
331 const Integer nbSubDomain = subDomain()->nbSubDomain();
343#ifndef NO_USER_WARNING
344#warning "optimisations possibles"
346 for(
Integer i_sub_domain=0; i_sub_domain<nbSubDomain;++i_sub_domain) {
347 if (i_sub_domain == subDomain()->subDomainId())
continue;
348 Internal::Box masterBox(allBoxes[4*i_sub_domain],allBoxes[4*i_sub_domain+1],nodesCoordinates);
349 masterBox.m_trace = traceMng();
351 if (masterBox.isInside(*iface)) {
352 faces_to_send[i_sub_domain].insert(iface->localId());
353 Cell boundaryCell = iface->boundaryCell();
354 if (boundaryCell.
null())
355 fatal() <<
"Non boundary face used in co-refinement";
356 cells_to_send[i_sub_domain].insert(boundaryCell.
localId());
358 nodes_to_send[i_sub_domain].insert(node.localId());
362 Internal::Box slaveBox(allBoxes[4*i_sub_domain+2],allBoxes[4*i_sub_domain+3],nodesCoordinates);
363 slaveBox.m_trace = traceMng();
365 if (masterBox.isInside(*iface)) {
366 faces_to_send[i_sub_domain].insert(iface->localId());
367 Cell boundaryCell = iface->boundaryCell();
368 if (boundaryCell.
null())
369 fatal() <<
"Non boundary face used in co-refinement";
370 cells_to_send[i_sub_domain].insert(boundaryCell.
localId());
372 nodes_to_send[i_sub_domain].insert(node.localId());
377 Internal::exchange_items(
mesh(),nodes_to_send,faces_to_send,cells_to_send);
380 << m_master_group.name() <<
"(" << m_master_group.size() <<
") and "
381 << m_slave_group.name() <<
"(" << m_slave_group.size() <<
")";
383 m_internal->migrationTimer.stop();
390 FaceGroup slave_coref_group = m_slave_group;
391 FaceGroup master_coref_group = m_master_group;
393 typedef Internal::NodeComparator::IntPair IntPair;
394 std::map<IntPair, Integer > slave_edges;
395 std::map<IntPair, Integer > master_edges;
396 Internal::surfaceSetup(slave_edges,slave_coref_group,m_geometry);
397 Internal::surfaceSetup(master_edges,master_coref_group,m_geometry);
401 for(std::map<IntPair, Integer>::iterator i=slave_edges.begin(); i!=slave_edges.end(); ++i)
404 else if (i->second > 2)
405 fatal() <<
"Not manifold slave surface";
406 if (addEdges.connexCount() > 1)
407 fatal() <<
"Slave surface is not connex";
411 for(std::map<IntPair, Integer>::iterator i=master_edges.begin(); i!=master_edges.end(); ++i)
414 else if (i->second > 2)
415 fatal() <<
"Not manifold master surface";
416 if (addEdges.connexCount() > 1)
417 fatal() <<
"Master surface is not connex";
431 FaceFaceContactList coarse_contacts;
455#ifndef NO_USER_WARNING
456#warning "utiliser un destroySurface ???"
458 delete masterSurface;
468 typedef std::map<Integer,Real3> SharedCorefinement;
469 SharedCorefinement voidface_shared_corefinement;
470 ARCANE_ASSERT(( coarse_contacts.empty() == master_coref_group.
empty() ),(
"Incompatible emptyness"));
472 if (coarse_contacts.empty())
475 voidface_shared_corefinement[iface->localId()];
481 SharedCorefinement facevoid_shared_corefinement;
482 for(FaceFaceContactList::iterator i = coarse_contacts.begin(); i != coarse_contacts.end(); ++i) {
484 const Face master_face = contact.faceA;
485 const Face slave_face = contact.faceB;
486 if (slave_face.
null()) {
487 if (master_face.
isOwn()) {
488 facevoid_shared_corefinement[master_face.
localId()] += contact.normalA;
490 }
else if (master_face.
null()) {
491 if (slave_face.
isOwn()) {
493 voidface_shared_corefinement[slave_face.
localId()];
495 }
else if (master_face.
isOwn() or slave_face.
isOwn()) {
496 if (checkFaces(master_face,slave_face)) {
499 if (master_face.
isOwn())
500 m_contacts.add(contact);
503 if (master_face.
isOwn()) {
504 facevoid_shared_corefinement[master_face.
localId()] += contact.normalA;
506 if (slave_face.
isOwn()) {
507 voidface_shared_corefinement[slave_face.
localId()];
514 for(SharedCorefinement::const_iterator i=facevoid_shared_corefinement.begin();
515 i != facevoid_shared_corefinement.end(); ++i) {
516 Face faceA(internals[i->first]);
518 ARCANE_ASSERT((faceA.
isOwn()),(
"Non local facevoid"));
520 contact.normalA = i->second;
522 m_contacts.
add(contact);
531 for(FaceFaceContactList::iterator i = m_contacts.begin(); i != m_contacts.end(); ++i)
534 const Face master_face = contact.faceA;
535 const Face slave_face = contact.faceB;
536 if (not slave_face.
null()) {
537 ARCANE_ASSERT((not master_face.
null()),(
"Integrity error"));
538 if (slave_face.
isOwn()) {
539 if (master_face.
isOwn()) {
541 SharedCorefinement::iterator vf_finder = voidface_shared_corefinement.find(slave_face.
localId());
542 if (vf_finder != voidface_shared_corefinement.end()) {
543 vf_finder->second += contact.normalB;
548 if (master_face.
isOwn())
549 ++info_to_send[slave_face.
owner()];
561 parallel_mng->allToAll(info_to_send,info_to_recv,1);
562 std::list<std::shared_ptr<SerializeMessage> > recv_messages;
563 for(
Integer i=0;i<nbSubDomain;++i)
565 if (info_to_recv[i] > 0)
568 recv_messages.push_back(std::shared_ptr<SerializeMessage>(message));
575 for(
Integer i=0;i<nbSubDomain;++i)
577 const Integer faceface_info_to_send = info_to_send[i];
578 if (faceface_info_to_send > 0)
581 sent_messages[i].reset(message);
584 sbuf.
setMode(ISerializer::ModeReserve);
585 sbuf.reserveInteger(2);
596 for(FaceFaceContactList::iterator i = m_contacts.begin(); i != m_contacts.end(); ++i)
599 const Face master_face = contact.faceA;
600 const Face slave_face = contact.faceB;
601 if (not slave_face.
null() and not slave_face.
isOwn() and master_face.
isOwn())
603 std::shared_ptr<SerializeMessage> message = sent_messages[slave_face.
owner()];
623 delete messageList; messageList = NULL;
627 for(std::list<std::shared_ptr<SerializeMessage> >::iterator i=recv_messages.begin(); i!=recv_messages.end(); ++i)
629 std::shared_ptr<SerializeMessage> & message = *i;
630 const Integer origDomainId = message->destRank();
631 ARCANE_ASSERT((origDomainId != subDomain()->subDomainId()),(
"Local to local sent"));
635 ARCANE_ASSERT((faceface_count == info_to_recv[origDomainId]),(
"Bad recv faceface count"));
639 mesh()->faceFamily()->itemsUniqueIdToLocalId(lids,uids,
true);
642 for(
Integer j=0;j<faceface_count;++j)
644 Face faceA(internals[lids[2*j ]]);
645 Face faceB(internals[lids[2*j+1]]);
646 ARCANE_ASSERT((faceB.
isOwn()),(
"Not local information recieved"));
652 m_contacts.add(contact);
654 SharedCorefinement::iterator vf_finder = voidface_shared_corefinement.find(faceB.
localId());
655 if (vf_finder != voidface_shared_corefinement.end()) {
656 vf_finder->second += contact.normalB;
663 for(SharedCorefinement::const_iterator i=voidface_shared_corefinement.begin();
664 i != voidface_shared_corefinement.end(); ++i) {
666 Face faceB(internals[i->first]);
667 ARCANE_ASSERT((faceB.
isOwn()),(
"Non local voidface"));
668 Real3 faceB_normal = m_geometry->computeOrientedMeasure(faceB);
672 contact.normalB = faceB_normal - i->second;
674 m_contacts.
add(contact);
681 m_internal->corefinementTimer.stop();
684 times[0] = m_internal->corefinementTimer.totalTime();
685 times[1] = m_internal->migrationTimer.totalTime();
687 info() <<
"Corefinement timers : all=" << times[0] <<
" migration=" << times[1] <<
" #domains=" << parallel_mng->
commSize();