private void GenerateMeshNodes(int LElements)
        {
            Nodes.Clear();
            boundaryNodes.Clear();
            MiddleNodes.Clear();

            int    indexCur = 0;
            double xCur     = _plate.Points[0].X;

            int LNodes = LElements + 1;

            double xStep = _plate.Width / Convert.ToDouble(LElements);

            for (int j = 0; j < LNodes; j++)
            {
                FiniteElementNode node = new FiniteElementNode();
                node.Index   = indexCur;
                node.Point.X = Math.Round(xCur, 4);
                node.Point.Y = 0;
                Nodes.Add(node);
                MiddleNodes.Add(node);
                if (j == 0)
                {
                    AddBoundaryNode(node, _plate.Edges[0]);
                }
                if (j == (LNodes - 1))
                {
                    AddBoundaryNode(node, _plate.Edges[2]);
                }
                indexCur++;
                xCur += xStep;
            }
        }
Esempio n. 2
0
        //Extends the path with a given node
        public Path ExtendPath(Node extension)
        {
            //Find new length for this path
            Length = ExtendLength(extension);
            //Add the end node to middle nodes
            MiddleNodes.Add(EndNode);
            //Removes duplicates in the list
            MiddleNodes = MiddleNodes.Distinct().ToList();
            //Set the end node to the extension
            EndNode = extension;

            //Returns this path
            return(this);
        }
        private void GenerateMeshNodes(int LElements, int HElements)
        {
            Nodes.Clear();
            LeftNodes.Clear();
            RightNodes.Clear();

            int    indexCur = 0;
            double xCur     = 0;
            double yCur     = _shape.H / 2;

            if (HElements % 2 == 1)
            {
                HElements++;
            }

            int HNodes = HElements + 1;
            int LNodes = LElements + 1;

            double xStep = _shape.L / Convert.ToDouble(LElements);
            double yStep = _shape.H / Convert.ToDouble(HElements);

            int HNodesdiv2 = HNodes / 2;

            for (int i = 0; i < HNodesdiv2; i++)
            {
                if (i == 0)
                {
                    TopNodes.Clear();
                }
                for (int j = 0; j < LNodes; j++)
                {
                    Node node = new Node();
                    node.Index = indexCur;
                    node.X     = xCur;
                    node.Y     = yCur;
                    Nodes.Add(node);
                    if (j == 0)
                    {
                        LeftNodes.Add(node);
                    }
                    if (j == (LNodes - 1))
                    {
                        RightNodes.Add(node);
                    }

                    indexCur++;
                    xCur += xStep;
                    if (i == 0)
                    {
                        TopNodes.Add(node);
                    }
                }
                yCur -= yStep;
                xCur  = 0;
            }

            xCur = 0;
            yCur = 0;
            MiddleNodes.Clear();
            for (int j = 0; j < LNodes; j++)
            {
                Node node = new Node();
                node.Index = indexCur;
                node.X     = xCur;
                node.Y     = yCur;
                Nodes.Add(node);
                MiddleNodes.Add(node);
                if (j == 0)
                {
                    LeftNodes.Add(node);
                }
                if (j == (LNodes - 1))
                {
                    RightNodes.Add(node);
                }
                indexCur++;
                xCur += xStep;
            }

            xCur  = 0;
            yCur -= yStep;
            for (int i = 0; i < HNodesdiv2; i++)
            {
                if (i == (HNodesdiv2 - 1))
                {
                    BottomNodes.Clear();
                }
                for (int j = 0; j < LNodes; j++)
                {
                    Node node = new Node();
                    node.Index = indexCur;
                    node.X     = xCur;
                    node.Y     = yCur;
                    Nodes.Add(node);
                    if (j == 0)
                    {
                        LeftNodes.Add(node);
                    }
                    if (j == (LNodes - 1))
                    {
                        RightNodes.Add(node);
                    }

                    if (i == (HNodesdiv2 - 1))
                    {
                        BottomNodes.Add(node);
                    }
                    indexCur++;
                    xCur += xStep;
                }
                yCur -= yStep;
                xCur  = 0;
            }
        }
Esempio n. 4
0
        private void GenerateMeshNodes(int LElements, int HElements)
        {
            Nodes.Clear();
            boundaryNodes.Clear();

            int    indexCur = 0;
            double xCur     = _rectangle.Points[0].X;
            double yCur     = _rectangle.Points[0].Y;

            if (HElements % 2 == 1)
            {
                HElements++;
            }

            int HNodes = HElements + 1;
            int LNodes = LElements + 1;

            double xStep = _rectangle.Width / Convert.ToDouble(LElements);
            double yStep = _rectangle.Height / Convert.ToDouble(HElements);

            int HNodesdiv2 = HNodes / 2;

            for (int i = 0; i < HNodesdiv2; i++)
            {
                for (int j = 0; j < LNodes; j++)
                {
                    FiniteElementNode node = new FiniteElementNode();
                    node.Index   = indexCur;
                    node.Point.X = Math.Round(xCur, 4);
                    node.Point.Y = Math.Round(yCur, 4);
                    Nodes.Add(node);
                    if (j == 0)
                    {
                        AddBoundaryNode(node, _rectangle.Edges[0]);
                    }
                    if (j == (LNodes - 1))
                    {
                        AddBoundaryNode(node, _rectangle.Edges[2]);
                    }

                    indexCur++;
                    xCur += xStep;
                    if (i == 0)
                    {
                        AddBoundaryNode(node, _rectangle.Edges[1]);
                    }
                }
                yCur -= yStep;
                xCur  = _rectangle.Points[0].X;
            }

            //xCur = _rectangle.Points[0].X;
            //yCur = (_rectangle.Points[0].Y + _rectangle.Points[1].Y) / 2;
            MiddleNodes.Clear();
            for (int j = 0; j < LNodes; j++)
            {
                FiniteElementNode node = new FiniteElementNode();
                node.Index   = indexCur;
                node.Point.X = Math.Round(xCur, 4);
                node.Point.Y = Math.Round(yCur, 4);
                Nodes.Add(node);
                MiddleNodes.Add(node);
                if (j == 0)
                {
                    AddBoundaryNode(node, _rectangle.Edges[0]);
                }
                if (j == (LNodes - 1))
                {
                    AddBoundaryNode(node, _rectangle.Edges[2]);
                }
                indexCur++;
                xCur += xStep;
            }

            yCur -= yStep;
            xCur  = _rectangle.Points[0].X;
            for (int i = 0; i < HNodesdiv2; i++)
            {
                for (int j = 0; j < LNodes; j++)
                {
                    FiniteElementNode node = new FiniteElementNode();
                    node.Index   = indexCur;
                    node.Point.X = Math.Round(xCur, 4);
                    node.Point.Y = Math.Round(yCur, 4);
                    Nodes.Add(node);
                    if (j == 0)
                    {
                        AddBoundaryNode(node, _rectangle.Edges[0]);
                    }
                    if (j == (LNodes - 1))
                    {
                        AddBoundaryNode(node, _rectangle.Edges[2]);
                    }

                    if (i == (HNodesdiv2 - 1))
                    {
                        AddBoundaryNode(node, _rectangle.Edges[3]);
                    }
                    indexCur++;
                    xCur += xStep;
                }
                yCur -= yStep;
                xCur  = _rectangle.Points[0].X;
            }
        }