plex.c (848bb224a82572e6e7352f699308165ae6d08228) plex.c (f13dfd9ea68e0ddeee984e65c377a1819eab8a8a)
1#include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/
2#include <petsc/private/dmlabelimpl.h>
3#include <petsc/private/isimpl.h>
4#include <petsc/private/vecimpl.h>
5#include <petsc/private/glvisvecimpl.h>
6#include <petscsf.h>
7#include <petscds.h>
8#include <petscdraw.h>

--- 1042 unchanged lines hidden (view full) ---

1051 const char *defcolors[3] = {"gray", "orange", "green"};
1052 const char *deflcolors[4] = {"blue", "cyan", "red", "magenta"};
1053 char lname[PETSC_MAX_PATH_LEN];
1054 PetscReal scale = 2.0;
1055 PetscReal tikzscale = 1.0;
1056 PetscBool useNumbers = PETSC_TRUE, drawNumbers[4], drawColors[4], useLabels, useColors, plotEdges, drawHasse = PETSC_FALSE;
1057 double tcoords[3];
1058 PetscScalar *coords;
1#include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/
2#include <petsc/private/dmlabelimpl.h>
3#include <petsc/private/isimpl.h>
4#include <petsc/private/vecimpl.h>
5#include <petsc/private/glvisvecimpl.h>
6#include <petscsf.h>
7#include <petscds.h>
8#include <petscdraw.h>

--- 1042 unchanged lines hidden (view full) ---

1051 const char *defcolors[3] = {"gray", "orange", "green"};
1052 const char *deflcolors[4] = {"blue", "cyan", "red", "magenta"};
1053 char lname[PETSC_MAX_PATH_LEN];
1054 PetscReal scale = 2.0;
1055 PetscReal tikzscale = 1.0;
1056 PetscBool useNumbers = PETSC_TRUE, drawNumbers[4], drawColors[4], useLabels, useColors, plotEdges, drawHasse = PETSC_FALSE;
1057 double tcoords[3];
1058 PetscScalar *coords;
1059 PetscInt numLabels, l, numColors, numLColors, dim, d, depth, cStart, cEnd, c, vStart, vEnd, v, eStart = 0, eEnd = 0, fStart = 0, fEnd = 0, e, p, n;
1059 PetscInt numLabels, l, numColors, numLColors, dim, d, depth, cStart, cEnd, c, vStart, vEnd, v, eStart = 0, eEnd = 0, e, p, n;
1060 PetscMPIInt rank, size;
1061 char **names, **colors, **lcolors;
1062 PetscBool flg, lflg;
1063 PetscBT wp = NULL;
1064 PetscInt pEnd, pStart;
1065
1066 PetscCall(DMGetCoordinateDM(dm, &cdm));
1067 PetscCall(DMGetCoordinateSection(dm, &coordSection));

--- 38 unchanged lines hidden (view full) ---

1106 if (depth < dim) plotEdges = PETSC_FALSE;
1107 PetscCall(PetscOptionsGetBool(((PetscObject)viewer)->options, ((PetscObject)viewer)->prefix, "-dm_plex_view_hasse", &drawHasse, NULL));
1108
1109 /* filter points with labelvalue != labeldefaultvalue */
1110 PetscCall(DMPlexGetChart(dm, &pStart, &pEnd));
1111 PetscCall(DMPlexGetDepthStratum(dm, 0, &vStart, &vEnd));
1112 PetscCall(DMPlexGetDepthStratum(dm, 1, &eStart, &eEnd));
1113 PetscCall(DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd));
1060 PetscMPIInt rank, size;
1061 char **names, **colors, **lcolors;
1062 PetscBool flg, lflg;
1063 PetscBT wp = NULL;
1064 PetscInt pEnd, pStart;
1065
1066 PetscCall(DMGetCoordinateDM(dm, &cdm));
1067 PetscCall(DMGetCoordinateSection(dm, &coordSection));

--- 38 unchanged lines hidden (view full) ---

1106 if (depth < dim) plotEdges = PETSC_FALSE;
1107 PetscCall(PetscOptionsGetBool(((PetscObject)viewer)->options, ((PetscObject)viewer)->prefix, "-dm_plex_view_hasse", &drawHasse, NULL));
1108
1109 /* filter points with labelvalue != labeldefaultvalue */
1110 PetscCall(DMPlexGetChart(dm, &pStart, &pEnd));
1111 PetscCall(DMPlexGetDepthStratum(dm, 0, &vStart, &vEnd));
1112 PetscCall(DMPlexGetDepthStratum(dm, 1, &eStart, &eEnd));
1113 PetscCall(DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd));
1114 PetscCall(DMPlexGetHeightStratum(dm, 1, &fStart, &fEnd));
1115 if (lflg) {
1116 DMLabel lbl;
1117
1118 PetscCall(DMGetLabel(dm, lname, &lbl));
1119 if (lbl) {
1120 PetscInt val, defval;
1121
1122 PetscCall(DMLabelGetDefaultValue(lbl, &defval));

--- 25 unchanged lines hidden (view full) ---

1148 PetscCall(PetscViewerASCIIPrintf(viewer, "%s for process ", name));
1149 for (p = 0; p < size; ++p) {
1150 if (p) PetscCall(PetscViewerASCIIPrintf(viewer, (p == size - 1) ? ", and " : ", "));
1151 PetscCall(PetscViewerASCIIPrintf(viewer, "{\\textcolor{%s}%" PetscInt_FMT "}", colors[p % numColors], p));
1152 }
1153 PetscCall(PetscViewerASCIIPrintf(viewer, ".\n\n\n"));
1154 }
1155 if (drawHasse) {
1114 if (lflg) {
1115 DMLabel lbl;
1116
1117 PetscCall(DMGetLabel(dm, lname, &lbl));
1118 if (lbl) {
1119 PetscInt val, defval;
1120
1121 PetscCall(DMLabelGetDefaultValue(lbl, &defval));

--- 25 unchanged lines hidden (view full) ---

1147 PetscCall(PetscViewerASCIIPrintf(viewer, "%s for process ", name));
1148 for (p = 0; p < size; ++p) {
1149 if (p) PetscCall(PetscViewerASCIIPrintf(viewer, (p == size - 1) ? ", and " : ", "));
1150 PetscCall(PetscViewerASCIIPrintf(viewer, "{\\textcolor{%s}%" PetscInt_FMT "}", colors[p % numColors], p));
1151 }
1152 PetscCall(PetscViewerASCIIPrintf(viewer, ".\n\n\n"));
1153 }
1154 if (drawHasse) {
1156 PetscInt maxStratum = PetscMax(vEnd - vStart, PetscMax(eEnd - eStart, PetscMax(fEnd - fStart, cEnd - cStart)));
1155 PetscInt maxStratum = PetscMax(vEnd - vStart, PetscMax(eEnd - eStart, cEnd - cStart));
1157
1158 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\vStart}{%" PetscInt_FMT "}\n", vStart));
1159 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\vEnd}{%" PetscInt_FMT "}\n", vEnd - 1));
1160 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\numVertices}{%" PetscInt_FMT "}\n", vEnd - vStart));
1161 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\vShift}{%.2f}\n", 3 + (maxStratum - (vEnd - vStart)) / 2.));
1162 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\eStart}{%" PetscInt_FMT "}\n", eStart));
1163 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\eEnd}{%" PetscInt_FMT "}\n", eEnd - 1));
1164 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\eShift}{%.2f}\n", 3 + (maxStratum - (eEnd - eStart)) / 2.));
1165 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\numEdges}{%" PetscInt_FMT "}\n", eEnd - eStart));
1156
1157 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\vStart}{%" PetscInt_FMT "}\n", vStart));
1158 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\vEnd}{%" PetscInt_FMT "}\n", vEnd - 1));
1159 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\numVertices}{%" PetscInt_FMT "}\n", vEnd - vStart));
1160 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\vShift}{%.2f}\n", 3 + (maxStratum - (vEnd - vStart)) / 2.));
1161 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\eStart}{%" PetscInt_FMT "}\n", eStart));
1162 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\eEnd}{%" PetscInt_FMT "}\n", eEnd - 1));
1163 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\eShift}{%.2f}\n", 3 + (maxStratum - (eEnd - eStart)) / 2.));
1164 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\numEdges}{%" PetscInt_FMT "}\n", eEnd - eStart));
1166 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\fStart}{%" PetscInt_FMT "}\n", fStart));
1167 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\fEnd}{%" PetscInt_FMT "}\n", fEnd - 1));
1168 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\fShift}{%.2f}\n", 3 + (maxStratum - (fEnd - fStart)) / 2.));
1169 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\numFaces}{%" PetscInt_FMT "}\n", fEnd - fStart));
1170 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\cStart}{%" PetscInt_FMT "}\n", cStart));
1171 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\cEnd}{%" PetscInt_FMT "}\n", cEnd - 1));
1172 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\numCells}{%" PetscInt_FMT "}\n", cEnd - cStart));
1173 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\cShift}{%.2f}\n", 3 + (maxStratum - (cEnd - cStart)) / 2.));
1174 }
1175 PetscCall(PetscViewerASCIIPrintf(viewer, "\\begin{tikzpicture}[scale = %g,font=\\fontsize{8}{8}\\selectfont]\n", (double)tikzscale));
1176
1177 /* Plot vertices */

