double[,] BuildLocalMatrix(FiniteElement e)
        {
            Point p1 = Mesh.Points[e[0]];
            Point p2 = Mesh.Points[e[1]];
            Point p3 = Mesh.Points[e[2]];

            double hx = p2.X - p1.X;
            double hy = p3.Y - p1.Y;

            double avgB = GetAverageB(e);
            double mu   = e.Material.Mu(avgB);

            double[,] G = new double[FEMParameters.BasisSize, FEMParameters.BasisSize];

            double lambda = 1.0 / mu;

            for (int i = 0; i < FEMParameters.BasisSize; i++)
            {
                for (int j = 0; j < FEMParameters.BasisSize; j++)
                {
                    G[i, j] = lambda * P[i, j];
                }
            }

            return(G);
        }
Пример #2
0
        /// <summary>
        /// Получение конечного элемента с заданным типом.
        /// </summary>
        /// <param name="Type"> Тип конечного элемента (0 - трапеции, 1 - прямоугольники). </param>
        /// <returns> Конечный элемент с заданным типом. </returns>
        public FiniteElement Finit(int Type)
        {
            FiniteElement Clone = new FiniteElement();

            switch (Type)
            {
            case 0:
            {
                Clone.Points[0]   = new PointSpline(this.Points[0].X, this.Points[0].Y);
                Clone.Points[1]   = new PointSpline(this.Points[1].X, this.Points[1].Y);
                Clone.Points[2]   = new PointSpline(this.Points[2].X, this.Points[2].Y);
                Clone.Points[3]   = new PointSpline(this.Points[3].X, this.Points[3].Y);
                Clone.MATERIAL[0] = this.Materials[0];
                Clone.MATERIAL[1] = this.Materials[1];
            }; break;

            case 1:
            {
                Clone.Points[0]   = new PointSpline(this.Points[0].X, (this.Points[0].Y + this.Points[1].Y) / 2);
                Clone.Points[1]   = new PointSpline(this.Points[1].X, (this.Points[0].Y + this.Points[1].Y) / 2);
                Clone.Points[2]   = new PointSpline(this.Points[2].X, (this.Points[2].Y + this.Points[3].Y) / 2);
                Clone.Points[3]   = new PointSpline(this.Points[3].X, (this.Points[2].Y + this.Points[3].Y) / 2);
                Clone.MATERIAL[0] = this.Materials[0];
                Clone.MATERIAL[1] = this.Materials[1];
            }; break;
            }
            return(Clone);
        }
        double[] BuildLocalB(FiniteElement e)
        {
            Point p1 = Mesh.Points[e[0]];
            Point p2 = Mesh.Points[e[1]];
            Point p3 = Mesh.Points[e[2]];

            double hx = p2.X - p1.X;
            double hy = p3.Y - p1.Y;

            double[] B = new double[FEMParameters.BasisSize];
            double   J = e.Material.J;

            for (int i = 0; i < FEMParameters.BasisSize; i++)
            {
                for (int j = 0; j < FEMParameters.BasisSize; j++)
                {
                    B[i] += localM[i, j] * J;
                }
            }

            for (int i = 0; i < FEMParameters.BasisSize; i++)
            {
                B[i] *= hx * hy / 36;
            }

            return(B);
        }
 void AddToGlobalB(double[] B, FiniteElement e, double[] local)
 {
     for (int i = 0; i < FEMParameters.BasisSize; i++)
     {
         B[e[i]] += local[i];
     }
 }
        /*
         * private Matrix GetVariableMatrixOnElement(FiniteElement element, double ksi, double eta)
         * {
         *  Matrix VariableMatrix = new Matrix(4, 4);
         *  Vector du = previousRes.DU(ksi, eta, element);
         *  double d1u1 = du[0];
         *  double d3u3 = du[1];
         *  double d3u1 = du[2];
         *  double d1u3 = du[3];
         *
         *  VariableMatrix[0, 0] = 1.5 * M1 * d1u1 + 0.5 * M2 * d3u3;
         *  VariableMatrix[0, 1] = M2 * d3u3 + M2 * d1u1;
         *  VariableMatrix[0, 2] = M2 * d3u1 + G13 * (2 * d3u1 + d1u3);
         *  VariableMatrix[0, 3] = M1 * d1u3 + G13 * d1u1;
         *
         *  VariableMatrix[1, 1] = 1.5 * M3 * d3u3 + 0.5 * M2 * d1u1;
         *  VariableMatrix[1, 2] = M3 * d3u1 + G13 * d1u3;
         *  VariableMatrix[1, 3] = M2 * d1u3 + G13 * (2 * d1u3 + d3u1);
         *
         *  VariableMatrix[2, 2] = 0.5 * M3 * d3u3 + (0.5 * M2 + G13)*d1u1;
         *  VariableMatrix[2, 3] = G13 * (d3u3 + d1u1);
         *
         *  VariableMatrix[3, 3] = 0.5 * M1 * d1u1 + (0.5 * M2 + G13) * d3u3;
         *
         *  return VariableMatrix;
         * }*/

        private Matrix GetLocalDerivativeMatrix(FiniteElement element, double ksi, double eta)
        {
            Matrix LocalDerivativeMatrix = new Matrix(8, 4);

            Matrix gradNksieta = new Matrix(2, 4);

            gradNksieta[0, 0] = (eta - 1) * 0.25;
            gradNksieta[1, 0] = (ksi - 1) * 0.25;
            gradNksieta[0, 1] = (1 - eta) * 0.25;
            gradNksieta[1, 1] = (-ksi - 1) * 0.25;
            gradNksieta[0, 2] = (eta + 1) * 0.25;
            gradNksieta[1, 2] = (ksi + 1) * 0.25;
            gradNksieta[0, 3] = (-eta - 1) * 0.25;
            gradNksieta[1, 3] = (1 - ksi) * 0.25;

            Jacobian J = new Jacobian();

            J.Element = element;

            Matrix gradN = J.GetInverseJacobian(ksi, eta) * gradNksieta;

            LocalDerivativeMatrix[0, 0] = LocalDerivativeMatrix[1, 3] = gradN[0, 0];
            LocalDerivativeMatrix[2, 0] = LocalDerivativeMatrix[3, 3] = gradN[0, 1];
            LocalDerivativeMatrix[4, 0] = LocalDerivativeMatrix[5, 3] = gradN[0, 2];
            LocalDerivativeMatrix[6, 0] = LocalDerivativeMatrix[7, 3] = gradN[0, 3];

            LocalDerivativeMatrix[1, 1] = LocalDerivativeMatrix[0, 2] = gradN[1, 0];
            LocalDerivativeMatrix[3, 1] = LocalDerivativeMatrix[2, 2] = gradN[1, 1];
            LocalDerivativeMatrix[5, 1] = LocalDerivativeMatrix[4, 2] = gradN[1, 2];
            LocalDerivativeMatrix[7, 1] = LocalDerivativeMatrix[6, 2] = gradN[1, 3];

            return(LocalDerivativeMatrix);
        }
