Example #1
0
        /// <summary>
        /// Split the current block using the invariants calculated in getInvariants.
        /// </summary>
        /// <param name="invariants">a map of neighbor counts to elements</param>
        /// <param name="partition">the partition that is being refined</param>
        private void Split(Dictionary <IInvariant, SortedSet <int> > invariants, Partition partition)
        {
            var nonEmptyInvariants = invariants.Keys.Count;

            if (nonEmptyInvariants > 1)
            {
                var invariantKeys = new List <IInvariant>(invariants.Keys);
                partition.RemoveCell(currentBlockIndex);
                var k = currentBlockIndex;
                if (splitOrder == SplitOrder.Reverse)
                {
                    invariantKeys.Sort();
                }
                else
                {
                    invariantKeys.Sort((a, b) => - a.CompareTo(b));
                }
                foreach (var h in invariantKeys)
                {
                    var setH = invariants[h];
                    partition.InsertCell(k, setH);
                    blocksToRefine.Enqueue(setH);
                    k++;
                }
                // skip over the newly added blocks
                currentBlockIndex += nonEmptyInvariants - 1;
            }
        }
Example #2
0
        public void InsertCellTest()
        {
            int[][]         cellData = new int[][] { new[] { 0 }, new[] { 2 }, new[] { 3 } };
            Partition       p        = new Partition(cellData);
            SortedSet <int> cell     = new SortedSet <int>();

            cell.Add(1);
            p.InsertCell(1, cell);
            Assert.IsTrue(p.IsDiscrete());
        }