--- 203 unchanged lines hidden (view full) ---

1381 }
1382 if (drawNumbers[dim]) {
1383 PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, ") node(%" PetscInt_FMT "_%d) [draw,shape=circle,color=%s] {%" PetscInt_FMT "};\n", c, rank, color, c));
1384 } else if (drawColors[dim]) {
1385 PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, ") node(%" PetscInt_FMT "_%d) [fill,inner sep=%dpt,shape=circle,color=%s] {};\n", c, rank, !isLabeled ? 1 : 2, color));
1386 } else PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, ") node(%" PetscInt_FMT "_%d) [] {};\n", c, rank));
1387 }
1388 if (drawHasse) {
1165 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\cStart}{%" PetscInt_FMT "}\n", cStart));
1166 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\cEnd}{%" PetscInt_FMT "}\n", cEnd - 1));
1167 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\numCells}{%" PetscInt_FMT "}\n", cEnd - cStart));
1168 PetscCall(PetscViewerASCIIPrintf(viewer, "\\newcommand{\\cShift}{%.2f}\n", 3 + (maxStratum - (cEnd - cStart)) / 2.));
1169 }
1170 PetscCall(PetscViewerASCIIPrintf(viewer, "\\begin{tikzpicture}[scale = %g,font=\\fontsize{8}{8}\\selectfont]\n", (double)tikzscale));
1171
1172 /* Plot vertices */

--- 203 unchanged lines hidden (view full) ---

