Пример #1
0
        public void IntegrationOf1ShouldEqualTheVolumn()
        {
            var node0 = new Node(new Vector3(0, 0, 0), 0, false);
            var node1 = new Node(new Vector3(1, 1, 1), 1, false);
            var node2 = new Node(new Vector3(1, 1, 0), 2, false);
            var node3 = new Node(new Vector3(0, 1, 0), 3, false);
            var finiteElement = new FiniteElement(node0, node1, node2, node3);

            Func<Vector3, double> function = v => 1;

            var result = Calculator.Integrate(function, finiteElement);
            Assert.AreEqual(1.0/6, result);
        }
Пример #2
0
        public void IntegrationShouldBeCorrect()
        {
            var node0 = new Node(new Vector3(0, 0, 0), 0, false);
            var node1 = new Node(new Vector3(0, 0, 1), 1, false);
            var node2 = new Node(new Vector3(1, 0, 0), 2, false);
            var node3 = new Node(new Vector3(0, 1, 0), 3, false);
            var finiteElement = new FiniteElement(node0, node1, node2, node3);

            Func<Vector3, double> function = v => Vector3.Dot(v, v);

            var result = Calculator.Integrate(function, finiteElement);
            var expected = 0.05;
            Assert.IsTrue(IsAlmostEqual(expected, result));
        }
Пример #3
0
        public void BasisFunctionShouldReturnSpecificValuesAtVertices()
        {
            var node0 = new Node(new Vector3(0, 0, 0), 0, false);
            var node1 = new Node(new Vector3(1, 1, 1), 1, false);
            var node2 = new Node(new Vector3(1, 1, 0), 2, false);
            var node3 = new Node(new Vector3(0, 1, 0), 3, false);

            var finiteElement = new FiniteElement(node0, node1, node2, node3);

            var phi0 = finiteElement.Nodes[0].Phi;
            Assert.AreEqual(1, phi0(node0.Position));
            Assert.AreEqual(0, phi0(node1.Position));
            Assert.AreEqual(0, phi0(node2.Position));
            Assert.AreEqual(0, phi0(node3.Position));
        }