This file is indexed.

/usr/lib/petscdir/3.1/include/sieve/Selection.hh is in libpetsc3.1-dev 3.1.dfsg-11ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
#ifndef included_ALE_Selection_hh
#define included_ALE_Selection_hh

#ifndef  included_ALE_SieveAlgorithms_hh
#include <SieveAlgorithms.hh>
#endif

#ifndef  included_ALE_SieveBuilder_hh
#include <SieveBuilder.hh>
#endif

namespace ALE {
  template<typename Mesh_>
  class Selection {
  public:
    typedef Mesh_                                mesh_type;
    typedef typename mesh_type::sieve_type       sieve_type;
    typedef typename mesh_type::point_type       point_type;
    typedef typename mesh_type::int_section_type int_section_type;
    typedef std::set<point_type>                 PointSet;
    typedef std::vector<point_type>              PointArray;
    typedef std::pair<typename sieve_type::point_type, int> oPoint_type;
    typedef std::vector<oPoint_type>                        oPointArray;
    typedef typename ALE::SieveAlg<mesh_type>    sieveAlg;
  protected:
    template<typename Sieve, typename FaceType>
    class FaceVisitor {
    public:
      typedef typename Sieve::point_type point_type;
      typedef typename Sieve::arrow_type arrow_type;
    protected:
      const FaceType& face;
      PointArray&     origVertices;
      PointArray&     faceVertices;
      int            *indices;
      const int       debug;
      int             oppositeVertex;
      int             v;
    public:
      FaceVisitor(const FaceType& f, PointArray& oV, PointArray& fV, int *i, const int debug) : face(f), origVertices(oV), faceVertices(fV), indices(i), debug(debug), oppositeVertex(-1), v(0) {};
      void visitPoint(const point_type& point) {
        if (face->find(point) != face->end()) {
          if (debug) std::cout << "    vertex " << point << std::endl;
          indices[origVertices.size()] = v;
          origVertices.insert(origVertices.end(), point);
        } else {
          if (debug) std::cout << "    vertex " << point << std::endl;
          oppositeVertex = v;
        }
        ++v;
      };
      void visitArrow(const arrow_type&) {};
    public:
      int getOppositeVertex() {return this->oppositeVertex;};
    };
  public:
    template<typename Processor>
    static void subsets(const PointArray& v, const int size, Processor& processor, Obj<PointArray> *out = NULL, const int min = 0) {
      if (size == 0) {
        processor(*out);
        return;
      }
      if (min == 0) {
        out  = new Obj<PointArray>();
        *out = new PointArray();
      }
      for(int i = min; i < (int) v.size(); ++i) {
        (*out)->push_back(v[i]);
        subsets(v, size-1, processor, out, i+1);
        (*out)->pop_back();
      }
      if (min == 0) {delete out;}
    };
    template<typename Mesh>
    static int numFaceVertices(const Obj<Mesh>& mesh) {
      return numFaceVertices(mesh, mesh->getNumCellCorners());
    };
    template<typename Mesh>
    static int numFaceVertices(const Obj<Mesh>& mesh, const unsigned int numCorners) {
      //unsigned int numCorners = mesh->getNumCellCorners(cell, depth);
      const    int cellDim          = mesh->getDimension();
      unsigned int _numFaceVertices = 0;

      switch (cellDim) {
      case 0 :
        _numFaceVertices = 0;
        break;
      case 1 :
        _numFaceVertices = 1;
        break;
      case 2:
        switch (numCorners) {
        case 3 : // triangle
          _numFaceVertices = 2; // Edge has 2 vertices
          break;
        case 4 : // quadrilateral
          _numFaceVertices = 2; // Edge has 2 vertices
          break;
        default :
          throw ALE::Exception("Invalid number of face corners");
        }
        break;
      case 3:
        switch (numCorners)	{
        case 4 : // tetradehdron
          _numFaceVertices = 3; // Face has 3 vertices
          break;
        case 8 : // hexahedron
          _numFaceVertices = 4; // Face has 4 vertices
          break;
        default :
          throw ALE::Exception("Invalid number of face corners");
        }
        break;
      default:
        throw ALE::Exception("Invalid cell dimension");
      }
      return _numFaceVertices;
    };
    // We need this method because we do not use interpolated sieves
    //   - Without interpolation, we cannot say what vertex collections are
    //     faces, and how they are oriented
    //   - Now we read off the list of face vertices IN THE ORDER IN WHICH
    //     THEY APPEAR IN THE CELL
    //   - This leads to simple algorithms for simplices and quads to check
    //     orientation since these sets are always valid faces
    //   - This is not true with hexes, so we just sort and check explicit cases
    //   - This means for hexes that we have to alter the vertex container as well
    template<typename Mesh>
    static bool faceOrientation(const point_type& cell, const Obj<Mesh>& mesh, const int numCorners,
                                const int indices[], const int oppositeVertex, PointArray *origVertices, PointArray *faceVertices) {
      const int cellDim   = mesh->getDimension();
      const int debug     = mesh->debug();
      bool      posOrient = false;

      // Simplices
      if (cellDim == numCorners-1) {
        posOrient = !(oppositeVertex%2);
      } else if (cellDim == 2) {
        // Quads
        if ((indices[1] > indices[0]) && (indices[1] - indices[0] == 1)) {
          posOrient = true;
        } else if ((indices[0] == 3) && (indices[1] == 0)) {
          posOrient = true;
        } else {
          if (((indices[0] > indices[1]) && (indices[0] - indices[1] == 1)) || ((indices[0] == 0) && (indices[1] == 3))) {
            posOrient = false;
          } else {
            throw ALE::Exception("Invalid quad crossedge");
          }
        }
      } else if (cellDim == 3) {
        // Hexes
        //   A hex is two oriented quads with the normal of the first
        //   pointing up at the second.
        //
        //     7---6
        //    /|  /|
        //   4---5 |
        //   | 3-|-2
        //   |/  |/
        //   0---1
        int  sortedIndices[4];
        bool found = false;

        for(int i = 0; i < 4; ++i) sortedIndices[i] = indices[i];
        std::sort(sortedIndices, sortedIndices+4);
        // Case 1: Bottom quad
        if ((sortedIndices[0] == 0) && (sortedIndices[1] == 1) && (sortedIndices[2] == 2) && (sortedIndices[3] == 3)) {
          if (debug) std::cout << "Bottom quad" << std::endl;
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 3) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 2) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 1) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 0) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          found = true;
        }
        // Case 2: Top quad
        if ((sortedIndices[0] == 4) && (sortedIndices[1] == 5) && (sortedIndices[2] == 6) && (sortedIndices[3] == 7)) {
          if (debug) std::cout << "Top quad" << std::endl;
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 5) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 6) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 7) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 4) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          found = true;
        }
        // Case 3: Front quad
        if ((sortedIndices[0] == 0) && (sortedIndices[1] == 1) && (sortedIndices[2] == 4) && (sortedIndices[3] == 5)) {
          if (debug) std::cout << "Front quad" << std::endl;
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 1) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 5) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 4) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 0) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          found = true;
        }
        // Case 4: Back quad
        if ((sortedIndices[0] == 2) && (sortedIndices[1] == 3) && (sortedIndices[2] == 6) && (sortedIndices[3] == 7)) {
          if (debug) std::cout << "Back quad" << std::endl;
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 7) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 6) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 2) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 3) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          found = true;
        }
        // Case 5: Right quad
        if ((sortedIndices[0] == 1) && (sortedIndices[1] == 2) && (sortedIndices[2] == 5) && (sortedIndices[3] == 6)) {
          if (debug) std::cout << "Right quad" << std::endl;
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 2) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 6) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 5) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 1) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          found = true;
        }
        // Case 6: Left quad
        if ((sortedIndices[0] == 0) && (sortedIndices[1] == 3) && (sortedIndices[2] == 4) && (sortedIndices[3] == 7)) {
          if (debug) std::cout << "Left quad" << std::endl;
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 4) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 7) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 3) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          for(int i = 0; i < 4; ++i) {
            if (indices[i] == 0) {
              faceVertices->push_back((*origVertices)[i]); break;
            }
          }
          found = true;
        }
        if (!found) {throw ALE::Exception("Invalid hex crossface");}
        return true;
      }
      if (!posOrient) {
        if (debug) std::cout << "  Reversing initial face orientation" << std::endl;
        faceVertices->insert(faceVertices->end(), (*origVertices).rbegin(), (*origVertices).rend());
      } else {
        if (debug) std::cout << "  Keeping initial face orientation" << std::endl;
        faceVertices->insert(faceVertices->end(), (*origVertices).begin(), (*origVertices).end());
      }
      return posOrient;
    };
    // Given a cell and a face, as a set of vertices,
    //   return the oriented face, as a set of vertices, in faceVertices
    // The orientation is such that the face normal points out of the cell
    template<typename Mesh, typename FaceType>
    static bool getOrientedFace(const Obj<Mesh>& mesh, const point_type& cell, FaceType face,
                                const int numCorners, int indices[], PointArray *origVertices, PointArray *faceVertices)
    {
      FaceVisitor<typename Mesh::sieve_type,FaceType> v(face, *origVertices, *faceVertices, indices, mesh->debug());

      origVertices->clear();
      faceVertices->clear();
      mesh->getSieve()->cone(cell, v);
      return faceOrientation(cell, mesh, numCorners, indices, v.getOppositeVertex(), origVertices, faceVertices);
    };
    template<typename FaceType>
    static bool getOrientedFace(const Obj<ALE::Mesh>& mesh, const point_type& cell, FaceType face,
                                const int numCorners, int indices[], PointArray *origVertices, PointArray *faceVertices)
    {
      const Obj<typename ALE::Mesh::sieve_type::traits::coneSequence>& cone = mesh->getSieve()->cone(cell);
      const int debug = mesh->debug();
      int       v     = 0;
      int       oppositeVertex;

      origVertices->clear();
      faceVertices->clear();
      for(typename ALE::Mesh::sieve_type::traits::coneSequence::iterator v_iter = cone->begin(); v_iter != cone->end(); ++v_iter, ++v) {
        if (face->find(*v_iter) != face->end()) {
          if (debug) std::cout << "    vertex " << *v_iter << std::endl;
          indices[origVertices->size()] = v;
          origVertices->insert(origVertices->end(), *v_iter);
        } else {
          if (debug) std::cout << "    vertex " << *v_iter << std::endl;
          oppositeVertex = v;
        }
      }
      return faceOrientation(cell, mesh, numCorners, indices, oppositeVertex, origVertices, faceVertices);
    };
    template<typename Sieve>
    static void insertFace(const Obj<mesh_type>& mesh, const Obj<Sieve>& subSieve, const Obj<PointSet>& face, point_type& f,
                           const point_type& cell, const int numCorners, int indices[], PointArray *origVertices, PointArray *faceVertices)
    {
      const Obj<typename Sieve::supportSet> preFace = subSieve->nJoin1(face);
      const int                             debug   = subSieve->debug();

      if (preFace->size() > 1) {
        throw ALE::Exception("Invalid fault sieve: Multiple faces from vertex set");
      } else if (preFace->size() == 1) {
        // Add the other cell neighbor for this face
        subSieve->addArrow(*preFace->begin(), cell);
      } else if (preFace->size() == 0) {
        if (debug) std::cout << "  Orienting face " << f << std::endl;
        try {
          getOrientedFace(mesh, cell, face, numCorners, indices, origVertices, faceVertices);
          if (debug) std::cout << "  Adding face " << f << std::endl;
          int color = 0;
          for(typename PointArray::const_iterator f_iter = faceVertices->begin(); f_iter != faceVertices->end(); ++f_iter) {
            if (debug) std::cout << "    vertex " << *f_iter << std::endl;
            subSieve->addArrow(*f_iter, f, color++);
          }
          subSieve->addArrow(f, cell);
          f++;
        } catch (ALE::Exception e) {
          if (debug) std::cout << "  Did not add invalid face " << f << std::endl;
        }
      }
    };
  public:
    class FaceInserter {
#if 0
    public:
      typedef Mesh_                                mesh_type;
      typedef typename mesh_type::sieve_type       sieve_type;
      typedef typename mesh_type::point_type       point_type;
      typedef std::set<point_type>                 PointSet;
      typedef std::vector<point_type>              PointArray;
#endif
    protected:
      const Obj<mesh_type>  mesh;
      const Obj<sieve_type> sieve;
      const Obj<sieve_type> subSieve;
      point_type&           f;
      const point_type      cell;
      const int             numCorners;
      int                  *indices;
      PointArray           *origVertices;
      PointArray           *faceVertices;
      PointSet             *subCells;
      const int             debug;
    public:
      FaceInserter(const Obj<mesh_type>& mesh, const Obj<sieve_type>& sieve, const Obj<sieve_type>& subSieve, point_type& f, const point_type& cell, const int numCorners, int indices[], PointArray *origVertices, PointArray *faceVertices, PointSet *subCells) : mesh(mesh), sieve(sieve), subSieve(subSieve), f(f), cell(cell), numCorners(numCorners), indices(indices), origVertices(origVertices), faceVertices(faceVertices), subCells(subCells), debug(mesh->debug()) {};
      virtual ~FaceInserter() {};
    public:
      void operator()(const Obj<PointArray>& face) {
        const Obj<typename sieve_type::supportSet> sievePreFace = sieve->nJoin1(face);

        if (sievePreFace->size() == 1) {
          if (debug) std::cout << "  Contains a boundary face on the submesh" << std::endl;
          PointSet faceSet(face->begin(), face->end());
          ALE::Selection<mesh_type>::insertFace(mesh, subSieve, faceSet, f, cell, numCorners, indices, origVertices, faceVertices);
          subCells->insert(cell);
        }
      };
    };
    template<typename Sieve>
    class FaceInserterV {
    protected:
      const Obj<mesh_type>&  mesh;
      const Obj<sieve_type>& sieve;
      const Obj<Sieve>&      subSieve;
      point_type&            f;
      const point_type       cell;
      const int              numCorners;
      int                   *indices;
      PointArray            *origVertices;
      PointArray            *faceVertices;
      PointSet              *subCells;
      const int              debug;
    public:
      FaceInserterV(const Obj<mesh_type>& mesh, const Obj<sieve_type>& sieve, const Obj<Sieve>& subSieve, point_type& f, const point_type& cell, const int numCorners, int indices[], PointArray *origVertices, PointArray *faceVertices, PointSet *subCells) : mesh(mesh), sieve(sieve), subSieve(subSieve), f(f), cell(cell), numCorners(numCorners), indices(indices), origVertices(origVertices), faceVertices(faceVertices), subCells(subCells), debug(mesh->debug()) {};
      virtual ~FaceInserterV() {};
    public:
      void operator()(const Obj<PointArray>& face) {
        ISieveVisitor::PointRetriever<sieve_type> jV(sieve->getMaxSupportSize());

        sieve->join(*face, jV);
        if (jV.getSize() == 1) {
          if (debug) std::cout << "  Contains a boundary face on the submesh" << std::endl;
          PointSet faceSet(face->begin(), face->end());
          ALE::Selection<mesh_type>::insertFace(mesh, subSieve, faceSet, f, cell, numCorners, indices, origVertices, faceVertices);
          subCells->insert(cell);
        }
      };
    };
  protected:
    static int binomial(const int i, const int j) {
      assert(j <= i);
      assert(i < 34);
      if (j == 0) {
        return 1;
      } else if (j == i) {
        return 1;
      } else {
        return binomial(i-1, j) + binomial(i-1, j-1);
      }
    };
  public:
    // This takes in a section and creates a submesh from the vertices in the section chart
    //   This is a hyperplane of one dimension lower than the mesh
    static Obj<mesh_type> submesh_uninterpolated(const Obj<mesh_type>& mesh, const Obj<int_section_type>& label, const int dimension = -1, const bool boundaryFaces = true) {
      // A challenge here is to coordinate the extra numbering of new faces
      //   In serial, it is enough to number after the last point:
      //     Use sieve->base()->size() + sieve->cap()->size(), or determine the greatest point
      //   In parallel, there are two steps:
      //     1) Use the serial result, and reduce either with add (for size) or max (for greatest point)
      //     2) Determine how many faces will be created on each process
      //        This will be bounded by C(numCorners, faceSize)*submeshCells
      //        Thus it looks like we should first accumulate submeshCells, and then create faces
      typedef typename mesh_type::label_type        label_type;
      typedef typename int_section_type::chart_type chart_type;
      const int                  dim        = (dimension > 0) ? dimension : mesh->getDimension()-1;
      const Obj<sieve_type>&     sieve      = mesh->getSieve();
      Obj<mesh_type>             submesh    = new mesh_type(mesh->comm(), dim, mesh->debug());
      Obj<sieve_type>            subSieve   = new sieve_type(mesh->comm(), mesh->debug());
      const bool                 censor     = mesh->hasLabel("censored depth");
      const Obj<label_type>&     depthLabel = censor ? mesh->getLabel("censored depth") : mesh->getLabel("depth");
      const int                  depth      = mesh->depth();
      const int                  height     = mesh->height();
      const chart_type&          chart      = label->getChart();
      const int                  numCorners = sieve->nCone(*mesh->heightStratum(0)->begin(), depth)->size();
      const int                  faceSize   = numFaceVertices(mesh);
      Obj<PointSet>              face       = new PointSet();
      int                        f          = sieve->base()->size() + sieve->cap()->size();
      const int                  debug      = mesh->debug();
      int                       *indices    = new int[faceSize];
      PointArray                 origVertices, faceVertices;
      PointSet                   submeshVertices, submeshCells;


      const typename chart_type::iterator chartEnd = chart.end();
      for(typename chart_type::iterator c_iter = chart.begin(); c_iter != chartEnd; ++c_iter) {
        if (label->getFiberDimension(*c_iter)) submeshVertices.insert(*c_iter);
      }
      const typename PointSet::const_iterator svBegin = submeshVertices.begin();
      const typename PointSet::const_iterator svEnd   = submeshVertices.end();

      for(typename PointSet::const_iterator sv_iter = svBegin; sv_iter != svEnd; ++sv_iter) {
        const Obj<typename sieveAlg::supportArray>&     cells  = sieveAlg::nSupport(mesh, *sv_iter, depth);
        const typename sieveAlg::supportArray::iterator cBegin = cells->begin();
        const typename sieveAlg::supportArray::iterator cEnd   = cells->end();

        if (debug) std::cout << "Checking submesh vertex " << *sv_iter << std::endl;
        for(typename sieveAlg::supportArray::iterator c_iter = cBegin; c_iter != cEnd; ++c_iter) {
          if (debug) std::cout << "  Checking cell " << *c_iter << std::endl;
          if (submeshCells.find(*c_iter) != submeshCells.end())	continue;
          if (censor && (!mesh->getValue(depthLabel, *c_iter))) continue;
          const Obj<typename sieveAlg::coneArray>& cone = sieveAlg::nCone(mesh, *c_iter, height);
          const typename sieveAlg::coneArray::iterator vBegin = cone->begin();
          const typename sieveAlg::coneArray::iterator vEnd   = cone->end();

          face->clear();
          for(typename sieveAlg::coneArray::iterator v_iter = vBegin; v_iter != vEnd; ++v_iter) {
            if (submeshVertices.find(*v_iter) != svEnd) {
              if (debug) std::cout << "    contains submesh vertex " << *v_iter << std::endl;
              face->insert(face->end(), *v_iter);
            }
          }
          if ((int) face->size() > faceSize) {
            if (!boundaryFaces) throw ALE::Exception("Invalid fault mesh: Too many vertices of an element on the fault");
            if (debug) std::cout << "  Has all boundary faces on the submesh" << std::endl;
            submeshCells.insert(*c_iter);
          }
          if ((int) face->size() == faceSize) {
            if (debug) std::cout << "  Contains a face on the submesh" << std::endl;
            submeshCells.insert(*c_iter);
          }
        }
      }
      if (mesh->commSize() > 1) {
        int localF     = f;
        int localFaces = binomial(numCorners, faceSize)*submeshCells.size();
        int maxFaces;

        MPI_Allreduce(&localF, &f, 1, MPI_INT, MPI_SUM, mesh->comm());
        //     2) Determine how many faces will be created on each process
        //        This will be bounded by faceSize*submeshCells
        //        Thus it looks like we should first accumulate submeshCells, and then create faces
        MPI_Scan(&localFaces, &maxFaces, 1, MPI_INT, MPI_SUM, mesh->comm());
        f += maxFaces - localFaces;
      }
      for(typename PointSet::const_iterator c_iter = submeshCells.begin(); c_iter != submeshCells.end(); ++c_iter) {
        if (debug) std::cout << "  Processing submesh cell " << *c_iter << std::endl;
        const Obj<typename sieveAlg::coneArray>& cone = sieveAlg::nCone(mesh, *c_iter, height);
        const typename sieveAlg::coneArray::iterator vBegin = cone->begin();
        const typename sieveAlg::coneArray::iterator vEnd   = cone->end();

        face->clear();
        for(typename sieveAlg::coneArray::iterator v_iter = vBegin; v_iter != vEnd; ++v_iter) {
          if (submeshVertices.find(*v_iter) != svEnd) {
            if (debug) std::cout << "    contains submesh vertex " << *v_iter << std::endl;
            face->insert(face->end(), *v_iter);
          }
        }
        if ((int) face->size() > faceSize) {
          // Here we allow a set of vertices to lie completely on a boundary cell (like a corner tetrahedron)
          //   We have to take all the faces, and discard those in the interior
          FaceInserter inserter(mesh, sieve, subSieve, f, *c_iter, numCorners, indices, &origVertices, &faceVertices, &submeshCells);
          PointArray   faceVec(face->begin(), face->end());

          subsets(faceVec, faceSize, inserter);
        }
        if ((int) face->size() == faceSize) {
          insertFace(mesh, subSieve, face, f, *c_iter, numCorners, indices, &origVertices, &faceVertices);
        }
      }
      delete [] indices;
      submesh->setSieve(subSieve);
      submesh->stratify();
      if (debug) submesh->view("Submesh");
      return submesh;
    };
    // This takes in a section and creates a submesh from the vertices in the section chart
    //   This is a hyperplane of one dimension lower than the mesh
    static Obj<mesh_type> submesh_interpolated(const Obj<mesh_type>& mesh, const Obj<int_section_type>& label, const int dimension = -1, const bool boundaryFaces = true) {
      const int debug  = mesh->debug();
      const int depth  = mesh->depth();
      const int height = mesh->height();
      const typename int_section_type::chart_type&                chart        = label->getChart();
      const typename int_section_type::chart_type::const_iterator chartEnd     = chart.end();
      const Obj<PointSet>                                         submeshFaces = new PointSet();
      PointSet submeshVertices;

      for(typename int_section_type::chart_type::const_iterator c_iter = chart.begin(); c_iter != chartEnd; ++c_iter) {
        //assert(!mesh->depth(*c_iter));
        submeshVertices.insert(*c_iter);
      }
      const typename PointSet::const_iterator svBegin = submeshVertices.begin();
      const typename PointSet::const_iterator svEnd   = submeshVertices.end();

      for(typename PointSet::const_iterator sv_iter = svBegin; sv_iter != svEnd; ++sv_iter) {
        const Obj<typename sieveAlg::supportArray>& faces = sieveAlg::nSupport(mesh, *sv_iter, depth-1);
        const typename sieveAlg::supportArray::iterator fBegin = faces->begin();
        const typename sieveAlg::supportArray::iterator fEnd   = faces->end();
    
        if (debug) std::cout << "Checking submesh vertex " << *sv_iter << std::endl;
        for(typename sieveAlg::supportArray::iterator f_iter = fBegin; f_iter != fEnd; ++f_iter) {
          if (debug) std::cout << "  Checking face " << *f_iter << std::endl;
          if (submeshFaces->find(*f_iter) != submeshFaces->end())	continue;
          const Obj<typename sieveAlg::coneArray>& cone = sieveAlg::nCone(mesh, *f_iter, height-1);
          const typename sieveAlg::coneArray::iterator vBegin = cone->begin();
          const typename sieveAlg::coneArray::iterator vEnd   = cone->end();
          bool                                         found  = true;

          for(typename sieveAlg::coneArray::iterator v_iter = vBegin; v_iter != vEnd; ++v_iter) {
            if (submeshVertices.find(*v_iter) != svEnd) {
              if (debug) std::cout << "    contains submesh vertex " << *v_iter << std::endl;
            } else {
              found = false;
            }
          }
          if (found) {
            if (boundaryFaces) {throw ALE::Exception("Not finished: should check that it is a boundary face");}
            if (debug) std::cout << "  Is a face on the submesh" << std::endl;
            submeshFaces->insert(*f_iter);
          }
        }
      }
      return submesh(mesh, submeshFaces, mesh->getDimension()-1);
    };
    template<typename output_mesh_type>
    static Obj<output_mesh_type> submeshV_uninterpolated(const Obj<mesh_type>& mesh, const Obj<int_section_type>& label, const int dimension = -1, const bool boundaryFaces = true) {
      typedef typename mesh_type::label_type        label_type;
      typedef typename int_section_type::chart_type chart_type;
      const int                           dim        = (dimension > 0) ? dimension : mesh->getDimension()-1;
      const Obj<sieve_type>&              sieve      = mesh->getSieve();
      Obj<ALE::Mesh>                      submesh    = new ALE::Mesh(mesh->comm(), dim, mesh->debug());
      Obj<typename ALE::Mesh::sieve_type> subSieve   = new typename ALE::Mesh::sieve_type(mesh->comm(), mesh->debug());
      const bool                          censor     = mesh->hasLabel("censored depth");
      const Obj<label_type>&              depthLabel = censor ? mesh->getLabel("censored depth") : mesh->getLabel("depth");
      const chart_type&                   chart      = label->getChart();
      const int                           numCorners = mesh->getNumCellCorners();
      const int                           faceSize   = numFaceVertices(mesh);
      Obj<PointSet>                       face       = new PointSet();
      int                                 f          = sieve->getBaseSize() + sieve->getCapSize();
      const int                           debug      = mesh->debug();
      int                                *indices    = new int[faceSize];
      PointArray                          origVertices, faceVertices;
      PointSet                            submeshVertices, submeshCells;

      const typename chart_type::const_iterator chartEnd = chart.end();
      for(typename chart_type::const_iterator c_iter = chart.begin(); c_iter != chartEnd; ++c_iter) {
        if (label->getFiberDimension(*c_iter)) submeshVertices.insert(*c_iter);
      }
      const typename PointSet::const_iterator svBegin = submeshVertices.begin();
      const typename PointSet::const_iterator svEnd   = submeshVertices.end();
      typename ISieveVisitor::PointRetriever<sieve_type> sV(sieve->getMaxSupportSize());
      typename ISieveVisitor::PointRetriever<sieve_type> cV(sieve->getMaxConeSize());

      for(typename PointSet::const_iterator sv_iter = svBegin; sv_iter != svEnd; ++sv_iter) {
        sieve->support(*sv_iter, sV);
        const int         numCells = sV.getSize();
        const point_type *cells    = sV.getPoints();
    
        if (debug) std::cout << "Checking submesh vertex " << *sv_iter << std::endl;
        for(int c = 0; c < numCells; ++c) {
          if (debug) std::cout << "  Checking cell " << cells[c] << std::endl;
          if (submeshCells.find(cells[c]) != submeshCells.end()) continue;
          if (censor && (!mesh->getValue(depthLabel, cells[c]))) continue;
          sieve->cone(cells[c], cV);
          const int         numVertices = cV.getSize();
          const point_type *vertices    = cV.getPoints();

          face->clear();
          for(int v = 0; v < numVertices; ++v) {
            if (submeshVertices.find(vertices[v]) != svEnd) {
              if (debug) std::cout << "    contains submesh vertex " << vertices[v] << std::endl;
              face->insert(face->end(), vertices[v]);
            }
          }
          if ((int) face->size() > faceSize) {
            if (!boundaryFaces) throw ALE::Exception("Invalid fault mesh: Too many vertices of an element on the fault");
            if (debug) std::cout << "  Has all boundary faces on the submesh" << std::endl;
            submeshCells.insert(cells[c]);
          }
          if ((int) face->size() == faceSize) {
            if (debug) std::cout << "  Contains a face on the submesh" << std::endl;
            submeshCells.insert(cells[c]);
          }
          cV.clear();
        }
        sV.clear();
      }
      if (mesh->commSize() > 1) {
        int localF     = f;
        int localFaces = binomial(numCorners, faceSize)*submeshCells.size();
        int maxFaces;

        MPI_Allreduce(&localF, &f, 1, MPI_INT, MPI_SUM, mesh->comm());
        //     2) Determine how many faces will be created on each process
        //        This will be bounded by faceSize*submeshCells
        //        Thus it looks like we should first accumulate submeshCells, and then create faces
        MPI_Scan(&localFaces, &maxFaces, 1, MPI_INT, MPI_SUM, mesh->comm());
        f += maxFaces - localFaces;
      }
      for(typename PointSet::const_iterator c_iter = submeshCells.begin(); c_iter != submeshCells.end(); ++c_iter) {
        if (debug) std::cout << "  Processing submesh cell " << *c_iter << std::endl;
        sieve->cone(*c_iter, cV);
        const int         numVertices = cV.getSize();
        const point_type *vertices    = cV.getPoints();

        face->clear();
        for(int v = 0; v < numVertices; ++v) {
          if (submeshVertices.find(vertices[v]) != svEnd) {
            if (debug) std::cout << "    contains submesh vertex " << vertices[v] << std::endl;
            face->insert(face->end(), vertices[v]);
          }
        }
        if ((int) face->size() > faceSize) {
          if (!boundaryFaces) throw ALE::Exception("Invalid fault mesh: Too many vertices of an element on the fault");
          // Here we allow a set of vertices to lie completely on a boundary cell (like a corner tetrahedron)
          //   We have to take all the faces, and discard those in the interior
          FaceInserterV<ALE::Mesh::sieve_type> inserter(mesh, sieve, subSieve, f, *c_iter, numCorners, indices, &origVertices, &faceVertices, &submeshCells);
          PointArray                           faceVec(face->begin(), face->end());

          subsets(faceVec, faceSize, inserter);
        }
        if ((int) face->size() == faceSize) {
          insertFace(mesh, subSieve, face, f, *c_iter, numCorners, indices, &origVertices, &faceVertices);
        }
        cV.clear();
      }
      delete [] indices;
      submesh->setSieve(subSieve);
      submesh->stratify();
      if (debug) submesh->view("Submesh");

      Obj<output_mesh_type> isubmesh = new output_mesh_type(submesh->comm(), submesh->getDimension(), submesh->debug());
      Obj<typename output_mesh_type::sieve_type> isieve = new typename output_mesh_type::sieve_type(submesh->comm(), submesh->debug());
      std::map<typename output_mesh_type::point_type,typename output_mesh_type::point_type> renumbering;
      isubmesh->setSieve(isieve);
      ALE::ISieveConverter::convertMesh(*submesh, *isubmesh, renumbering, false);
      return isubmesh;
    };
  public:
    // This takes in a section and creates a submesh from the vertices in the section chart
    //   This is a hyperplane of one dimension lower than the mesh
    static Obj<mesh_type> submesh(const Obj<mesh_type>& mesh, const Obj<int_section_type>& label, const int dimension = -1) {
      const int dim   = mesh->getDimension();
      const int depth = mesh->depth();

      if (dim == depth) {
        return submesh_interpolated(mesh, label, dimension, false);
      } else if (depth == 1) {
        return submesh_uninterpolated(mesh, label, dimension);
      }
      throw ALE::Exception("Cannot handle partially interpolated meshes");
    };
    template<typename output_mesh_type>
    static Obj<output_mesh_type> submeshV(const Obj<mesh_type>& mesh, const Obj<int_section_type>& label, const int dimension = -1) {
      const int dim   = mesh->getDimension();
      const int depth = mesh->depth();

#if 0
      if (dim == depth) {
        //return submesh_interpolated(mesh, label, dimension, false);
        throw ALE::Exception("Cannot handle interpolated meshes");
      } else if (depth == 1) {
        return submeshV_uninterpolated<output_mesh_type>(mesh, label, dimension);
      }
#else
      if (depth == 1) {
        return submeshV_uninterpolated<output_mesh_type>(mesh, label, dimension);
      } else if (dim == depth) {
        //return submesh_interpolated(mesh, label, dimension, false);
        throw ALE::Exception("Cannot handle interpolated meshes");
      }
#endif
      throw ALE::Exception("Cannot handle partially interpolated meshes");
    };
    // This creates a submesh consisting of the union of the closures of the given points
    //   This mesh is the same dimension as in the input mesh
    template<typename Points>
    static Obj<mesh_type> submesh(const Obj<mesh_type>& mesh, const Obj<Points>& points, const int dim = -1) {
      const Obj<sieve_type>& sieve     = mesh->getSieve();
      Obj<mesh_type>         newMesh   = new mesh_type(mesh->comm(), dim >= 0 ? dim : mesh->getDimension(), mesh->debug());
      Obj<sieve_type>        newSieve  = new sieve_type(mesh->comm(), mesh->debug());
      Obj<PointSet>          newPoints = new PointSet();
      Obj<PointSet>          modPoints = new PointSet();
      Obj<PointSet>          tmpPoints;

      newMesh->setSieve(newSieve);
      for(typename Points::iterator p_iter = points->begin(); p_iter != points->end(); ++p_iter) {
        newPoints->insert(*p_iter);
        do {
          modPoints->clear();
          for(typename PointSet::iterator np_iter = newPoints->begin(); np_iter != newPoints->end(); ++np_iter) {
            const Obj<typename sieve_type::traits::coneSequence>&     cone = sieve->cone(*np_iter);
            const typename sieve_type::traits::coneSequence::iterator end  = cone->end();
            int c = 0;

            for(typename sieve_type::traits::coneSequence::iterator c_iter = cone->begin(); c_iter != end; ++c_iter, ++c) {
              newSieve->addArrow(*c_iter, *np_iter, c);
            }
            modPoints->insert(cone->begin(), cone->end());
          }
          tmpPoints = newPoints;
          newPoints = modPoints;
          modPoints = tmpPoints;
        } while(newPoints->size());
        newPoints->insert(*p_iter);
        do {
          modPoints->clear();
          for(typename PointSet::iterator np_iter = newPoints->begin(); np_iter != newPoints->end(); ++np_iter) {
            const Obj<typename sieve_type::traits::supportSequence>&     support = sieve->support(*np_iter);
            const typename sieve_type::traits::supportSequence::iterator end     = support->end();
            int s = 0;

            for(typename sieve_type::traits::supportSequence::iterator s_iter = support->begin(); s_iter != end; ++s_iter, ++s) {
              newSieve->addArrow(*np_iter, *s_iter, s);
            }
            modPoints->insert(support->begin(), support->end());
          }
          tmpPoints = newPoints;
          newPoints = modPoints;
          modPoints = tmpPoints;
        } while(newPoints->size());
      }
      newMesh->stratify();
      newMesh->setRealSection("coordinates", mesh->getRealSection("coordinates"));
      newMesh->setArrowSection("orientation", mesh->getArrowSection("orientation"));
      return newMesh;
    };
  protected:
    static Obj<mesh_type> boundary_uninterpolated(const Obj<mesh_type>& mesh) {
      throw ALE::Exception("Not yet implemented");
      const Obj<typename mesh_type::label_sequence>&     cells    = mesh->heightStratum(0);
      const Obj<sieve_type>&                             sieve    = mesh->getSieve();
      const typename mesh_type::label_sequence::iterator cBegin   = cells->begin();
      const typename mesh_type::label_sequence::iterator cEnd     = cells->end();
      const int                                          faceSize = numFaceVertices(mesh);

      for(typename mesh_type::label_sequence::iterator c_iter = cBegin; c_iter != cEnd; ++c_iter) {
        const Obj<typename sieve_type::traits::coneSequence>&     vertices = sieve->cone(*c_iter);
        const typename sieve_type::traits::coneSequence::iterator vBegin   = vertices->begin();
        const typename sieve_type::traits::coneSequence::iterator vEnd     = vertices->end();
        //PointArray cell(vertices->begin(), vertices->end());

        // For each vertex, gather 
        for(typename sieve_type::traits::coneSequence::iterator v_iter = vBegin; v_iter != vEnd; ++v_iter) {
          const Obj<typename sieve_type::traits::supportSequence>&     neighbors = sieve->support(*v_iter);
          const typename sieve_type::traits::supportSequence::iterator nBegin    = neighbors->begin();
          const typename sieve_type::traits::supportSequence::iterator nEnd      = neighbors->end();

          for(typename sieve_type::traits::supportSequence::iterator n_iter = nBegin; n_iter != nEnd; ++n_iter) {
            const Obj<typename sieve_type::coneSet>& preFace = sieve->nMeet(*c_iter, *n_iter, 1);

            if (preFace->size() == faceSize) {
            }
          }
        }
        // For each face
        // - determine if its legal
        
        // - determine if its part of a neighboring cell
        // - if not, its a boundary face
        //subsets(cell, faceSize, inserter);
      }
    };
    static void addClosure(const Obj<sieve_type>& sieveA, const Obj<sieve_type>& sieveB, const point_type& p, const int depth = 1) {
      Obj<typename sieve_type::coneSet> current = new typename sieve_type::coneSet();
      Obj<typename sieve_type::coneSet> next    = new typename sieve_type::coneSet();
      Obj<typename sieve_type::coneSet> tmp;

      current->insert(p);
      while(current->size()) {
        for(typename sieve_type::coneSet::const_iterator p_iter = current->begin(); p_iter != current->end(); ++p_iter) {
          const Obj<typename sieve_type::traits::coneSequence>&     cone  = sieveA->cone(*p_iter);
          const typename sieve_type::traits::coneSequence::iterator begin = cone->begin();
          const typename sieve_type::traits::coneSequence::iterator end   = cone->end();

          for(typename sieve_type::traits::coneSequence::iterator c_iter = begin; c_iter != end; ++c_iter) {
            sieveB->addArrow(*c_iter, *p_iter, c_iter.color());
            next->insert(*c_iter);
          }
        }
        tmp = current; current = next; next = tmp;
        next->clear();
      }
      if (!depth) {
        const Obj<typename sieve_type::traits::supportSequence>&     support = sieveA->support(p);
        const typename sieve_type::traits::supportSequence::iterator begin   = support->begin();
        const typename sieve_type::traits::supportSequence::iterator end     = support->end();
            
        for(typename sieve_type::traits::supportSequence::iterator s_iter = begin; s_iter != end; ++s_iter) {
          sieveB->addArrow(p, *s_iter, s_iter.color());
          next->insert(*s_iter);
        }
      }
    };
    static Obj<mesh_type> boundary_interpolated(const Obj<mesh_type>& mesh, const int faceHeight = 1) {
      Obj<mesh_type>                                     newMesh  = new mesh_type(mesh->comm(), mesh->getDimension()-1, mesh->debug());
      Obj<sieve_type>                                    newSieve = new sieve_type(mesh->comm(), mesh->debug());
      const Obj<sieve_type>&                             sieve    = mesh->getSieve();
      const Obj<typename mesh_type::label_sequence>&     faces    = mesh->heightStratum(faceHeight);
      const typename mesh_type::label_sequence::iterator fBegin   = faces->begin();
      const typename mesh_type::label_sequence::iterator fEnd     = faces->end();
      const int                                          depth    = faceHeight - mesh->depth();

      for(typename mesh_type::label_sequence::iterator f_iter = fBegin; f_iter != fEnd; ++f_iter) {
        const Obj<typename sieve_type::traits::supportSequence>& support = sieve->support(*f_iter);

        if (support->size() == 1) {
          addClosure(sieve, newSieve, *f_iter, depth);
        }
      }
      newMesh->setSieve(newSieve);
      newMesh->stratify();
      return newMesh;
    };
    template<typename SieveTypeA, typename SieveTypeB>
    static void addClosureV(const Obj<SieveTypeA>& sieveA, const Obj<SieveTypeB>& sieveB, const point_type& p, const int depth = 1) {
      typedef std::set<typename SieveTypeA::point_type> coneSet;
      ALE::ISieveVisitor::PointRetriever<SieveTypeA> cV(std::max(1, sieveA->getMaxConeSize()));
      Obj<coneSet> current = new coneSet();
      Obj<coneSet> next    = new coneSet();
      Obj<coneSet> tmp;

      current->insert(p);
      while(current->size()) {
        for(typename coneSet::const_iterator p_iter = current->begin(); p_iter != current->end(); ++p_iter) {
          sieveA->cone(*p_iter, cV);
          const typename SieveTypeA::point_type *cone = cV.getPoints();

          for(int c = 0; c < (int) cV.getSize(); ++c) {
            sieveB->addArrow(cone[c], *p_iter);
            next->insert(cone[c]);
          }
          cV.clear();
        }
        tmp = current; current = next; next = tmp;
        next->clear();
      }
      if (!depth) {
        ALE::ISieveVisitor::PointRetriever<SieveTypeA> sV(std::max(1, sieveA->getMaxSupportSize()));

        sieveA->support(p, sV);
        const typename SieveTypeA::point_type *support = sV.getPoints();
            
        for(int s = 0; s < (int) sV.getSize(); ++s) {
          sieveB->addArrow(p, support[s]);
        }
        sV.clear();
      }
    };
  public:
    static Obj<mesh_type> boundary(const Obj<mesh_type>& mesh) {
      const int dim   = mesh->getDimension();
      const int depth = mesh->depth();

      if (dim == depth) {
        return boundary_interpolated(mesh);
      } else if (depth == dim+1) {
        return boundary_interpolated(mesh, 2);
      } else if (depth == 1) {
        return boundary_uninterpolated(mesh);
      } else if (depth == -1) {
        Obj<mesh_type>  newMesh  = new mesh_type(mesh->comm(), mesh->getDimension()-1, mesh->debug());
        Obj<sieve_type> newSieve = new sieve_type(mesh->comm(), mesh->debug());

        newMesh->setSieve(newSieve);
        newMesh->stratify();
        return newMesh;
      }
      throw ALE::Exception("Cannot handle partially interpolated meshes");
    };
    template<typename MeshTypeQ>
    static Obj<ALE::Mesh> boundaryV_uninterpolated(const Obj<MeshTypeQ>& mesh, const int faceHeight = 1) {
        throw ALE::Exception("Cannot handle uninterpolated meshes");
    };
    // This method takes in an interpolated mesh, and returns the boundary
    template<typename MeshTypeQ>
    static Obj<ALE::Mesh> boundaryV_interpolated(const Obj<MeshTypeQ>& mesh, const int faceHeight = 1) {
      Obj<ALE::Mesh>                                      newMesh  = new ALE::Mesh(mesh->comm(), mesh->getDimension()-1, mesh->debug());
      Obj<typename ALE::Mesh::sieve_type>                 newSieve = new typename ALE::Mesh::sieve_type(mesh->comm(), mesh->debug());
      const Obj<typename MeshTypeQ::sieve_type>&          sieve    = mesh->getSieve();
      const Obj<typename MeshTypeQ::label_sequence>&      faces    = mesh->heightStratum(faceHeight);
      const typename MeshTypeQ::label_sequence::iterator  fBegin   = faces->begin();
      const typename MeshTypeQ::label_sequence::iterator  fEnd     = faces->end();
      const int                                           depth    = faceHeight - mesh->depth();
      ALE::ISieveVisitor::PointRetriever<sieve_type>      sV(std::max(1, sieve->getMaxSupportSize()));

      for(typename MeshTypeQ::label_sequence::iterator f_iter = fBegin; f_iter != fEnd; ++f_iter) {
        sieve->support(*f_iter, sV);

        if (sV.getSize() == 1) {
          addClosureV(sieve, newSieve, *f_iter, depth);
        }
        sV.clear();
      }
      newMesh->setSieve(newSieve);
      newMesh->stratify();
      return newMesh;
    };
    template<typename MeshTypeQ>
    static Obj<ALE::Mesh> boundaryV(const Obj<MeshTypeQ>& mesh, const int faceHeight = 1) {
      const int dim   = mesh->getDimension();
      const int depth = mesh->depth();

      if (dim == depth) {
        return boundaryV_interpolated(mesh);
      } else if (depth == dim+1) {
        return boundaryV_interpolated(mesh, 2);
      } else if (depth == 1) {
        throw ALE::Exception("Cannot handle uninterpolated meshes");
      } else if (depth == -1) {
        Obj<mesh_type>  newMesh  = new mesh_type(mesh->comm(), mesh->getDimension()-1, mesh->debug());
        Obj<sieve_type> newSieve = new sieve_type(mesh->comm(), mesh->debug());

        newMesh->setSieve(newSieve);
        newMesh->stratify();
        return newMesh;
      }
      throw ALE::Exception("Cannot handle partially interpolated meshes");
    };
  public:
    static Obj<mesh_type> interpolateMesh(const Obj<mesh_type>& mesh) {
      const Obj<sieve_type>                              sieve       = mesh->getSieve();
      const int  dim         = mesh->getDimension();
      const int  numVertices = mesh->depthStratum(0)->size();
      const Obj<typename mesh_type::label_sequence>&     cells       = mesh->heightStratum(0);
      const int  numCells    = cells->size();
      const int  corners     = sieve->cone(*cells->begin())->size();
      const int  firstVertex = numCells;
      const int  debug       = sieve->debug();
      Obj<mesh_type>                                     newMesh     = new mesh_type(mesh->comm(), dim, mesh->debug());
      Obj<sieve_type>                                    newSieve    = new sieve_type(mesh->comm(), mesh->debug());
      const Obj<typename mesh_type::arrow_section_type>& orientation = newMesh->getArrowSection("orientation");

      newMesh->setSieve(newSieve);
      // Create a map from dimension to the current element number for that dimension
      std::map<int,point_type*> curElement;
      std::map<int,PointArray>  bdVertices;
      std::map<int,PointArray>  faces;
      std::map<int,oPointArray> oFaces;
      int                       curCell    = 0;
      int                       curVertex  = firstVertex;
      int                       newElement = firstVertex+numVertices;
      int                       o;

      curElement[0]   = &curVertex;
      curElement[dim] = &curCell;
      for(int d = 1; d < dim; d++) {
        curElement[d] = &newElement;
      }
      typename mesh_type::label_sequence::iterator cBegin = cells->begin();
      typename mesh_type::label_sequence::iterator cEnd   = cells->end();

      for(typename mesh_type::label_sequence::iterator c_iter = cBegin; c_iter != cEnd; ++c_iter) {
        typename sieve_type::point_type                           cell   = *c_iter;
        const Obj<typename sieve_type::traits::coneSequence>&     cone   = sieve->cone(cell);
        const typename sieve_type::traits::coneSequence::iterator vBegin = cone->begin();
        const typename sieve_type::traits::coneSequence::iterator vEnd   = cone->end();

        // Build the cell
        bdVertices[dim].clear();
        for(typename sieve_type::traits::coneSequence::iterator v_iter = vBegin; v_iter != vEnd; ++v_iter) {
          typename sieve_type::point_type vertex(*v_iter);

          if (debug > 1) {std::cout << "Adding boundary vertex " << vertex << std::endl;}
          bdVertices[dim].push_back(vertex);
        }
        if (debug) {std::cout << "cell " << cell << " num boundary vertices " << bdVertices[dim].size() << std::endl;}

        if (corners != dim+1) {
          ALE::SieveBuilder<mesh_type>::buildHexFaces(newSieve, dim, curElement, bdVertices, faces, cell);
        } else {
          ALE::SieveBuilder<mesh_type>::buildFaces(newSieve, orientation, dim, curElement, bdVertices, oFaces, cell, o);
        }
      }
      newMesh->stratify();
      newMesh->setRealSection("coordinates", mesh->getRealSection("coordinates"));
      return newMesh;
    };
  };
}

