コード例 #1
0
 public override void InitLayer(double time, WBOneDemLayerOptions opts, Func <double, double, OvCell> initCellFunc, Func <double, double, OvBound> initBoundFunc)
 {
     base.InitLayer(time, opts, initCellFunc, initBoundFunc);
     foreach (var c in AllCells)
     {
         c.Sync();
     }
 }
コード例 #2
0
        public void InitBoundCellRefsTest1()
        {
            var opts = new WBOneDemLayerOptions()
            {
                LeftNodesCount  = 4,
                RightNodesCount = 4,
                RealNodesCount  = OvLayer.GetNumOfRealNodes(5),
                X_left          = 0,
                X_right         = 10
            };

            opts.SynchH();

            Assert.AreEqual(19, opts.AllNodesCount);

            var lr = new OvLayer();

            lr.InitLayer(0, opts, (t, x) => new OvCell(), (t, x) => new OvBound());
            lr.InitBoundCellRefs();

            Assert.AreEqual(5, lr.RealCells.Count);
            Assert.AreEqual(5, lr.RealCellsRev.Count);

            Assert.AreEqual(6, lr.RealBounds.Count);
            Assert.AreEqual(6, lr.RealBoundsRev.Count);

            Assert.AreEqual(2, lr.LeftCells.Count);
            Assert.AreEqual(2, lr.RightCells.Count);

            Assert.AreEqual(2, lr.LeftBounds.Count);
            Assert.AreEqual(2, lr.RightBounds.Count);

            Assert.AreEqual(9, lr.AllCells.Count);
            Assert.AreEqual(9, lr.AllCellsRev.Count);

            Assert.AreEqual(10, lr.AllBounds.Count);
            Assert.AreEqual(10, lr.AllBoundsRev.Count);

            Assert.IsNotNull(lr.AllCells[0].LeftBound);
            Assert.IsNotNull(lr.AllCellsRev[0].RightBound);

            Assert.IsNull(lr.AllBoundsRev[0].RightCell);
            Assert.IsNull(lr.AllBounds[0].LeftCell);

            foreach (var c in lr.AllCells)
            {
                Assert.IsTrue(c.RightBound != null || c.LeftBound != null);
            }
            foreach (var b in lr.AllBounds)
            {
                Assert.IsTrue(b.RightCell != null || b.LeftCell != null);
            }
        }