| plexdistribute.c (c5e4d11f6a865b7e67dc0aae98421b672bf01406) | plexdistribute.c (df0420ec0cabd052d76b6e285652119a1edfc9b2) |
|---|---|
| 1#include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/ 2 3#undef __FUNCT__ 4#define __FUNCT__ "DMPlexSetAdjacencyUseCone" 5/*@ 6 DMPlexSetAdjacencyUseCone - Define adjacency in the mesh using either the cone or the support first 7 8 Input Parameters: --- 1062 unchanged lines hidden (view full) --- 1071 PetscFunctionReturn(0); 1072} 1073 1074#undef __FUNCT__ 1075#define __FUNCT__ "DMPlexDistributeLabels" 1076/* Here we are assuming that process 0 always has everything */ 1077PetscErrorCode DMPlexDistributeLabels(DM dm, PetscSF migrationSF, DM dmParallel) 1078{ | 1#include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/ 2 3#undef __FUNCT__ 4#define __FUNCT__ "DMPlexSetAdjacencyUseCone" 5/*@ 6 DMPlexSetAdjacencyUseCone - Define adjacency in the mesh using either the cone or the support first 7 8 Input Parameters: --- 1062 unchanged lines hidden (view full) --- 1071 PetscFunctionReturn(0); 1072} 1073 1074#undef __FUNCT__ 1075#define __FUNCT__ "DMPlexDistributeLabels" 1076/* Here we are assuming that process 0 always has everything */ 1077PetscErrorCode DMPlexDistributeLabels(DM dm, PetscSF migrationSF, DM dmParallel) 1078{ |
| 1079 MPI_Comm comm; 1080 PetscMPIInt rank; 1081 PetscInt numLabels, numLocalLabels, l; 1082 PetscBool hasLabels = PETSC_FALSE; 1083 PetscErrorCode ierr; | 1079 DM_Plex *mesh = (DM_Plex*) dm->data; 1080 MPI_Comm comm; 1081 DMLabel depth; 1082 PetscMPIInt rank; 1083 PetscInt numLabels, numLocalLabels, l; 1084 PetscBool hasLabels = PETSC_FALSE, lsendDepth, sendDepth; 1085 PetscObjectState depthState = -1; 1086 PetscErrorCode ierr; |
| 1084 1085 PetscFunctionBegin; 1086 PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 1087 PetscValidHeaderSpecific(dm, DM_CLASSID, 3); 1088 ierr = PetscLogEventBegin(DMPLEX_DistributeLabels,dm,0,0,0);CHKERRQ(ierr); 1089 ierr = PetscObjectGetComm((PetscObject)dm, &comm);CHKERRQ(ierr); 1090 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr); 1091 | 1087 1088 PetscFunctionBegin; 1089 PetscValidHeaderSpecific(dm, DM_CLASSID, 1); 1090 PetscValidHeaderSpecific(dm, DM_CLASSID, 3); 1091 ierr = PetscLogEventBegin(DMPLEX_DistributeLabels,dm,0,0,0);CHKERRQ(ierr); 1092 ierr = PetscObjectGetComm((PetscObject)dm, &comm);CHKERRQ(ierr); 1093 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr); 1094 |
| 1095 /* If the user has changed the depth label, communicate it instead */ 1096 ierr = DMPlexGetDepthLabel(dm, &depth);CHKERRQ(ierr); 1097 if (depth) {ierr = DMLabelGetState(depth, &depthState);CHKERRQ(ierr);} 1098 lsendDepth = mesh->depthState != depthState ? PETSC_TRUE : PETSC_FALSE; 1099 ierr = MPI_Allreduce(&lsendDepth, &sendDepth, 1, MPIU_BOOL, MPI_LOR, comm);CHKERRQ(ierr); 1100 if (sendDepth) { 1101 ierr = DMPlexRemoveLabel(dmParallel, "depth", &depth);CHKERRQ(ierr); 1102 ierr = DMLabelDestroy(&depth);CHKERRQ(ierr); 1103 } |
|
| 1092 /* Everyone must have either the same number of labels, or none */ 1093 ierr = DMPlexGetNumLabels(dm, &numLocalLabels);CHKERRQ(ierr); 1094 numLabels = numLocalLabels; 1095 ierr = MPI_Bcast(&numLabels, 1, MPIU_INT, 0, comm);CHKERRQ(ierr); 1096 if (numLabels == numLocalLabels) hasLabels = PETSC_TRUE; 1097 for (l = numLabels-1; l >= 0; --l) { 1098 DMLabel label = NULL, labelNew = NULL; 1099 PetscBool isdepth; 1100 1101 if (hasLabels) { 1102 ierr = DMPlexGetLabelByNum(dm, l, &label);CHKERRQ(ierr); 1103 /* Skip "depth" because it is recreated */ 1104 ierr = PetscStrcmp(label->name, "depth", &isdepth);CHKERRQ(ierr); 1105 } 1106 ierr = MPI_Bcast(&isdepth, 1, MPIU_BOOL, 0, comm);CHKERRQ(ierr); | 1104 /* Everyone must have either the same number of labels, or none */ 1105 ierr = DMPlexGetNumLabels(dm, &numLocalLabels);CHKERRQ(ierr); 1106 numLabels = numLocalLabels; 1107 ierr = MPI_Bcast(&numLabels, 1, MPIU_INT, 0, comm);CHKERRQ(ierr); 1108 if (numLabels == numLocalLabels) hasLabels = PETSC_TRUE; 1109 for (l = numLabels-1; l >= 0; --l) { 1110 DMLabel label = NULL, labelNew = NULL; 1111 PetscBool isdepth; 1112 1113 if (hasLabels) { 1114 ierr = DMPlexGetLabelByNum(dm, l, &label);CHKERRQ(ierr); 1115 /* Skip "depth" because it is recreated */ 1116 ierr = PetscStrcmp(label->name, "depth", &isdepth);CHKERRQ(ierr); 1117 } 1118 ierr = MPI_Bcast(&isdepth, 1, MPIU_BOOL, 0, comm);CHKERRQ(ierr); |
| 1107 if (isdepth) continue; | 1119 if (isdepth && !sendDepth) continue; |
| 1108 ierr = DMLabelDistribute(label, migrationSF, &labelNew);CHKERRQ(ierr); 1109 ierr = DMPlexAddLabel(dmParallel, labelNew);CHKERRQ(ierr); 1110 } 1111 ierr = PetscLogEventEnd(DMPLEX_DistributeLabels,dm,0,0,0);CHKERRQ(ierr); 1112 PetscFunctionReturn(0); 1113} 1114 1115#undef __FUNCT__ --- 597 unchanged lines hidden --- | 1120 ierr = DMLabelDistribute(label, migrationSF, &labelNew);CHKERRQ(ierr); 1121 ierr = DMPlexAddLabel(dmParallel, labelNew);CHKERRQ(ierr); 1122 } 1123 ierr = PetscLogEventEnd(DMPLEX_DistributeLabels,dm,0,0,0);CHKERRQ(ierr); 1124 PetscFunctionReturn(0); 1125} 1126 1127#undef __FUNCT__ --- 597 unchanged lines hidden --- |