Exemplo n.º 1
0
static void
_sub_neighborhood_near_far_traversal (VsgPRTree2@t@ *tree,
                                      VsgNFConfig2@t@ *nfc,
                                      VsgPRTree2@t@Node *one,
                                      VsgPRTree2@t@NodeInfo *one_info,
                                      VsgPRTree2@t@Node *other,
                                      VsgPRTree2@t@NodeInfo *other_info,
                                      gint8 x, gint8 y)
{
  vsgloc2 i, j, si, sj;
  vsgloc2 sym[4] = {
    _SYMMETRY (0, x, y),
    _SYMMETRY (1, x, y),
    _SYMMETRY (2, x, y),
    _SYMMETRY (3, x, y),
  };

  if (_NODE_IS_EMPTY(one) || _NODE_IS_EMPTY(other))
    return;

#ifdef VSG_HAVE_MPI
  if (nfc->sz > 1)
    vsg_prtree2@t@_nf_check_receive (tree, nfc, MPI_ANY_TAG, FALSE);
#endif

  if (PRTREE2@T@NODE_ISINT (one) && PRTREE2@T@NODE_ISINT (other))
    {
      /* near/far interaction between one and other children */

      for (i=0; i<4; i++)
        {
          VsgPRTree2@t@Node *one_child = PRTREE2@T@NODE_CHILD(one, i);
          VsgPRTree2@t@NodeInfo one_child_info;

#ifdef VSG_HAVE_MPI
          if (PRTREE2@T@NODE_IS_REMOTE (one_child)) continue;
#endif

          _vsg_prtree2@t@node_get_info (one_child, &one_child_info,
                                        one_info, i);

          si = sym[i];

          for (j=0; j<4; j++)
            {
              gboolean far;
              VsgPRTree2@t@Node *other_child =
                PRTREE2@T@NODE_CHILD(other, j);
              VsgPRTree2@t@NodeInfo other_child_info;
              gboolean far_done = TRUE;

#ifdef VSG_HAVE_MPI
              if (PRTREE2@T@NODE_IS_REMOTE (other_child)) continue;
#endif

              _vsg_prtree2@t@node_get_info (other_child,
                                            &other_child_info,
                                            other_info, j);

              sj = sym[j];

              far = NEAR_FAR (x, y, si, sj);

              if (far)
                {
                  /* far interaction between one and other */
                  if (nfc->far_func &&
                      ! (_NODE_IS_EMPTY (one_child) ||
                         _NODE_IS_EMPTY (other_child)))
                    {
#ifdef VSG_HAVE_MPI
                      /* in parallel, only one of the processors has to do a
                         shared/shared far interaction */
                      if (PRTREE2@T@NODE_IS_SHARED (one_child) &&
                          PRTREE2@T@NODE_IS_SHARED (other_child) &&
                          PRTREE2@T@NODE_PROC (one_child) != nfc->rk)
                        continue;
#endif

                      far_done = nfc->far_func (&one_child_info, &other_child_info,
                                                nfc->user_data);
                      if (!far_done)
                        {
#ifdef VSG_HAVE_MPI
                          if (PRTREE2@T@NODE_IS_SHARED (one_child) ||
                              PRTREE2@T@NODE_IS_SHARED (other_child))
                            {
                              g_critical ("far_func() -> FALSE not handled " \
                                          "for shared nodes in \"%s\"",
                                          __PRETTY_FUNCTION__);

                            }
#endif

                          /* near interaction between one and other */
                          recursive_near_func (one_child, &one_child_info,
                                               other_child, &other_child_info,
                                               nfc->near_func,
                                               nfc->user_data);
                        }
                    }
                }
              else
                {
                  gint8 newx = _SUB_INTERACTION (i, j, x, _X);
                  gint8 newy = _SUB_INTERACTION (i, j, y, _Y);

                  _sub_neighborhood_near_far_traversal (tree, nfc, one_child,
                                                        &one_child_info,
                                                        other_child,
                                                        &other_child_info,
                                                        newx, newy);
                }
            }
        }

    }
  else
    {
      if (nfc->near_func)
        {
          /* near interaction between one and other */
          recursive_near_func (one, one_info, other, other_info, nfc->near_func,
                               nfc->user_data);
        }
    }
}
Exemplo n.º 2
0
static void recursive_near_func (VsgPRTree2@t@Node *one,
                                 VsgPRTree2@t@NodeInfo *one_info,
                                 VsgPRTree2@t@Node *other,
                                 VsgPRTree2@t@NodeInfo *other_info,
                                 VsgNFConfig2@t@ *nfc)
{
  vsgloc2 i;

#ifdef VSG_HAVE_MPI
  if (nfc->sz > 1)
    vsg_prtree2@t@_nf_check_receive (nfc, MPI_ANY_TAG, FALSE);
#endif

  /* try to execute semifar function instead of near_func, if possible */
  if (_check_and_execute_semifar_func (nfc, one_info, other_info))
    return;

  if (PRTREE2@T@NODE_ISINT (one))
    {
      for (i=0; i<CN; i++)
        {
          VsgPRTree2@t@Node *one_child = PRTREE2@T@NODE_CHILD(one, i);
          VsgPRTree2@t@NodeInfo one_child_info;

#ifdef VSG_HAVE_MPI
          if (PRTREE2@T@NODE_IS_REMOTE (one_child)) continue;
#endif

          _vsg_prtree2@t@node_get_info (one_child, &one_child_info, one_info,
                                        i);

          recursive_near_func (one_child, &one_child_info, other, other_info,
                               nfc);
        }
    }
  else if (PRTREE2@T@NODE_ISINT (other))
    {
      for (i=0; i<CN; i++)
        {
          VsgPRTree2@t@Node *other_child = PRTREE2@T@NODE_CHILD(other, i);
          VsgPRTree2@t@NodeInfo other_child_info;

#ifdef VSG_HAVE_MPI
          if (PRTREE2@T@NODE_IS_REMOTE (other_child)) continue;
#endif

          _vsg_prtree2@t@node_get_info (other_child, &other_child_info,
                                        other_info, i);

          recursive_near_func (one, one_info, other_child, &other_child_info,
                               nfc);
        }
    }
  else
    {
      /* near interaction between one and other */
      if (one->point_count != 0 && other->point_count != 0)
        nfc->near_func (one_info, other_info, nfc->user_data);
    }


}