Пример #6
0
 public void SetUp()
 {
     nodeFactory    = new NodeFactory(ModelType.Truss1D);
     start          = nodeFactory.Create(0);
     end            = nodeFactory.Create(1);
     elementFactory = new ElementFactory(ModelType.Truss1D);
     SUT            = elementFactory.CreateLinearConstantSpring(start, end, 0);
 }
        private Matrix GetNonlinearLocalTotalVector(FiniteElement element)
        {
            elementCurrent = element;

            Matrix NonlinearLocalTotalVector = Integration.GaussianIntegrationMatrix(LocalVectorFunction);

            return(NonlinearLocalTotalVector);
        }
        private Matrix GetLocalStiffnessMatrix(FiniteElement element)
        {
            elementCurrent = element;

            Matrix localStiffnessMatrix = Integration.GaussianIntegrationMatrix(LocalStiffnessMatrixFunction);

            return(localStiffnessMatrix);
        }
Пример #9
0
        protected void CreateAndStore3DSpringFromOriginTo(double x, double y, double z)
        {
            nodeFactory = new NodeFactory(ModelType.Truss3D);
            start       = nodeFactory.Create(0, 0, 0);
            end         = nodeFactory.Create(x, y, z);

            elementFactory = new ElementFactory(ModelType.Truss3D);
            this.SUT       = elementFactory.CreateLinearConstantSpring(start, end, 1);
        }
