xref: /petsc/src/dm/impls/plex/tests/ex69.c (revision d926f305ac15871fee75e03a63c2f87d02489723)
16fc05355SMatthew G. Knepley static char help[] = "Tests for creation of cohesive meshes by transforms\n\n";
26fc05355SMatthew G. Knepley 
36fc05355SMatthew G. Knepley #include <petscdmplex.h>
46fc05355SMatthew G. Knepley #include <petscsf.h>
56fc05355SMatthew G. Knepley 
66fc05355SMatthew G. Knepley #include <petsc/private/dmpleximpl.h>
76fc05355SMatthew G. Knepley 
86fc05355SMatthew G. Knepley PETSC_EXTERN char tri_2_cv[];
96fc05355SMatthew G. Knepley char              tri_2_cv[] = "\
106fc05355SMatthew G. Knepley 2 4 6 3 1\n\
116fc05355SMatthew G. Knepley 0 2 1\n\
126fc05355SMatthew G. Knepley 1 2 3\n\
136fc05355SMatthew G. Knepley 4 1 5\n\
146fc05355SMatthew G. Knepley 4 0 1\n\
156fc05355SMatthew G. Knepley -1.0  0.0 0.0  1\n\
166fc05355SMatthew G. Knepley  0.0  1.0 0.0 -1\n\
176fc05355SMatthew G. Knepley  0.0 -1.0 0.0  1\n\
186fc05355SMatthew G. Knepley  1.0  0.0 0.0 -1\n\
196fc05355SMatthew G. Knepley -2.0  1.0 0.0  1\n\
206fc05355SMatthew G. Knepley -1.0  2.0 0.0 -1";
216fc05355SMatthew G. Knepley 
226fc05355SMatthew G. Knepley /* List of test meshes
236fc05355SMatthew G. Knepley 
246fc05355SMatthew G. Knepley Test tri_0: triangle
256fc05355SMatthew G. Knepley 
266fc05355SMatthew G. Knepley  4-10--5      8-16--7-14--4
276fc05355SMatthew G. Knepley  |\  1 |      |\     \  1 |
286fc05355SMatthew G. Knepley  | \   |      | \     \   |
296fc05355SMatthew G. Knepley  6  8  9  ->  9 12  2  11 13
306fc05355SMatthew G. Knepley  |   \ |      |   \     \ |
316fc05355SMatthew G. Knepley  | 0  \|      | 0  \     \|
326fc05355SMatthew G. Knepley  2--7--3      3-10--6-15--5
336fc05355SMatthew G. Knepley 
346fc05355SMatthew G. Knepley Test tri_1: triangle, not tensor
356fc05355SMatthew G. Knepley 
366fc05355SMatthew G. Knepley  4-10--5      8-10--7-16--4
376fc05355SMatthew G. Knepley  |\  1 |      |\     \  1 |
386fc05355SMatthew G. Knepley  | \   |      | \     \   |
396fc05355SMatthew G. Knepley  6  8  9  -> 11 14  2  13 15
406fc05355SMatthew G. Knepley  |   \ |      |   \     \ |
416fc05355SMatthew G. Knepley  | 0  \|      | 0  \     \|
426fc05355SMatthew G. Knepley  2--7--3      3-12--6--9--5
436fc05355SMatthew G. Knepley 
446fc05355SMatthew G. Knepley Test tri_2: 4 triangles, non-oriented surface
456fc05355SMatthew G. Knepley 
466fc05355SMatthew G. Knepley            9
476fc05355SMatthew G. Knepley           / \
486fc05355SMatthew G. Knepley          /   \
496fc05355SMatthew G. Knepley        17  2  16
506fc05355SMatthew G. Knepley        /       \
516fc05355SMatthew G. Knepley       /         \
526fc05355SMatthew G. Knepley      8-----15----5
536fc05355SMatthew G. Knepley       \         /|\
546fc05355SMatthew G. Knepley        \       / | \
556fc05355SMatthew G. Knepley        18  3  12 |  14
566fc05355SMatthew G. Knepley          \   /   |   \
576fc05355SMatthew G. Knepley           \ /    |    \
586fc05355SMatthew G. Knepley            4  0 11  1  7
596fc05355SMatthew G. Knepley             \    |    /
606fc05355SMatthew G. Knepley              \   |   /
616fc05355SMatthew G. Knepley              10  |  13
626fc05355SMatthew G. Knepley                \ | /
636fc05355SMatthew G. Knepley                 \|/
646fc05355SMatthew G. Knepley                  6
656fc05355SMatthew G. Knepley   becomes
666fc05355SMatthew G. Knepley            8
676fc05355SMatthew G. Knepley           / \
686fc05355SMatthew G. Knepley          /   \
696fc05355SMatthew G. Knepley         /     \
706fc05355SMatthew G. Knepley       25   2   24
716fc05355SMatthew G. Knepley       /         \
726fc05355SMatthew G. Knepley      /           \
736fc05355SMatthew G. Knepley    13-----18------9
746fc05355SMatthew G. Knepley 28  |     5    26/ \
756fc05355SMatthew G. Knepley    14----19----10   \
766fc05355SMatthew G. Knepley      \         /|   |\
776fc05355SMatthew G. Knepley       \       / |   | \
786fc05355SMatthew G. Knepley       21  3  20 |   |  23
796fc05355SMatthew G. Knepley         \   /   |   |   \
806fc05355SMatthew G. Knepley          \ /    |   |    \
816fc05355SMatthew G. Knepley           6  0 17 4 16 1  7
826fc05355SMatthew G. Knepley            \    |   |    /
836fc05355SMatthew G. Knepley             \   |   |   /
846fc05355SMatthew G. Knepley             15  |   |  22
856fc05355SMatthew G. Knepley               \ |   | /
866fc05355SMatthew G. Knepley                \|   |/
876fc05355SMatthew G. Knepley                12---11
886fc05355SMatthew G. Knepley                  27
896fc05355SMatthew G. Knepley 
906fc05355SMatthew G. Knepley Test tri_3: tri_2, in parallel
916fc05355SMatthew G. Knepley 
926fc05355SMatthew G. Knepley            6
936fc05355SMatthew G. Knepley           / \
946fc05355SMatthew G. Knepley          /   \
956fc05355SMatthew G. Knepley         /     \
966fc05355SMatthew G. Knepley       12   1   11
976fc05355SMatthew G. Knepley       /         \
986fc05355SMatthew G. Knepley      /           \
996fc05355SMatthew G. Knepley     5-----10------2
1006fc05355SMatthew G. Knepley                    \
1016fc05355SMatthew G. Knepley     5-----9-----3   2
1026fc05355SMatthew G. Knepley      \         /|   |\
1036fc05355SMatthew G. Knepley       \       / |   | \
1046fc05355SMatthew G. Knepley       10  1  8  |   |  9
1056fc05355SMatthew G. Knepley         \   /   |   |   \
1066fc05355SMatthew G. Knepley          \ /    |   |    \
1076fc05355SMatthew G. Knepley           2  0  7   7  0  4
1086fc05355SMatthew G. Knepley            \    |   |    /
1096fc05355SMatthew G. Knepley             \   |   |   /
1106fc05355SMatthew G. Knepley              6  |   |  8
1116fc05355SMatthew G. Knepley               \ |   | /
1126fc05355SMatthew G. Knepley                \|   |/
1136fc05355SMatthew G. Knepley                 4   3
1146fc05355SMatthew G. Knepley   becomes
1156fc05355SMatthew G. Knepley                  11
1166fc05355SMatthew G. Knepley                 / \
1176fc05355SMatthew G. Knepley                /   \
1186fc05355SMatthew G. Knepley               /     \
1196fc05355SMatthew G. Knepley             19   1   18
1206fc05355SMatthew G. Knepley             /         \
1216fc05355SMatthew G. Knepley            /           \
1226fc05355SMatthew G. Knepley           8-----14------4
1236fc05355SMatthew G. Knepley         22 \     3       |
1246fc05355SMatthew G. Knepley             9------15    |\
1256fc05355SMatthew G. Knepley                     \    | \
1266fc05355SMatthew G. Knepley     9------14-----5  \  20 |
1276fc05355SMatthew G. Knepley   20\    3     18/ \  \/   |
1286fc05355SMatthew G. Knepley    10----15-----6   |  5   |
1296fc05355SMatthew G. Knepley      \         /|   |  |   |\
1306fc05355SMatthew G. Knepley       \       / |   |  |   | \
1316fc05355SMatthew G. Knepley       17  1 16  |   |  |   |  17
1326fc05355SMatthew G. Knepley         \   /   | 2 |  | 2 |   \
1336fc05355SMatthew G. Knepley          \ /    |   |  |   |    \
1346fc05355SMatthew G. Knepley           4  0  13 12  13  12 0 10
1356fc05355SMatthew G. Knepley            \    |   |  |   |    /
1366fc05355SMatthew G. Knepley             \   |   |  |   |   /
1376fc05355SMatthew G. Knepley             11  |   |  |   |  16
1386fc05355SMatthew G. Knepley               \ |   |  |   | /
1396fc05355SMatthew G. Knepley                \|   |  |   |/
1406fc05355SMatthew G. Knepley                 8---7  7---6
1416fc05355SMatthew G. Knepley                  19      21
1426fc05355SMatthew G. Knepley 
1436fc05355SMatthew G. Knepley Test quad_0: quadrilateral
1446fc05355SMatthew G. Knepley 
1456fc05355SMatthew G. Knepley  5-10--6-11--7       5-12-10-20--9-14--6
1466fc05355SMatthew G. Knepley  |     |     |       |     |     |     |
1476fc05355SMatthew G. Knepley 12  0 13  1  14 --> 15  0 18  2 17  1  16
1486fc05355SMatthew G. Knepley  |     |     |       |     |     |     |
1496fc05355SMatthew G. Knepley  2--8--3--9--4       3-11--8-19--7-13--4
1506fc05355SMatthew G. Knepley 
1516fc05355SMatthew G. Knepley Test quad_1: quadrilateral, not tensor
1526fc05355SMatthew G. Knepley 
1536fc05355SMatthew G. Knepley  5-10--6-11--7       5-14-10-12--9-16--6
1546fc05355SMatthew G. Knepley  |     |     |       |     |     |     |
1556fc05355SMatthew G. Knepley 12  0 13  1  14 --> 17  0 20  2 19  1  18
1566fc05355SMatthew G. Knepley  |     |     |       |     |     |     |
1576fc05355SMatthew G. Knepley  2--8--3--9--4       3-13--8-11--7-15--4
1586fc05355SMatthew G. Knepley 
1596fc05355SMatthew G. Knepley Test quad_2: quadrilateral, 2 processes
1606fc05355SMatthew G. Knepley 
1616fc05355SMatthew G. Knepley  3--6--4  3--6--4       3--9--7-14--6   5-14--4--9--7
1626fc05355SMatthew G. Knepley  |     |  |     |       |     |     |   |     |     |
1636fc05355SMatthew G. Knepley  7  0  8  7  0  8  --> 10  0 12  1 11  12  1 11  0  10
1646fc05355SMatthew G. Knepley  |     |  |     |       |     |     |   |     |     |
1656fc05355SMatthew G. Knepley  1--5--2  1--5--2       2--8--5-13--4   3-13--2--8--6
1666fc05355SMatthew G. Knepley 
1676fc05355SMatthew G. Knepley Test quad_3: quadrilateral, 4 processes, non-oriented surface
1686fc05355SMatthew G. Knepley 
1696fc05355SMatthew G. Knepley  3--6--4  3--6--4      3--9--7-14--6   5-14--4--9--7
1706fc05355SMatthew G. Knepley  |     |  |     |      |     |     |   |     |     |
1716fc05355SMatthew G. Knepley  7  0  8  7  0  8     10  0  12 1  11 12  1 11  0  10
1726fc05355SMatthew G. Knepley  |     |  |     |      |     |     |   |     |     |
1736fc05355SMatthew G. Knepley  1--5--2  1--5--2      2--8--5-13--4   3-13--2--8--6
1746fc05355SMatthew G. Knepley                    -->
1756fc05355SMatthew G. Knepley  3--6--4  3--6--4      3--9--7-14--6   5-14--4--9--7
1766fc05355SMatthew G. Knepley  |     |  |     |      |     |     |   |     |     |
1776fc05355SMatthew G. Knepley  7  0  8  7  0  8     10  0  12 1  11 12  1 11  0  10
1786fc05355SMatthew G. Knepley  |     |  |     |      |     |     |   |     |     |
1796fc05355SMatthew G. Knepley  1--5--2  1--5--2      2--8--5-13--4   3-13--2--8--6
1806fc05355SMatthew G. Knepley 
1816fc05355SMatthew G. Knepley Test quad_4: embedded fault
1826fc05355SMatthew G. Knepley 
1836fc05355SMatthew G. Knepley 14-24-15-25-16-26--17
1846fc05355SMatthew G. Knepley  |     |     |     |
1856fc05355SMatthew G. Knepley 28  3 30  4 32  5  34
1866fc05355SMatthew G. Knepley  |     |     |     |
1876fc05355SMatthew G. Knepley 10-21-11-22-12-23--13
1886fc05355SMatthew G. Knepley  |     |     |     |
1896fc05355SMatthew G. Knepley 27  0 29  1 31  2  33
1906fc05355SMatthew G. Knepley  |     |     |     |
1916fc05355SMatthew G. Knepley  6-18--7-19--8-20--9
1926fc05355SMatthew G. Knepley 
1936fc05355SMatthew G. Knepley becomes
1946fc05355SMatthew G. Knepley 
1956fc05355SMatthew G. Knepley  13-26-14-27-15-28--16
1966fc05355SMatthew G. Knepley   |     |     |     |
1976fc05355SMatthew G. Knepley  30  3 32  4 39  5  40
1986fc05355SMatthew G. Knepley   |     |     |     |
1996fc05355SMatthew G. Knepley  12-25-17-36-19-38--21
2006fc05355SMatthew G. Knepley         |     |     |
2016fc05355SMatthew G. Knepley        41  6 42  7  43
2026fc05355SMatthew G. Knepley         |     |     |
2036fc05355SMatthew G. Knepley  12-25-17-35-18-37--20
2046fc05355SMatthew G. Knepley   |     |     |     |
2056fc05355SMatthew G. Knepley  29  0 31  1 33  2  34
2066fc05355SMatthew G. Knepley   |     |     |     |
2076fc05355SMatthew G. Knepley   8-22--9-23-10-24--11
2086fc05355SMatthew G. Knepley 
2096fc05355SMatthew G. Knepley Test quad_5: two faults
2106fc05355SMatthew G. Knepley 
2116fc05355SMatthew G. Knepley 14-24-15-25-16-26--17
2126fc05355SMatthew G. Knepley  |     |     |     |
2136fc05355SMatthew G. Knepley 28  3 30  4 32  5  34
2146fc05355SMatthew G. Knepley  |     |     |     |
2156fc05355SMatthew G. Knepley 10-21-11-22-12-23--13
2166fc05355SMatthew G. Knepley  |     |     |     |
2176fc05355SMatthew G. Knepley 27  0 29  1 31  2  33
2186fc05355SMatthew G. Knepley  |     |     |     |
2196fc05355SMatthew G. Knepley  6-18--7-19--8-20--9
2206fc05355SMatthew G. Knepley 
2216fc05355SMatthew G. Knepley becomes
2226fc05355SMatthew G. Knepley 
2236fc05355SMatthew G. Knepley 12-26-13-27-14-28--15
2246fc05355SMatthew G. Knepley  |     |     |     |
2256fc05355SMatthew G. Knepley 37  4 31  3 33  5  40
2266fc05355SMatthew G. Knepley  |     |     |     |
2276fc05355SMatthew G. Knepley 17-36-18-25-19-39--21
2286fc05355SMatthew G. Knepley  |     |     |     |
2296fc05355SMatthew G. Knepley 43  6  44   41  7  42
2306fc05355SMatthew G. Knepley  |     |     |     |
2316fc05355SMatthew G. Knepley 16-35-18-25-19-38--20
2326fc05355SMatthew G. Knepley  |     |     |     |
2336fc05355SMatthew G. Knepley 29  0 30  1 32  2  34
2346fc05355SMatthew G. Knepley  |     |     |     |
2356fc05355SMatthew G. Knepley  8-22--9-23-10-24--11
2366fc05355SMatthew G. Knepley 
2376fc05355SMatthew G. Knepley Test quad_6: T-junction
2386fc05355SMatthew G. Knepley 
2396fc05355SMatthew G. Knepley 14-24-15-25-16-26--17
2406fc05355SMatthew G. Knepley  |     |     |     |
2416fc05355SMatthew G. Knepley 28  3 30  4 32  5  34
2426fc05355SMatthew G. Knepley  |     |     |     |
2436fc05355SMatthew G. Knepley 10-21-11-22-12-23--13
2446fc05355SMatthew G. Knepley  |     |     |     |
2456fc05355SMatthew G. Knepley 27  0 29  1 31  2  33
2466fc05355SMatthew G. Knepley  |     |     |     |
2476fc05355SMatthew G. Knepley  6-18--7-19--8-20--9
2486fc05355SMatthew G. Knepley 
2496fc05355SMatthew G. Knepley becomes
2506fc05355SMatthew G. Knepley 
2516fc05355SMatthew G. Knepley  13-26-14-27-15-28--16
2526fc05355SMatthew G. Knepley   |     |     |     |
2536fc05355SMatthew G. Knepley  30  3 32  4 39  5  40
2546fc05355SMatthew G. Knepley   |     |     |     |
2556fc05355SMatthew G. Knepley  12-25-17-36-19-38--21
2566fc05355SMatthew G. Knepley         |     |     |
2576fc05355SMatthew G. Knepley        41  6 42  7  43
2586fc05355SMatthew G. Knepley         |     |     |
2596fc05355SMatthew G. Knepley  12-25-17-35-18-37--20
2606fc05355SMatthew G. Knepley   |     |     |     |
2616fc05355SMatthew G. Knepley  29  0 31  1 33  2  34
2626fc05355SMatthew G. Knepley   |     |     |     |
2636fc05355SMatthew G. Knepley   8-22--9-23-10-24--11
2646fc05355SMatthew G. Knepley 
2656fc05355SMatthew G. Knepley becomes
2666fc05355SMatthew G. Knepley 
2676fc05355SMatthew G. Knepley  14-28-15-41-21-44--20-29-16
2686fc05355SMatthew G. Knepley   |     |     |     |     |
2696fc05355SMatthew G. Knepley  31  3 33  5 43  8 42  4  40
2706fc05355SMatthew G. Knepley   |     |     |     |     |
2716fc05355SMatthew G. Knepley  13-27-17-37-23-46--23-39-19
2726fc05355SMatthew G. Knepley         |     |     |     |
2736fc05355SMatthew G. Knepley        47  6 48    48  7  49
2746fc05355SMatthew G. Knepley         |     |     |     |
2756fc05355SMatthew G. Knepley  13-27-17-36-22-45--22-38-18
2766fc05355SMatthew G. Knepley   |     |     |     |     |
2776fc05355SMatthew G. Knepley  30  0 32  1 34    34  2  35
2786fc05355SMatthew G. Knepley   |     |     |     |     |
2796fc05355SMatthew G. Knepley   9-24-10-25-11-----11-26-12
2806fc05355SMatthew G. Knepley 
281*d926f305SMatthew G. Knepley Test tet_0: Two tets sharing a face
282*d926f305SMatthew G. Knepley 
283*d926f305SMatthew G. Knepley  cell   5 _______    cell
284*d926f305SMatthew G. Knepley  0    / | \      \      1
285*d926f305SMatthew G. Knepley     19  |  16     20
286*d926f305SMatthew G. Knepley     /  15   \      \
287*d926f305SMatthew G. Knepley    2-17------4--22--6
288*d926f305SMatthew G. Knepley     \   |   /      /
289*d926f305SMatthew G. Knepley     18  |  14     21
290*d926f305SMatthew G. Knepley       \ | /      /
291*d926f305SMatthew G. Knepley         3-------
292*d926f305SMatthew G. Knepley 
293*d926f305SMatthew G. Knepley becomes
294*d926f305SMatthew G. Knepley 
295*d926f305SMatthew G. Knepley  cell  10 ___36____9______    cell
296*d926f305SMatthew G. Knepley  0    / | \        |\      \     1
297*d926f305SMatthew G. Knepley     29  |  27      | 26     31
298*d926f305SMatthew G. Knepley     /  25   \     24  \      \
299*d926f305SMatthew G. Knepley    3-28------8--35-----7--33--4
300*d926f305SMatthew G. Knepley     \   |   /      |  /      /
301*d926f305SMatthew G. Knepley     30  |  23      | 22     32
302*d926f305SMatthew G. Knepley       \ | /        |/      /
303*d926f305SMatthew G. Knepley         6----34----5------
304*d926f305SMatthew G. Knepley          cell 2
305*d926f305SMatthew G. Knepley 
306*d926f305SMatthew G. Knepley Test tet_1: Two tets sharing a face in parallel
307*d926f305SMatthew G. Knepley 
308*d926f305SMatthew G. Knepley  cell   4          3______    cell
309*d926f305SMatthew G. Knepley  0    / | \        |\      \     0
310*d926f305SMatthew G. Knepley     14  |  11      | 11     12
311*d926f305SMatthew G. Knepley     /  10   \     10  \      \
312*d926f305SMatthew G. Knepley    1-12------3     |   2--14--4
313*d926f305SMatthew G. Knepley     \   |   /      |  /      /
314*d926f305SMatthew G. Knepley     13  |  9       | 9      13
315*d926f305SMatthew G. Knepley       \ | /        |/      /
316*d926f305SMatthew G. Knepley         2          1------
317*d926f305SMatthew G. Knepley 
318*d926f305SMatthew G. Knepley becomes
319*d926f305SMatthew G. Knepley            cell 1              cell 1
320*d926f305SMatthew G. Knepley  cell   8---28---7           7---28---6______    cell
321*d926f305SMatthew G. Knepley  0    / | \      |\          |\       |\      \     0
322*d926f305SMatthew G. Knepley     24  |  22    | 21        | 22     | 21     23
323*d926f305SMatthew G. Knepley     /  20   \    |   \       |  \    19  \      \
324*d926f305SMatthew G. Knepley    2-23------6---27---5     20  5---27---4--25--8
325*d926f305SMatthew G. Knepley     \   |   /   19   /       |  /     |  /      /
326*d926f305SMatthew G. Knepley     25  |  18    | 17        | 18     | 17     24
327*d926f305SMatthew G. Knepley       \ | /      |/          |/       |/      /
328*d926f305SMatthew G. Knepley         4---26---3           3---26---2------
329*d926f305SMatthew G. Knepley 
330*d926f305SMatthew G. Knepley Test hex_0: Two hexes sharing a face
331*d926f305SMatthew G. Knepley 
332*d926f305SMatthew G. Knepley cell  11-----31-----12-----32------13 cell
333*d926f305SMatthew G. Knepley 0     /|            /|            /|     1
334*d926f305SMatthew G. Knepley     36 |   22      37|   24      38|
335*d926f305SMatthew G. Knepley     /  |          /  |          /  |
336*d926f305SMatthew G. Knepley    8-----29------9-----30------10  |
337*d926f305SMatthew G. Knepley    |   |     18  |   |     20  |   |
338*d926f305SMatthew G. Knepley    |  42         |  43         |   44
339*d926f305SMatthew G. Knepley    |14 |         |15 |         |16 |
340*d926f305SMatthew G. Knepley   39   |  17    40   |   19   41   |
341*d926f305SMatthew G. Knepley    |   5-----27--|---6-----28--|---7
342*d926f305SMatthew G. Knepley    |  /          |  /          |  /
343*d926f305SMatthew G. Knepley    | 33   21     | 34    23    | 35
344*d926f305SMatthew G. Knepley    |/            |/            |/
345*d926f305SMatthew G. Knepley    2-----25------3-----26------4
346*d926f305SMatthew G. Knepley 
347*d926f305SMatthew G. Knepley becomes
348*d926f305SMatthew G. Knepley 
349*d926f305SMatthew G. Knepley                          cell 2
350*d926f305SMatthew G. Knepley cell   9-----38-----18-----62------17----42------10 cell
351*d926f305SMatthew G. Knepley 0     /|            /|            /|            /|     1
352*d926f305SMatthew G. Knepley     45 |   30      54|  32       53|   24      46|
353*d926f305SMatthew G. Knepley     /  |          /  |          /  |          /  |
354*d926f305SMatthew G. Knepley    7-----37-----16-----61------15--|-41------8   |
355*d926f305SMatthew G. Knepley    |   |     28  |   |         |   |     22  |   |
356*d926f305SMatthew G. Knepley    |  49         |  58         |   57        |   50
357*d926f305SMatthew G. Knepley    |19 |         |26 |         |25 |         |20 |
358*d926f305SMatthew G. Knepley   47   |  27    56   |        55   |   21   48   |
359*d926f305SMatthew G. Knepley    |   5-----36--|--14-----60--|---13----40--|---6
360*d926f305SMatthew G. Knepley    |  /          |  /          |  /          |  /
361*d926f305SMatthew G. Knepley    | 43   29     | 52   31     | 51    23    | 44
362*d926f305SMatthew G. Knepley    |/            |/            |/            |/
363*d926f305SMatthew G. Knepley    3-----35-----12-----59------11----39------4
364*d926f305SMatthew G. Knepley 
365*d926f305SMatthew G. Knepley Test hex_1: Two hexes sharing a face, in parallel
366*d926f305SMatthew G. Knepley 
367*d926f305SMatthew G. Knepley cell   7-----18------8             7-----18------8 cell
368*d926f305SMatthew G. Knepley 0     /|            /|            /|            /|    0
369*d926f305SMatthew G. Knepley     21 |   14      22|           21|   14      22|
370*d926f305SMatthew G. Knepley     /  |          /  |          /  |          /  |
371*d926f305SMatthew G. Knepley    5-----17------6   |         5---|-17------6   |
372*d926f305SMatthew G. Knepley    |   |     12  |   |         |   |     12  |   |
373*d926f305SMatthew G. Knepley    |  25         |  26         |  25         |  26
374*d926f305SMatthew G. Knepley    | 9 |         |10 |         | 9 |         |10 |
375*d926f305SMatthew G. Knepley   23   |  11    24   |        23   |   11   24   |
376*d926f305SMatthew G. Knepley    |   3-----16--|---4         |   3-----16--|---4
377*d926f305SMatthew G. Knepley    |  /          |  /          |  /          |  /
378*d926f305SMatthew G. Knepley    | 19   13     | 20          | 19    13    | 20
379*d926f305SMatthew G. Knepley    |/            |/            |/            |/
380*d926f305SMatthew G. Knepley    1-----15------2             1-----15------2
381*d926f305SMatthew G. Knepley 
382*d926f305SMatthew G. Knepley becomes
383*d926f305SMatthew G. Knepley                         cell 1                      cell 1
384*d926f305SMatthew G. Knepley cell   5-----28-----13-----44-----12             9-----44-----8-----28------13 cell
385*d926f305SMatthew G. Knepley 0     /|            /|           /|             /|           /|            /|     0
386*d926f305SMatthew G. Knepley     30 |   20      36|   22     35|            36|   22     35|   20      30|
387*d926f305SMatthew G. Knepley     /  |          /  |         /  |           /  |         /  |          /  |
388*d926f305SMatthew G. Knepley    4-----27-----11-----43-----10  |          7-----43-----6-----27------12  |
389*d926f305SMatthew G. Knepley    |   |     18  |   |        |   |          |   |        |   |     18  |   |
390*d926f305SMatthew G. Knepley    |  32         |  40        |   39         |  40        |   39        |   32
391*d926f305SMatthew G. Knepley    |14 |         |16 |        | 15|          |15 |        |14 |         |16 |
392*d926f305SMatthew G. Knepley   31   |  17    38   |        37  |         38   |       37   |   17   31   |
393*d926f305SMatthew G. Knepley    |   3-----26--|---9-----42-|---8          |   5----42--|---4-----26--|---11
394*d926f305SMatthew G. Knepley    |  /          |  /         |  /           |  /         |  /          |  /
395*d926f305SMatthew G. Knepley    | 29   19     | 34    21   | 33           | 34    21   | 33    19    | 29
396*d926f305SMatthew G. Knepley    |/            |/           |/             |/           |/            |/
397*d926f305SMatthew G. Knepley    2-----25------7-----41-----6              3-----41-----2-----25------10
398*d926f305SMatthew G. Knepley 
399*d926f305SMatthew G. Knepley Test hex_2: hexahedra, 4 processes, non-oriented surface
400*d926f305SMatthew G. Knepley 
401*d926f305SMatthew G. Knepley           cell 0                  cell 0
402*d926f305SMatthew G. Knepley        7-----18------8       7-----18------8
403*d926f305SMatthew G. Knepley       /|            /|      /|            /|
404*d926f305SMatthew G. Knepley     21 |   14      22|    21 |   14      22|
405*d926f305SMatthew G. Knepley     /  |          /  |    /  |          /  |
406*d926f305SMatthew G. Knepley    5-----17------6   |   5-----17------6   |
407*d926f305SMatthew G. Knepley    |   |     12  |   |   |   |     12  |   |
408*d926f305SMatthew G. Knepley    |  25         |  26   |  25         |   26
409*d926f305SMatthew G. Knepley    |9  |         |10 |   |9  |         |10 |
410*d926f305SMatthew G. Knepley   23   |  11    24   |  23   |  11    24   |
411*d926f305SMatthew G. Knepley    |   3-----16--|---4   |   3-----16--|---4
412*d926f305SMatthew G. Knepley    |  /          |  /    |  /          |  /
413*d926f305SMatthew G. Knepley    | 19    13    | 20    | 19    13    | 20
414*d926f305SMatthew G. Knepley    |/            |/      |/            |/
415*d926f305SMatthew G. Knepley    1-----15------2       1-----15------2
416*d926f305SMatthew G. Knepley 
417*d926f305SMatthew G. Knepley        7-----18------8       7-----18------8
418*d926f305SMatthew G. Knepley       /|            /|      /|            /|
419*d926f305SMatthew G. Knepley     21 |   14      22|    21 |   14      22|
420*d926f305SMatthew G. Knepley     /  |          /  |    /  |          /  |
421*d926f305SMatthew G. Knepley    5-----17------6   |   5-----17------6   |
422*d926f305SMatthew G. Knepley    |   |     12  |   |   |   |     12  |   |
423*d926f305SMatthew G. Knepley    |  25         |  26   |  25         |  26
424*d926f305SMatthew G. Knepley    |9  |         |10 |   |9  |         |10 |
425*d926f305SMatthew G. Knepley   23   |  11    24   |  23   |   11   24   |
426*d926f305SMatthew G. Knepley    |   3-----16--|---4   |   3-----16--|---4
427*d926f305SMatthew G. Knepley    |  /          |  /    |  /          |  /
428*d926f305SMatthew G. Knepley    | 19   13     | 20    | 19    13    | 20
429*d926f305SMatthew G. Knepley    |/            |/      |/            |/
430*d926f305SMatthew G. Knepley    1-----15------2       1-----15------2
431*d926f305SMatthew G. Knepley       cell 0                cell 0
432*d926f305SMatthew G. Knepley 
433*d926f305SMatthew G. Knepley becomes
434*d926f305SMatthew G. Knepley 
435*d926f305SMatthew G. Knepley           cell 0         cell 1                cell 1        cell 0
436*d926f305SMatthew G. Knepley        5-----28------13----44------12      9-----44------8-----28------13
437*d926f305SMatthew G. Knepley       /|            /|            /|      /|            /|            /|
438*d926f305SMatthew G. Knepley     30 |   20      36|   22      35|     36|   22     35 |   20      30|
439*d926f305SMatthew G. Knepley     /  |          /  |          /  |    /  |          /  |          /  |
440*d926f305SMatthew G. Knepley    4-----27------11----43------10  |   7-----43------6-----27------12  |
441*d926f305SMatthew G. Knepley    |   |     18  |   |         |   |   |   |         |   |     18  |   |
442*d926f305SMatthew G. Knepley    |  32         |  40         |  39   |  40         |  39         |   32
443*d926f305SMatthew G. Knepley    |14 |         |16 |         |15 |   |15 |         |14 |         |16 |
444*d926f305SMatthew G. Knepley   31   |  17    38   |         37  |   38  |        37   |  17    31   |
445*d926f305SMatthew G. Knepley    |   3-----26--|---9-----42--|---8   |   5-----42--|---4-----26--|---11
446*d926f305SMatthew G. Knepley    |  /          |  /          |  /    |  /          |  /          |  /
447*d926f305SMatthew G. Knepley    | 29    19    | 34    21    |33     | 34    21    | 33    19    | 29
448*d926f305SMatthew G. Knepley    |/            |/            |/      |/            |/            |/
449*d926f305SMatthew G. Knepley    2-----25------7-----41------6       3-----41------2-----25------10
450*d926f305SMatthew G. Knepley 
451*d926f305SMatthew G. Knepley        5-----28------13----44------12      9-----44------8-----28------13
452*d926f305SMatthew G. Knepley       /|            /|            /|      /|            /|            /|
453*d926f305SMatthew G. Knepley     30 |   20      36|   22      35|     36|    22     35|   20      30|
454*d926f305SMatthew G. Knepley     /  |          /  |          /  |    /  |          /  |          /  |
455*d926f305SMatthew G. Knepley    4-----27------11----43------10  |   7-----43------6-----27------12  |
456*d926f305SMatthew G. Knepley    |   |     18  |   |         |   |   |   |         |   |     18  |   |
457*d926f305SMatthew G. Knepley    |  32         |  40         |   39  |   40        |  39         |   32
458*d926f305SMatthew G. Knepley    |14 |         |16 |         |15 |   |15 |         |14 |         |16 |
459*d926f305SMatthew G. Knepley   31   |  17    38   |         37  |   38  |        37   |  17    31   |
460*d926f305SMatthew G. Knepley    |   3-----26--|---9-----42--|---8   |   5-----42--|---4-----26--|---11
461*d926f305SMatthew G. Knepley    |  /          |  /          |  /    |  /          |  /          |  /
462*d926f305SMatthew G. Knepley    | 29    19    | 34    21    |33     | 34    21    | 33    19    | 29
463*d926f305SMatthew G. Knepley    |/            |/            |/      |/            |/            |/
464*d926f305SMatthew G. Knepley    2-----25------7-----41------6       3-----41------2-----25------10
465*d926f305SMatthew G. Knepley       cell 0         cell 1                cell 1        cell 0
466*d926f305SMatthew G. Knepley 
467*d926f305SMatthew G. Knepley Test hex_3: T-junction
468*d926f305SMatthew G. Knepley 
469*d926f305SMatthew G. Knepley       19-----52-----20-----53------21
470*d926f305SMatthew G. Knepley       /|            /|            /|
471*d926f305SMatthew G. Knepley     60 |   38      61|   41      62|
472*d926f305SMatthew G. Knepley     /  |          /  |          /  |
473*d926f305SMatthew G. Knepley   16-----50-----17-----51------18  |
474*d926f305SMatthew G. Knepley    |   |     33  |   |     35  |   |
475*d926f305SMatthew G. Knepley    |  70         |  72         |   74
476*d926f305SMatthew G. Knepley    |25 |         |26 |         |27 |
477*d926f305SMatthew G. Knepley   64   |  32    66   |  34    68   |
478*d926f305SMatthew G. Knepley    |  13-----48--|--14-----49--|---15
479*d926f305SMatthew G. Knepley    |  /|         |  /|         |  /|
480*d926f305SMatthew G. Knepley    |57 |   37    | 58|   40    | 59|
481*d926f305SMatthew G. Knepley    |/  |         |/  |         |/  |
482*d926f305SMatthew G. Knepley   10-----46-----11-----47------12  |
483*d926f305SMatthew G. Knepley    |   |     29  |   |     31  |   |
484*d926f305SMatthew G. Knepley    |  69         |  71         |   73
485*d926f305SMatthew G. Knepley    |22 |         |23 |         |24 |
486*d926f305SMatthew G. Knepley   63   |  28    65   |   30   67   |
487*d926f305SMatthew G. Knepley    |   7-----44--|---8-----45--|---9
488*d926f305SMatthew G. Knepley    |  /          |  /          |  /
489*d926f305SMatthew G. Knepley    | 54   36     | 55    39    | 56
490*d926f305SMatthew G. Knepley    |/            |/            |/
491*d926f305SMatthew G. Knepley    4-----42------5-----43------6
492*d926f305SMatthew G. Knepley       cell 0         cell 1
493*d926f305SMatthew G. Knepley 
494*d926f305SMatthew G. Knepley becomes
495*d926f305SMatthew G. Knepley 
496*d926f305SMatthew G. Knepley       15----102-----28---112----___27-----73------16
497*d926f305SMatthew G. Knepley       /|            /|         /   /             /|
498*d926f305SMatthew G. Knepley     77 |   55     104|      ---  103    46      78|
499*d926f305SMatthew G. Knepley     /  |          /  |     /     /             /  |
500*d926f305SMatthew G. Knepley   13----101-----26---111--/----25-----72------14  |
501*d926f305SMatthew G. Knepley    |   |     54  |   |  107   /           43  |   |
502*d926f305SMatthew G. Knepley    |  81         |  108 / 51 /                |   82
503*d926f305SMatthew G. Knepley    |40 |         |52 | /   105                |41 |
504*d926f305SMatthew G. Knepley   79   |  53    106  |/   /            42    80   |
505*d926f305SMatthew G. Knepley    |  21-----87--|--31---/-89------23-------/----/
506*d926f305SMatthew G. Knepley    |  /|         |  /|  /         /|       /
507*d926f305SMatthew G. Knepley    |91 |   47    |109|-- 49      93|  -----
508*d926f305SMatthew G. Knepley    |/  |         |/ /|          /  | /
509*d926f305SMatthew G. Knepley   17-----83-----29-----85------19----
510*d926f305SMatthew G. Knepley    |   |         |   |         |   |
511*d926f305SMatthew G. Knepley    |  120        |  121        |  122
512*d926f305SMatthew G. Knepley    |   |         |26 |         |   |
513*d926f305SMatthew G. Knepley  117   |        118  |        119  |
514*d926f305SMatthew G. Knepley    |  22-----88--|--32-----90--|---24
515*d926f305SMatthew G. Knepley    |  /|         |  /|         |  /|
516*d926f305SMatthew G. Knepley    |92 |   48    |110|   50    | 94|
517*d926f305SMatthew G. Knepley    |/  |         |/  |         |/  |
518*d926f305SMatthew G. Knepley   18-----84-----30-----86------20  |
519*d926f305SMatthew G. Knepley    |   |     37  |   |     39  |   |
520*d926f305SMatthew G. Knepley    |  98         |  99         |   100
521*d926f305SMatthew G. Knepley    |33 |         |34 |         |35 |
522*d926f305SMatthew G. Knepley   95   |  36    96   |   38   97   |
523*d926f305SMatthew G. Knepley    |  10-----70--|--11-----71--|---12
524*d926f305SMatthew G. Knepley    |  /          |  /          |  /
525*d926f305SMatthew G. Knepley    | 74   44     | 75    45    | 76
526*d926f305SMatthew G. Knepley    |/            |/            |/
527*d926f305SMatthew G. Knepley    7-----68------8-----69------9
528*d926f305SMatthew G. Knepley       cell 0         cell 1
529*d926f305SMatthew G. Knepley 
530*d926f305SMatthew G. Knepley Test hex_4: Two non-intersecting faults
531*d926f305SMatthew G. Knepley 
532*d926f305SMatthew G. Knepley           cell 4         cell 5         cell 6        cell 7
533*d926f305SMatthew G. Knepley       33-----96-----34-----97-----35-----98-----36-----99------37
534*d926f305SMatthew G. Knepley       /|            /|            /|            /|            /|
535*d926f305SMatthew G. Knepley     110|   66     111|   69     112|   72     113|   75     114|
536*d926f305SMatthew G. Knepley     /  |          /  |          /  |          /  |          /  |
537*d926f305SMatthew G. Knepley   28-----92-----29-----93-----30-----94-----31-----95------32  |
538*d926f305SMatthew G. Knepley    |   |     57  |   |     59  |   |     61  |   |     63  |   |
539*d926f305SMatthew G. Knepley    |  126        |  128        |  130        |  132        |  134
540*d926f305SMatthew G. Knepley    |43 |         |44 |         |45 |         |46 |         |47 |
541*d926f305SMatthew G. Knepley   116  |  56    118  |  58    120  |  60    122  |  62    124  |
542*d926f305SMatthew G. Knepley    |  23-----88--|--24-----89--|--25-----90--|--26-----91--|---27
543*d926f305SMatthew G. Knepley    |  /|         |  /|         |  /|         |  /|         |  /|
544*d926f305SMatthew G. Knepley    |105|   65    |106|   68    |107|   71    |108|   74    |109|
545*d926f305SMatthew G. Knepley    |/  |         |/  |         |/  |         |/  |         |/  |
546*d926f305SMatthew G. Knepley   18-----84-----19-----95-----20-----86-----21-----87------22  |
547*d926f305SMatthew G. Knepley    |   |     49  |   |     51  |   |     53  |   |     55  |   |
548*d926f305SMatthew G. Knepley    |  125        |  127        |  129        |  131        |  133
549*d926f305SMatthew G. Knepley    |38 |         |39 |         |40 |         |41 |         |42 |
550*d926f305SMatthew G. Knepley   115  |  48    117  |  50    119  |  52    121  |  54    123  |
551*d926f305SMatthew G. Knepley    |  13-----80--|--14-----81--|--15-----82--|--16-----83--|---17
552*d926f305SMatthew G. Knepley    |  /          |  /          |  /          |  /          |  /
553*d926f305SMatthew G. Knepley    |100    64    |101    67    |102    70    |103    73    |104
554*d926f305SMatthew G. Knepley    |/            |/            |/            |/            |/
555*d926f305SMatthew G. Knepley    8-----76------9-----77-----10-----78-----11-----79------12
556*d926f305SMatthew G. Knepley       cell 0         cell 1        cell 2        cell 3
557*d926f305SMatthew G. Knepley 
558*d926f305SMatthew G. Knepley becomes
559*d926f305SMatthew G. Knepley 
560*d926f305SMatthew G. Knepley           cell 4         cell 5        cell 7        cell 10       cell 6
561*d926f305SMatthew G. Knepley       27-----114----28-----115----29-----159----46-----170----45------116----30
562*d926f305SMatthew G. Knepley       /|            /|            /|            /|            /|            /|
563*d926f305SMatthew G. Knepley     123|   71     124|   73     125|   87     162|          161|    78    126|
564*d926f305SMatthew G. Knepley     /  |          /  |          /  |          /  |          /  |          /  |
565*d926f305SMatthew G. Knepley   23-----111----24-----112----25-----158----44-----169----43-----113-----26  |
566*d926f305SMatthew G. Knepley    |   |     65  |   |    67   |   |    86   |   |         |   |     69  |   |
567*d926f305SMatthew G. Knepley    |  134        |  135        |  137        |  166        |  165        |  140
568*d926f305SMatthew G. Knepley    |56 |         |57 |         |58 |         |84 |         |83 |         |59 |
569*d926f305SMatthew G. Knepley   127  |  64    128  |  66    130  |  85    164  |        163  |  68    133  |
570*d926f305SMatthew G. Knepley    |  35-----143-|--37-----151-|--40-----109-|--42-----168-|--42-----110-|---22
571*d926f305SMatthew G. Knepley    |  /|         |  /|         |  /|         |  /          |  /          |  /
572*d926f305SMatthew G. Knepley    |145|   79    |147|   81    |153|   75    |160          |160    77    |122
573*d926f305SMatthew G. Knepley    |/ 173        |/ 174        |/ 176        |/            |/            |/
574*d926f305SMatthew G. Knepley   31-----141----33-----149----39-----107----41-----167----41-----108-----21
575*d926f305SMatthew G. Knepley cell   |         |   |         |   | cell 9
576*d926f305SMatthew G. Knepley 8  |  36-----144-|--38-----152-|--40-----109----42-----110-----22
577*d926f305SMatthew G. Knepley   171 /|        172 /|        175 /|            /|            /|
578*d926f305SMatthew G. Knepley    |146|   80    |148|   82    |153|    75    160|   77     122|
579*d926f305SMatthew G. Knepley    |/  |         |/  |         |/  |          /  |          /  |
580*d926f305SMatthew G. Knepley   32-----142----34-----150----39-----107----41-----108-----21  |
581*d926f305SMatthew G. Knepley    |   |     50  |   |    52   |   |    61   |   |     63  |   |
582*d926f305SMatthew G. Knepley    |  156        |  157        |  136        |  138        |  139
583*d926f305SMatthew G. Knepley    |47 |         |48 |         |53 |         |54 |         |55 |
584*d926f305SMatthew G. Knepley   154  |  49    155  |  51    129  |  60    131  |  62    132  |
585*d926f305SMatthew G. Knepley    |  16-----103-|--17-----104-|--18-----105-|--19-----106-|---20
586*d926f305SMatthew G. Knepley    |  /          |  /          |  /          |  /          |  /
587*d926f305SMatthew G. Knepley    |117    70    |118    72    |119    74    |120    76    |121
588*d926f305SMatthew G. Knepley    |/            |/            |/            |/            |/
589*d926f305SMatthew G. Knepley   11-----99-----12-----100----13-----101----14-----102-----15
590*d926f305SMatthew G. Knepley       cell 0         cell 1        cell 2        cell 3
591*d926f305SMatthew G. Knepley 
5926fc05355SMatthew G. Knepley */
5936fc05355SMatthew G. Knepley 
5946fc05355SMatthew G. Knepley typedef struct {
5956fc05355SMatthew G. Knepley   PetscInt testNum; // The mesh to test
5966fc05355SMatthew G. Knepley } AppCtx;
5976fc05355SMatthew G. Knepley 
5986fc05355SMatthew G. Knepley static PetscErrorCode ProcessOptions(MPI_Comm comm, AppCtx *options)
5996fc05355SMatthew G. Knepley {
6006fc05355SMatthew G. Knepley   PetscFunctionBegin;
6016fc05355SMatthew G. Knepley   options->testNum = 0;
6026fc05355SMatthew G. Knepley 
6036fc05355SMatthew G. Knepley   PetscOptionsBegin(comm, "", "Cohesive Meshing Options", "DMPLEX");
6046fc05355SMatthew G. Knepley   PetscCall(PetscOptionsBoundedInt("-test_num", "The particular mesh to test", "ex5.c", options->testNum, &options->testNum, NULL, 0));
6056fc05355SMatthew G. Knepley   PetscOptionsEnd();
6066fc05355SMatthew G. Knepley   PetscFunctionReturn(PETSC_SUCCESS);
6076fc05355SMatthew G. Knepley }
6086fc05355SMatthew G. Knepley 
6096fc05355SMatthew G. Knepley static PetscErrorCode CreateQuadMesh1(MPI_Comm comm, AppCtx *user, DM *dm)
6106fc05355SMatthew G. Knepley {
6116fc05355SMatthew G. Knepley   const PetscInt faces[2] = {1, 1};
6126fc05355SMatthew G. Knepley   PetscReal      lower[2], upper[2];
6136fc05355SMatthew G. Knepley   DMLabel        label;
6146fc05355SMatthew G. Knepley   PetscMPIInt    rank;
6156fc05355SMatthew G. Knepley   void          *get_tmp;
6166fc05355SMatthew G. Knepley   PetscInt64    *cidx;
6176fc05355SMatthew G. Knepley   PetscMPIInt    flg;
6186fc05355SMatthew G. Knepley 
6196fc05355SMatthew G. Knepley   PetscFunctionBeginUser;
6206fc05355SMatthew G. Knepley   PetscCallMPI(MPI_Comm_rank(comm, &rank));
6216fc05355SMatthew G. Knepley   // Create serial mesh
6226fc05355SMatthew G. Knepley   lower[0] = (PetscReal)(rank % 2);
6236fc05355SMatthew G. Knepley   lower[1] = (PetscReal)(rank / 2);
6246fc05355SMatthew G. Knepley   upper[0] = (PetscReal)(rank % 2) + 1.;
6256fc05355SMatthew G. Knepley   upper[1] = (PetscReal)(rank / 2) + 1.;
6266fc05355SMatthew G. Knepley   PetscCall(DMPlexCreateBoxMesh(PETSC_COMM_SELF, 2, PETSC_FALSE, faces, lower, upper, NULL, PETSC_TRUE, dm));
6276fc05355SMatthew G. Knepley   PetscCall(PetscObjectSetName((PetscObject)*dm, "box"));
6286fc05355SMatthew G. Knepley   // Flip edges to make fault non-oriented
6296fc05355SMatthew G. Knepley   switch (rank) {
6306fc05355SMatthew G. Knepley   case 2:
6316fc05355SMatthew G. Knepley     PetscCall(DMPlexOrientPoint(*dm, 8, -1));
6326fc05355SMatthew G. Knepley     break;
6336fc05355SMatthew G. Knepley   case 3:
6346fc05355SMatthew G. Knepley     PetscCall(DMPlexOrientPoint(*dm, 7, -1));
6356fc05355SMatthew G. Knepley     break;
6366fc05355SMatthew G. Knepley   default:
6376fc05355SMatthew G. Knepley     break;
6386fc05355SMatthew G. Knepley   }
6396fc05355SMatthew G. Knepley   // Need this so that all procs create the cell types
6406fc05355SMatthew G. Knepley   PetscCall(DMPlexGetCellTypeLabel(*dm, &label));
6416fc05355SMatthew G. Knepley   // Replace comm in object (copied from PetscHeaderCreate/Destroy())
6426fc05355SMatthew G. Knepley   PetscCall(PetscCommDestroy(&(*dm)->hdr.comm));
6436fc05355SMatthew G. Knepley   PetscCall(PetscCommDuplicate(comm, &(*dm)->hdr.comm, &(*dm)->hdr.tag));
6446fc05355SMatthew G. Knepley   PetscCallMPI(MPI_Comm_get_attr((*dm)->hdr.comm, Petsc_CreationIdx_keyval, &get_tmp, &flg));
6456fc05355SMatthew G. Knepley   PetscCheck(flg, (*dm)->hdr.comm, PETSC_ERR_ARG_CORRUPT, "MPI_Comm does not have an object creation index");
6466fc05355SMatthew G. Knepley   cidx            = (PetscInt64 *)get_tmp;
6476fc05355SMatthew G. Knepley   (*dm)->hdr.cidx = (*cidx)++;
6486fc05355SMatthew G. Knepley   // Create new pointSF
6496fc05355SMatthew G. Knepley   {
6506fc05355SMatthew G. Knepley     PetscSF      sf;
6516fc05355SMatthew G. Knepley     PetscInt    *local  = NULL;
6526fc05355SMatthew G. Knepley     PetscSFNode *remote = NULL;
6536fc05355SMatthew G. Knepley     PetscInt     Nl;
6546fc05355SMatthew G. Knepley 
6556fc05355SMatthew G. Knepley     PetscCall(PetscSFCreate(comm, &sf));
6566fc05355SMatthew G. Knepley     switch (rank) {
6576fc05355SMatthew G. Knepley     case 0:
6586fc05355SMatthew G. Knepley       Nl = 5;
6596fc05355SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &local));
6606fc05355SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &remote));
6616fc05355SMatthew G. Knepley       local[0]        = 2;
6626fc05355SMatthew G. Knepley       remote[0].index = 1;
6636fc05355SMatthew G. Knepley       remote[0].rank  = 1;
6646fc05355SMatthew G. Knepley       local[1]        = 3;
6656fc05355SMatthew G. Knepley       remote[1].index = 1;
6666fc05355SMatthew G. Knepley       remote[1].rank  = 2;
6676fc05355SMatthew G. Knepley       local[2]        = 4;
6686fc05355SMatthew G. Knepley       remote[2].index = 1;
6696fc05355SMatthew G. Knepley       remote[2].rank  = 3;
6706fc05355SMatthew G. Knepley       local[3]        = 6;
6716fc05355SMatthew G. Knepley       remote[3].index = 5;
6726fc05355SMatthew G. Knepley       remote[3].rank  = 2;
6736fc05355SMatthew G. Knepley       local[4]        = 8;
6746fc05355SMatthew G. Knepley       remote[4].index = 7;
6756fc05355SMatthew G. Knepley       remote[4].rank  = 1;
6766fc05355SMatthew G. Knepley       break;
6776fc05355SMatthew G. Knepley     case 1:
6786fc05355SMatthew G. Knepley       Nl = 3;
6796fc05355SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &local));
6806fc05355SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &remote));
6816fc05355SMatthew G. Knepley       local[0]        = 3;
6826fc05355SMatthew G. Knepley       remote[0].index = 1;
6836fc05355SMatthew G. Knepley       remote[0].rank  = 3;
6846fc05355SMatthew G. Knepley       local[1]        = 4;
6856fc05355SMatthew G. Knepley       remote[1].index = 2;
6866fc05355SMatthew G. Knepley       remote[1].rank  = 3;
6876fc05355SMatthew G. Knepley       local[2]        = 6;
6886fc05355SMatthew G. Knepley       remote[2].index = 5;
6896fc05355SMatthew G. Knepley       remote[2].rank  = 3;
6906fc05355SMatthew G. Knepley       break;
6916fc05355SMatthew G. Knepley     case 2:
6926fc05355SMatthew G. Knepley       Nl = 3;
6936fc05355SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &local));
6946fc05355SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &remote));
6956fc05355SMatthew G. Knepley       local[0]        = 2;
6966fc05355SMatthew G. Knepley       remote[0].index = 1;
6976fc05355SMatthew G. Knepley       remote[0].rank  = 3;
6986fc05355SMatthew G. Knepley       local[1]        = 4;
6996fc05355SMatthew G. Knepley       remote[1].index = 3;
7006fc05355SMatthew G. Knepley       remote[1].rank  = 3;
7016fc05355SMatthew G. Knepley       local[2]        = 8;
7026fc05355SMatthew G. Knepley       remote[2].index = 7;
7036fc05355SMatthew G. Knepley       remote[2].rank  = 3;
7046fc05355SMatthew G. Knepley       break;
7056fc05355SMatthew G. Knepley     case 3:
7066fc05355SMatthew G. Knepley       Nl = 0;
7076fc05355SMatthew G. Knepley       break;
7086fc05355SMatthew G. Knepley     default:
7096fc05355SMatthew G. Knepley       SETERRQ(comm, PETSC_ERR_SUP, "This example only supports 4 ranks");
7106fc05355SMatthew G. Knepley     }
7116fc05355SMatthew G. Knepley     PetscCall(PetscSFSetGraph(sf, 9, Nl, local, PETSC_OWN_POINTER, remote, PETSC_OWN_POINTER));
7126fc05355SMatthew G. Knepley     PetscCall(DMSetPointSF(*dm, sf));
7136fc05355SMatthew G. Knepley     PetscCall(PetscSFDestroy(&sf));
7146fc05355SMatthew G. Knepley   }
7156fc05355SMatthew G. Knepley   // Create fault label
7166fc05355SMatthew G. Knepley   PetscCall(DMCreateLabel(*dm, "fault"));
7176fc05355SMatthew G. Knepley   PetscCall(DMGetLabel(*dm, "fault", &label));
7186fc05355SMatthew G. Knepley   switch (rank) {
7196fc05355SMatthew G. Knepley   case 0:
7206fc05355SMatthew G. Knepley   case 2:
7216fc05355SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 8, 1));
7226fc05355SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 2, 0));
7236fc05355SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 4, 0));
7246fc05355SMatthew G. Knepley     break;
7256fc05355SMatthew G. Knepley   case 1:
7266fc05355SMatthew G. Knepley   case 3:
7276fc05355SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 7, 1));
7286fc05355SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 1, 0));
7296fc05355SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 3, 0));
7306fc05355SMatthew G. Knepley     break;
7316fc05355SMatthew G. Knepley   default:
7326fc05355SMatthew G. Knepley     break;
7336fc05355SMatthew G. Knepley   }
7346fc05355SMatthew G. Knepley   PetscCall(DMPlexOrientLabel(*dm, label));
7356fc05355SMatthew G. Knepley   PetscCall(DMPlexLabelCohesiveComplete(*dm, label, NULL, 1, PETSC_FALSE, PETSC_FALSE, NULL));
7366fc05355SMatthew G. Knepley   PetscCall(DMPlexDistributeSetDefault(*dm, PETSC_FALSE));
7376fc05355SMatthew G. Knepley   PetscFunctionReturn(PETSC_SUCCESS);
7386fc05355SMatthew G. Knepley }
7396fc05355SMatthew G. Knepley 
740*d926f305SMatthew G. Knepley static PetscErrorCode CreateHexMesh1(MPI_Comm comm, AppCtx *user, DM *dm)
741*d926f305SMatthew G. Knepley {
742*d926f305SMatthew G. Knepley   const PetscInt faces[3] = {1, 1, 1};
743*d926f305SMatthew G. Knepley   PetscReal      lower[3], upper[3];
744*d926f305SMatthew G. Knepley   DMLabel        label;
745*d926f305SMatthew G. Knepley   PetscMPIInt    rank;
746*d926f305SMatthew G. Knepley   void          *get_tmp;
747*d926f305SMatthew G. Knepley   PetscInt64    *cidx;
748*d926f305SMatthew G. Knepley   PetscMPIInt    flg;
749*d926f305SMatthew G. Knepley 
750*d926f305SMatthew G. Knepley   PetscFunctionBeginUser;
751*d926f305SMatthew G. Knepley   PetscCallMPI(MPI_Comm_rank(comm, &rank));
752*d926f305SMatthew G. Knepley   // Create serial mesh
753*d926f305SMatthew G. Knepley   lower[0] = (PetscReal)(rank % 2);
754*d926f305SMatthew G. Knepley   lower[1] = 0.;
755*d926f305SMatthew G. Knepley   lower[2] = (PetscReal)(rank / 2);
756*d926f305SMatthew G. Knepley   upper[0] = (PetscReal)(rank % 2) + 1.;
757*d926f305SMatthew G. Knepley   upper[1] = 1.;
758*d926f305SMatthew G. Knepley   upper[2] = (PetscReal)(rank / 2) + 1.;
759*d926f305SMatthew G. Knepley   PetscCall(DMPlexCreateBoxMesh(PETSC_COMM_SELF, 3, PETSC_FALSE, faces, lower, upper, NULL, PETSC_TRUE, dm));
760*d926f305SMatthew G. Knepley   PetscCall(PetscObjectSetName((PetscObject)*dm, "box"));
761*d926f305SMatthew G. Knepley   // Flip edges to make fault non-oriented
762*d926f305SMatthew G. Knepley   switch (rank) {
763*d926f305SMatthew G. Knepley   case 2:
764*d926f305SMatthew G. Knepley     PetscCall(DMPlexOrientPoint(*dm, 10, -1));
765*d926f305SMatthew G. Knepley     break;
766*d926f305SMatthew G. Knepley   case 3:
767*d926f305SMatthew G. Knepley     PetscCall(DMPlexOrientPoint(*dm, 9, -1));
768*d926f305SMatthew G. Knepley     break;
769*d926f305SMatthew G. Knepley   default:
770*d926f305SMatthew G. Knepley     break;
771*d926f305SMatthew G. Knepley   }
772*d926f305SMatthew G. Knepley   // Need this so that all procs create the cell types
773*d926f305SMatthew G. Knepley   PetscCall(DMPlexGetCellTypeLabel(*dm, &label));
774*d926f305SMatthew G. Knepley   // Replace comm in object (copied from PetscHeaderCreate/Destroy())
775*d926f305SMatthew G. Knepley   PetscCall(PetscCommDestroy(&(*dm)->hdr.comm));
776*d926f305SMatthew G. Knepley   PetscCall(PetscCommDuplicate(comm, &(*dm)->hdr.comm, &(*dm)->hdr.tag));
777*d926f305SMatthew G. Knepley   PetscCallMPI(MPI_Comm_get_attr((*dm)->hdr.comm, Petsc_CreationIdx_keyval, &get_tmp, &flg));
778*d926f305SMatthew G. Knepley   PetscCheck(flg, (*dm)->hdr.comm, PETSC_ERR_ARG_CORRUPT, "MPI_Comm does not have an object creation index");
779*d926f305SMatthew G. Knepley   cidx            = (PetscInt64 *)get_tmp;
780*d926f305SMatthew G. Knepley   (*dm)->hdr.cidx = (*cidx)++;
781*d926f305SMatthew G. Knepley   // Create new pointSF
782*d926f305SMatthew G. Knepley   {
783*d926f305SMatthew G. Knepley     PetscSF      sf;
784*d926f305SMatthew G. Knepley     PetscInt    *local  = NULL;
785*d926f305SMatthew G. Knepley     PetscSFNode *remote = NULL;
786*d926f305SMatthew G. Knepley     PetscInt     Nl;
787*d926f305SMatthew G. Knepley 
788*d926f305SMatthew G. Knepley     PetscCall(PetscSFCreate(comm, &sf));
789*d926f305SMatthew G. Knepley     switch (rank) {
790*d926f305SMatthew G. Knepley     case 0:
791*d926f305SMatthew G. Knepley       Nl = 15;
792*d926f305SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &local));
793*d926f305SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &remote));
794*d926f305SMatthew G. Knepley       local[0]         = 2;
795*d926f305SMatthew G. Knepley       remote[0].index  = 1;
796*d926f305SMatthew G. Knepley       remote[0].rank   = 1;
797*d926f305SMatthew G. Knepley       local[1]         = 4;
798*d926f305SMatthew G. Knepley       remote[1].index  = 3;
799*d926f305SMatthew G. Knepley       remote[1].rank   = 1;
800*d926f305SMatthew G. Knepley       local[2]         = 5;
801*d926f305SMatthew G. Knepley       remote[2].index  = 1;
802*d926f305SMatthew G. Knepley       remote[2].rank   = 2;
803*d926f305SMatthew G. Knepley       local[3]         = 6;
804*d926f305SMatthew G. Knepley       remote[3].index  = 1;
805*d926f305SMatthew G. Knepley       remote[3].rank   = 3;
806*d926f305SMatthew G. Knepley       local[4]         = 7;
807*d926f305SMatthew G. Knepley       remote[4].index  = 3;
808*d926f305SMatthew G. Knepley       remote[4].rank   = 2;
809*d926f305SMatthew G. Knepley       local[5]         = 8;
810*d926f305SMatthew G. Knepley       remote[5].index  = 3;
811*d926f305SMatthew G. Knepley       remote[5].rank   = 3;
812*d926f305SMatthew G. Knepley       local[6]         = 17;
813*d926f305SMatthew G. Knepley       remote[6].index  = 15;
814*d926f305SMatthew G. Knepley       remote[6].rank   = 2;
815*d926f305SMatthew G. Knepley       local[7]         = 18;
816*d926f305SMatthew G. Knepley       remote[7].index  = 16;
817*d926f305SMatthew G. Knepley       remote[7].rank   = 2;
818*d926f305SMatthew G. Knepley       local[8]         = 20;
819*d926f305SMatthew G. Knepley       remote[8].index  = 19;
820*d926f305SMatthew G. Knepley       remote[8].rank   = 1;
821*d926f305SMatthew G. Knepley       local[9]         = 21;
822*d926f305SMatthew G. Knepley       remote[9].index  = 19;
823*d926f305SMatthew G. Knepley       remote[9].rank   = 2;
824*d926f305SMatthew G. Knepley       local[10]        = 22;
825*d926f305SMatthew G. Knepley       remote[10].index = 19;
826*d926f305SMatthew G. Knepley       remote[10].rank  = 3;
827*d926f305SMatthew G. Knepley       local[11]        = 24;
828*d926f305SMatthew G. Knepley       remote[11].index = 23;
829*d926f305SMatthew G. Knepley       remote[11].rank  = 1;
830*d926f305SMatthew G. Knepley       local[12]        = 26;
831*d926f305SMatthew G. Knepley       remote[12].index = 25;
832*d926f305SMatthew G. Knepley       remote[12].rank  = 1;
833*d926f305SMatthew G. Knepley       local[13]        = 10;
834*d926f305SMatthew G. Knepley       remote[13].index = 9;
835*d926f305SMatthew G. Knepley       remote[13].rank  = 1;
836*d926f305SMatthew G. Knepley       local[14]        = 14;
837*d926f305SMatthew G. Knepley       remote[14].index = 13;
838*d926f305SMatthew G. Knepley       remote[14].rank  = 2;
839*d926f305SMatthew G. Knepley       break;
840*d926f305SMatthew G. Knepley     case 1:
841*d926f305SMatthew G. Knepley       Nl = 9;
842*d926f305SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &local));
843*d926f305SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &remote));
844*d926f305SMatthew G. Knepley       local[0]        = 5;
845*d926f305SMatthew G. Knepley       remote[0].index = 1;
846*d926f305SMatthew G. Knepley       remote[0].rank  = 3;
847*d926f305SMatthew G. Knepley       local[1]        = 6;
848*d926f305SMatthew G. Knepley       remote[1].index = 2;
849*d926f305SMatthew G. Knepley       remote[1].rank  = 3;
850*d926f305SMatthew G. Knepley       local[2]        = 7;
851*d926f305SMatthew G. Knepley       remote[2].index = 3;
852*d926f305SMatthew G. Knepley       remote[2].rank  = 3;
853*d926f305SMatthew G. Knepley       local[3]        = 8;
854*d926f305SMatthew G. Knepley       remote[3].index = 4;
855*d926f305SMatthew G. Knepley       remote[3].rank  = 3;
856*d926f305SMatthew G. Knepley       local[4]        = 17;
857*d926f305SMatthew G. Knepley       remote[4].index = 15;
858*d926f305SMatthew G. Knepley       remote[4].rank  = 3;
859*d926f305SMatthew G. Knepley       local[5]        = 18;
860*d926f305SMatthew G. Knepley       remote[5].index = 16;
861*d926f305SMatthew G. Knepley       remote[5].rank  = 3;
862*d926f305SMatthew G. Knepley       local[6]        = 21;
863*d926f305SMatthew G. Knepley       remote[6].index = 19;
864*d926f305SMatthew G. Knepley       remote[6].rank  = 3;
865*d926f305SMatthew G. Knepley       local[7]        = 22;
866*d926f305SMatthew G. Knepley       remote[7].index = 20;
867*d926f305SMatthew G. Knepley       remote[7].rank  = 3;
868*d926f305SMatthew G. Knepley       local[8]        = 14;
869*d926f305SMatthew G. Knepley       remote[8].index = 13;
870*d926f305SMatthew G. Knepley       remote[8].rank  = 3;
871*d926f305SMatthew G. Knepley       break;
872*d926f305SMatthew G. Knepley     case 2:
873*d926f305SMatthew G. Knepley       Nl = 9;
874*d926f305SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &local));
875*d926f305SMatthew G. Knepley       PetscCall(PetscMalloc1(Nl, &remote));
876*d926f305SMatthew G. Knepley       local[0]        = 2;
877*d926f305SMatthew G. Knepley       remote[0].index = 1;
878*d926f305SMatthew G. Knepley       remote[0].rank  = 3;
879*d926f305SMatthew G. Knepley       local[1]        = 4;
880*d926f305SMatthew G. Knepley       remote[1].index = 3;
881*d926f305SMatthew G. Knepley       remote[1].rank  = 3;
882*d926f305SMatthew G. Knepley       local[2]        = 6;
883*d926f305SMatthew G. Knepley       remote[2].index = 5;
884*d926f305SMatthew G. Knepley       remote[2].rank  = 3;
885*d926f305SMatthew G. Knepley       local[3]        = 8;
886*d926f305SMatthew G. Knepley       remote[3].index = 7;
887*d926f305SMatthew G. Knepley       remote[3].rank  = 3;
888*d926f305SMatthew G. Knepley       local[4]        = 20;
889*d926f305SMatthew G. Knepley       remote[4].index = 19;
890*d926f305SMatthew G. Knepley       remote[4].rank  = 3;
891*d926f305SMatthew G. Knepley       local[5]        = 22;
892*d926f305SMatthew G. Knepley       remote[5].index = 21;
893*d926f305SMatthew G. Knepley       remote[5].rank  = 3;
894*d926f305SMatthew G. Knepley       local[6]        = 24;
895*d926f305SMatthew G. Knepley       remote[6].index = 23;
896*d926f305SMatthew G. Knepley       remote[6].rank  = 3;
897*d926f305SMatthew G. Knepley       local[7]        = 26;
898*d926f305SMatthew G. Knepley       remote[7].index = 25;
899*d926f305SMatthew G. Knepley       remote[7].rank  = 3;
900*d926f305SMatthew G. Knepley       local[8]        = 10;
901*d926f305SMatthew G. Knepley       remote[8].index = 9;
902*d926f305SMatthew G. Knepley       remote[8].rank  = 3;
903*d926f305SMatthew G. Knepley       break;
904*d926f305SMatthew G. Knepley     case 3:
905*d926f305SMatthew G. Knepley       Nl = 0;
906*d926f305SMatthew G. Knepley       break;
907*d926f305SMatthew G. Knepley     default:
908*d926f305SMatthew G. Knepley       SETERRQ(comm, PETSC_ERR_SUP, "This example only supports 4 ranks");
909*d926f305SMatthew G. Knepley     }
910*d926f305SMatthew G. Knepley     PetscCall(PetscSFSetGraph(sf, 27, Nl, local, PETSC_OWN_POINTER, remote, PETSC_OWN_POINTER));
911*d926f305SMatthew G. Knepley     PetscCall(DMSetPointSF(*dm, sf));
912*d926f305SMatthew G. Knepley     PetscCall(PetscSFDestroy(&sf));
913*d926f305SMatthew G. Knepley   }
914*d926f305SMatthew G. Knepley   // Create fault label
915*d926f305SMatthew G. Knepley   PetscCall(DMCreateLabel(*dm, "fault"));
916*d926f305SMatthew G. Knepley   PetscCall(DMGetLabel(*dm, "fault", &label));
917*d926f305SMatthew G. Knepley   switch (rank) {
918*d926f305SMatthew G. Knepley   case 0:
919*d926f305SMatthew G. Knepley   case 2:
920*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 10, 2));
921*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 20, 1));
922*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 22, 1));
923*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 24, 1));
924*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 26, 1));
925*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 2, 0));
926*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 4, 0));
927*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 6, 0));
928*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 8, 0));
929*d926f305SMatthew G. Knepley     break;
930*d926f305SMatthew G. Knepley   case 1:
931*d926f305SMatthew G. Knepley   case 3:
932*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 9, 2));
933*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 19, 1));
934*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 21, 1));
935*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 23, 1));
936*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 25, 1));
937*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 1, 0));
938*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 3, 0));
939*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 5, 0));
940*d926f305SMatthew G. Knepley     PetscCall(DMLabelSetValue(label, 7, 0));
941*d926f305SMatthew G. Knepley     break;
942*d926f305SMatthew G. Knepley   default:
943*d926f305SMatthew G. Knepley     break;
944*d926f305SMatthew G. Knepley   }
945*d926f305SMatthew G. Knepley   PetscCall(DMPlexOrientLabel(*dm, label));
946*d926f305SMatthew G. Knepley   PetscCall(DMPlexLabelCohesiveComplete(*dm, label, NULL, 1, PETSC_FALSE, PETSC_FALSE, NULL));
947*d926f305SMatthew G. Knepley   PetscCall(DMPlexDistributeSetDefault(*dm, PETSC_FALSE));
948*d926f305SMatthew G. Knepley   PetscFunctionReturn(PETSC_SUCCESS);
949*d926f305SMatthew G. Knepley }
950*d926f305SMatthew G. Knepley 
9516fc05355SMatthew G. Knepley static PetscErrorCode CreateMesh(MPI_Comm comm, AppCtx *user, DM *dm)
9526fc05355SMatthew G. Knepley {
9536fc05355SMatthew G. Knepley   PetscFunctionBegin;
954*d926f305SMatthew G. Knepley   switch (user->testNum) {
955*d926f305SMatthew G. Knepley   case 1:
9566fc05355SMatthew G. Knepley     PetscCall(CreateQuadMesh1(comm, user, dm));
957*d926f305SMatthew G. Knepley     break;
958*d926f305SMatthew G. Knepley   case 2:
959*d926f305SMatthew G. Knepley     PetscCall(CreateHexMesh1(comm, user, dm));
960*d926f305SMatthew G. Knepley     break;
961*d926f305SMatthew G. Knepley   default:
9626fc05355SMatthew G. Knepley     PetscCall(DMCreate(comm, dm));
9636fc05355SMatthew G. Knepley     PetscCall(DMSetType(*dm, DMPLEX));
964*d926f305SMatthew G. Knepley     break;
9656fc05355SMatthew G. Knepley   }
9666fc05355SMatthew G. Knepley   PetscCall(DMSetFromOptions(*dm));
9676fc05355SMatthew G. Knepley   {
9686fc05355SMatthew G. Knepley     const char *prefix;
9696fc05355SMatthew G. Knepley 
9706fc05355SMatthew G. Knepley     // We cannot redistribute with cohesive cells in the SF
9716fc05355SMatthew G. Knepley     PetscCall(DMPlexDistributeSetDefault(*dm, PETSC_FALSE));
9726fc05355SMatthew G. Knepley     PetscCall(PetscObjectGetOptionsPrefix((PetscObject)*dm, &prefix));
9736fc05355SMatthew G. Knepley     PetscCall(PetscObjectSetOptionsPrefix((PetscObject)*dm, "f0_"));
9746fc05355SMatthew G. Knepley     PetscCall(DMSetFromOptions(*dm));
9756fc05355SMatthew G. Knepley     PetscCall(PetscObjectSetOptionsPrefix((PetscObject)*dm, "f1_"));
9766fc05355SMatthew G. Knepley     PetscCall(DMSetFromOptions(*dm));
9776fc05355SMatthew G. Knepley     PetscCall(PetscObjectSetOptionsPrefix((PetscObject)*dm, prefix));
9786fc05355SMatthew G. Knepley   }
9796fc05355SMatthew G. Knepley   PetscCall(DMViewFromOptions(*dm, NULL, "-dm_view"));
9806fc05355SMatthew G. Knepley   PetscFunctionReturn(PETSC_SUCCESS);
9816fc05355SMatthew G. Knepley }
9826fc05355SMatthew G. Knepley 
9836fc05355SMatthew G. Knepley int main(int argc, char **argv)
9846fc05355SMatthew G. Knepley {
9856fc05355SMatthew G. Knepley   DM     dm;
9866fc05355SMatthew G. Knepley   AppCtx user;
9876fc05355SMatthew G. Knepley 
9886fc05355SMatthew G. Knepley   PetscFunctionBeginUser;
9896fc05355SMatthew G. Knepley   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
9906fc05355SMatthew G. Knepley   PetscCall(ProcessOptions(PETSC_COMM_WORLD, &user));
9916fc05355SMatthew G. Knepley   PetscCall(CreateMesh(PETSC_COMM_WORLD, &user, &dm));
9926fc05355SMatthew G. Knepley   PetscCall(DMDestroy(&dm));
9936fc05355SMatthew G. Knepley   PetscCall(PetscFinalize());
9946fc05355SMatthew G. Knepley   return 0;
9956fc05355SMatthew G. Knepley }
9966fc05355SMatthew G. Knepley 
9976fc05355SMatthew G. Knepley /*TEST
9986fc05355SMatthew G. Knepley 
9996fc05355SMatthew G. Knepley   testset:
10006fc05355SMatthew G. Knepley     requires: triangle
10016fc05355SMatthew G. Knepley     args: -dm_refine 1 -dm_plex_transform_type cohesive_extrude \
10026fc05355SMatthew G. Knepley             -dm_plex_transform_active fault \
10036fc05355SMatthew G. Knepley           -dm_view ::ascii_info_detail -coarse_dm_view ::ascii_info_detail
10046fc05355SMatthew G. Knepley 
10056fc05355SMatthew G. Knepley     test:
10066fc05355SMatthew G. Knepley       suffix: tri_0
10076fc05355SMatthew G. Knepley       args: -dm_plex_box_faces 1,1 -dm_plex_cohesive_label_fault 8
10086fc05355SMatthew G. Knepley     test:
10096fc05355SMatthew G. Knepley       suffix: tri_1
10106fc05355SMatthew G. Knepley       args: -dm_plex_box_faces 1,1 -dm_plex_cohesive_label_fault 8 \
10116fc05355SMatthew G. Knepley               -dm_plex_transform_extrude_use_tensor 0
10126fc05355SMatthew G. Knepley     test:
10136fc05355SMatthew G. Knepley       suffix: tri_2
10146fc05355SMatthew G. Knepley       args: -dm_plex_file_contents dat:tri_2_cv -dm_plex_cohesive_label_fault 11,15
10156fc05355SMatthew G. Knepley     test:
10166fc05355SMatthew G. Knepley       suffix: tri_3
10176fc05355SMatthew G. Knepley       nsize: 2
10186fc05355SMatthew G. Knepley       args: -dm_plex_file_contents dat:tri_2_cv -dm_plex_cohesive_label_fault 11,15 \
10196fc05355SMatthew G. Knepley               -petscpartitioner_type shell -petscpartitioner_shell_sizes 2,2 \
10206fc05355SMatthew G. Knepley               -petscpartitioner_shell_points 0,3,1,2
10216fc05355SMatthew G. Knepley 
10226fc05355SMatthew G. Knepley   testset:
10236fc05355SMatthew G. Knepley     args: -dm_plex_simplex 0 -dm_plex_box_faces 2,1 \
10246fc05355SMatthew G. Knepley           -dm_refine 1 -dm_plex_transform_type cohesive_extrude \
10256fc05355SMatthew G. Knepley             -dm_plex_transform_active fault -dm_plex_cohesive_label_fault 13 \
10266fc05355SMatthew G. Knepley           -dm_view ::ascii_info_detail -coarse_dm_view ::ascii_info_detail
10276fc05355SMatthew G. Knepley 
10286fc05355SMatthew G. Knepley     test:
10296fc05355SMatthew G. Knepley       suffix: quad_0
10306fc05355SMatthew G. Knepley     test:
10316fc05355SMatthew G. Knepley       suffix: quad_1
10326fc05355SMatthew G. Knepley       args: -dm_plex_transform_extrude_use_tensor 0
10336fc05355SMatthew G. Knepley     test:
10346fc05355SMatthew G. Knepley       suffix: quad_2
10356fc05355SMatthew G. Knepley       nsize: 2
10366fc05355SMatthew G. Knepley       args: -petscpartitioner_type simple
10376fc05355SMatthew G. Knepley 
10386fc05355SMatthew G. Knepley   test:
10396fc05355SMatthew G. Knepley     suffix: quad_3
10406fc05355SMatthew G. Knepley     nsize: 4
10416fc05355SMatthew G. Knepley     args: -test_num 1 \
10426fc05355SMatthew G. Knepley           -dm_refine 1 -dm_plex_transform_type cohesive_extrude \
10436fc05355SMatthew G. Knepley             -dm_plex_transform_active fault \
10446fc05355SMatthew G. Knepley           -dm_view ::ascii_info_detail -coarse_dm_view ::ascii_info_detail \
10456fc05355SMatthew G. Knepley           -orientation_view -orientation_view_synchronized
10466fc05355SMatthew G. Knepley 
10476fc05355SMatthew G. Knepley   test:
10486fc05355SMatthew G. Knepley     suffix: quad_4
10496fc05355SMatthew G. Knepley     args: -dm_plex_simplex 0 -dm_plex_box_faces 3,2 \
10506fc05355SMatthew G. Knepley           -dm_refine 1 -dm_plex_transform_type cohesive_extrude \
10516fc05355SMatthew G. Knepley             -dm_plex_transform_active fault -dm_plex_cohesive_label_fault 22,23 \
10526fc05355SMatthew G. Knepley           -dm_view ::ascii_info_detail -coarse_dm_view ::ascii_info_detail
10536fc05355SMatthew G. Knepley 
10546fc05355SMatthew G. Knepley   test:
10556fc05355SMatthew G. Knepley     suffix: quad_5
10566fc05355SMatthew G. Knepley     args: -dm_plex_simplex 0 -dm_plex_box_faces 3,2 \
10576fc05355SMatthew G. Knepley             -dm_plex_cohesive_label_fault0 21 \
10586fc05355SMatthew G. Knepley             -dm_plex_cohesive_label_fault1 23 \
10596fc05355SMatthew G. Knepley           -f0_dm_refine 1 -f0_dm_plex_transform_type cohesive_extrude \
10606fc05355SMatthew G. Knepley             -f0_dm_plex_transform_active fault0  -f0_coarse_dm_view ::ascii_info_detail \
10616fc05355SMatthew G. Knepley           -f1_dm_refine 1 -f1_dm_plex_transform_type cohesive_extrude \
10626fc05355SMatthew G. Knepley             -f1_dm_plex_transform_active fault1  -f1_coarse_dm_view ::ascii_info_detail \
10636fc05355SMatthew G. Knepley           -dm_view ::ascii_info_detail
10646fc05355SMatthew G. Knepley 
10656fc05355SMatthew G. Knepley   test:
10666fc05355SMatthew G. Knepley     suffix: quad_6
10676fc05355SMatthew G. Knepley     args: -dm_plex_simplex 0 -dm_plex_box_faces 3,2 \
10686fc05355SMatthew G. Knepley             -dm_plex_cohesive_label_fault0 22,23 \
10696fc05355SMatthew G. Knepley             -dm_plex_cohesive_label_fault1 32 \
10706fc05355SMatthew G. Knepley           -f0_dm_refine 1 -f0_dm_plex_transform_type cohesive_extrude \
10716fc05355SMatthew G. Knepley             -f0_dm_plex_transform_active fault0  -f0_coarse_dm_view ::ascii_info_detail \
10726fc05355SMatthew G. Knepley           -f1_dm_refine 1 -f1_dm_plex_transform_type cohesive_extrude \
10736fc05355SMatthew G. Knepley             -f1_dm_plex_transform_active fault1  -f1_coarse_dm_view ::ascii_info_detail \
10746fc05355SMatthew G. Knepley           -dm_view ::ascii_info_detail
10756fc05355SMatthew G. Knepley 
1076*d926f305SMatthew G. Knepley   testset:
1077*d926f305SMatthew G. Knepley     args: -dm_plex_dim 3 -dm_plex_shape doublet \
1078*d926f305SMatthew G. Knepley           -dm_refine 1 -dm_plex_transform_type cohesive_extrude \
1079*d926f305SMatthew G. Knepley             -dm_plex_transform_active fault -dm_plex_cohesive_label_fault 7 \
1080*d926f305SMatthew G. Knepley           -dm_view ::ascii_info_detail -coarse_dm_view ::ascii_info_detail
1081*d926f305SMatthew G. Knepley 
1082*d926f305SMatthew G. Knepley     test:
1083*d926f305SMatthew G. Knepley       suffix: tet_0
1084*d926f305SMatthew G. Knepley     test:
1085*d926f305SMatthew G. Knepley       suffix: tet_1
1086*d926f305SMatthew G. Knepley       nsize: 2
1087*d926f305SMatthew G. Knepley       args: -petscpartitioner_type simple
1088*d926f305SMatthew G. Knepley 
1089*d926f305SMatthew G. Knepley   testset:
1090*d926f305SMatthew G. Knepley     args: -dm_plex_dim 3 -dm_plex_simplex 0 -dm_plex_box_faces 2,1,1 -dm_plex_box_upper 2,1,1 \
1091*d926f305SMatthew G. Knepley           -dm_refine 1 -dm_plex_transform_type cohesive_extrude \
1092*d926f305SMatthew G. Knepley             -dm_plex_transform_active fault -dm_plex_cohesive_label_fault 15 \
1093*d926f305SMatthew G. Knepley           -dm_view ::ascii_info_detail -coarse_dm_view ::ascii_info_detail
1094*d926f305SMatthew G. Knepley 
1095*d926f305SMatthew G. Knepley     test:
1096*d926f305SMatthew G. Knepley       suffix: hex_0
1097*d926f305SMatthew G. Knepley     test:
1098*d926f305SMatthew G. Knepley       suffix: hex_1
1099*d926f305SMatthew G. Knepley       nsize: 2
1100*d926f305SMatthew G. Knepley       args: -petscpartitioner_type simple
1101*d926f305SMatthew G. Knepley 
1102*d926f305SMatthew G. Knepley   test:
1103*d926f305SMatthew G. Knepley     suffix: hex_2
1104*d926f305SMatthew G. Knepley     nsize: 4
1105*d926f305SMatthew G. Knepley     args: -test_num 2 \
1106*d926f305SMatthew G. Knepley           -dm_refine 1 -dm_plex_transform_type cohesive_extrude \
1107*d926f305SMatthew G. Knepley             -dm_plex_transform_active fault \
1108*d926f305SMatthew G. Knepley           -dm_view ::ascii_info_detail -coarse_dm_view ::ascii_info_detail \
1109*d926f305SMatthew G. Knepley           -orientation_view -orientation_view_synchronized
1110*d926f305SMatthew G. Knepley 
1111*d926f305SMatthew G. Knepley   test:
1112*d926f305SMatthew G. Knepley     suffix: hex_3
1113*d926f305SMatthew G. Knepley     args: -dm_plex_dim 3 -dm_plex_simplex 0 -dm_plex_box_faces 2,1,2 -dm_plex_box_upper 2.,1.,2. \
1114*d926f305SMatthew G. Knepley             -dm_plex_cohesive_label_fault0 37,40 \
1115*d926f305SMatthew G. Knepley             -dm_plex_cohesive_label_fault1 26 \
1116*d926f305SMatthew G. Knepley           -f0_dm_refine 1 -f0_dm_plex_transform_type cohesive_extrude \
1117*d926f305SMatthew G. Knepley             -f0_dm_plex_transform_active fault0  -f0_coarse_dm_view ::ascii_info_detail \
1118*d926f305SMatthew G. Knepley           -f1_dm_refine 1 -f1_dm_plex_transform_type cohesive_extrude \
1119*d926f305SMatthew G. Knepley             -f1_dm_plex_transform_active fault1  -f1_coarse_dm_view ::ascii_info_detail \
1120*d926f305SMatthew G. Knepley           -dm_view ::ascii_info_detail
1121*d926f305SMatthew G. Knepley 
1122*d926f305SMatthew G. Knepley   test:
1123*d926f305SMatthew G. Knepley     suffix: hex_4
1124*d926f305SMatthew G. Knepley     args: -dm_plex_dim 3 -dm_plex_simplex 0 -dm_plex_box_faces 4,1,2 -dm_plex_box_upper 4.,1.,2. \
1125*d926f305SMatthew G. Knepley             -dm_plex_cohesive_label_fault0 65,68 \
1126*d926f305SMatthew G. Knepley             -dm_plex_cohesive_label_fault1 46 \
1127*d926f305SMatthew G. Knepley           -f0_dm_refine 1 -f0_dm_plex_transform_type cohesive_extrude \
1128*d926f305SMatthew G. Knepley             -f0_dm_plex_transform_active fault0  -f0_coarse_dm_view ::ascii_info_detail \
1129*d926f305SMatthew G. Knepley           -f1_dm_refine 1 -f1_dm_plex_transform_type cohesive_extrude \
1130*d926f305SMatthew G. Knepley             -f1_dm_plex_transform_active fault1  -f1_coarse_dm_view ::ascii_info_detail \
1131*d926f305SMatthew G. Knepley           -dm_view ::ascii_info_detail
1132*d926f305SMatthew G. Knepley 
11336fc05355SMatthew G. Knepley TEST*/
1134