|
31 | 31 | * |
32 | 32 | -------------------------------------------------------- |
33 | 33 | * |
34 | | - * Last updated: 30 April, 2020 |
| 34 | + * Last updated: 12 Sept., 2020 |
35 | 35 | * |
36 | 36 | * Copyright 2013-2020 |
37 | 37 | * Darren Engwirda |
|
399 | 399 | std::min(_0src, *_iter) ; |
400 | 400 |
|
401 | 401 | _msrc += std::pow( |
402 | | - (real_type)1. / *_iter, +5); |
| 402 | + (real_type)1. / *_iter, +7); |
403 | 403 | } |
404 | 404 | for (auto _iter = _cdst.head(), |
405 | 405 | _tend = _cdst.tend(); |
|
410 | 410 | std::min(_0dst, *_iter) ; |
411 | 411 |
|
412 | 412 | _mdst += std::pow ( |
413 | | - (real_type)1. / *_iter, +5); |
| 413 | + (real_type)1. / *_iter, +7); |
414 | 414 | } |
415 | 415 |
|
416 | 416 | _qtol *= std::max(_0src, _zero); |
417 | 417 |
|
418 | 418 | _msrc = std::pow( |
419 | | - _csrc.count() / _msrc, +1./5.) ; |
| 419 | + _csrc.count() / _msrc, +1./7.) ; |
420 | 420 | _mdst = std::pow( |
421 | | - _cdst.count() / _mdst, +1./5.) ; |
| 421 | + _cdst.count() / _mdst, +1./7.) ; |
422 | 422 |
|
423 | 423 | _qtol /= |
424 | | - std::pow(_csrc.count(), 1./5.) ; |
| 424 | + std::pow(_csrc.count(), 1./7.) ; |
425 | 425 | _qtol /= |
426 | | - std::pow(_cdst.count(), 1./5.) ; |
| 426 | + std::pow(_cdst.count(), 1./7.) ; |
427 | 427 |
|
428 | 428 | /*---------------------------- test move = "okay" */ |
429 | 429 | if (_0dst >= _GOOD) |
|
663 | 663 | { |
664 | 664 | /*---------------- optimise single node's coordinates */ |
665 | 665 | iptr_type static |
666 | | - constexpr _ITER = (iptr_type) +5 ; |
| 666 | + constexpr _ITER = (iptr_type) +4 ; |
667 | 667 |
|
668 | 668 | _move = (iptr_type)-1 ; |
669 | 669 |
|
|
737 | 737 | if (_kern == dqdx_kern) // "relax" dQ./dx |
738 | 738 | { |
739 | 739 | real_type _BIAS = |
740 | | - (real_type) +2.0 / 3.0 ; |
| 740 | + (real_type) +3.0 / 4.0 ; |
741 | 741 |
|
742 | 742 | for (auto _idim = |
743 | 743 | pred_type::geom_dims; _idim-- != +0; ) |
|
844 | 844 | { |
845 | 845 | /*---------------- optimise single node's coordinates */ |
846 | 846 | iptr_type static |
847 | | - constexpr _ITER = (iptr_type) +5 ; |
| 847 | + constexpr _ITER = (iptr_type) +4 ; |
848 | 848 |
|
849 | 849 | __unreferenced(_geom); |
850 | 850 | __unreferenced(_hfun); |
|
1545 | 1545 | { |
1546 | 1546 | public : |
1547 | 1547 | /*------------------------ tuple for edge re-ordering */ |
1548 | | - iptr_type _edge ; |
| 1548 | + iptr_type _inod ; |
| 1549 | + iptr_type _jnod ; |
1549 | 1550 | float _cost ; |
1550 | 1551 | public : |
1551 | 1552 | __inline_call sort_pair ( |
1552 | | - iptr_type _esrc , |
| 1553 | + iptr_type _isrc , |
| 1554 | + iptr_type _jsrc , |
1553 | 1555 | float _csrc |
1554 | | - ) : _edge(_esrc), _cost(_csrc) {} |
| 1556 | + ) : _inod(_isrc), _jnod(_jsrc), |
| 1557 | + _cost(_csrc) {} |
1555 | 1558 | } ; |
1556 | 1559 | class sort_less |
1557 | 1560 | { |
@@ -1598,138 +1601,127 @@ |
1598 | 1601 |
|
1599 | 1602 | _nzip = +0 ; _ndiv = +0 ; |
1600 | 1603 |
|
1601 | | - for (auto _node = |
1602 | | - _mesh. node().count(); _node-- != 0; ) |
1603 | | - { |
1604 | | - /*--------------------- scan nodes and zip//div edges */ |
1605 | | - if (_mesh. node(_node).mark () >= 0 && |
1606 | | - std::abs ( |
1607 | | - _mark._node[_node]) > _imrk - 4 ) |
| 1604 | + // assemble list of edges attached to "recent" nodes |
| 1605 | + |
| 1606 | + for (auto _enum = |
| 1607 | + _mesh. edge().count(); _enum-- != 0; ) |
1608 | 1608 | { |
1609 | | - _conn.set_count(+0) ; |
1610 | | - _sort.set_count(+0) ; |
1611 | | - /*----------------------- scan edges adj. to node */ |
1612 | | - _mesh.connect_1( |
1613 | | - (iptr_type)_node, POINT_tag, _conn) ; |
| 1609 | + auto _eptr =&_mesh.edge(_enum) ; |
1614 | 1610 |
|
1615 | | - for (auto _edge = _conn.head() ; |
1616 | | - _edge != _conn.tend() ; |
1617 | | - ++_edge ) |
1618 | | - { |
1619 | | - /*----------------------- sort local edges by len */ |
1620 | | - auto _enum = _edge-> _cell ; |
1621 | | - auto _eptr = |
1622 | | - _mesh.edge().head() + _enum ; |
| 1611 | + auto _inod = _eptr->node(0) ; |
| 1612 | + auto _jnod = _eptr->node(1) ; |
1623 | 1613 |
|
1624 | | - auto _iptr = _mesh. |
1625 | | - node().head()+_eptr->node(0) ; |
1626 | | - auto _jptr = _mesh. |
1627 | | - node().head()+_eptr->node(1) ; |
| 1614 | + auto _iptr = _mesh. |
| 1615 | + node().head()+_eptr->node(0) ; |
| 1616 | + auto _jptr = _mesh. |
| 1617 | + node().head()+_eptr->node(1) ; |
1628 | 1618 |
|
| 1619 | + if (_eptr->mark() >= +0 && |
| 1620 | + ( std::abs ( |
| 1621 | + _mark._node[_inod]) > _imrk - 4 || |
| 1622 | + std::abs ( |
| 1623 | + _mark._node[_jnod]) > _imrk - 4 )) |
| 1624 | + { |
1629 | 1625 | float _lsqr = |
1630 | 1626 | (float)pred_type::length_sq ( |
1631 | 1627 | & _iptr->pval(0) , |
1632 | 1628 | & _jptr->pval(0) ) ; |
1633 | 1629 |
|
1634 | 1630 | _sort.push_tail( |
1635 | | - sort_pair(_enum, _lsqr)) ; |
| 1631 | + sort_pair(_inod, _jnod, _lsqr)) ; |
1636 | 1632 | } |
| 1633 | + } |
1637 | 1634 |
|
1638 | | - if (_sort.empty()) continue; |
| 1635 | + if (_sort.empty()) return ; |
1639 | 1636 |
|
1640 | | - /*----------------------- scan local edges by len */ |
1641 | | - algorithms::isort( |
1642 | | - _sort.head() , |
1643 | | - _sort.tend() , sort_less()); |
| 1637 | + algorithms::qsort( // sort edge list by lsqr |
| 1638 | + _sort.head() , |
| 1639 | + _sort.tend() , sort_less()); |
1644 | 1640 |
|
1645 | | - bool_type _move = false ; |
| 1641 | + // scan edges longest-to-shortest and try to div any |
| 1642 | + // unvisited edges |
1646 | 1643 |
|
1647 | | - for (auto _iter = _sort.tail(); |
1648 | | - _iter != _sort.hend(); |
1649 | | - --_iter ) |
1650 | | - { |
1651 | | - /*----------------------- try to "div" local edge */ |
1652 | | - auto _eadj = _iter->_edge; |
| 1644 | + for (auto _iter = _sort.tail(); |
| 1645 | + _iter != _sort.hend(); |
| 1646 | + --_iter ) |
| 1647 | + { |
| 1648 | + /*--------------------------- try to "div" local edge */ |
| 1649 | + iptr_type _eadj, _enod[2] ; |
| 1650 | + _enod[0] = _iter->_inod; |
| 1651 | + _enod[1] = _iter->_jnod; |
1653 | 1652 |
|
1654 | | - auto _eptr = |
1655 | | - _mesh. edge().head()+ _eadj; |
| 1653 | + if (MARKNODE(_enod[0])>_imrk) continue ; |
| 1654 | + if (MARKNODE(_enod[1])>_imrk) continue ; |
1656 | 1655 |
|
1657 | | - iptr_type _enod[2] ; |
1658 | | - _enod[0] = _eptr->node(0); |
1659 | | - _enod[1] = _eptr->node(1); |
| 1656 | + if (MARKNODE(_enod[0]) < +0 || |
| 1657 | + MARKNODE(_enod[1]) < +0 ) continue ; |
1660 | 1658 |
|
1661 | | - if (MARKNODE(_enod[0])>_imrk) continue ; |
1662 | | - if (MARKNODE(_enod[1])>_imrk) continue ; |
| 1659 | + if(!_mesh.find_edge( |
| 1660 | + _enod, _eadj) ) continue ; |
1663 | 1661 |
|
1664 | | - if (MARKNODE(_enod[0]) < +0 || |
1665 | | - MARKNODE(_enod[1]) < +0 ) continue ; |
| 1662 | + if (_opts.div_()) |
| 1663 | + { |
| 1664 | + /*--------------------------- "div" for topo. + score */ |
| 1665 | + iptr_type _nnew = -1; |
| 1666 | + |
| 1667 | + bool_type _move; |
| 1668 | + _div_edge( _geom, _mesh, |
| 1669 | + _hfun, _hval, _opts, |
| 1670 | + _imrk, _eadj, |
| 1671 | + _kern, _move, _nnew, |
| 1672 | + _iset, _jset, |
| 1673 | + _aset, _bset, |
| 1674 | + _qold, _qnew, |
| 1675 | + _qtmp, _QLIM) ; |
1666 | 1676 |
|
1667 | | - if (_opts.div_()) |
| 1677 | + if (_move) |
1668 | 1678 | { |
1669 | | - /*----------------------- "div" for topo. + score */ |
1670 | | - iptr_type _nnew = -1; |
1671 | | - |
1672 | | - _div_edge( _geom, _mesh, |
1673 | | - _hfun, _hval, _opts, |
1674 | | - _imrk, _eadj, |
1675 | | - _kern, _move, _nnew, |
1676 | | - _iset, _jset, |
1677 | | - _aset, _bset, |
1678 | | - _qold, _qnew, |
1679 | | - _qtmp, _QLIM) ; |
1680 | | - |
1681 | | - if (_move) |
1682 | | - { |
1683 | | - PUSHMARK; _ndiv += +1; break ; |
1684 | | - } |
| 1679 | + PUSHMARK; _ndiv += +1; |
1685 | 1680 | } |
1686 | 1681 | } |
| 1682 | + } |
1687 | 1683 |
|
1688 | | - if (_move) continue ; |
| 1684 | + // scan edges shortest-to-longest and try to zip any |
| 1685 | + // unvisited edges |
1689 | 1686 |
|
1690 | | - for (auto _iter = _sort.head(); |
1691 | | - _iter != _sort.tend(); |
1692 | | - ++_iter ) |
1693 | | - { |
1694 | | - /*----------------------- try to "zip" local edge */ |
1695 | | - auto _eadj = _iter->_edge; |
| 1687 | + for (auto _iter = _sort.head(); |
| 1688 | + _iter != _sort.tend(); |
| 1689 | + ++_iter ) |
| 1690 | + { |
| 1691 | + /*--------------------------- try to "zip" local edge */ |
| 1692 | + iptr_type _eadj, _enod[2] ; |
| 1693 | + _enod[0] = _iter->_inod; |
| 1694 | + _enod[1] = _iter->_jnod; |
1696 | 1695 |
|
1697 | | - auto _eptr = |
1698 | | - _mesh. edge().head()+ _eadj; |
| 1696 | + if (MARKNODE(_enod[0])>_imrk) continue ; |
| 1697 | + if (MARKNODE(_enod[1])>_imrk) continue ; |
1699 | 1698 |
|
1700 | | - iptr_type _enod[2] ; |
1701 | | - _enod[0] = _eptr->node(0); |
1702 | | - _enod[1] = _eptr->node(1); |
| 1699 | + if (MARKNODE(_enod[0]) < +0 || |
| 1700 | + MARKNODE(_enod[1]) < +0 ) continue ; |
1703 | 1701 |
|
1704 | | - if (MARKNODE(_enod[0])>_imrk) continue ; |
1705 | | - if (MARKNODE(_enod[1])>_imrk) continue ; |
| 1702 | + if(!_mesh.find_edge( |
| 1703 | + _enod, _eadj) ) continue ; |
1706 | 1704 |
|
1707 | | - if (MARKNODE(_enod[0]) < +0 || |
1708 | | - MARKNODE(_enod[1]) < +0 ) continue ; |
| 1705 | + if (_opts.zip_()) |
| 1706 | + { |
| 1707 | + /*--------------------------- "zip" for topo. + score */ |
| 1708 | + iptr_type _nnew = -1; |
| 1709 | + |
| 1710 | + bool_type _move; |
| 1711 | + _zip_edge( _geom, _mesh, |
| 1712 | + _hfun, _hval, _opts, |
| 1713 | + _eadj, |
| 1714 | + _kern, _move, _nnew, |
| 1715 | + _iset, _jset, |
| 1716 | + _aset, _bset, _cset, |
| 1717 | + _qold, _qnew, |
| 1718 | + _qtmp, _QLIM) ; |
1709 | 1719 |
|
1710 | | - if (_opts.zip_()) |
| 1720 | + if (_move) |
1711 | 1721 | { |
1712 | | - /*----------------------- "zip" for topo. + score */ |
1713 | | - iptr_type _nnew = -1; |
1714 | | - |
1715 | | - _zip_edge( _geom, _mesh, |
1716 | | - _hfun, _hval, _opts, |
1717 | | - _eadj, |
1718 | | - _kern, _move, _nnew, |
1719 | | - _iset, _jset, |
1720 | | - _aset, _bset, _cset, |
1721 | | - _qold, _qnew, |
1722 | | - _qtmp, _QLIM) ; |
1723 | | - |
1724 | | - if (_move) |
1725 | | - { |
1726 | | - PUSHMARK; _nzip += +1; break ; |
1727 | | - } |
| 1722 | + PUSHMARK; _nzip += +1; |
1728 | 1723 | } |
1729 | 1724 | } |
1730 | | - |
1731 | | - if (_move) continue ; |
1732 | | - } |
1733 | 1725 | } |
1734 | 1726 |
|
1735 | 1727 | for (auto _iter = _mark._node.head() ; |
|
1990 | 1982 |
|
1991 | 1983 | real_type _DLIM = |
1992 | 1984 | (real_type)(1. - |
1993 | | - 1. * std::pow(1.0-_QLIM, +2)) ; |
| 1985 | + .5 * std::pow(1.0-_QLIM, +2)) ; |
1994 | 1986 |
|
1995 | 1987 | /*------------------------------ 1. CELL GEOM. PASSES */ |
1996 | 1988 |
|
|
0 commit comments