Пример #10
0
        protected void CreateAndStore2DSpringFromOriginTo(double x, double z)
        {
            this.nodeFactory = new NodeFactory(ModelType.Truss2D);
            this.start       = nodeFactory.CreateFor2DTruss(0, 0);
            this.end         = nodeFactory.CreateFor2DTruss(x, z);

            this.elementFactory = new ElementFactory(ModelType.Truss2D);
            this.SUT            = elementFactory.CreateLinearConstantSpring(this.start, this.end, 1);
        }
        protected void CreateAndStore2DSpringBetween(double startX, double startZ, double endX, double endZ)
        {
            this.nodeFactory = new NodeFactory(ModelType.Truss2D);
            this.start       = nodeFactory.CreateFor2DTruss(startX, startZ);
            this.end         = nodeFactory.CreateFor2DTruss(endX, endZ);

            this.elementFactory = new ElementFactory(ModelType.Truss2D);
            this.SUT            = elementFactory.CreateLinearConstantSpring(this.start, this.end, 1);
        }
Пример #12
0
        public void HashCode_depends_only_on_connected_nodes()
        {
            int SUTOriginalHash = SUT.GetHashCode();

            FiniteElement equal = elementFactory.CreateLinearConstantSpring(start, end, 0);

            Assert.AreEqual(SUTOriginalHash, equal.GetHashCode());
            Assert.IsFalse(SUT.IsDirty(SUTOriginalHash));
            Assert.IsFalse(SUT.IsDirty(equal.GetHashCode()));
        }
        double[,] BuildLocalMatrix(FiniteElement e)
        {
            Point p1 = Mesh.Points[e[0]];
            Point p2 = Mesh.Points[e[1]];
            Point p3 = Mesh.Points[e[2]];

            double hx = p2.X - p1.X;
            double hy = p3.Y - p1.Y;

            double mes   = hx * hy;
            double avgB  = GetAverageB(e);
            double mu    = e.Material.Mu(avgB);
            double muDer = e.Material.MuDer(avgB);

            double[,] G = new double[FEMParameters.BasisSize, FEMParameters.BasisSize];

            double lambda = 1.0 / mu;

            // Calculate G(q0)
            for (int i = 0; i < FEMParameters.BasisSize; i++)
            {
                for (int j = 0; j < FEMParameters.BasisSize; j++)
                {
                    G[i, j] = lambda * P[i, j];
                }
            }

            if (!FloatComparision.IsEqual(0.0, muDer))
            {
                // Calculate sums
                double der = -muDer / (mu * mu * 2 * avgB);

                for (int i = 0; i < FEMParameters.BasisSize; i++)
                {
                    for (int r = 0; r < FEMParameters.BasisSize; r++)
                    {
                        double sum1 = 0;
                        for (int s = 0; s < FEMParameters.BasisSize; s++)
                        {
                            sum1 += P[i, s] * q[e[s]];
                        }

                        double sum2 = 0;
                        for (int p = 0; p < FEMParameters.BasisSize; p++)
                        {
                            sum2 += P[r, p] * q[e[p]];
                        }

                        G[i, r] += 2.0 * der * sum1 * sum2 / mes;
                    }
                }
            }

            return(G);
        }
Пример #14
0
        /// <summary>
        /// Computes the K matrix for the element
        /// </summary>
        /// <returns>K-Matrix</returns>
        private Matrix KMatrix(FiniteElement element)
        {
            double area;

            var bMatrix = BMatrix(element.A, element.B, element.C, out area);
            var bt      = bMatrix.Transpose();
            var btD     = bt * d;
            var k       = btD * bMatrix;

            k = area * k;
            return(k);
        }
