Example #1
0
        private void FileOpen2dClicked(object sender, RoutedEventArgs e)
        {
            // 初期化
            ClearClicked(null, null);

            // 入力用のCSVファイルを読み込む
            var diag = new OpenFileDialog();

            diag.Filter = "CSVファイル (*.csv)|*.csv";
            if (diag.ShowDialog() == true)
            {
                FEMData2d femData = new FEMData2d();
                femData.ReadCSVFile2d(diag.FileName);

                fem = new Shell2dFEM(femData);

                // モデルを描画する
                var elems = fem.Elems;
                for (int i = 0; i < elems.Count; i++)
                {
                    var elem = elems[i].ShallowCopy();   // 要素をコピーする

                    // 描画する
                    DrawShell2dElement((Shell2dElement)elems[i], Brushes.LightGreen, Brushes.Blue, 1.0);
                }
            }
        }
Example #2
0
        public Shell2dFEM(FEMData2d data)
        {
            // 節点数を格納する
            NodeNum = data.nodes.Count;

            // 要素の形式を変換して格納する
            Elems = new List <FEM_Element>();
            {
                for (int i = 0; i < data.elems.Count; i++)
                {
                    Node[] nodes = new Node[ElementNodeNum];
                    nodes[0].No    = data.elems[i].NodeNo1;
                    nodes[0].Point = data.nodes[nodes[0].No - 1].Point;
                    nodes[1].No    = data.elems[i].NodeNo2;
                    nodes[1].Point = data.nodes[nodes[1].No - 1].Point;
                    nodes[2].No    = data.elems[i].NodeNo3;
                    nodes[2].Point = data.nodes[nodes[2].No - 1].Point;
                    nodes[3].No    = data.elems[i].NodeNo4;
                    nodes[3].Point = data.nodes[nodes[3].No - 1].Point;
                    nodes[4].No    = data.elems[i].NodeNo5;
                    nodes[4].Point = data.nodes[nodes[4].No - 1].Point;
                    nodes[5].No    = data.elems[i].NodeNo6;
                    nodes[5].Point = data.nodes[nodes[5].No - 1].Point;
                    nodes[6].No    = data.elems[i].NodeNo7;
                    nodes[6].Point = data.nodes[nodes[6].No - 1].Point;
                    nodes[7].No    = data.elems[i].NodeNo8;
                    nodes[7].Point = data.nodes[nodes[7].No - 1].Point;

                    int    materialNo = data.elems[i].MaterialNo - 1;
                    double young      = data.materials[materialNo].Young;
                    double poisson    = data.materials[materialNo].Poisson;
                    double thickness  = data.materials[materialNo].Thickness;

                    Elems.Add(new Shell2dElement(nodes, thickness, young, poisson));
                }
            }

            // 拘束条件の形式を変換して格納する
            // 変位
            List <double> disp       = new List <double>();
            List <double> force      = new List <double>();
            List <bool>   constraint = new List <bool>();

            for (int i = 0; i < data.nodes.Count; i++)
            {
                disp.Add(data.nodes[i].Displacement.X);
                disp.Add(data.nodes[i].Displacement.Y);
                force.Add(data.nodes[i].Force.X);
                force.Add(data.nodes[i].Force.Y);
                constraint.Add(data.nodes[i].ConstraintX);
                constraint.Add(data.nodes[i].ConstraintY);
            }
            DenseVector dispVector  = DenseVector.OfArray(disp.ToArray());
            DenseVector forceVector = DenseVector.OfArray(force.ToArray());

            setBoundaryCondition(dispVector, forceVector, constraint);
        }
Example #3
0
        public override void Analysis()
        {
            DenseMatrix kMatrix = makeKMatrix();

            // 変位を計算する
            DispVector = (DenseVector)(kMatrix.Inverse().Multiply(ForceVector));
            Console.WriteLine("変位ベクトル");
            Console.WriteLine(DispVector);

            // 各要素の変位、応力ベクトルを計算する
            DenseVector dispElemVector = DenseVector.Create(16, 0.0);

            for (int i = 0; i < Elems.Count; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    dispElemVector[2 * j]     = DispVector[2 * (Elems[i].Nodes[j].No - 1)];
                    dispElemVector[2 * j + 1] = DispVector[2 * (Elems[i].Nodes[j].No - 1) + 1];
                }

                Console.WriteLine("要素" + (i + 1).ToString());
                Elems[i].makeStrainVector(dispElemVector);
                Elems[i].makeStressVector();

                // 線形外挿法により各要素の節点応力を求める
                Elems[i].makeNodeStressVector();
            }

            // 各節点の結果を算出する
            List <ResultNode> resultNodes = new List <ResultNode>();

            for (int i = 0; i < NodeNum; i++)
            {
                // 節点応力を計算する
                ResultNode resultNode = new ResultNode();
                resultNode.StressVector = DenseVector.Create(3, 0.0);
                int NodeCount = 0;
                for (int j = 0; j < Elems.Count; j++)
                {
                    for (int k = 0; k < 8; k++)
                    {
                        if (Elems[j].Nodes[k].No == (i + 1))
                        {
                            resultNode.StressVector += Elems[j].NodeStressVector[k];
                            NodeCount++;
                        }
                    }
                }
                resultNode.StressVector /= (double)NodeCount;

                // 変位を格納する
                System.Windows.Vector displacement = new System.Windows.Vector();
                displacement.X          = DispVector[2 * i];
                displacement.Y          = DispVector[2 * i + 1];
                resultNode.Displacement = displacement;

                // 主応力、ミーゼス応力を計算する
                resultNode.PriStressVector = makePriStress(resultNode.StressVector);
                resultNode.MisesStress     = makeMisesStress(resultNode.PriStressVector);

                resultNodes.Add(resultNode);
            }

            // 結果を「output_quad8.csv」で出力する
            FEMData2d data = new FEMData2d();

            data.resultnodes = resultNodes;
            data.WriteCSVFile("output_quad8.csv");

            for (int i = 0; i < NodeNum; i++)
            {
                Console.WriteLine("節点" + (i + 1).ToString());
                Console.WriteLine("節点応力ベクトル");
                Console.WriteLine(resultNodes[i].StressVector);
                Console.WriteLine("節点変位ベクトル");
                Console.WriteLine(resultNodes[i].Displacement + "\n");
                Console.WriteLine("主応力");
                Console.WriteLine(resultNodes[i].PriStressVector);
                Console.WriteLine("ミーゼス応力");
                Console.WriteLine(resultNodes[i].MisesStress + "\n");
            }
        }