コード例 #1
0
ファイル: FiniteElement.cs プロジェクト: phamhathanh/2DFEM
 public FiniteElement(FEM3D.Node node0, FEM3D.Node node1, FEM3D.Node node2, FEM3D.Node node3)
 {
     var feNode0 = new Node(node0.Position, node1.Position, node2.Position, node3.Position, node0.Index, node0.IsInside);
     var feNode1 = new Node(node1.Position, node2.Position, node3.Position, node0.Position, node1.Index, node1.IsInside);
     var feNode2 = new Node(node2.Position, node3.Position, node0.Position, node1.Position, node2.Index, node2.IsInside);
     var feNode3 = new Node(node3.Position, node0.Position, node1.Position, node2.Position, node3.Index, node3.IsInside);
     Nodes = new ReadOnlyCollection<Node>(new[] { feNode0, feNode1, feNode2, feNode3 });
 }
コード例 #2
0
ファイル: IntegrationTest.cs プロジェクト: phamhathanh/2DFEM
        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);
        }
コード例 #3
0
ファイル: IntegrationTest.cs プロジェクト: phamhathanh/2DFEM
        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));
        }
コード例 #4
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));
        }