Пример #15
0
        public void Can_determine_if_equal()
        {
            Assert.IsTrue(SUT.Equals(SUT));

            FiniteElement equal = elementFactory.CreateLinearConstantSpring(start, end, 0);

            Assert.IsTrue(SUT.Equals(equal));

            FiniteElementNode otherNode = this.nodeFactory.Create(3);
            FiniteElement     notEqual  = elementFactory.CreateLinearConstantSpring(start, otherNode, 0);

            Assert.IsFalse(SUT.Equals(notEqual));
        }
        private Vector GetUByElement(FiniteElement element)
        {
            Vector res = new Vector(8);

            if (U != null)
            {
                for (int i = 0; i < element.Count; i++)
                {
                    res[2 * i]     = U[2 * element[i].Index];
                    res[2 * i + 1] = U[2 * element[i].Index + 1];
                }
            }
            return(res);
        }
Пример #17
0
    void Test()
    {
        Node[] nodes = new Node[]
        {
            new Node(new Vector2(1, 0), 0, 0),
            new Node(new Vector2(3, 2), 1, 0),
            new Node(new Vector2(-1, 1), 2, 0)
        };

        Materiall testMaterial = new Materiall();

        testMaterial.ConductCoefficientX = 4.7f;
        testMaterial.ConductCoefficientY = 5.1f;

        FiniteElement fe = new FiniteElement(nodes, testMaterial);
    }
        void CalculateP(FiniteElement e)
        {
            Point p1 = Mesh.Points[e[0]];
            Point p2 = Mesh.Points[e[1]];
            Point p3 = Mesh.Points[e[2]];

            double hx = p2.X - p1.X;
            double hy = p3.Y - p1.Y;

            for (int i = 0; i < FEMParameters.BasisSize; i++)
            {
                for (int j = 0; j < FEMParameters.BasisSize; j++)
                {
                    P[i, j] = (hy * localG1[i, j] / hx + hx * localG2[i, j] / hy) / 6.0;
                }
            }
        }
        void AddToGlobalMatrix(IMatrix A, FiniteElement e, double[,] local)
        {
            for (int i = 0; i < FEMParameters.BasisSize; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    int iGlobal = e[i];
                    int jGlobal = e[j];

                    if (jGlobal > iGlobal)
                    {
                        (jGlobal, iGlobal) = (iGlobal, jGlobal);
                    }

                    A.Add(iGlobal, jGlobal, local[i, j]);
                }
            }
        }
        private Matrix GetVariableVectorOnElement(FiniteElement element, double ksi, double eta)
        {
            Matrix VariableVector = new Matrix(4, 1);
            Vector du             = previousRes.DU(ksi, eta, element);
            double d1u1           = du[0];
            double d3u3           = du[1];
            double d3u1           = du[2];
            double d1u3           = du[3];


            /*VariableVector[0, 0] = 2 * M1 * d1u1 + 2 * M2 * d3u3 + 1.5 * M1 * d1u1 * d1u1 + 0.5 * M1 * d1u3 * d1u3 + (0.5 * M2 + G13) * d3u1 * d3u1 + 0.5 * M2 * d3u3 * d3u3 + M2 * d1u1 * d3u3 + G13 * d3u1 * d1u3;
             * VariableVector[1, 0] = 2 * M2 * d1u1 + 2 * M3 * d3u3 + 1.5 * M3 * d3u3 * d3u3 + 0.5 * M2 * d1u1 * d1u1 + (0.5 * M2 + G13) * d1u3 * d1u3 + 0.5 * M3 * d3u1 * d3u1 + M2 * d3u3 * d1u1 + G13 * d1u3 * d3u1;
             * VariableVector[2, 0] = G13 * (2 * d1u3 + 2 * d3u1 + d1u3 * d3u3 + d1u1 * d1u3) + (M2 + 2 * G13) * d3u1 * d1u1 + M3 * d3u1 * d3u3;
             * VariableVector[3, 0] = G13 * (2 * d3u1 + 2 * d1u3 + d3u1 * d1u1 + d3u1 * d3u3) + (M2 + 2 * G13) * d3u3 * d1u3 + M1 * d1u3 * d1u1;
             */

            VariableVector[0, 0] = 0.5 * M1 * d1u1 * d1u1 + 0.5 * M1 * d1u3 * d1u3 + 0.5 * M2 * d3u1 * d3u1 + 0.5 * M2 * d3u3 * d3u3;
            VariableVector[1, 0] = 0.5 * M2 * d1u1 * d1u1 + 0.5 * M2 * d1u3 * d1u3 + 0.5 * M3 * d3u1 * d3u1 + 0.5 * M3 * d3u3 * d3u3;
            VariableVector[2, 0] = G13 * (d1u1 * d3u1 + d1u3 * d3u3);
            VariableVector[3, 0] = G13 * (d1u1 * d3u1 + d1u3 * d3u3);

            return(VariableVector);
        }
        double[,] BuildLocalMatrix(FiniteElement e)
        {
            Point p1 = Mesh.Points[e[0]];
            Point p2 = Mesh.Points[e[1]];
            Point p3 = Mesh.Points[e[2]];

            double hx = p2.X - p1.X;
            double hy = p3.Y - p1.Y;

            double[,] G = new double[FEMParameters.BasisSize, FEMParameters.BasisSize];

            double lambda = 1.0 / e.Material.Mu(0);

            for (int i = 0; i < FEMParameters.BasisSize; i++)
            {
                for (int j = 0; j < FEMParameters.BasisSize; j++)
                {
                    G[i, j] = lambda * (hy * localG1[i, j] / hx + hx * localG2[i, j] / hy) / 6;
                }
            }

            return(G);
        }
        double GetAverageB(FiniteElement e)
        {
            Point p1 = Mesh.Points[e[0]];
            Point p2 = Mesh.Points[e[1]];
            Point p3 = Mesh.Points[e[2]];

            double hx = p2.X - p1.X;
            double hy = p3.Y - p1.Y;

            double B2 = 0.0;

            double mes = hx * hy;

            for (int i = 0; i < FEMParameters.BasisSize; i++)
            {
                for (int j = 0; j < FEMParameters.BasisSize; j++)
                {
                    B2 += P[i, j] * q[e[i]] * q[e[j]];
                }
            }

            return(Math.Sqrt(B2 / mes));
        }
