Actual source code: pcbddcgraphhashmap.h

  1: #pragma once

  3: #include <petsc/private/hashtable.h>
  4: #include <petsc/private/pcbddcstructsimpl.h>

  6: static inline PetscHash_t PCBDDCGraphNodeHash(const PCBDDCGraphNode *node)
  7: {
  8:   PetscHash_t hash;
  9:   hash = PetscHashCombine(PetscHashInt(node->count), PetscHashInt(node->which_dof));
 10:   hash = PetscHashCombine(hash, PetscHashInt(node->special_dof));
 11:   for (PetscInt i = 0; i < node->count; i++) hash = PetscHashCombine(hash, PetscHashInt(node->neighbours_set[i]));
 12:   hash = PetscHashCombine(hash, PetscHashInt(node->local_groups_count));
 13:   if (!node->shared) {
 14:     for (PetscInt i = 0; i < node->local_groups_count; i++) hash = PetscHashCombine(hash, PetscHashInt(node->local_groups[i]));
 15:   }
 16:   return hash;
 17: }

 19: static inline int PCBDDCGraphNodeEqual(const PCBDDCGraphNode *a, const PCBDDCGraphNode *b)
 20: {
 21:   if (a->count != b->count) return 0;
 22:   if (a->which_dof != b->which_dof) return 0;
 23:   if (a->special_dof != b->special_dof) return 0;
 24:   /* check only for same local groups if not shared
 25:      shared dofs at the process boundaries will be handled differently */
 26:   PetscBool mpi_shared = a->shared;
 27:   PetscBool same_set;
 28:   PetscCallContinue(PetscArraycmp(a->neighbours_set, b->neighbours_set, a->count, &same_set));
 29:   if (same_set && !mpi_shared) {
 30:     if (a->local_groups_count != b->local_groups_count) same_set = PETSC_FALSE;
 31:     else PetscCallContinue(PetscArraycmp(a->local_groups, b->local_groups, a->local_groups_count, &same_set));
 32:   }
 33:   return same_set ? 1 : 0;
 34: }

 36: PETSC_HASH_MAP(HMapPCBDDCGraphNode, PCBDDCGraphNode *, PetscInt, PCBDDCGraphNodeHash, PCBDDCGraphNodeEqual, -1)