1376 }
1377 if (drawNumbers[dim]) {
1378 PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, ") node(%" PetscInt_FMT "_%d) [draw,shape=circle,color=%s] {%" PetscInt_FMT "};\n", c, rank, color, c));
1379 } else if (drawColors[dim]) {
1380 PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, ") node(%" PetscInt_FMT "_%d) [fill,inner sep=%dpt,shape=circle,color=%s] {};\n", c, rank, !isLabeled ? 1 : 2, color));
1381 } else PetscCall(PetscViewerASCIISynchronizedPrintf(viewer, ") node(%" PetscInt_FMT "_%d) [] {};\n", c, rank));
1382 }
1383 if (drawHasse) {
1389 int height = 0;
1390
1391 color = colors[depth % numColors];
1392 PetscCall(PetscViewerASCIIPrintf(viewer, "%% Cells\n"));
1393 PetscCall(PetscViewerASCIIPrintf(viewer, "\\foreach \\c in {\\cStart,...,\\cEnd}\n"));
1394 PetscCall(PetscViewerASCIIPrintf(viewer, "{\n"));
1384 color = colors[depth % numColors];
1385 PetscCall(PetscViewerASCIIPrintf(viewer, "%% Cells\n"));
1386 PetscCall(PetscViewerASCIIPrintf(viewer, "\\foreach \\c in {\\cStart,...,\\cEnd}\n"));
1387 PetscCall(PetscViewerASCIIPrintf(viewer, "{\n"));
1395 PetscCall(PetscViewerASCIIPrintf(viewer, " \\node(\\c_%d) [draw,shape=circle,color=%s,minimum size = 6mm] at (\\cShift+\\c-\\cStart,%d) {\\c};\n", rank, color, height++));
1388 PetscCall(PetscViewerASCIIPrintf(viewer, " \\node(\\c_%d) [draw,shape=circle,color=%s,minimum size = 6mm] at (\\cShift+\\c-\\cStart,0) {\\c};\n", rank, color));
1396 PetscCall(PetscViewerASCIIPrintf(viewer, "}\n"));
1397
1389 PetscCall(PetscViewerASCIIPrintf(viewer, "}\n"));
1390
1398 if (depth > 2) {
1399 color = colors[1 % numColors];
1400 PetscCall(PetscViewerASCIIPrintf(viewer, "%% Faces\n"));
1401 PetscCall(PetscViewerASCIIPrintf(viewer, "\\foreach \\f in {\\fStart,...,\\fEnd}\n"));
1402 PetscCall(PetscViewerASCIIPrintf(viewer, "{\n"));
1403 PetscCall(PetscViewerASCIIPrintf(viewer, " \\node(\\f_%d) [draw,shape=circle,color=%s,minimum size = 6mm] at (\\fShift+\\f-\\fStart,%d) {\\f};\n", rank, color, height++));
1404 PetscCall(PetscViewerASCIIPrintf(viewer, "}\n"));
1405 }
1406
1407 color = colors[1 % numColors];
1408 PetscCall(PetscViewerASCIIPrintf(viewer, "%% Edges\n"));
1409 PetscCall(PetscViewerASCIIPrintf(viewer, "\\foreach \\e in {\\eStart,...,\\eEnd}\n"));
1410 PetscCall(PetscViewerASCIIPrintf(viewer, "{\n"));
1391 color = colors[1 % numColors];
1392 PetscCall(PetscViewerASCIIPrintf(viewer, "%% Edges\n"));
1393 PetscCall(PetscViewerASCIIPrintf(viewer, "\\foreach \\e in {\\eStart,...,\\eEnd}\n"));
1394 PetscCall(PetscViewerASCIIPrintf(viewer, "{\n"));
1411 PetscCall(PetscViewerASCIIPrintf(viewer, " \\node(\\e_%d) [draw,shape=circle,color=%s,minimum size = 6mm] at (\\eShift+\\e-\\eStart,%d) {\\e};\n", rank, color, height++));
1395 PetscCall(PetscViewerASCIIPrintf(viewer, " \\node(\\e_%d) [draw,shape=circle,color=%s,minimum size = 6mm] at (\\eShift+\\e-\\eStart,1) {\\e};\n", rank, color));
1412 PetscCall(PetscViewerASCIIPrintf(viewer, "}\n"));
1413
1414 color = colors[0 % numColors];
1415 PetscCall(PetscViewerASCIIPrintf(viewer, "%% Vertices\n"));
1416 PetscCall(PetscViewerASCIIPrintf(viewer, "\\foreach \\v in {\\vStart,...,\\vEnd}\n"));
1417 PetscCall(PetscViewerASCIIPrintf(viewer, "{\n"));
1396 PetscCall(PetscViewerASCIIPrintf(viewer, "}\n"));
1397
1398 color = colors[0 % numColors];
1399 PetscCall(PetscViewerASCIIPrintf(viewer, "%% Vertices\n"));
1400 PetscCall(PetscViewerASCIIPrintf(viewer, "\\foreach \\v in {\\vStart,...,\\vEnd}\n"));
1401 PetscCall(PetscViewerASCIIPrintf(viewer, "{\n"));
1418 PetscCall(PetscViewerASCIIPrintf(viewer, " \\node(\\v_%d) [draw,shape=circle,color=%s,minimum size = 6mm] at (\\vShift+\\v-\\vStart,%d) {\\v};\n", rank, color, height++));
1402 PetscCall(PetscViewerASCIIPrintf(viewer, " \\node(\\v_%d) [draw,shape=circle,color=%s,minimum size = 6mm] at (\\vShift+\\v-\\vStart,2) {\\v};\n", rank, color));
1419 PetscCall(PetscViewerASCIIPrintf(viewer, "}\n"));
1420
1421 for (p = pStart; p < pEnd; ++p) {
1422 const PetscInt *cone;
1423 PetscInt coneSize, cp;
1424
1425 PetscCall(DMPlexGetCone(dm, p, &cone));
1426 PetscCall(DMPlexGetConeSize(dm, p, &coneSize));

--- 1373 unchanged lines hidden (view full) ---

2800 PetscCall(PetscStrcmp(mtype, MATBAIJ, &isBlock));
2801 PetscCall(PetscStrcmp(mtype, MATSEQBAIJ, &isSeqBlock));
2802 PetscCall(PetscStrcmp(mtype, MATMPIBAIJ, &isMPIBlock));
2803 PetscCall(PetscStrcmp(mtype, MATSBAIJ, &isSymBlock));
2804 PetscCall(PetscStrcmp(mtype, MATSEQSBAIJ, &isSymSeqBlock));
2805 PetscCall(PetscStrcmp(mtype, MATMPISBAIJ, &isSymMPIBlock));
2806 PetscCall(PetscStrcmp(mtype, MATIS, &isMatIS));
2807 if (!isShell) {
1403 PetscCall(PetscViewerASCIIPrintf(viewer, "}\n"));
1404
1405 for (p = pStart; p < pEnd; ++p) {
1406 const PetscInt *cone;
1407 PetscInt coneSize, cp;
1408
1409 PetscCall(DMPlexGetCone(dm, p, &cone));
1410 PetscCall(DMPlexGetConeSize(dm, p, &coneSize));

--- 1373 unchanged lines hidden (view full) ---

2784 PetscCall(PetscStrcmp(mtype, MATBAIJ, &isBlock));
2785 PetscCall(PetscStrcmp(mtype, MATSEQBAIJ, &isSeqBlock));
2786 PetscCall(PetscStrcmp(mtype, MATMPIBAIJ, &isMPIBlock));
2787 PetscCall(PetscStrcmp(mtype, MATSBAIJ, &isSymBlock));
2788 PetscCall(PetscStrcmp(mtype, MATSEQSBAIJ, &isSymSeqBlock));
2789 PetscCall(PetscStrcmp(mtype, MATMPISBAIJ, &isSymMPIBlock));
2790 PetscCall(PetscStrcmp(mtype, MATIS, &isMatIS));
2791 if (!isShell) {
2808 // There are three states with pblocks, since block starts can have no dofs:
2809 // UNKNOWN) New Block: An open block has been signalled by pblocks[p] == 1
2810 // TRUE) Block Start: The first entry in a block has been added
2811 // FALSE) Block Add: An additional block entry has been added, since pblocks[p] == 0
2812 PetscBT blst;
2813 PetscBool3 bstate = PETSC_BOOL3_UNKNOWN;
2814 PetscBool fillMatrix = (PetscBool)(!dm->prealloc_only && !isMatIS);
2815 const PetscInt *perm = NULL;
2816 PetscInt *dnz, *onz, *dnzu, *onzu, bsLocal[2], bsMinMax[2], *pblocks;
2817 PetscInt pStart, pEnd, dof, cdof, num_fields;
2792 PetscBool fillMatrix = (PetscBool)(!dm->prealloc_only && !isMatIS);
2793 PetscInt *dnz, *onz, *dnzu, *onzu, bsLocal[2], bsMinMax[2], *pblocks;
2794 PetscInt pStart, pEnd, p, dof, cdof, num_fields;
2818
2819 PetscCall(DMGetLocalToGlobalMapping(dm, &ltog));
2795
2796 PetscCall(DMGetLocalToGlobalMapping(dm, &ltog));
2820 PetscCall(PetscSectionGetBlockStarts(sectionLocal, &blst));
2821 if (sectionLocal->perm) PetscCall(ISGetIndices(sectionLocal->perm, &perm));
2822
2823 PetscCall(PetscCalloc1(localSize, &pblocks));
2824 PetscCall(PetscSectionGetChart(sectionGlobal, &pStart, &pEnd));
2825 PetscCall(PetscSectionGetNumFields(sectionGlobal, &num_fields));
2797
2798 PetscCall(PetscCalloc1(localSize, &pblocks));
2799 PetscCall(PetscSectionGetChart(sectionGlobal, &pStart, &pEnd));
2800 PetscCall(PetscSectionGetNumFields(sectionGlobal, &num_fields));
2826 // We need to process in the permuted order to get block sizes right
2827 for (PetscInt point = pStart; point < pEnd; ++point) {
2828 const PetscInt p = perm ? perm[point] : point;
2829
2801 for (p = pStart; p < pEnd; ++p) {
2830 switch (dm->blocking_type) {
2831 case DM_BLOCKING_TOPOLOGICAL_POINT: { // One block per topological point
2832 PetscInt bdof, offset;
2833
2834 PetscCall(PetscSectionGetDof(sectionGlobal, p, &dof));
2835 PetscCall(PetscSectionGetOffset(sectionGlobal, p, &offset));
2836 PetscCall(PetscSectionGetConstraintDof(sectionGlobal, p, &cdof));
2802 switch (dm->blocking_type) {
2803 case DM_BLOCKING_TOPOLOGICAL_POINT: { // One block per topological point
2804 PetscInt bdof, offset;
2805
2806 PetscCall(PetscSectionGetDof(sectionGlobal, p, &dof));
2807 PetscCall(PetscSectionGetOffset(sectionGlobal, p, &offset));
2808 PetscCall(PetscSectionGetConstraintDof(sectionGlobal, p, &cdof));
2837 if (blst && PetscBTLookup(blst, p)) bstate = PETSC_BOOL3_UNKNOWN;
2838 if (dof > 0) {
2809 if (dof > 0) {
2839 // State change
2840 if (bstate == PETSC_BOOL3_UNKNOWN) bstate = PETSC_BOOL3_TRUE;
2841 else if (bstate == PETSC_BOOL3_TRUE && blst && !PetscBTLookup(blst, p)) bstate = PETSC_BOOL3_FALSE;
2842
2843 for (PetscInt i = 0; i < dof - cdof; ++i) pblocks[offset - localStart + i] = dof - cdof;
2844 // Signal block concatenation
2810 for (PetscInt i = 0; i < dof - cdof; ++i) pblocks[offset - localStart + i] = dof - cdof;
2811 // Signal block concatenation
2845 if (bstate == PETSC_BOOL3_FALSE && dof - cdof) pblocks[offset - localStart] = -(dof - cdof);
2812 if (dof - cdof && sectionLocal->blockStarts && !PetscBTLookup(sectionLocal->blockStarts, p)) pblocks[offset - localStart] = -(dof - cdof);
2846 }
2847 dof = dof < 0 ? -(dof + 1) : dof;
2848 bdof = cdof && (dof - cdof) ? 1 : dof;
2849 if (dof) {
2850 if (bs < 0) {
2851 bs = bdof;
2852 } else if (bs != bdof) {
2853 bs = 1;

--- 19 unchanged lines hidden (view full) ---

2873 } else if (bs != bdof) {
2874 bs = 1;
2875 }
2876 }
2877 }
2878 } break;
2879 }
2880 }
2813 }
2814 dof = dof < 0 ? -(dof + 1) : dof;
2815 bdof = cdof && (dof - cdof) ? 1 : dof;
2816 if (dof) {
2817 if (bs < 0) {
2818 bs = bdof;
2819 } else if (bs != bdof) {
2820 bs = 1;

--- 19 unchanged lines hidden (view full) ---

2840 } else if (bs != bdof) {
2841 bs = 1;
2842 }
2843 }
2844 }
2845 } break;
2846 }
2847 }
2881 if (sectionLocal->perm) PetscCall(ISRestoreIndices(sectionLocal->perm, &perm));
2882 /* Must have same blocksize on all procs (some might have no points) */
2883 bsLocal[0] = bs < 0 ? PETSC_MAX_INT : bs;
2884 bsLocal[1] = bs;
2885 PetscCall(PetscGlobalMinMaxInt(PetscObjectComm((PetscObject)dm), bsLocal, bsMinMax));
2886 if (bsMinMax[0] != bsMinMax[1]) bs = 1;
2887 else bs = bsMinMax[0];
2888 bs = PetscMax(1, bs);
2889 PetscCall(MatSetLocalToGlobalMapping(*J, ltog, ltog));

--- 12 unchanged lines hidden (view full) ---

2902 if (pblocks[i] == 0) continue;
2903 // Negative block size indicates the blocks should be concatenated
2904 if (pblocks[i] < 0) {
2905 pblocks[i] = -pblocks[i];
2906 pblocks[nblocks - 1] += pblocks[i];
2907 } else {
2908 pblocks[nblocks++] = pblocks[i]; // nblocks always <= i
2909 }
2848 /* Must have same blocksize on all procs (some might have no points) */
2849 bsLocal[0] = bs < 0 ? PETSC_MAX_INT : bs;
2850 bsLocal[1] = bs;
2851 PetscCall(PetscGlobalMinMaxInt(PetscObjectComm((PetscObject)dm), bsLocal, bsMinMax));
2852 if (bsMinMax[0] != bsMinMax[1]) bs = 1;
2853 else bs = bsMinMax[0];
2854 bs = PetscMax(1, bs);
2855 PetscCall(MatSetLocalToGlobalMapping(*J, ltog, ltog));

--- 12 unchanged lines hidden (view full) ---

2868 if (pblocks[i] == 0) continue;
2869 // Negative block size indicates the blocks should be concatenated
2870 if (pblocks[i] < 0) {
2871 pblocks[i] = -pblocks[i];
2872 pblocks[nblocks - 1] += pblocks[i];
2873 } else {
2874 pblocks[nblocks++] = pblocks[i]; // nblocks always <= i
2875 }
2910 for (PetscInt j = 1; j < pblocks[i]; j++)
2911 PetscCheck(pblocks[i + j] == pblocks[i], PETSC_COMM_SELF, PETSC_ERR_PLIB, "Block of size %" PetscInt_FMT " at %" PetscInt_FMT " mismatches entry %" PetscInt_FMT " at %" PetscInt_FMT, pblocks[i], i, pblocks[i + j], i + j);
2876 for (PetscInt j = 1; j < pblocks[i]; j++) PetscCheck(pblocks[i + j] == pblocks[i], PETSC_COMM_SELF, PETSC_ERR_PLIB, "Block of size %" PetscInt_FMT " mismatches entry %" PetscInt_FMT, pblocks[i], pblocks[i + j]);
2912 }
2913 PetscCall(MatSetVariableBlockSizes(*J, nblocks, pblocks));
2914 }
2915 PetscCall(PetscFree(pblocks));
2916 }
2917 PetscCall(MatSetDM(*J, dm));
2918 PetscFunctionReturn(PETSC_SUCCESS);
2919}