Пример #23
0
        FiniteElement FindElement(Point p)
        {
            FiniteElement element = null;

            foreach (var e in Mesh.Elements)
            {
                Point p1 = Mesh.Points[e[0]];
                Point p2 = Mesh.Points[e[1]];
                Point p3 = Mesh.Points[e[2]];

                double x1 = p1.X;
                double x2 = p2.X;
                double y1 = p1.Y;
                double y2 = p3.Y;

                if (p.X >= x1 && p.X <= x2 && p.Y >= y1 && p.Y <= y2)
                {
                    element = e;
                    break;
                }
            }

            return(element);
        }
        protected void CreateAndStore3DSpringFromOriginTo(double x, double y, double z)
        {
            nodeFactory = new NodeFactory(ModelType.Truss3D);
            start = nodeFactory.Create(0, 0, 0);
            end = nodeFactory.Create(x, y, z);

            elementFactory = new ElementFactory(ModelType.Truss3D);
            this.SUT = elementFactory.CreateLinearConstantSpring(start, end, 1);
        }
Пример #25
0
    public void Solve(Loader loader)
    {
        Materiall material = loader.activeMaterial;
        Mesh      mesh     = loader.activeExample.Mesh;

        elements = new FiniteElement[mesh.triangles.Length / 3];
        var edges         = Edge.GetEdges(mesh.triangles);
        var boundaries    = Edge.GetBoudaries(edges);
        var boundaryNodes = Edge.GetBoundaryNodesIndexes(boundaries);

        boundaryNodes.Sort();

        Color[] colors = new Color[mesh.vertices.Length];

        mesh.colors = colors;

        Test();

        for (int i = 0; i < elements.Length; i++)
        {
            Node[] nodes = new Node[]
            {
                new Node(mesh.vertices[mesh.triangles[3 * i]], mesh.triangles[3 * i], loader.ObjectTemperature),
                new Node(mesh.vertices[mesh.triangles[3 * i + 1]], mesh.triangles[3 * i + 1], loader.ObjectTemperature),
                new Node(mesh.vertices[mesh.triangles[3 * i + 2]], mesh.triangles[3 * i + 2], loader.ObjectTemperature)
            };
            elements[i] = new FiniteElement(nodes, material);
        }

//        flux = Program.Instance.CountFlux(material, loader.EnviromentTemperature);

        for (int i = 0; i < elements.Length; i++)
        {
            string s = elements[i].LocalStiffnessMatrix.ToMatrixString(3, 3);
            File.WriteAllText(@"D:\LocalStifnessMatrix" + i + ".txt", s);
        }

        GlobalStiffnessMatrix = Program.Instance.AssembleGlobalStiffnessMatrix(elements, mesh.vertices.Length);

        double[,] A = new double[, ] {
            { -3.7789, 5.78805, -7.62743, 0, 0, 0, 0, 0, -9.969672, 6.18115, 0.0417701, 0, 0, 0, 0, 0 },
            { 5.78805, -41.87343, 1.39282, 5.92057, 12.4384, 0, 0, 0, 9.59497, 0, -5.73882, 0, 0, 0, 0, 0 },
            { -7.62743, 1.39282, -0.169700000000001, 17.73411, 10.5128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 17.25037, 6.40431, -17.05938, -0.5406453, -6.0546, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 22.9512, 0, -0.5406453, -33.8782, -3.6762, 31.95365, 0, 0, 0, -9.4744, -7.33534, 0, 0, 0, 0 },
            { 0, 0, 0, -6.0546, -3.6762, 18.3219, 10.89105, -19.4821, 0, 0, 0, 0, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 31.95365, 10.89105, -52.17642, -28.9698, 0, 0, 0, 38.3015, 0, 0, 0, 0 },
            { 0, 0, 0, 0, 0, -19.4821, -28.9698, 48.4519, 0, 0, 0, 0, 0, 0, 0, 0 },
            { -9.969672, 9.59497, 0, 0, 0, 0, 0, 0, 4.02099, 0.340399999999999, 5.2473, 0, -9.98461, 0, 0.750631, 0 },
            { 6.18115, 0, 0, 0, 0, 0, 0, 0, 0.340399999999999, -28.365, 0, 0, -8.71305, 30.5565, 0, 0 },
            { 0.0417701, -5.73882, 0, 0, -9.4744, 0, 0, 0, 5.2473, 0, 16.86528, -6.64443, 0, 0, 2.57429, -2.870879 },
            { 0, 0, 0, 0, -7.33534, 0, 38.3015, 0, 0, 0, -6.64443, -42.53872, 0, 0, 0, 18.217 },
            { 0, 0, 0, 0, 0, 0, 0, 0, -9.98461, -8.71305, 0, 0, 21.95786, 9.54011, -12.8003, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 30.5565, 0, 0, 9.54011, -40.0966, 0, 0 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0.750631, 0, 2.57429, 0, -12.8003, 0, 24.73181, -15.2564 },
            { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2.870879, 18.217, 0, 0, -15.2564, -0.089700000000001 }
        };

        // GlobalStiffnessMatrix = Matrix<double>.Build.DenseOfArray(A);

        temps = Program.Instance.BoundryConditionsTemp(loader.EnviromentTemperature, boundaries, mesh.vertexCount, mesh);

        for (int i = 0; i < boundaryNodes.Count / 4; i++)
        {
            temps[boundaryNodes[i]] = 10;
        }

        string str = GlobalStiffnessMatrix.ToMatrixString(mesh.vertexCount, mesh.vertexCount);

        File.WriteAllText(@"D:\matrix.txt", str);

        str = temps.ToVectorString();

        File.WriteAllText(@"D:\vector.txt", str);

        var rightSide = Program.Instance.SimplifyEquation(ref GlobalStiffnessMatrix, temps, boundaryNodes, material);

        str = GlobalStiffnessMatrix.ToMatrixString(mesh.vertexCount, mesh.vertexCount);

        File.WriteAllText(@"D:\matrix2.txt", str);

        str = rightSide.ToVectorString();

        File.WriteAllText(@"D:\vector2.txt", str);

        temperatures = GlobalStiffnessMatrix.Solve(rightSide);

        var temperatures2 = Program.Instance.CountSolution(GlobalStiffnessMatrix, rightSide);

        double[,] d = { { 2, 1,  3 },
                        { 2, 6,  8 },
                        { 6, 8, 18 } };

        Matrix <double> matrix = Matrix <double> .Build.DenseOfArray(d);

        double[] v = { 1, 3, 5 };

        Vector <double> vect = Vector <double> .Build.DenseOfArray(v);

        var result = matrix.Solve(vect);

        for (int i = 0; i < mesh.vertexCount; i++)
        {
            colors[i] = GetTemperatureFromValue((float)temperatures[i], loader.Gradient);
        }

        mesh.colors = colors;
    }
