예제 #1
0
        public BaseGridTest()
        {
            double[] CellCentersX  = { 15, 15, 25, 25, 25, 25, 35, 35, 35, 35, 45, 45 };
            double[] CellCentersY  = { 25, 35, 15, 25, 35, 45, 15, 25, 35, 45, 25, 35 };
            double   cellSize      = 10.0;
            int      numberOfCells = 12;

            _gridInfo = new GridInfo(numberOfCells, CellCentersX, CellCentersY, cellSize);

            _baseGrid = new BaseGrid(_gridInfo);
        }
예제 #2
0
        public void GetXCoordinate()
        {
            WriteMethodNameToConsole("GetXCoordinate");
            Assert.AreEqual(10.0, _baseGrid.GetXCoordinate(0, 0));
            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(0, 1));
            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(0, 2));
            Assert.AreEqual(10.0, _baseGrid.GetXCoordinate(0, 3));

            Assert.AreEqual(10.0, _baseGrid.GetXCoordinate(1, 0));
            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(1, 1));
            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(1, 2));
            Assert.AreEqual(10.0, _baseGrid.GetXCoordinate(1, 3));

            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(2, 0));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(2, 1));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(2, 2));
            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(2, 3));

            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(3, 0));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(3, 1));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(3, 2));
            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(3, 3));

            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(4, 0));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(4, 1));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(4, 2));
            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(4, 3));

            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(5, 0));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(5, 1));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(5, 2));
            Assert.AreEqual(20.0, _baseGrid.GetXCoordinate(5, 3));

            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(6, 0));
            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(6, 1));
            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(6, 2));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(6, 3));

            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(7, 0));
            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(7, 1));
            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(7, 2));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(7, 3));

            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(8, 0));
            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(8, 1));
            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(8, 2));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(8, 3));

            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(9, 0));
            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(9, 1));
            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(9, 2));
            Assert.AreEqual(30.0, _baseGrid.GetXCoordinate(9, 3));

            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(10, 0));
            Assert.AreEqual(50.0, _baseGrid.GetXCoordinate(10, 1));
            Assert.AreEqual(50.0, _baseGrid.GetXCoordinate(10, 2));
            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(10, 3));

            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(11, 0));
            Assert.AreEqual(50.0, _baseGrid.GetXCoordinate(11, 1));
            Assert.AreEqual(50.0, _baseGrid.GetXCoordinate(11, 2));
            Assert.AreEqual(40.0, _baseGrid.GetXCoordinate(11, 3));

            // Now using a different contructor for GridInfo object

            double ox       = 1000.0;
            double oy       = 2000.0;
            double cellSize = 900.0;
            int    nx       = 2;
            int    ny       = 2;

            Oatc.OpenMI.Examples.ModelComponents.SpatialModels.GroundWaterModel.GridInfo gridInfo = new Oatc.OpenMI.Examples.ModelComponents.SpatialModels.GroundWaterModel.GridInfo(ox, oy, cellSize, nx, ny, 0);
            IElementSet elementSet = new Oatc.OpenMI.Examples.ModelComponents.SpatialModels.GroundWaterModel.BaseGrid(gridInfo);

            Assert.AreEqual(ox, elementSet.GetXCoordinate(0, 0));
            Assert.AreEqual(ox + cellSize, elementSet.GetXCoordinate(0, 1));
            Assert.AreEqual(ox + cellSize, elementSet.GetXCoordinate(0, 2));
            Assert.AreEqual(ox, elementSet.GetXCoordinate(0, 3));

            Assert.AreEqual(ox + cellSize * (nx - 1), elementSet.GetXCoordinate(nx * ny - 1, 0));
            Assert.AreEqual(ox + cellSize * nx, elementSet.GetXCoordinate(nx * ny - 1, 1));
            Assert.AreEqual(ox + cellSize * nx, elementSet.GetXCoordinate(nx * ny - 1, 2));
            Assert.AreEqual(ox + cellSize * (nx - 1), elementSet.GetXCoordinate(nx * ny - 1, 3));
        }
예제 #3
0
        public void ElementCount()
        {
            WriteMethodNameToConsole("ElementCount");
            Assert.AreEqual(12, _baseGrid.ElementCount);

            // Now using a different contructor for GridInfo object

            double ox       = 1000.0;
            double oy       = 2000.0;
            double cellSize = 900.0;
            int    nx       = 2;
            int    ny       = 2;

            Oatc.OpenMI.Examples.ModelComponents.SpatialModels.GroundWaterModel.GridInfo gridInfo = new Oatc.OpenMI.Examples.ModelComponents.SpatialModels.GroundWaterModel.GridInfo(ox, oy, cellSize, nx, ny, 0);
            IElementSet elementSet = new Oatc.OpenMI.Examples.ModelComponents.SpatialModels.GroundWaterModel.BaseGrid(gridInfo);

            Assert.AreEqual(4, elementSet.ElementCount);
        }