#if 0
namespace ALE {
  class MySelection {
  public:
    typedef ALE::SieveAlg<ALE::Mesh> sieveAlg;
    typedef ALE::Selection<ALE::Mesh> selection;
    typedef ALE::Mesh::sieve_type sieve_type;
    typedef ALE::Mesh::int_section_type int_section_type;
    typedef ALE::Mesh::real_section_type real_section_type;
    typedef std::set<ALE::Mesh::point_type> PointSet;
    typedef std::vector<ALE::Mesh::point_type> PointArray;
  public:
    template<class InputPoints>
    static bool _compatibleOrientation(const Obj<Mesh>& mesh,
                                       const ALE::Mesh::point_type& p,
                                       const ALE::Mesh::point_type& q,
                                       const int numFaultCorners,
                                       const int faultFaceSize,
                                       const int faultDepth,
                                       const Obj<InputPoints>& points,
                                       int indices[],
                                       PointArray *origVertices,
                                       PointArray *faceVertices,
                                       PointArray *neighborVertices)
    {
      typedef ALE::Selection<ALE::Mesh> selection;
      const int debug = mesh->debug();
      bool compatible;

      bool eOrient = selection::getOrientedFace(mesh, p, points, numFaultCorners, indices, origVertices, faceVertices);
      bool nOrient = selection::getOrientedFace(mesh, q, points, numFaultCorners, indices, origVertices, neighborVertices);

      if (faultFaceSize > 1) {
        if (debug) {
          for(PointArray::iterator v_iter = faceVertices->begin(); v_iter != faceVertices->end(); ++v_iter) {
            std::cout << "  face vertex " << *v_iter << std::endl;
          }
          for(PointArray::iterator v_iter = neighborVertices->begin(); v_iter != neighborVertices->end(); ++v_iter) {
            std::cout << "  neighbor vertex " << *v_iter << std::endl;
          }
        }
        compatible = !(*faceVertices->begin() == *neighborVertices->begin());
      } else {
        compatible = !(nOrient == eOrient);
      }
      return compatible;
    };
    static void _replaceCell(const Obj<sieve_type>& sieve,
                             const ALE::Mesh::point_type cell,
                             std::map<int,int> *vertexRenumber,
                             const int debug)
    {
      bool       replace = false;
      PointArray newVertices;

      const Obj<sieve_type::traits::coneSequence>& cCone = sieve->cone(cell);

      for(sieve_type::traits::coneSequence::iterator v_iter = cCone->begin(); v_iter != cCone->end(); ++v_iter) {
        if (vertexRenumber->find(*v_iter) != vertexRenumber->end()) {
          if (debug) std::cout << "    vertex " << (*vertexRenumber)[*v_iter] << std::endl;
          newVertices.insert(newVertices.end(), (*vertexRenumber)[*v_iter]);
          replace = true;
        } else {
          if (debug) std::cout << "    vertex " << *v_iter << std::endl;
          newVertices.insert(newVertices.end(), *v_iter);
        } // if/else
      } // for
      if (replace) {
        if (debug) std::cout << "  Replacing cell " << cell << std::endl;
        sieve->clearCone(cell);
        int color = 0;
        for(PointArray::const_iterator v_iter = newVertices.begin(); v_iter != newVertices.end(); ++v_iter) {
          sieve->addArrow(*v_iter, cell, color++);
        } // for
      }
    };
    template<class InputPoints>
    static void _computeCensoredDepth(const Obj<ALE::Mesh>& mesh,
                                      const Obj<ALE::Mesh::label_type>& depth,
                                      const Obj<ALE::Mesh::sieve_type>& sieve,
                                      const Obj<InputPoints>& points,
                                      const ALE::Mesh::point_type& firstCohesiveCell,
                                      const Obj<std::set<ALE::Mesh::point_type> >& modifiedPoints)
    {
      modifiedPoints->clear();

      for(typename InputPoints::iterator p_iter = points->begin(); p_iter != points->end(); ++p_iter) {
        if (*p_iter >= firstCohesiveCell) continue;
        // Compute the max depth of the points in the cone of p, and add 1
        int d0 = mesh->getValue(depth, *p_iter, -1);
        int d1 = mesh->getMaxValue(depth, sieve->cone(*p_iter), -1) + 1;

        if(d1 != d0) {
          mesh->setValue(depth, *p_iter, d1);
          modifiedPoints->insert(*p_iter);
        }
      }
      // FIX: We would like to avoid the copy here with support()
      if(modifiedPoints->size() > 0) {
        _computeCensoredDepth(mesh, depth, sieve, sieve->support(modifiedPoints), firstCohesiveCell, modifiedPoints);
      }
    };
    static void create(const Obj<Mesh>& mesh, Obj<Mesh> fault, const Obj<Mesh::int_section_type>& groupField) {
      static PetscLogEvent CreateFaultMesh_Event = 0, OrientFaultMesh_Event = 0, AddCohesivePoints_Event = 0, SplitMesh_Event = 0;

      if (!CreateFaultMesh_Event) {
        PetscLogEventRegister("CreateFaultMesh", 0,&CreateFaultMesh_Event);
      }
      if (!OrientFaultMesh_Event) {
        PetscLogEventRegister("OrientFaultMesh", 0,&OrientFaultMesh_Event);
      }
      if (!AddCohesivePoints_Event) {
        PetscLogEventRegister("AddCohesivePoints", 0,&AddCohesivePoints_Event);
      }
      if (!SplitMesh_Event) {
        PetscLogEventRegister("SplitMesh", 0,&SplitMesh_Event);
      }

      const Obj<sieve_type>& sieve = mesh->getSieve();
      const int  debug      = mesh->debug();
      int        numCorners = 0;    // The number of vertices in a mesh cell
      int        faceSize   = 0;    // The number of vertices in a mesh face
      int       *indices    = NULL; // The indices of a face vertex set in a cell
      PointArray origVertices;
      PointArray faceVertices;
      PointArray neighborVertices;
      const bool constraintCell = false;

      if (!mesh->commRank()) {
        numCorners = sieve->nCone(*mesh->heightStratum(0)->begin(), mesh->depth())->size();
        faceSize   = selection::numFaceVertices(mesh);
        indices    = new int[faceSize];
      }

      //int f = sieve->base()->size() + sieve->cap()->size();
      //ALE::Obj<PointSet> face = new PointSet();
  
      // Create a sieve which captures the fault
      PetscLogEventBegin(CreateFaultMesh_Event,0,0,0,0);
      fault = ALE::Selection<ALE::Mesh>::submesh(mesh, groupField);
      if (debug) {fault->view("Fault mesh");}
      PetscLogEventEnd(CreateFaultMesh_Event,0,0,0,0);
      // Orient the fault sieve
      PetscLogEventBegin(OrientFaultMesh_Event,0,0,0,0);
      const Obj<sieve_type>&                faultSieve = fault->getSieve();
      const ALE::Obj<Mesh::label_sequence>& fFaces     = fault->heightStratum(1);
      int faultDepth      = fault->depth()-1; // Depth of fault cells
      int numFaultCorners = 0; // The number of vertices in a fault cell

      if (!fault->commRank()) {
        numFaultCorners = faultSieve->nCone(*fFaces->begin(), faultDepth)->size();
        if (debug) std::cout << "  Fault corners " << numFaultCorners << std::endl;
        assert(numFaultCorners == faceSize);
      }
      PetscLogEventEnd(OrientFaultMesh_Event,0,0,0,0);

      // Add new shadow vertices and possibly Lagrange multipler vertices
      PetscLogEventBegin(AddCohesivePoints_Event,0,0,0,0);
      const ALE::Obj<Mesh::label_sequence>&   fVertices  = fault->depthStratum(0);
      const ALE::Obj<std::set<std::string> >& groupNames = mesh->getIntSections();
      Mesh::point_type newPoint = sieve->base()->size() + sieve->cap()->size();
      std::map<int,int> vertexRenumber;
  
      for(Mesh::label_sequence::iterator v_iter = fVertices->begin(); v_iter != fVertices->end(); ++v_iter, ++newPoint) {
        vertexRenumber[*v_iter] = newPoint;
        if (debug) {std::cout << "Duplicating " << *v_iter << " to " << vertexRenumber[*v_iter] << std::endl;}

        // Add shadow and constraint vertices (if they exist) to group
        // associated with fault
        groupField->addPoint(newPoint, 1);
        if (constraintCell) groupField->addPoint(newPoint+1, 1);

        // Add shadow vertices to other groups, don't add constraint
        // vertices (if they exist) because we don't want BC, etc to act
        // on constraint vertices
        for(std::set<std::string>::const_iterator name = groupNames->begin(); name != groupNames->end(); ++name) {
          const ALE::Obj<int_section_type>& group = mesh->getIntSection(*name);
          if (group->hasPoint(*v_iter)) group->addPoint(newPoint, 1);
        }
        if (constraintCell) newPoint++;
      }
      for(std::set<std::string>::const_iterator name = groupNames->begin(); name != groupNames->end(); ++name) {
        mesh->reallocate(mesh->getIntSection(*name));
      }

      // Split the mesh along the fault sieve and create cohesive elements
      const Obj<ALE::Mesh::label_sequence>&     faces       = fault->depthStratum(1);
      const Obj<ALE::Mesh::arrow_section_type>& orientation = mesh->getArrowSection("orientation");
      int firstCohesiveCell = newPoint;
      PointSet replaceCells;
      PointSet noReplaceCells;

      for(ALE::Mesh::label_sequence::iterator f_iter = faces->begin(); f_iter != faces->end(); ++f_iter, ++newPoint) {
        if (debug) std::cout << "Considering fault face " << *f_iter << std::endl;
        const ALE::Obj<sieve_type::traits::supportSequence>& cells = faultSieve->support(*f_iter);
        const ALE::Mesh::arrow_section_type::point_type arrow(*cells->begin(), *f_iter);
        bool reversed = orientation->restrictPoint(arrow)[0] < 0;
        const ALE::Mesh::point_type cell = *cells->begin();

        if (debug) std::cout << "  Checking orientation against cell " << cell << std::endl;
        if (numFaultCorners == 2) reversed = orientation->restrictPoint(arrow)[0] == -2;
        if (reversed) {
          replaceCells.insert(cell);
          noReplaceCells.insert(*(++cells->begin()));
        } else {
          replaceCells.insert(*(++cells->begin()));
          noReplaceCells.insert(cell);
        }
        //selection::getOrientedFace(mesh, cell, &vertexRenumber, numCorners, indices, &origVertices, &faceVertices);
        //const Obj<sieve_type::coneArray> faceCone = faultSieve->nCone(*f_iter, faultDepth);

        // Adding cohesive cell (not interpolated)
        const Obj<sieve_type::coneArray>&     fCone  = faultSieve->nCone(*f_iter, faultDepth);
        const sieve_type::coneArray::iterator fBegin = fCone->begin();
        const sieve_type::coneArray::iterator fEnd   = fCone->end();
        int color = 0;

        if (debug) {std::cout << "  Creating cohesive cell " << newPoint << std::endl;}
        for(sieve_type::coneArray::iterator v_iter = fBegin; v_iter != fEnd; ++v_iter) {
          if (debug) {std::cout << "    vertex " << *v_iter << std::endl;}
          sieve->addArrow(*v_iter, newPoint, color++);
        }
        for(sieve_type::coneArray::iterator v_iter = fBegin; v_iter != fEnd; ++v_iter) {
          if (debug) {std::cout << "    shadow vertex " << vertexRenumber[*v_iter] << std::endl;}
          sieve->addArrow(vertexRenumber[*v_iter], newPoint, color++);
        }
      }
      PetscLogEventEnd(AddCohesivePoints_Event,0,0,0,0);
      // Replace all cells with a vertex on the fault that share a face with this one, or with one that does
      PetscLogEventBegin(SplitMesh_Event,0,0,0,0);
      const int_section_type::chart_type&          chart    = groupField->getChart();
      const int_section_type::chart_type::iterator chartEnd = chart.end();

      for(PointSet::const_iterator v_iter = chart.begin(); v_iter != chartEnd; ++v_iter) {
        bool modified = true;

        while(modified) {
          modified = false;
          const Obj<sieve_type::traits::supportSequence>&     neighbors = sieve->support(*v_iter);
          const sieve_type::traits::supportSequence::iterator end       = neighbors->end();

          for(sieve_type::traits::supportSequence::iterator n_iter = neighbors->begin(); n_iter != end; ++n_iter) {
            if (replaceCells.find(*n_iter)   != replaceCells.end())   continue;
            if (noReplaceCells.find(*n_iter) != noReplaceCells.end()) continue;
            if (*n_iter >= firstCohesiveCell) continue;
            if (debug) std::cout << "  Checking fault neighbor " << *n_iter << std::endl;
            // If neighbors shares a faces with anyone in replaceCells, then add
            for(PointSet::const_iterator c_iter = replaceCells.begin(); c_iter != replaceCells.end(); ++c_iter) {
              const ALE::Obj<sieve_type::coneSet>& preFace = sieve->nMeet(*c_iter, *n_iter, mesh->depth());

              if ((int) preFace->size() == faceSize) {
                if (debug) std::cout << "    Scheduling " << *n_iter << " for replacement" << std::endl;
                replaceCells.insert(*n_iter);
                modified = true;
                break;
              }
            }
          }
        }
      }
      for(PointSet::const_iterator c_iter = replaceCells.begin(); c_iter != replaceCells.end(); ++c_iter) {
        _replaceCell(sieve, *c_iter, &vertexRenumber, debug);
      }
      if (!fault->commRank()) delete [] indices;
      mesh->stratify();
      const ALE::Obj<Mesh::label_type>& label          = mesh->createLabel(std::string("censored depth"));
      const ALE::Obj<PointSet>          modifiedPoints = new PointSet();
      _computeCensoredDepth(mesh, label, mesh->getSieve(), mesh->getSieve()->roots(), firstCohesiveCell, modifiedPoints);
      if (debug) mesh->view("Mesh with Cohesive Elements");

      // Fix coordinates
      const Obj<real_section_type>&         coordinates = mesh->getRealSection("coordinates");
      const Obj<ALE::Mesh::label_sequence>& fVertices2  = fault->depthStratum(0);

      for(ALE::Mesh::label_sequence::iterator v_iter = fVertices2->begin(); v_iter != fVertices2->end(); ++v_iter) {
        coordinates->addPoint(vertexRenumber[*v_iter], coordinates->getFiberDimension(*v_iter));
        if (constraintCell) {
          coordinates->addPoint(vertexRenumber[*v_iter]+1, coordinates->getFiberDimension(*v_iter));
        }
      }
      mesh->reallocate(coordinates);
      for(ALE::Mesh::label_sequence::iterator v_iter = fVertices2->begin(); v_iter != fVertices2->end(); ++v_iter) {
        coordinates->updatePoint(vertexRenumber[*v_iter], coordinates->restrictPoint(*v_iter));
        if (constraintCell) {
        coordinates->updatePoint(vertexRenumber[*v_iter]+1, coordinates->restrictPoint(*v_iter));
        }
      }
      if (debug) coordinates->view("Coordinates with shadow vertices");
      PetscLogEventEnd(SplitMesh_Event,0,0,0,0);
    };
  };
};
#endif

#endif