Пример #26
0
 public void SetUp()
 {
     nodeFactory = new NodeFactory(ModelType.Truss1D);
     start = nodeFactory.Create(0);
     end = nodeFactory.Create(1);
     elementFactory = new ElementFactory(ModelType.Truss1D);
     SUT = elementFactory.CreateLinearConstantSpring(start, end, 0);
 }
        public Vector DU(double ksi, double eta, FiniteElement element)
        {
            Vector uElement = GetUByElement(element);

            return(uElement * GetLocalDerivativeMatrix(element, ksi, eta));
        }
        double[] BuildLocalB(FiniteElement e)
        {
            Point p1 = Mesh.Points[e[0]];
            Point p2 = Mesh.Points[e[1]];
            Point p3 = Mesh.Points[e[2]];

            double hx  = p2.X - p1.X;
            double hy  = p3.Y - p1.Y;
            double mes = hx * hy;

            double avgB  = GetAverageB(e);
            double mu    = e.Material.Mu(avgB);
            double muDer = e.Material.MuDer(avgB);

            double[] B = new double[FEMParameters.BasisSize];
            double   J = e.Material.J;

            // Calculate b(q0)
            for (int i = 0; i < FEMParameters.BasisSize; i++)
            {
                for (int j = 0; j < FEMParameters.BasisSize; j++)
                {
                    B[i] += localM[i, j] * J;
                }
            }

            for (int i = 0; i < FEMParameters.BasisSize; i++)
            {
                B[i] *= hx * hy / 36;
            }

            if (!FloatComparision.IsEqual(0.0, muDer))
            {
                double der = -muDer / (mu * mu * 2 * avgB);

                // Calculate sum
                for (int i = 0; i < FEMParameters.BasisSize; i++)
                {
                    double sum1 = 0;
                    for (int s = 0; s < FEMParameters.BasisSize; s++)
                    {
                        sum1 += P[i, s] * q[e[s]];
                    }

                    double sum2 = 0;
                    for (int r = 0; r < FEMParameters.BasisSize; r++)
                    {
                        double sum = 0;
                        for (int p = 0; p < FEMParameters.BasisSize; p++)
                        {
                            sum += P[r, p] * q[e[p]];
                        }

                        sum2 += q[e[r]] * sum;
                    }

                    B[i] += 2.0 * der * sum1 * sum2 / mes;
                }
            }

            return(B);
        }
        protected void CreateAndStore2DSpringFromOriginTo(double x, double z)
        {
            this.nodeFactory = new NodeFactory(ModelType.Truss2D);
            this.start = nodeFactory.CreateFor2DTruss(0, 0);
            this.end = nodeFactory.CreateFor2DTruss(x, z);

            this.elementFactory = new ElementFactory(ModelType.Truss2D);
            this.SUT = elementFactory.CreateLinearConstantSpring(this.start, this.end, 1);
        }