--- 169 unchanged lines hidden (view full) ---

3089 PetscFunctionBegin;
3090 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
3091 PetscAssertPointer(cone, 3);
3092 PetscCall(PetscSectionGetOffset(mesh->coneSection, p, &off));
3093 *cone = PetscSafePointerPlusOffset(mesh->cones, off);
3094 PetscFunctionReturn(PETSC_SUCCESS);
3095}
3096
2877 }
2878 PetscCall(MatSetVariableBlockSizes(*J, nblocks, pblocks));
2879 }
2880 PetscCall(PetscFree(pblocks));
2881 }
2882 PetscCall(MatSetDM(*J, dm));
2883 PetscFunctionReturn(PETSC_SUCCESS);
2884}

--- 169 unchanged lines hidden (view full) ---

3054 PetscFunctionBegin;
3055 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
3056 PetscAssertPointer(cone, 3);
3057 PetscCall(PetscSectionGetOffset(mesh->coneSection, p, &off));
3058 *cone = PetscSafePointerPlusOffset(mesh->cones, off);
3059 PetscFunctionReturn(PETSC_SUCCESS);
3060}
3061
3097/*@
3062/*@C
3098 DMPlexGetConeTuple - Return the points on the in-edges of several points in the DAG
3099
3100 Not Collective
3101
3102 Input Parameters:
3103+ dm - The `DMPLEX`
3104- p - The `IS` of points, which must lie in the chart set with `DMPlexSetChart()`
3105

--- 1003 unchanged lines hidden (view full) ---

4109.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexRestoreTransitiveClosure()`, `DMPlexCreate()`, `DMPlexSetCone()`, `DMPlexSetChart()`, `DMPlexGetCone()`
4110@*/
4111PetscErrorCode DMPlexGetTransitiveClosure(DM dm, PetscInt p, PetscBool useCone, PetscInt *numPoints, PetscInt *points[])
4112{
4113 PetscFunctionBeginHot;
4114 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
4115 if (numPoints) PetscAssertPointer(numPoints, 4);
4116 if (points) PetscAssertPointer(points, 5);
3063 DMPlexGetConeTuple - Return the points on the in-edges of several points in the DAG
3064
3065 Not Collective
3066
3067 Input Parameters:
3068+ dm - The `DMPLEX`
3069- p - The `IS` of points, which must lie in the chart set with `DMPlexSetChart()`
3070

--- 1003 unchanged lines hidden (view full) ---

4074.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexRestoreTransitiveClosure()`, `DMPlexCreate()`, `DMPlexSetCone()`, `DMPlexSetChart()`, `DMPlexGetCone()`
4075@*/
4076PetscErrorCode DMPlexGetTransitiveClosure(DM dm, PetscInt p, PetscBool useCone, PetscInt *numPoints, PetscInt *points[])
4077{
4078 PetscFunctionBeginHot;
4079 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
4080 if (numPoints) PetscAssertPointer(numPoints, 4);
4081 if (points) PetscAssertPointer(points, 5);
4117 if (PetscDefined(USE_DEBUG)) {
4118 PetscInt pStart, pEnd;
4119 PetscCall(DMPlexGetChart(dm, &pStart, &pEnd));
4120 PetscCheck(p >= pStart && p < pEnd, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Point %" PetscInt_FMT " is not in [%" PetscInt_FMT ", %" PetscInt_FMT ")", p, pStart, pEnd);
4121 }
4122 PetscCall(DMPlexGetTransitiveClosure_Internal(dm, p, 0, useCone, numPoints, points));
4123 PetscFunctionReturn(PETSC_SUCCESS);
4124}
4125
4126/*@C
4127 DMPlexRestoreTransitiveClosure - Restore the array of points on the transitive closure of the in-edges or out-edges for this point in the DAG
4128
4129 Not Collective

--- 946 unchanged lines hidden (view full) ---

5076 *coveredPoints = meet[i];
5077 for (p = 0; p < numPoints; ++p) PetscCall(DMPlexRestoreTransitiveClosure(dm, points[p], PETSC_TRUE, NULL, &closures[p]));
5078 PetscCall(PetscFree(closures));
5079 PetscCall(DMRestoreWorkArray(dm, numPoints * (height + 2), MPIU_INT, &offsets));
5080 PetscCall(DMRestoreWorkArray(dm, mc, MPIU_INT, &meet[1 - i]));
5081 PetscFunctionReturn(PETSC_SUCCESS);
5082}
5083
4082 PetscCall(DMPlexGetTransitiveClosure_Internal(dm, p, 0, useCone, numPoints, points));
4083 PetscFunctionReturn(PETSC_SUCCESS);
4084}
4085
4086/*@C
4087 DMPlexRestoreTransitiveClosure - Restore the array of points on the transitive closure of the in-edges or out-edges for this point in the DAG
4088
4089 Not Collective

--- 946 unchanged lines hidden (view full) ---

5036 *coveredPoints = meet[i];
5037 for (p = 0; p < numPoints; ++p) PetscCall(DMPlexRestoreTransitiveClosure(dm, points[p], PETSC_TRUE, NULL, &closures[p]));
5038 PetscCall(PetscFree(closures));
5039 PetscCall(DMRestoreWorkArray(dm, numPoints * (height + 2), MPIU_INT, &offsets));
5040 PetscCall(DMRestoreWorkArray(dm, mc, MPIU_INT, &meet[1 - i]));
5041 PetscFunctionReturn(PETSC_SUCCESS);
5042}
5043
5084/*@
5044/*@C
5085 DMPlexEqual - Determine if two `DM` have the same topology
5086
5087 Not Collective
5088
5089 Input Parameters:
5090+ dmA - A `DMPLEX` object
5091- dmB - A `DMPLEX` object
5092

--- 46 unchanged lines hidden (view full) ---

5139 for (s = 0; s < supportSize; ++s) {
5140 if (support[s] != supportB[s]) PetscFunctionReturn(PETSC_SUCCESS);
5141 }
5142 }
5143 *equal = PETSC_TRUE;
5144 PetscFunctionReturn(PETSC_SUCCESS);
5145}
5146
5045 DMPlexEqual - Determine if two `DM` have the same topology
5046
5047 Not Collective
5048
5049 Input Parameters:
5050+ dmA - A `DMPLEX` object
5051- dmB - A `DMPLEX` object
5052

--- 46 unchanged lines hidden (view full) ---

5099 for (s = 0; s < supportSize; ++s) {
5100 if (support[s] != supportB[s]) PetscFunctionReturn(PETSC_SUCCESS);
5101 }
5102 }
5103 *equal = PETSC_TRUE;
5104 PetscFunctionReturn(PETSC_SUCCESS);
5105}
5106
5147/*@
5107/*@C
5148 DMPlexGetNumFaceVertices - Returns the number of vertices on a face
5149
5150 Not Collective
5151
5152 Input Parameters:
5153+ dm - The `DMPLEX`
5154. cellDim - The cell dimension
5155- numCorners - The number of vertices on a cell

--- 121 unchanged lines hidden (view full) ---

5277 An empty mesh gives -1.
5278
5279.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexGetDepthLabel()`, `DMPlexGetDepthStratum()`, `DMPlexGetPointDepth()`, `DMPlexSymmetrize()`
5280@*/
5281PetscErrorCode DMPlexGetDepth(DM dm, PetscInt *depth)
5282{
5283 DM_Plex *mesh = (DM_Plex *)dm->data;
5284 DMLabel label;
5108 DMPlexGetNumFaceVertices - Returns the number of vertices on a face
5109
5110 Not Collective
5111
5112 Input Parameters:
5113+ dm - The `DMPLEX`
5114. cellDim - The cell dimension
5115- numCorners - The number of vertices on a cell

--- 121 unchanged lines hidden (view full) ---

5237 An empty mesh gives -1.
5238
5239.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexGetDepthLabel()`, `DMPlexGetDepthStratum()`, `DMPlexGetPointDepth()`, `DMPlexSymmetrize()`
5240@*/
5241PetscErrorCode DMPlexGetDepth(DM dm, PetscInt *depth)
5242{
5243 DM_Plex *mesh = (DM_Plex *)dm->data;
5244 DMLabel label;
5285 PetscInt d = -1;
5245 PetscInt d = 0;
5286
5287 PetscFunctionBegin;
5288 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
5289 PetscAssertPointer(depth, 2);
5290 if (mesh->tr) {
5291 PetscCall(DMPlexTransformGetDepth(mesh->tr, depth));
5292 } else {
5293 PetscCall(DMPlexGetDepthLabel(dm, &label));
5246
5247 PetscFunctionBegin;
5248 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
5249 PetscAssertPointer(depth, 2);
5250 if (mesh->tr) {
5251 PetscCall(DMPlexTransformGetDepth(mesh->tr, depth));
5252 } else {
5253 PetscCall(DMPlexGetDepthLabel(dm, &label));
5294 // Allow missing depths
5295 if (label) PetscCall(DMLabelGetValueBounds(label, NULL, &d));
5296 *depth = d;
5254 if (label) PetscCall(DMLabelGetNumValues(label, &d));
5255 *depth = d - 1;
5297 }
5298 PetscFunctionReturn(PETSC_SUCCESS);
5299}
5300
5301/*@
5302 DMPlexGetDepthStratum - Get the bounds [`start`, `end`) for all points at a certain depth.
5303
5304 Not Collective

--- 307 unchanged lines hidden (view full) ---

5612 PetscCall(DMGetCellCoordinateDM(dm, &cellCoordsDM));
5613 if (coordsLocal && coordsDM) {
5614 if (cellCoordsLocal && cellCoordsDM) PetscCall(DMFieldCreateDSWithDG(coordsDM, cellCoordsDM, 0, coordsLocal, cellCoordsLocal, field));
5615 else PetscCall(DMFieldCreateDS(coordsDM, 0, coordsLocal, field));
5616 }
5617 PetscFunctionReturn(PETSC_SUCCESS);
5618}
5619
5256 }
5257 PetscFunctionReturn(PETSC_SUCCESS);
5258}
5259
5260/*@
5261 DMPlexGetDepthStratum - Get the bounds [`start`, `end`) for all points at a certain depth.
5262
5263 Not Collective

--- 307 unchanged lines hidden (view full) ---

5571 PetscCall(DMGetCellCoordinateDM(dm, &cellCoordsDM));
5572 if (coordsLocal && coordsDM) {
5573 if (cellCoordsLocal && cellCoordsDM) PetscCall(DMFieldCreateDSWithDG(coordsDM, cellCoordsDM, 0, coordsLocal, cellCoordsLocal, field));
5574 else PetscCall(DMFieldCreateDS(coordsDM, 0, coordsLocal, field));
5575 }
5576 PetscFunctionReturn(PETSC_SUCCESS);
5577}
5578
5620/*@
5579/*@C
5621 DMPlexGetConeSection - Return a section which describes the layout of cone data
5622
5623 Not Collective
5624
5625 Input Parameter:
5626. dm - The `DMPLEX` object
5627
5628 Output Parameter:

--- 8 unchanged lines hidden (view full) ---

5637 DM_Plex *mesh = (DM_Plex *)dm->data;
5638
5639 PetscFunctionBegin;
5640 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
5641 if (section) *section = mesh->coneSection;
5642 PetscFunctionReturn(PETSC_SUCCESS);
5643}
5644
5580 DMPlexGetConeSection - Return a section which describes the layout of cone data
5581
5582 Not Collective
5583
5584 Input Parameter:
5585. dm - The `DMPLEX` object
5586
5587 Output Parameter:

--- 8 unchanged lines hidden (view full) ---

5596 DM_Plex *mesh = (DM_Plex *)dm->data;
5597
5598 PetscFunctionBegin;
5599 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
5600 if (section) *section = mesh->coneSection;
5601 PetscFunctionReturn(PETSC_SUCCESS);
5602}
5603
5645/*@
5604/*@C
5646 DMPlexGetSupportSection - Return a section which describes the layout of support data
5647
5648 Not Collective
5649
5650 Input Parameter:
5651. dm - The `DMPLEX` object
5652
5653 Output Parameter:

--- 840 unchanged lines hidden (view full) ---

6494 }
6495 }
6496 PetscFree(values);
6497.ve
6498
6499 Fortran Notes:
6500 The `csize` argument is not present in the Fortran binding since it is internal to the array.
6501
5605 DMPlexGetSupportSection - Return a section which describes the layout of support data
5606
5607 Not Collective
5608
5609 Input Parameter:
5610. dm - The `DMPLEX` object
5611
5612 Output Parameter:

--- 840 unchanged lines hidden (view full) ---

6453 }
6454 }
6455 PetscFree(values);
6456.ve
6457
6458 Fortran Notes:
6459 The `csize` argument is not present in the Fortran binding since it is internal to the array.
6460
6461 `values` must be declared with
6462.vb
6463 PetscScalar,dimension(:),pointer :: values
6464.ve
6465 and it will be allocated internally by PETSc to hold the values returned
6466
6502.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexVecRestoreClosure()`, `DMPlexVecSetClosure()`, `DMPlexMatSetClosure()`
6503@*/
6504PetscErrorCode DMPlexVecGetClosure(DM dm, PetscSection section, Vec v, PetscInt point, PetscInt *csize, PetscScalar *values[])
6505{
6506 PetscFunctionBeginHot;
6507 PetscCall(DMPlexVecGetOrientedClosure_Internal(dm, section, PETSC_TRUE, v, point, 0, csize, values));
6508 PetscFunctionReturn(PETSC_SUCCESS);
6509}

--- 70 unchanged lines hidden (view full) ---

6580 } else {
6581 PetscCheck(size <= *csize, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Size of input array %" PetscInt_FMT " < actual size %" PetscInt_FMT, *csize, size);
6582 *csize = size;
6583 }
6584 PetscFunctionReturn(PETSC_SUCCESS);
6585}
6586
6587/*@C
6467.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexVecRestoreClosure()`, `DMPlexVecSetClosure()`, `DMPlexMatSetClosure()`
6468@*/
6469PetscErrorCode DMPlexVecGetClosure(DM dm, PetscSection section, Vec v, PetscInt point, PetscInt *csize, PetscScalar *values[])
6470{
6471 PetscFunctionBeginHot;
6472 PetscCall(DMPlexVecGetOrientedClosure_Internal(dm, section, PETSC_TRUE, v, point, 0, csize, values));
6473 PetscFunctionReturn(PETSC_SUCCESS);
6474}

--- 70 unchanged lines hidden (view full) ---

6545 } else {
6546 PetscCheck(size <= *csize, PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Size of input array %" PetscInt_FMT " < actual size %" PetscInt_FMT, *csize, size);
6547 *csize = size;
6548 }
6549 PetscFunctionReturn(PETSC_SUCCESS);
6550}
6551
6552/*@C
6588 DMPlexVecRestoreClosure - Restore the array of the values on the closure of 'point'
6553 DMPlexVecRestoreClosure - Restore the array of the values on the closure of 'point' obtained with `DMPlexVecGetClosure()`
6589
6590 Not collective
6591
6592 Input Parameters:
6593+ dm - The `DM`
6594. section - The section describing the layout in `v`, or `NULL` to use the default section
6595. v - The local vector
6596. point - The point in the `DM`
6597. csize - The number of values in the closure, or `NULL`
6554
6555 Not collective
6556
6557 Input Parameters:
6558+ dm - The `DM`
6559. section - The section describing the layout in `v`, or `NULL` to use the default section
6560. v - The local vector
6561. point - The point in the `DM`
6562. csize - The number of values in the closure, or `NULL`
6598- values - The array of values, which is a borrowed array and should not be freed
6563- values - The array of values
6599
6600 Level: intermediate
6601
6602 Note:
6603 The array values are discarded and not copied back into `v`. In order to copy values back to `v`, use `DMPlexVecSetClosure()`
6604
6564
6565 Level: intermediate
6566
6567 Note:
6568 The array values are discarded and not copied back into `v`. In order to copy values back to `v`, use `DMPlexVecSetClosure()`
6569
6605 Fortran Notes:
6570 Fortran Note:
6606 The `csize` argument is not present in the Fortran binding since it is internal to the array.
6607
6608.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexVecGetClosure()`, `DMPlexVecSetClosure()`, `DMPlexMatSetClosure()`
6609@*/
6610PetscErrorCode DMPlexVecRestoreClosure(DM dm, PetscSection section, Vec v, PetscInt point, PetscInt *csize, PetscScalar *values[])
6611{
6612 PetscInt size = 0;
6613

--- 385 unchanged lines hidden (view full) ---

6999
7000 Input Parameters:
7001+ dm - The `DM`
7002. section - The section describing the layout in `v`, or `NULL` to use the default section
7003. v - The local vector
7004. point - The point in the `DM`
7005. values - The array of values
7006- mode - The insert mode. One of `INSERT_ALL_VALUES`, `ADD_ALL_VALUES`, `INSERT_VALUES`, `ADD_VALUES`, `INSERT_BC_VALUES`, and `ADD_BC_VALUES`,
6571 The `csize` argument is not present in the Fortran binding since it is internal to the array.
6572
6573.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexVecGetClosure()`, `DMPlexVecSetClosure()`, `DMPlexMatSetClosure()`
6574@*/
6575PetscErrorCode DMPlexVecRestoreClosure(DM dm, PetscSection section, Vec v, PetscInt point, PetscInt *csize, PetscScalar *values[])
6576{
6577 PetscInt size = 0;
6578

--- 385 unchanged lines hidden (view full) ---

6964
6965 Input Parameters:
6966+ dm - The `DM`
6967. section - The section describing the layout in `v`, or `NULL` to use the default section
6968. v - The local vector
6969. point - The point in the `DM`
6970. values - The array of values
6971- mode - The insert mode. One of `INSERT_ALL_VALUES`, `ADD_ALL_VALUES`, `INSERT_VALUES`, `ADD_VALUES`, `INSERT_BC_VALUES`, and `ADD_BC_VALUES`,
7007 where `INSERT_ALL_VALUES` and `ADD_ALL_VALUES` also overwrite boundary conditions.
6972 where `INSERT_ALL_VALUES` and `ADD_ALL_VALUES` also overwrite boundary conditions.
7008
7009 Level: intermediate
7010
6973
6974 Level: intermediate
6975
6976 Note:
6977 Usually the input arrays were obtained with `DMPlexVecGetClosure()`
6978
6979 Fortran Note:
6980 `values` must be declared with
6981.vb
6982 PetscScalar,dimension(:),pointer :: values
6983.ve
6984
7011.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexVecGetClosure()`, `DMPlexMatSetClosure()`
7012@*/
7013PetscErrorCode DMPlexVecSetClosure(DM dm, PetscSection section, Vec v, PetscInt point, const PetscScalar values[], InsertMode mode)
7014{
7015 PetscSection clSection;
7016 IS clPoints;
7017 PetscScalar *array;
7018 PetscInt *points = NULL;

--- 1556 unchanged lines hidden (view full) ---

8575 PetscCall(PetscSectionRestorePointSyms(fsection, numFPoints, ftotpoints, &permsF, NULL));
8576 PetscCall(PetscSectionRestorePointSyms(csection, numCPoints, cpoints, &permsC, NULL));
8577 }
8578 PetscCall(DMRestoreWorkArray(dmf, numCPoints * 2 * 4, MPIU_INT, &ftotpoints));
8579 PetscCall(DMPlexRestoreTransitiveClosure(dmc, point, PETSC_TRUE, &numCPoints, &cpoints));
8580 PetscFunctionReturn(PETSC_SUCCESS);
8581}
8582
6985.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexVecGetClosure()`, `DMPlexMatSetClosure()`
6986@*/
6987PetscErrorCode DMPlexVecSetClosure(DM dm, PetscSection section, Vec v, PetscInt point, const PetscScalar values[], InsertMode mode)
6988{
6989 PetscSection clSection;
6990 IS clPoints;
6991 PetscScalar *array;
6992 PetscInt *points = NULL;

--- 1556 unchanged lines hidden (view full) ---

8549 PetscCall(PetscSectionRestorePointSyms(fsection, numFPoints, ftotpoints, &permsF, NULL));
8550 PetscCall(PetscSectionRestorePointSyms(csection, numCPoints, cpoints, &permsC, NULL));
8551 }
8552 PetscCall(DMRestoreWorkArray(dmf, numCPoints * 2 * 4, MPIU_INT, &ftotpoints));
8553 PetscCall(DMPlexRestoreTransitiveClosure(dmc, point, PETSC_TRUE, &numCPoints, &cpoints));
8554 PetscFunctionReturn(PETSC_SUCCESS);
8555}
8556
8583/*@
8557/*@C
8584 DMPlexGetVTKCellHeight - Returns the height in the DAG used to determine which points are cells (normally 0)
8585
8586 Input Parameter:
8587. dm - The `DMPLEX` object
8588
8589 Output Parameter:
8590. cellHeight - The height of a cell
8591

--- 7 unchanged lines hidden (view full) ---

8599
8600 PetscFunctionBegin;
8601 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
8602 PetscAssertPointer(cellHeight, 2);
8603 *cellHeight = mesh->vtkCellHeight;
8604 PetscFunctionReturn(PETSC_SUCCESS);
8605}
8606
8558 DMPlexGetVTKCellHeight - Returns the height in the DAG used to determine which points are cells (normally 0)
8559
8560 Input Parameter:
8561. dm - The `DMPLEX` object
8562
8563 Output Parameter:
8564. cellHeight - The height of a cell
8565

--- 7 unchanged lines hidden (view full) ---

8573
8574 PetscFunctionBegin;
8575 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
8576 PetscAssertPointer(cellHeight, 2);
8577 *cellHeight = mesh->vtkCellHeight;
8578 PetscFunctionReturn(PETSC_SUCCESS);
8579}
8580
8607/*@
8581/*@C
8608 DMPlexSetVTKCellHeight - Sets the height in the DAG used to determine which points are cells (normally 0)
8609
8610 Input Parameters:
8611+ dm - The `DMPLEX` object
8612- cellHeight - The height of a cell
8613
8614 Level: developer
8615

--- 233 unchanged lines hidden (view full) ---

8849 shift += gsize;
8850 }
8851 PetscCall(ISConcatenate(PETSC_COMM_SELF, depth + 1, nums, globalPointNumbers));
8852 for (d = 0; d <= depth; ++d) PetscCall(ISDestroy(&nums[d]));
8853 PetscFunctionReturn(PETSC_SUCCESS);
8854}
8855
8856/*@
8582 DMPlexSetVTKCellHeight - Sets the height in the DAG used to determine which points are cells (normally 0)
8583
8584 Input Parameters:
8585+ dm - The `DMPLEX` object
8586- cellHeight - The height of a cell
8587
8588 Level: developer
8589

--- 233 unchanged lines hidden (view full) ---

8823 shift += gsize;
8824 }
8825 PetscCall(ISConcatenate(PETSC_COMM_SELF, depth + 1, nums, globalPointNumbers));
8826 for (d = 0; d <= depth; ++d) PetscCall(ISDestroy(&nums[d]));
8827 PetscFunctionReturn(PETSC_SUCCESS);
8828}
8829
8830/*@
8857 DMPlexCreateEdgeNumbering - Create a global numbering for edges.
8858
8859 Collective
8860
8861 Input Parameter:
8862. dm - The `DMPLEX` object
8863
8864 Output Parameter:
8865. globalEdgeNumbers - Global numbers for all edges on this process
8866
8867 Level: developer
8868
8869 Notes:
8870 The point numbering `IS` is parallel, with local portion indexed by local points (see `DMGetLocalSection()`). In the IS, owned edges will have their non-negative value while edges owned by different ranks will be involuted -(idx+1).
8871
8872.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexGetCellNumbering()`, `DMPlexGetVertexNumbering()`, `DMPlexCreatePointNumbering()`
8873@*/
8874PetscErrorCode DMPlexCreateEdgeNumbering(DM dm, IS *globalEdgeNumbers)
8875{
8876 PetscSF sf;
8877 PetscInt eStart, eEnd;
8878
8879 PetscFunctionBegin;
8880 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
8881 PetscCall(DMGetPointSF(dm, &sf));
8882 PetscCall(DMPlexGetDepthStratum(dm, 1, &eStart, &eEnd));
8883 PetscCall(DMPlexCreateNumbering_Plex(dm, eStart, eEnd, 0, NULL, sf, globalEdgeNumbers));
8884 PetscFunctionReturn(PETSC_SUCCESS);
8885}
8886
8887/*@
8888 DMPlexCreateRankField - Create a cell field whose value is the rank of the owner
8889
8890 Input Parameter:
8891. dm - The `DMPLEX` object
8892
8893 Output Parameter:
8894. ranks - The rank field
8895

--- 583 unchanged lines hidden (view full) ---

9479 }
9480 }
9481 }
9482 }
9483 PetscFunctionReturn(PETSC_SUCCESS);
9484}
9485
9486/*@
8831 DMPlexCreateRankField - Create a cell field whose value is the rank of the owner
8832
8833 Input Parameter:
8834. dm - The `DMPLEX` object
8835
8836 Output Parameter:
8837. ranks - The rank field
8838

--- 583 unchanged lines hidden (view full) ---

9422 }
9423 }
9424 }
9425 }
9426 PetscFunctionReturn(PETSC_SUCCESS);
9427}
9428
9429/*@
9487 DMPlexCheckOrphanVertices - Check that no vertices are disconnected from the mesh, unless the mesh only consists of disconnected vertices.
9488
9489 Collective
9490
9491 Input Parameter:
9492. dm - The `DMPLEX` object
9493
9494 Level: developer
9495
9496 Notes:
9497 This is mainly intended for debugging/testing purposes.
9498
9499 Other cell types which are disconnected would be caught by the symmetry and face checks.
9500
9501 For the complete list of DMPlexCheck* functions, see `DMSetFromOptions()`.
9502
9503.seealso: [](ch_unstructured), `DM`, `DMPLEX`, `DMPlexCheck()`, `DMSetFromOptions()`
9504@*/
9505PetscErrorCode DMPlexCheckOrphanVertices(DM dm)
9506{
9507 PetscInt pStart, pEnd, vStart, vEnd;
9508
9509 PetscFunctionBegin;
9510 PetscCall(DMPlexGetChart(dm, &pStart, &pEnd));
9511 PetscCall(DMPlexGetDepthStratum(dm, 0, &vStart, &vEnd));
9512 if (pStart == vStart && pEnd == vEnd) PetscFunctionReturn(PETSC_SUCCESS);
9513 for (PetscInt v = vStart; v < vEnd; ++v) {
9514 PetscInt suppSize;
9515
9516 PetscCall(DMPlexGetSupportSize(dm, v, &suppSize));
9517 PetscCheck(suppSize, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Vertex %" PetscInt_FMT " is disconnected from the mesh", v);
9518 }
9519 PetscFunctionReturn(PETSC_SUCCESS);
9520}
9521
9522/*@
9523 DMPlexCheck - Perform various checks of `DMPLEX` sanity
9524
9525 Input Parameter:
9526. dm - The `DMPLEX` object
9527
9528 Level: developer
9529
9530 Notes:

--- 12 unchanged lines hidden (view full) ---

9543 PetscFunctionBegin;
9544 PetscCall(DMPlexGetVTKCellHeight(dm, &cellHeight));
9545 PetscCall(DMPlexCheckSymmetry(dm));
9546 PetscCall(DMPlexCheckSkeleton(dm, cellHeight));
9547 PetscCall(DMPlexCheckFaces(dm, cellHeight));
9548 PetscCall(DMPlexCheckGeometry(dm));
9549 PetscCall(DMPlexCheckPointSF(dm, NULL, PETSC_FALSE));
9550 PetscCall(DMPlexCheckInterfaceCones(dm));
9430 DMPlexCheck - Perform various checks of `DMPLEX` sanity
9431
9432 Input Parameter:
9433. dm - The `DMPLEX` object
9434
9435 Level: developer
9436
9437 Notes:

--- 12 unchanged lines hidden (view full) ---

9450 PetscFunctionBegin;
9451 PetscCall(DMPlexGetVTKCellHeight(dm, &cellHeight));
9452 PetscCall(DMPlexCheckSymmetry(dm));
9453 PetscCall(DMPlexCheckSkeleton(dm, cellHeight));
9454 PetscCall(DMPlexCheckFaces(dm, cellHeight));
9455 PetscCall(DMPlexCheckGeometry(dm));
9456 PetscCall(DMPlexCheckPointSF(dm, NULL, PETSC_FALSE));
9457 PetscCall(DMPlexCheckInterfaceCones(dm));
9551 PetscCall(DMPlexCheckOrphanVertices(dm));
9552 PetscFunctionReturn(PETSC_SUCCESS);
9553}
9554
9555typedef struct cell_stats {
9556 PetscReal min, max, sum, squaresum;
9557 PetscInt count;
9558} cell_stats_t;
9559

--- 1069 unchanged lines hidden ---
9458 PetscFunctionReturn(PETSC_SUCCESS);
9459}
9460
9461typedef struct cell_stats {
9462 PetscReal min, max, sum, squaresum;
9463 PetscInt count;
9464} cell_stats_t;
9465

--- 1069 unchanged lines hidden ---