Lines Matching refs:graph
22 PetscErrorCode PCBDDCGraphGetDirichletDofsB(PCBDDCGraph graph, IS *dirdofs) in PCBDDCGraphGetDirichletDofsB() argument
25 if (graph->dirdofsB) { in PCBDDCGraphGetDirichletDofsB()
26 PetscCall(PetscObjectReference((PetscObject)graph->dirdofsB)); in PCBDDCGraphGetDirichletDofsB()
27 } else if (graph->has_dirichlet) { in PCBDDCGraphGetDirichletDofsB()
32 for (i = 0; i < graph->nvtxs; i++) { in PCBDDCGraphGetDirichletDofsB()
33 …if (graph->nodes[i].count > 1 && graph->nodes[i].special_dof == PCBDDCGRAPH_DIRICHLET_MARK) size++; in PCBDDCGraphGetDirichletDofsB()
38 for (i = 0; i < graph->nvtxs; i++) { in PCBDDCGraphGetDirichletDofsB()
39 …if (graph->nodes[i].count > 1 && graph->nodes[i].special_dof == PCBDDCGRAPH_DIRICHLET_MARK) dirdof… in PCBDDCGraphGetDirichletDofsB()
41 …PetscCall(ISCreateGeneral(PETSC_COMM_SELF, size, dirdofs_idxs, PETSC_OWN_POINTER, &graph->dirdofsB… in PCBDDCGraphGetDirichletDofsB()
42 PetscCall(PetscObjectReference((PetscObject)graph->dirdofsB)); in PCBDDCGraphGetDirichletDofsB()
44 *dirdofs = graph->dirdofsB; in PCBDDCGraphGetDirichletDofsB()
48 PetscErrorCode PCBDDCGraphGetDirichletDofs(PCBDDCGraph graph, IS *dirdofs) in PCBDDCGraphGetDirichletDofs() argument
51 if (graph->dirdofs) { in PCBDDCGraphGetDirichletDofs()
52 PetscCall(PetscObjectReference((PetscObject)graph->dirdofs)); in PCBDDCGraphGetDirichletDofs()
53 } else if (graph->has_dirichlet) { in PCBDDCGraphGetDirichletDofs()
58 for (i = 0; i < graph->nvtxs; i++) { in PCBDDCGraphGetDirichletDofs()
59 if (graph->nodes[i].special_dof == PCBDDCGRAPH_DIRICHLET_MARK) size++; in PCBDDCGraphGetDirichletDofs()
64 for (i = 0; i < graph->nvtxs; i++) { in PCBDDCGraphGetDirichletDofs()
65 if (graph->nodes[i].special_dof == PCBDDCGRAPH_DIRICHLET_MARK) dirdofs_idxs[size++] = i; in PCBDDCGraphGetDirichletDofs()
67 …(ISCreateGeneral(PetscObjectComm((PetscObject)graph->l2gmap), size, dirdofs_idxs, PETSC_OWN_POINTE… in PCBDDCGraphGetDirichletDofs()
68 PetscCall(PetscObjectReference((PetscObject)graph->dirdofs)); in PCBDDCGraphGetDirichletDofs()
70 *dirdofs = graph->dirdofs; in PCBDDCGraphGetDirichletDofs()
74 PetscErrorCode PCBDDCGraphASCIIView(PCBDDCGraph graph, PetscInt verbosity_level, PetscViewer viewer) in PCBDDCGraphASCIIView() argument
80 …wer) PetscCall(PetscViewerASCIIGetStdout(graph->seq_graph ? PETSC_COMM_SELF : PetscObjectComm((Pet… in PCBDDCGraphASCIIView()
85 …intf(viewer, "Local BDDC graph for subdomain %04d (seq %d)\n", PetscGlobalRank, graph->seq_graph)); in PCBDDCGraphASCIIView()
86 …etscViewerASCIISynchronizedPrintf(viewer, "Number of vertices %" PetscInt_FMT "\n", graph->nvtxs)); in PCBDDCGraphASCIIView()
87 …intf(viewer, "Number of local subdomains %" PetscInt_FMT "\n", graph->n_local_subs ? graph->n_loca… in PCBDDCGraphASCIIView()
88 …SCIISynchronizedPrintf(viewer, "Custom minimal size %" PetscInt_FMT "\n", graph->custom_minimal_si… in PCBDDCGraphASCIIView()
89 …if (graph->maxcount != PETSC_INT_MAX) PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, "Max co… in PCBDDCGraphASCIIView()
90 …tf(viewer, "Topological two dim? %s (set %s)\n", PetscBools[graph->twodim], PetscBools[graph->twod… in PCBDDCGraphASCIIView()
92 for (i = 0; i < graph->nvtxs; i++) { in PCBDDCGraphASCIIView()
94 …iewerASCIISynchronizedPrintf(viewer, " which_dof: %" PetscInt_FMT "\n", graph->nodes[i].which_do… in PCBDDCGraphASCIIView()
95 …werASCIISynchronizedPrintf(viewer, " special_dof: %" PetscInt_FMT "\n", graph->nodes[i].special_… in PCBDDCGraphASCIIView()
96 …ViewerASCIISynchronizedPrintf(viewer, " shared by: %" PetscInt_FMT "\n", graph->nodes[i].count)); in PCBDDCGraphASCIIView()
98 if (graph->nodes[i].count) { in PCBDDCGraphASCIIView()
100 …for (j = 0; j < graph->nodes[i].count; j++) PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, "… in PCBDDCGraphASCIIView()
105 …chronizedPrintf(viewer, " number of local groups: %" PetscInt_FMT "\n", graph->nodes[i].local_gr… in PCBDDCGraphASCIIView()
107 if (graph->nodes[i].local_groups_count) { in PCBDDCGraphASCIIView()
109 …for (j = 0; j < graph->nodes[i].local_groups_count; j++) PetscCall(PetscViewerASCIISynchronizedPri… in PCBDDCGraphASCIIView()
116 if (graph->xadj) { in PCBDDCGraphASCIIView()
119 …for (j = graph->xadj[i]; j < graph->xadj[i + 1]; j++) PetscCall(PetscViewerASCIISynchronizedPrintf… in PCBDDCGraphASCIIView()
127 …if (graph->n_local_subs) PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, " local sub id: %"… in PCBDDCGraphASCIIView()
128 …SynchronizedPrintf(viewer, " interface subset id: %" PetscInt_FMT "\n", graph->nodes[i].subset)); in PCBDDCGraphASCIIView()
129 …graph->nodes[i].subset && graph->subset_ncc) PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, … in PCBDDCGraphASCIIView()
132 …ynchronizedPrintf(viewer, "Total number of connected components %" PetscInt_FMT "\n", graph->ncc)); in PCBDDCGraphASCIIView()
133 PetscCall(PetscMalloc1(graph->cptr[graph->ncc], &queue_in_global_numbering)); in PCBDDCGraphASCIIView()
134 …PetscCall(ISLocalToGlobalMappingApply(graph->l2gmap, graph->cptr[graph->ncc], graph->queue, queue_… in PCBDDCGraphASCIIView()
135 for (i = 0; i < graph->ncc; i++) { in PCBDDCGraphASCIIView()
136 PetscInt node_num = graph->queue[graph->cptr[i]]; in PCBDDCGraphASCIIView()
138 …%" PetscInt_FMT ", fid %" PetscInt_FMT ", neighs:", i, graph->cptr[i + 1] - graph->cptr[i], graph-… in PCBDDCGraphASCIIView()
140 …for (j = 0; j < graph->nodes[node_num].count; j++) PetscCall(PetscViewerASCIISynchronizedPrintf(vi… in PCBDDCGraphASCIIView()
143 …if (verbosity_level > 2 || graph->twodim || graph->nodes[node_num].count > 2 || (graph->nodes[node… in PCBDDCGraphASCIIView()
145 …j = graph->cptr[i]; j < graph->cptr[i + 1]; j++) PetscCall(PetscViewerASCIISynchronizedPrintf(view… in PCBDDCGraphASCIIView()
159 PetscErrorCode PCBDDCGraphRestoreCandidatesIS(PCBDDCGraph graph, PetscInt *n_faces, IS *FacesIS[], … in PCBDDCGraphRestoreCandidatesIS() argument
165 …PetscCall(PetscObjectQuery((PetscObject)graph->l2gmap, "_PCBDDCGraphCandidatesIS", (PetscObject *)… in PCBDDCGraphRestoreCandidatesIS()
191 PetscErrorCode PCBDDCGraphGetCandidatesIS(PCBDDCGraph graph, PetscInt *n_faces, IS *FacesIS[], Pets… in PCBDDCGraphGetCandidatesIS() argument
198 …PetscCall(PetscObjectQuery((PetscObject)graph->l2gmap, "_PCBDDCGraphCandidatesIS", (PetscObject *)… in PCBDDCGraphGetCandidatesIS()
210 PetscCall(PetscCalloc1(graph->ncc, &mark)); in PCBDDCGraphGetCandidatesIS()
215 for (i = 0; i < graph->ncc; i++) { in PCBDDCGraphGetCandidatesIS()
216 PetscInt repdof = graph->queue[graph->cptr[i]]; in PCBDDCGraphGetCandidatesIS()
217 …if (graph->cptr[i + 1] - graph->cptr[i] > graph->custom_minimal_size && graph->nodes[repdof].count… in PCBDDCGraphGetCandidatesIS()
218 …if (!graph->twodim && graph->nodes[repdof].count == 2 && graph->nodes[repdof].special_dof != PCBDD… in PCBDDCGraphGetCandidatesIS()
226 nvc += graph->cptr[i + 1] - graph->cptr[i]; in PCBDDCGraphGetCandidatesIS()
236 if (!graph->queue_sorted) { in PCBDDCGraphGetCandidatesIS()
239 PetscCall(PetscMalloc1(graph->cptr[graph->ncc], &queue_global)); in PCBDDCGraphGetCandidatesIS()
240 …PetscCall(ISLocalToGlobalMappingApply(graph->l2gmap, graph->cptr[graph->ncc], graph->queue, queue_… in PCBDDCGraphGetCandidatesIS()
241 … 0; i < graph->ncc; i++) PetscCall(PetscSortIntWithArray(graph->cptr[i + 1] - graph->cptr[i], &que… in PCBDDCGraphGetCandidatesIS()
243 graph->queue_sorted = PETSC_TRUE; in PCBDDCGraphGetCandidatesIS()
247 for (i = 0; i < graph->ncc; i++) { in PCBDDCGraphGetCandidatesIS()
249 …sIS) PetscCall(ISCreateGeneral(PETSC_COMM_SELF, graph->cptr[i + 1] - graph->cptr[i], &graph->queue… in PCBDDCGraphGetCandidatesIS()
252 …sIS) PetscCall(ISCreateGeneral(PETSC_COMM_SELF, graph->cptr[i + 1] - graph->cptr[i], &graph->queue… in PCBDDCGraphGetCandidatesIS()
260 for (i = 0; i < graph->ncc; i++) { in PCBDDCGraphGetCandidatesIS()
264 for (j = graph->cptr[i]; j < graph->cptr[i + 1]; j++) { in PCBDDCGraphGetCandidatesIS()
265 idx[nvc] = graph->queue[j]; in PCBDDCGraphGetCandidatesIS()
285 PetscErrorCode PCBDDCGraphComputeConnectedComponents(PCBDDCGraph graph) in PCBDDCGraphComputeConnectedComponents() argument
292 PetscCall(PetscObjectGetComm((PetscObject)graph->l2gmap, &interface_comm)); in PCBDDCGraphComputeConnectedComponents()
294 PetscCall(PCBDDCGraphComputeConnectedComponentsLocal(graph)); in PCBDDCGraphComputeConnectedComponents()
295 if (graph->seq_graph) PetscFunctionReturn(PETSC_SUCCESS); in PCBDDCGraphComputeConnectedComponents()
297 …if (graph->active_coords && !graph->multi_element) { /* face based corner selection XXX multi_elem… in PCBDDCGraphComputeConnectedComponents()
303 PetscCall(PetscBTCreate(graph->nvtxs, &cornerp)); in PCBDDCGraphComputeConnectedComponents()
304 PetscCall(ISLocalToGlobalMappingGetInfo(graph->l2gmap, &n_neigh, &neigh, &n_shared, &shared)); in PCBDDCGraphComputeConnectedComponents()
306 PetscCall(PetscMalloc1(maxc * graph->cdim, &wdist)); in PCBDDCGraphComputeConnectedComponents()
311 PetscInt fst, j, k, d, cdim = graph->cdim, n = n_shared[ns]; in PCBDDCGraphComputeConnectedComponents()
319 PetscReal c = graph->coords[shared[ns][j] * cdim + d]; in PCBDDCGraphComputeConnectedComponents()
426 … PetscCall(ISLocalToGlobalMappingRestoreInfo(graph->l2gmap, &n_neigh, &neigh, &n_shared, &shared)); in PCBDDCGraphComputeConnectedComponents()
430 adapt_interface = (cornerp || graph->multi_element) ? PETSC_TRUE : PETSC_FALSE; in PCBDDCGraphComputeConnectedComponents()
431 for (PetscInt i = 0; i < graph->n_subsets && !adapt_interface; i++) { in PCBDDCGraphComputeConnectedComponents()
432 if (graph->subset_ncc[i] > 1) adapt_interface = PETSC_TRUE; in PCBDDCGraphComputeConnectedComponents()
441 PetscCall(PetscMalloc1(graph->nvtxs, &labels)); in PCBDDCGraphComputeConnectedComponents()
442 PetscCall(PetscArrayzero(labels, graph->nvtxs)); in PCBDDCGraphComputeConnectedComponents()
443 for (PetscInt i = 0, k = 0; i < graph->ncc; i++) { in PCBDDCGraphComputeConnectedComponents()
445 for (PetscInt j = graph->cptr[i]; j < graph->cptr[i + 1]; j++) { in PCBDDCGraphComputeConnectedComponents()
446 if (cornerp && PetscBTLookup(cornerp, graph->queue[j])) { in PCBDDCGraphComputeConnectedComponents()
447 labels[graph->queue[j]] = -(k + s + 1); in PCBDDCGraphComputeConnectedComponents()
450 labels[graph->queue[j]] = -(k + 1); in PCBDDCGraphComputeConnectedComponents()
455 PetscCall(PetscSFGetGraph(graph->interface_ref_sf, &nr, NULL, NULL, NULL)); in PCBDDCGraphComputeConnectedComponents()
456 PetscCall(PetscSFGetGraph(graph->interface_subset_sf, &nrs, NULL, NULL, NULL)); in PCBDDCGraphComputeConnectedComponents()
457 PetscCall(PetscSFGetMultiSF(graph->interface_subset_sf, &msf)); in PCBDDCGraphComputeConnectedComponents()
461 PetscCall(PetscSFComputeDegreeBegin(graph->interface_subset_sf, &n_ref_sharing)); in PCBDDCGraphComputeConnectedComponents()
462 PetscCall(PetscSFComputeDegreeEnd(graph->interface_subset_sf, &n_ref_sharing)); in PCBDDCGraphComputeConnectedComponents()
463 PetscCall(PetscSFGatherBegin(graph->interface_subset_sf, MPIU_INT, labels, mrlabels)); in PCBDDCGraphComputeConnectedComponents()
464 PetscCall(PetscSFGatherEnd(graph->interface_subset_sf, MPIU_INT, labels, mrlabels)); in PCBDDCGraphComputeConnectedComponents()
481 const PetscInt subset_size = graph->interface_ref_rsize[i]; in PCBDDCGraphComputeConnectedComponents()
513 …PetscCall(PetscSFBcastBegin(graph->interface_subset_sf, MPIU_INT, rootlabels, labels, MPI_REPLACE)… in PCBDDCGraphComputeConnectedComponents()
514 … PetscCall(PetscSFBcastEnd(graph->interface_subset_sf, MPIU_INT, rootlabels, labels, MPI_REPLACE)); in PCBDDCGraphComputeConnectedComponents()
521 …PetscCall(PetscMalloc3(graph->ncc + 1, &ocptr, graph->cptr[graph->ncc], &oqueue, graph->cptr[graph… in PCBDDCGraphComputeConnectedComponents()
522 PetscCall(PetscArraycpy(ocptr, graph->cptr, graph->ncc + 1)); in PCBDDCGraphComputeConnectedComponents()
523 PetscCall(PetscArraycpy(oqueue, graph->queue, graph->cptr[graph->ncc])); in PCBDDCGraphComputeConnectedComponents()
524 PetscCall(PetscArrayzero(touched, graph->cptr[graph->ncc])); in PCBDDCGraphComputeConnectedComponents()
528 for (PetscInt i = 0; i < graph->ncc; i++) { in PCBDDCGraphComputeConnectedComponents()
533 graph->cptr[ncc] = cum_queue; in PCBDDCGraphComputeConnectedComponents()
537 graph->queue[cum_queue++] = oqueue[k]; in PCBDDCGraphComputeConnectedComponents()
546 graph->cptr[ncc] = cum_queue; in PCBDDCGraphComputeConnectedComponents()
547 graph->queue_sorted = PETSC_FALSE; in PCBDDCGraphComputeConnectedComponents()
548 graph->ncc = ncc; in PCBDDCGraphComputeConnectedComponents()
553 if (!graph->twodimset) { in PCBDDCGraphComputeConnectedComponents()
555 for (PetscInt i = 0; i < graph->ncc; i++) { in PCBDDCGraphComputeConnectedComponents()
556 PetscInt repdof = graph->queue[graph->cptr[i]]; in PCBDDCGraphComputeConnectedComponents()
557 PetscInt ccsize = graph->cptr[i + 1] - graph->cptr[i]; in PCBDDCGraphComputeConnectedComponents()
558 if (graph->nodes[repdof].count > 2 && ccsize > graph->custom_minimal_size) { in PCBDDCGraphComputeConnectedComponents()
563 …PetscCallMPI(MPIU_Allreduce(&twodim, &graph->twodim, 1, MPI_C_BOOL, MPI_LAND, PetscObjectComm((Pet… in PCBDDCGraphComputeConnectedComponents()
564 graph->twodimset = PETSC_TRUE; in PCBDDCGraphComputeConnectedComponents()
569 static inline PetscErrorCode PCBDDCGraphComputeCC_Private(PCBDDCGraph graph, PetscInt pid, PetscInt… in PCBDDCGraphComputeCC_Private() argument
573 const PetscInt *PETSC_RESTRICT xadj = graph->xadj; in PCBDDCGraphComputeCC_Private()
574 const PetscInt *PETSC_RESTRICT adjncy = graph->adjncy; in PCBDDCGraphComputeCC_Private()
575 const PetscInt *PETSC_RESTRICT subset_idxs = graph->subset_idxs[pid - 1]; in PCBDDCGraphComputeCC_Private()
576 const PetscInt *PETSC_RESTRICT local_subs = graph->local_subs; in PCBDDCGraphComputeCC_Private()
577 const PetscInt subset_size = graph->subset_size[pid - 1]; in PCBDDCGraphComputeCC_Private()
579 PCBDDCGraphNode *PETSC_RESTRICT nodes = graph->nodes; in PCBDDCGraphComputeCC_Private()
582 const PetscBool havesubs = (PetscBool)(!!graph->n_local_subs); in PCBDDCGraphComputeCC_Private()
668 PetscErrorCode PCBDDCGraphComputeConnectedComponentsLocal(PCBDDCGraph graph) in PCBDDCGraphComputeConnectedComponentsLocal() argument
673 …PetscCheck(graph->setupcalled, PetscObjectComm((PetscObject)graph->l2gmap), PETSC_ERR_ORDER, "PCBD… in PCBDDCGraphComputeConnectedComponentsLocal()
675 if (!graph->xadj && !graph->n_local_subs) PetscFunctionReturn(PETSC_SUCCESS); in PCBDDCGraphComputeConnectedComponentsLocal()
678 for (PetscInt i = 0; i < graph->nvtxs; i++) graph->nodes[i].touched = PETSC_FALSE; in PCBDDCGraphComputeConnectedComponentsLocal()
679 if (!graph->seq_graph) { in PCBDDCGraphComputeConnectedComponentsLocal()
680 for (PetscInt i = 0; i < graph->nvtxs; i++) { in PCBDDCGraphComputeConnectedComponentsLocal()
681 …if (graph->nodes[i].special_dof == PCBDDCGRAPH_DIRICHLET_MARK || graph->nodes[i].count < 2) graph-… in PCBDDCGraphComputeConnectedComponentsLocal()
688 for (PetscInt n = 0; n < graph->n_subsets; n++) { in PCBDDCGraphComputeConnectedComponentsLocal()
689 const PetscInt *subset_idxs = graph->subset_idxs[n]; in PCBDDCGraphComputeConnectedComponentsLocal()
694 while (found != graph->subset_size[n]) { in PCBDDCGraphComputeConnectedComponentsLocal()
698 while (graph->nodes[subset_idxs[first]].touched) first++; in PCBDDCGraphComputeConnectedComponentsLocal()
699 graph->nodes[subset_idxs[first]].touched = PETSC_TRUE; in PCBDDCGraphComputeConnectedComponentsLocal()
700 graph->queue[cum_queue] = subset_idxs[first]; in PCBDDCGraphComputeConnectedComponentsLocal()
701 graph->cptr[ncc] = cum_queue; in PCBDDCGraphComputeConnectedComponentsLocal()
708 PetscCall(PCBDDCGraphComputeCC_Private(graph, pid, graph->queue + cum_queue, prev, &added)); in PCBDDCGraphComputeConnectedComponentsLocal()
710 graph->subset_ncc[n] = ncc_pid; in PCBDDCGraphComputeConnectedComponentsLocal()
711 graph->cptr[ncc] = cum_queue; in PCBDDCGraphComputeConnectedComponentsLocal()
716 if (added && found == graph->subset_size[n]) { in PCBDDCGraphComputeConnectedComponentsLocal()
717 graph->subset_ncc[n] = ncc_pid; in PCBDDCGraphComputeConnectedComponentsLocal()
718 graph->cptr[ncc] = cum_queue; in PCBDDCGraphComputeConnectedComponentsLocal()
722 graph->ncc = ncc; in PCBDDCGraphComputeConnectedComponentsLocal()
723 graph->queue_sorted = PETSC_FALSE; in PCBDDCGraphComputeConnectedComponentsLocal()
727 PetscErrorCode PCBDDCGraphSetUp(PCBDDCGraph graph, PetscInt custom_minimal_size, IS neumann_is, IS … in PCBDDCGraphSetUp() argument
734 PetscInt i, j, k, nodes_touched, is_size, nvtxs = graph->nvtxs; in PCBDDCGraphSetUp()
738 PetscValidLogicalCollectiveInt(graph->l2gmap, custom_minimal_size, 2); in PCBDDCGraphSetUp()
741 PetscCheckSameComm(graph->l2gmap, 1, neumann_is, 3); in PCBDDCGraphSetUp()
743 graph->has_dirichlet = PETSC_FALSE; in PCBDDCGraphSetUp()
746 PetscCheckSameComm(graph->l2gmap, 1, dirichlet_is, 4); in PCBDDCGraphSetUp()
747 graph->has_dirichlet = PETSC_TRUE; in PCBDDCGraphSetUp()
749 PetscValidLogicalCollectiveInt(graph->l2gmap, n_ISForDofs, 5); in PCBDDCGraphSetUp()
752 PetscCheckSameComm(graph->l2gmap, 1, ISForDofs[i], 6); in PCBDDCGraphSetUp()
756 PetscCheckSameComm(graph->l2gmap, 1, custom_primal_vertices, 7); in PCBDDCGraphSetUp()
758 for (i = 0; i < nvtxs; i++) graph->nodes[i].touched = PETSC_FALSE; in PCBDDCGraphSetUp()
760 PetscCall(PetscObjectGetComm((PetscObject)graph->l2gmap, &comm)); in PCBDDCGraphSetUp()
765 graph->custom_minimal_size = custom_minimal_size; in PCBDDCGraphSetUp()
768 PetscCall(ISLocalToGlobalMappingGetNodeInfo(graph->l2gmap, NULL, &nodecount, &nodeneighs)); in PCBDDCGraphSetUp()
771 graph->multi_element = PETSC_FALSE; in PCBDDCGraphSetUp()
773 graph->nodes[i].count = nodecount[i]; in PCBDDCGraphSetUp()
774 if (!graph->seq_graph) { in PCBDDCGraphSetUp()
775 PetscCall(PetscMalloc1(nodecount[i], &graph->nodes[i].neighbours_set)); in PCBDDCGraphSetUp()
776 PetscCall(PetscArraycpy(graph->nodes[i].neighbours_set, nodeneighs[i], nodecount[i])); in PCBDDCGraphSetUp()
778 if (!graph->multi_element) { in PCBDDCGraphSetUp()
780 for (j = 0, nself = 0; j < graph->nodes[i].count; j++) in PCBDDCGraphSetUp()
781 if (graph->nodes[i].neighbours_set[j] == rank) nself++; in PCBDDCGraphSetUp()
782 if (nself > 1) graph->multi_element = PETSC_TRUE; in PCBDDCGraphSetUp()
785 PetscCall(PetscCalloc1(nodecount[i], &graph->nodes[i].neighbours_set)); in PCBDDCGraphSetUp()
788 PetscCall(ISLocalToGlobalMappingRestoreNodeInfo(graph->l2gmap, NULL, &nodecount, &nodeneighs)); in PCBDDCGraphSetUp()
789 PetscCallMPI(MPIU_Allreduce(MPI_IN_PLACE, &graph->multi_element, 1, MPI_C_BOOL, MPI_LOR, comm)); in PCBDDCGraphSetUp()
792 if (graph->multi_element) { in PCBDDCGraphSetUp()
799 …PetscCheck(!nvtxs || graph->local_subs, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Missing local subdomain … in PCBDDCGraphSetUp()
801 PetscCall(ISLocalToGlobalMappingGetIndices(graph->l2gmap, &idxs)); in PCBDDCGraphSetUp()
806 PetscCall(ISLocalToGlobalMappingRestoreIndices(graph->l2gmap, &idxs)); in PCBDDCGraphSetUp()
820 PetscCall(PetscSFGatherBegin(sf, MPIU_INT, graph->local_subs, multi_root_subs)); in PCBDDCGraphSetUp()
821 PetscCall(PetscSFGatherEnd(sf, MPIU_INT, graph->local_subs, multi_root_subs)); in PCBDDCGraphSetUp()
825 graph->nodes[i].local_sub = graph->local_subs[i]; in PCBDDCGraphSetUp()
826 for (j = 0, c = 0; j < graph->nodes[i].count; j++) { in PCBDDCGraphSetUp()
827 if (graph->nodes[i].neighbours_set[j] == rank) c++; in PCBDDCGraphSetUp()
830 PetscCall(PetscMalloc1(c, &graph->nodes[i].local_groups)); in PCBDDCGraphSetUp()
831 for (j = 0; j < c; j++) graph->nodes[i].local_groups[j] = multi_root_subs[start[gid] + j]; in PCBDDCGraphSetUp()
832 PetscCall(PetscSortInt(c, graph->nodes[i].local_groups)); in PCBDDCGraphSetUp()
833 graph->nodes[i].local_groups_count = c; in PCBDDCGraphSetUp()
851 …for (i = 0; i < nvtxs; i++) graph->nodes[i].which_dof = k; /* by default a dof belongs to the comp… in PCBDDCGraphSetUp()
865 graph->nodes[is_indices[jj]].which_dof = k + b; in PCBDDCGraphSetUp()
879 graph->nodes[is_indices[i]].special_dof = PCBDDCGRAPH_NEUMANN_MARK; in PCBDDCGraphSetUp()
891 if (!graph->seq_graph) { /* dirichlet nodes treated as internal */ in PCBDDCGraphSetUp()
892 graph->nodes[is_indices[i]].touched = PETSC_TRUE; in PCBDDCGraphSetUp()
893 graph->nodes[is_indices[i]].subset = 0; in PCBDDCGraphSetUp()
895 graph->nodes[is_indices[i]].special_dof = PCBDDCGRAPH_DIRICHLET_MARK; in PCBDDCGraphSetUp()
906 …if (is_indices[i] > -1 && is_indices[i] < nvtxs && graph->nodes[is_indices[i]].special_dof != PCBD… in PCBDDCGraphSetUp()
907 graph->nodes[is_indices[i]].special_dof = PCBDDCGRAPH_SPECIAL_MARK - j; in PCBDDCGraphSetUp()
915 if (!graph->seq_graph) { in PCBDDCGraphSetUp()
917 const PetscInt icount = graph->nodes[i].count; in PCBDDCGraphSetUp()
918 if (graph->nodes[i].count < 2) { in PCBDDCGraphSetUp()
919 graph->nodes[i].touched = PETSC_TRUE; in PCBDDCGraphSetUp()
920 graph->nodes[i].subset = 0; in PCBDDCGraphSetUp()
922 if (graph->multi_element) { in PCBDDCGraphSetUp()
923 graph->nodes[i].shared = PETSC_FALSE; in PCBDDCGraphSetUp()
925 if (graph->nodes[i].neighbours_set[k] != rank) { in PCBDDCGraphSetUp()
926 graph->nodes[i].shared = PETSC_TRUE; in PCBDDCGraphSetUp()
930 graph->nodes[i].shared = PETSC_TRUE; in PCBDDCGraphSetUp()
935 for (i = 0; i < nvtxs; i++) graph->nodes[i].shared = PETSC_TRUE; in PCBDDCGraphSetUp()
941 if (graph->nodes[i].touched) nodes_touched++; in PCBDDCGraphSetUp()
944 if (graph->seq_graph) { in PCBDDCGraphSetUp()
945 PetscCall(PetscMalloc2(nvtxs + 1, &graph->cptr, nvtxs, &graph->queue)); in PCBDDCGraphSetUp()
948 PetscCall(PetscMalloc2(nused + 1, &graph->cptr, nused, &graph->queue)); in PCBDDCGraphSetUp()
951 graph->ncc = 0; in PCBDDCGraphSetUp()
959 if (graph->nodes[i].touched) continue; in PCBDDCGraphSetUp()
960 graph->nodes[i].touched = PETSC_TRUE; in PCBDDCGraphSetUp()
961 PetscCall(PetscHMapPCBDDCGraphNodePut(subsetmaps, &graph->nodes[i], &iter, &missing)); in PCBDDCGraphSetUp()
963 graph->ncc++; in PCBDDCGraphSetUp()
964 PetscCall(PetscHMapPCBDDCGraphNodeIterSet(subsetmaps, iter, graph->ncc)); in PCBDDCGraphSetUp()
965 subset = graph->ncc; in PCBDDCGraphSetUp()
968 graph->nodes[i].subset = subset; in PCBDDCGraphSetUp()
971 graph->cptr[0] = 0; in PCBDDCGraphSetUp()
972 for (i = 0; i < graph->ncc; i++) graph->cptr[i + 1] = graph->cptr[i] + subset_sizes[i]; in PCBDDCGraphSetUp()
973 for (i = 0; i < graph->ncc; i++) subset_sizes[i] = 0; in PCBDDCGraphSetUp()
976 const PetscInt subset = graph->nodes[i].subset - 1; in PCBDDCGraphSetUp()
978 …PetscCheck(subset_sizes[subset] + graph->cptr[subset] < graph->cptr[subset + 1], PETSC_COMM_SELF, … in PCBDDCGraphSetUp()
979 graph->queue[subset_sizes[subset] + graph->cptr[subset]] = i; in PCBDDCGraphSetUp()
982 …for (i = 0; i < graph->ncc; i++) PetscCheck(subset_sizes[i] + graph->cptr[i] == graph->cptr[i + 1]… in PCBDDCGraphSetUp()
988 graph->n_subsets = graph->ncc; in PCBDDCGraphSetUp()
989 PetscCall(PetscMalloc1(graph->n_subsets, &graph->subset_ncc)); in PCBDDCGraphSetUp()
990 for (i = 0; i < graph->n_subsets; i++) graph->subset_ncc[i] = 1; in PCBDDCGraphSetUp()
992 PetscCall(PetscMalloc1(graph->ncc, &graph->subset_ref_node)); in PCBDDCGraphSetUp()
993 PetscCall(PetscMalloc1(graph->cptr[graph->ncc], &queue_global)); in PCBDDCGraphSetUp()
994 PetscCall(PetscMalloc2(graph->ncc, &graph->subset_size, graph->ncc, &graph->subset_idxs)); in PCBDDCGraphSetUp()
995 if (graph->multi_element) PetscCall(PetscMalloc1(graph->ncc, &graph->gsubset_size)); in PCBDDCGraphSetUp()
996 else graph->gsubset_size = graph->subset_size; in PCBDDCGraphSetUp()
997 …PetscCall(ISLocalToGlobalMappingApply(graph->l2gmap, graph->cptr[graph->ncc], graph->queue, queue_… in PCBDDCGraphSetUp()
1002 for (j = 0; j < graph->ncc; j++) { in PCBDDCGraphSetUp()
1005 for (k = graph->cptr[j]; k < graph->cptr[j + 1]; k++) { in PCBDDCGraphSetUp()
1007 if (graph->multi_element) { in PCBDDCGraphSetUp()
1015 graph->gsubset_size[j] = c; in PCBDDCGraphSetUp()
1016 graph->subset_size[j] = graph->cptr[j + 1] - graph->cptr[j]; in PCBDDCGraphSetUp()
1017 graph->subset_ref_node[j] = ref_node; in PCBDDCGraphSetUp()
1018 if (graph->multi_element) PetscCall(PetscHMapIClear(cnt_unique)); in PCBDDCGraphSetUp()
1023 if (graph->ncc) { in PCBDDCGraphSetUp()
1024 PetscCall(PetscMalloc1(graph->cptr[graph->ncc], &graph->subset_idxs[0])); in PCBDDCGraphSetUp()
1025 PetscCall(PetscArrayzero(graph->subset_idxs[0], graph->cptr[graph->ncc])); in PCBDDCGraphSetUp()
1026 …for (j = 1; j < graph->ncc; j++) graph->subset_idxs[j] = graph->subset_idxs[j - 1] + graph->subset… in PCBDDCGraphSetUp()
1027 PetscCall(PetscArraycpy(graph->subset_idxs[0], graph->queue, graph->cptr[graph->ncc])); in PCBDDCGraphSetUp()
1031 if (!graph->seq_graph) { in PCBDDCGraphSetUp()
1041 …PetscCall(ISCreateGeneral(comm, graph->n_subsets, graph->subset_ref_node, PETSC_USE_POINTER, &subs… in PCBDDCGraphSetUp()
1045 PetscCall(PetscSFCreate(comm, &graph->interface_ref_sf)); in PCBDDCGraphSetUp()
1048 …PetscCall(PetscSFSetGraphLayout(graph->interface_ref_sf, map, graph->n_subsets, NULL, PETSC_OWN_PO… in PCBDDCGraphSetUp()
1053 PetscCall(PetscSFComputeDegreeBegin(graph->interface_ref_sf, °ree)); in PCBDDCGraphSetUp()
1054 PetscCall(PetscSFComputeDegreeEnd(graph->interface_ref_sf, °ree)); in PCBDDCGraphSetUp()
1055 PetscCall(PetscSFGetMultiSF(graph->interface_ref_sf, &msf)); in PCBDDCGraphSetUp()
1056 PetscCall(PetscSFGetGraph(graph->interface_ref_sf, &nr, NULL, NULL, NULL)); in PCBDDCGraphSetUp()
1059 PetscCall(PetscSFGatherBegin(graph->interface_ref_sf, MPIU_INT, graph->gsubset_size, rdata)); in PCBDDCGraphSetUp()
1060 PetscCall(PetscSFGatherEnd(graph->interface_ref_sf, MPIU_INT, graph->gsubset_size, rdata)); in PCBDDCGraphSetUp()
1075 PetscCall(PetscSFGetGraph(graph->interface_ref_sf, NULL, NULL, NULL, &subs_remote)); in PCBDDCGraphSetUp()
1076 for (PetscInt i = 0; i < graph->n_subsets; i++) mss = PetscMax(graph->subset_size[i], mss); in PCBDDCGraphSetUp()
1079 PetscCall(PetscCalloc1(graph->n_subsets + 1, &start_rsize)); in PCBDDCGraphSetUp()
1080 PetscCall(PetscCalloc1(nr, &graph->interface_ref_rsize)); in PCBDDCGraphSetUp()
1082 …PetscCall(PetscSFReduceBegin(graph->interface_ref_sf, MPIU_INT, graph->gsubset_size, graph->interf… in PCBDDCGraphSetUp()
1083 …PetscCall(PetscSFReduceEnd(graph->interface_ref_sf, MPIU_INT, graph->gsubset_size, graph->interfac… in PCBDDCGraphSetUp()
1088 nri += graph->interface_ref_rsize[i]; in PCBDDCGraphSetUp()
1089 cum_rsize[i + 1] = cum_rsize[i] + graph->interface_ref_rsize[i]; in PCBDDCGraphSetUp()
1091 nli = graph->cptr[graph->ncc]; in PCBDDCGraphSetUp()
1092 …PetscCall(PetscSFBcastBegin(graph->interface_ref_sf, MPIU_INT, cum_rsize, start_rsize, MPI_REPLACE… in PCBDDCGraphSetUp()
1093 …PetscCall(PetscSFBcastEnd(graph->interface_ref_sf, MPIU_INT, cum_rsize, start_rsize, MPI_REPLACE)); in PCBDDCGraphSetUp()
1100 PetscCall(PetscSFCreate(comm, &graph->interface_subset_sf)); in PCBDDCGraphSetUp()
1104 for (PetscInt i = 0, nli = 0; i < graph->n_subsets; i++) { in PCBDDCGraphSetUp()
1107 const PetscInt subset_size = graph->subset_size[i]; in PCBDDCGraphSetUp()
1108 const PetscInt gsubset_size = graph->gsubset_size[i]; in PCBDDCGraphSetUp()
1109 const PetscInt *subset_idxs = graph->subset_idxs[i]; in PCBDDCGraphSetUp()
1110 const PetscInt *lsub_queue_global = queue_global + graph->cptr[i]; in PCBDDCGraphSetUp()
1122 const PetscInt ls = graph->nodes[subset_idxs[j]].local_sub; in PCBDDCGraphSetUp()
1125 if (graph->nodes[subset_idxs[k]].local_sub == ls) { in PCBDDCGraphSetUp()
1139 …nli == graph->cptr[graph->ncc], PETSC_COMM_SELF, PETSC_ERR_PLIB, "Invalid ilocal size %" PetscInt_… in PCBDDCGraphSetUp()
1140 …PetscCall(PetscSFSetGraph(graph->interface_subset_sf, nri, nli, ilocal, PETSC_OWN_POINTER, iremote… in PCBDDCGraphSetUp()
1147 graph->setupcalled = PETSC_TRUE; in PCBDDCGraphSetUp()
1151 PetscErrorCode PCBDDCGraphResetCoords(PCBDDCGraph graph) in PCBDDCGraphResetCoords() argument
1154 if (!graph) PetscFunctionReturn(PETSC_SUCCESS); in PCBDDCGraphResetCoords()
1155 PetscCall(PetscFree(graph->coords)); in PCBDDCGraphResetCoords()
1156 graph->cdim = 0; in PCBDDCGraphResetCoords()
1157 graph->cnloc = 0; in PCBDDCGraphResetCoords()
1158 graph->cloc = PETSC_FALSE; in PCBDDCGraphResetCoords()
1162 PetscErrorCode PCBDDCGraphResetCSR(PCBDDCGraph graph) in PCBDDCGraphResetCSR() argument
1165 if (!graph) PetscFunctionReturn(PETSC_SUCCESS); in PCBDDCGraphResetCSR()
1166 if (graph->freecsr) { in PCBDDCGraphResetCSR()
1167 PetscCall(PetscFree(graph->xadj)); in PCBDDCGraphResetCSR()
1168 PetscCall(PetscFree(graph->adjncy)); in PCBDDCGraphResetCSR()
1170 graph->xadj = NULL; in PCBDDCGraphResetCSR()
1171 graph->adjncy = NULL; in PCBDDCGraphResetCSR()
1173 graph->freecsr = PETSC_FALSE; in PCBDDCGraphResetCSR()
1174 graph->nvtxs_csr = 0; in PCBDDCGraphResetCSR()
1178 PetscErrorCode PCBDDCGraphReset(PCBDDCGraph graph) in PCBDDCGraphReset() argument
1181 if (!graph) PetscFunctionReturn(PETSC_SUCCESS); in PCBDDCGraphReset()
1182 PetscCall(ISLocalToGlobalMappingDestroy(&graph->l2gmap)); in PCBDDCGraphReset()
1183 PetscCall(PetscFree(graph->subset_ncc)); in PCBDDCGraphReset()
1184 PetscCall(PetscFree(graph->subset_ref_node)); in PCBDDCGraphReset()
1185 for (PetscInt i = 0; i < graph->nvtxs; i++) { in PCBDDCGraphReset()
1186 PetscCall(PetscFree(graph->nodes[i].neighbours_set)); in PCBDDCGraphReset()
1187 PetscCall(PetscFree(graph->nodes[i].local_groups)); in PCBDDCGraphReset()
1189 PetscCall(PetscFree(graph->nodes)); in PCBDDCGraphReset()
1190 PetscCall(PetscFree2(graph->cptr, graph->queue)); in PCBDDCGraphReset()
1191 if (graph->subset_idxs) PetscCall(PetscFree(graph->subset_idxs[0])); in PCBDDCGraphReset()
1192 PetscCall(PetscFree2(graph->subset_size, graph->subset_idxs)); in PCBDDCGraphReset()
1193 if (graph->multi_element) PetscCall(PetscFree(graph->gsubset_size)); in PCBDDCGraphReset()
1194 PetscCall(PetscFree(graph->interface_ref_rsize)); in PCBDDCGraphReset()
1195 PetscCall(PetscSFDestroy(&graph->interface_subset_sf)); in PCBDDCGraphReset()
1196 PetscCall(PetscSFDestroy(&graph->interface_ref_sf)); in PCBDDCGraphReset()
1197 PetscCall(ISDestroy(&graph->dirdofs)); in PCBDDCGraphReset()
1198 PetscCall(ISDestroy(&graph->dirdofsB)); in PCBDDCGraphReset()
1199 if (graph->n_local_subs) PetscCall(PetscFree(graph->local_subs)); in PCBDDCGraphReset()
1200 graph->multi_element = PETSC_FALSE; in PCBDDCGraphReset()
1201 graph->has_dirichlet = PETSC_FALSE; in PCBDDCGraphReset()
1202 graph->twodimset = PETSC_FALSE; in PCBDDCGraphReset()
1203 graph->twodim = PETSC_FALSE; in PCBDDCGraphReset()
1204 graph->nvtxs = 0; in PCBDDCGraphReset()
1205 graph->nvtxs_global = 0; in PCBDDCGraphReset()
1206 graph->n_subsets = 0; in PCBDDCGraphReset()
1207 graph->custom_minimal_size = 1; in PCBDDCGraphReset()
1208 graph->n_local_subs = 0; in PCBDDCGraphReset()
1209 graph->maxcount = PETSC_INT_MAX; in PCBDDCGraphReset()
1210 graph->seq_graph = PETSC_FALSE; in PCBDDCGraphReset()
1211 graph->setupcalled = PETSC_FALSE; in PCBDDCGraphReset()
1215 PetscErrorCode PCBDDCGraphInit(PCBDDCGraph graph, ISLocalToGlobalMapping l2gmap, PetscInt N, PetscI… in PCBDDCGraphInit() argument
1220 PetscAssertPointer(graph, 1); in PCBDDCGraphInit()
1225 …PetscCheck(!graph->nvtxs_global, PetscObjectComm((PetscObject)l2gmap), PETSC_ERR_PLIB, "BDDCGraph … in PCBDDCGraphInit()
1228 graph->l2gmap = l2gmap; in PCBDDCGraphInit()
1230 graph->nvtxs = n; in PCBDDCGraphInit()
1231 graph->nvtxs_global = N; in PCBDDCGraphInit()
1233 PetscCall(PetscCalloc1(graph->nvtxs, &graph->nodes)); in PCBDDCGraphInit()
1235 for (n = 0; n < graph->nvtxs; n++) graph->nodes[n].which_dof = -1; in PCBDDCGraphInit()
1238 graph->subset_ncc = NULL; in PCBDDCGraphInit()
1239 graph->subset_ref_node = NULL; in PCBDDCGraphInit()
1241 graph->maxcount = maxcount; in PCBDDCGraphInit()
1245 PetscErrorCode PCBDDCGraphDestroy(PCBDDCGraph *graph) in PCBDDCGraphDestroy() argument
1248 PetscCall(PCBDDCGraphResetCSR(*graph)); in PCBDDCGraphDestroy()
1249 PetscCall(PCBDDCGraphResetCoords(*graph)); in PCBDDCGraphDestroy()
1250 PetscCall(PCBDDCGraphReset(*graph)); in PCBDDCGraphDestroy()
1251 PetscCall(PetscFree(*graph)); in PCBDDCGraphDestroy()
1255 PetscErrorCode PCBDDCGraphCreate(PCBDDCGraph *graph) in PCBDDCGraphCreate() argument
1262 *graph = new_graph; in PCBDDCGraphCreate()