public void ElmtGridWrapperTest()
        {
            ICoordinate[,] coordinates = new ICoordinate[4, 3];
            coordinates[0, 0]          = new Coordinate(0, 0);
            coordinates[1, 0]          = new Coordinate(1, 0);
            coordinates[2, 0]          = new Coordinate(2, 0);
            coordinates[3, 0]          = new Coordinate(3, 0);

            coordinates[0, 1] = new Coordinate(0, 1);
            coordinates[1, 1] = new Coordinate(1.2, 1.1);
            coordinates[2, 1] = new Coordinate(2.4, 1.2);
            coordinates[3, 1] = new Coordinate(3.8, 1.3);

            coordinates[0, 2] = new Coordinate(0, 2);
            coordinates[1, 2] = new Coordinate(1.3, 2.1);
            coordinates[2, 2] = new Coordinate(2.9, 2.2);
            coordinates[3, 2] = new Coordinate(4.5, 2.3);

            Spatial2DCurveLinearGrid grid = new Spatial2DCurveLinearGrid()
            {
                Coordinates = coordinates,
                IsNodeBased = false,
            };

            Spatial2DGridWrapper wrapper = new Spatial2DGridWrapper(grid);

            Assert.AreEqual(ElementType.Polygon, wrapper.ElementType);
            Assert.AreEqual(6, wrapper.ElementCount);

            Assert.AreEqual(4, wrapper.GetVertexCount(0));
            Assert.AreEqual(4, wrapper.GetVertexCount(3));
            Assert.AreEqual(4, wrapper.GetVertexCount(8));
            Assert.AreEqual(4, wrapper.GetVertexCount(11));

            Assert.AreEqual(0, wrapper.GetVertexXCoordinate(0, 0));
            Assert.AreEqual(0, wrapper.GetVertexYCoordinate(0, 0));
            Assert.AreEqual(1, wrapper.GetVertexXCoordinate(0, 1));
            Assert.AreEqual(0, wrapper.GetVertexYCoordinate(0, 1));
            Assert.AreEqual(1.2, wrapper.GetVertexXCoordinate(0, 2));
            Assert.AreEqual(1.1, wrapper.GetVertexYCoordinate(0, 2));
            Assert.AreEqual(0, wrapper.GetVertexXCoordinate(0, 3));
            Assert.AreEqual(1, wrapper.GetVertexYCoordinate(0, 3));

            Assert.AreEqual(2.4, wrapper.GetVertexXCoordinate(5, 0));
            Assert.AreEqual(1.2, wrapper.GetVertexYCoordinate(5, 0));
            Assert.AreEqual(3.8, wrapper.GetVertexXCoordinate(5, 1));
            Assert.AreEqual(1.3, wrapper.GetVertexYCoordinate(5, 1));
            Assert.AreEqual(4.5, wrapper.GetVertexXCoordinate(5, 2));
            Assert.AreEqual(2.3, wrapper.GetVertexYCoordinate(5, 2));
            Assert.AreEqual(2.9, wrapper.GetVertexXCoordinate(5, 3));
            Assert.AreEqual(2.2, wrapper.GetVertexYCoordinate(5, 3));
        }
        public void ElementAreaOperationTest()
        {
            Spatial2DCurveLinearGrid grid = new Spatial2DCurveLinearGrid()
            {
                IsNodeBased = false,
                Caption     = "grid",
                Description = "grid"
            };

            grid.Coordinates       = new ICoordinate[3, 4];
            grid.Coordinates[0, 0] = new Coordinate(0, 0);
            grid.Coordinates[1, 0] = new Coordinate(5, 0);
            grid.Coordinates[2, 0] = new Coordinate(10, 0);

            grid.Coordinates[0, 1] = new Coordinate(0, 5);
            grid.Coordinates[1, 1] = new Coordinate(5, 5);
            grid.Coordinates[2, 1] = new Coordinate(10, 7);

            grid.Coordinates[0, 2] = new Coordinate(0, 12);
            grid.Coordinates[1, 2] = new Coordinate(5, 12);
            grid.Coordinates[2, 2] = new Coordinate(10, 16);

            grid.Coordinates[0, 3] = new Coordinate(0, 15);
            grid.Coordinates[1, 3] = new Coordinate(3, 17);
            grid.Coordinates[2, 3] = new Coordinate(7, 20);

            TestMperSOutput mperS = new TestMperSOutput("dummy", new Spatial2DGridWrapper(grid));

            foreach (double d in mperS.GetValues(null).GetElementValuesForTime <double>(0))
            {
                Assert.AreEqual(1.0, d);
            }

            ElementAreaOperationAdaptor adaptor = new ElementAreaOperationAdaptor("dummyadaptor", mperS);

            adaptor.Initialize();
            IQuantity quantity = adaptor.Quantity();

            Assert.AreEqual("vd: m/s * area^1", quantity.Caption);
            Assert.AreEqual("m/s * m^2", quantity.Unit.Caption);
            Assert.AreEqual(3, quantity.Unit.Dimension.GetPower(DimensionBase.Length));

            double[] values = adaptor.GetValues(null).GetElementValuesForTime <double>(0);
            Assert.AreEqual(25, values[0]);
            Assert.AreEqual(30, values[1]);
            Assert.AreEqual(35, values[2]);
            Assert.AreEqual(40, values[3]);
            Assert.AreEqual(17, values[4]);
            Assert.AreEqual(29, values[5]);

            adaptor.Arguments[0].Value = -1.0;
            adaptor.Initialize();
            quantity = adaptor.Quantity();
            Assert.AreEqual("vd: m/s * area^-1", quantity.Caption);
            Assert.AreEqual(-1, quantity.Unit.Dimension.GetPower(DimensionBase.Length));

            values = adaptor.GetValues(null).GetElementValuesForTime <double>(0);
            Assert.AreEqual(1.0 / 25, values[0]);
            Assert.AreEqual(1.0 / 30, values[1]);
            Assert.AreEqual(1.0 / 35, values[2]);
            Assert.AreEqual(1.0 / 40, values[3]);
            Assert.AreEqual(1.0 / 17, values[4]);
            Assert.AreEqual(1.0 / 29, values[5]);

            adaptor.Arguments[0].Value = 0.5;
            adaptor.Initialize();
            quantity = adaptor.Quantity();
            Assert.AreEqual("vd: m/s * area^0.5", quantity.Caption);
            Assert.AreEqual(2, quantity.Unit.Dimension.GetPower(DimensionBase.Length));

            values = adaptor.GetValues(null).GetElementValuesForTime <double>(0);
            Assert.AreEqual(5, values[0]);
            Assert.AreEqual(Math.Sqrt(30), values[1], 1e-12);
            Assert.AreEqual(Math.Sqrt(35), values[2], 1e-12);
            Assert.AreEqual(Math.Sqrt(40), values[3], 1e-12);
            Assert.AreEqual(Math.Sqrt(17), values[4], 1e-12);
            Assert.AreEqual(Math.Sqrt(29), values[5], 1e-12);
        }