示例#1
0
 public static void PrintModelInfo(FESystem sys)
 {
     Console.WriteLine("------------------- Model Info -------------------");
     Console.WriteLine("Nodes: " + sys.Model.Nodes.Count.ToString());
     Console.WriteLine("Elements: " + sys.Model.Elements.Count.ToString());
     Console.WriteLine("Type: " + sys.Model.Elements[0].Type.ToString());
 }
示例#2
0
 public static void PrintSystemInfo(FESystem sys)
 {
     Console.Write(sys.Model.ModelInfo());
     Console.Write(sys.MatrixInfo());
     Console.Write(sys.SolvingInfo());
     Console.WriteLine();
 }
示例#3
0
 public static void PrintDisplacement(FESystem sys)
 {
     foreach (var item in sys.Model.Nodes)
     {
         Console.WriteLine(item.Displacement.X.ToString() + '\t'
                           + item.Displacement.Y.ToString());
     }
 }
示例#4
0
        public static void TestTriangles(int x = 7, int y = 5)
        {
            Model    model2d = new Cantilever2D(ElementType.TriangleElement, x, y).Model;
            FESystem sys     = new FESystem(model2d);

            sys.Solve();
            FEPrint.PrintSystemInfo(sys);
            FEPrint.PrintDisplacement(sys);
            FEIO.WriteCOOMatrix(sys.GetKG().ToCOO(), "C:/Users/alber/Desktop/matA.mtx");
        }
示例#5
0
        public static void TestPixels(int x = 7, int y = 5)
        {
            Model model2d = new Cantilever2D(ElementType.PixelElement, x + 1, y + 1).Model;
            var   _Filter = new ALFE.TopOpt.Filter(model2d.Elements, 2.0, 2);

            _Filter.PreFlt();

            FESystem sys = new FESystem(model2d);

            sys.Solve();
            FEPrint.PrintSystemInfo(sys);

            ////FEPrint.PrintDisplacement(sys);
            ////var disp = sys.GetDisplacement();
            ////FEPrint.PrintCSR(KG);
            ////FEIO.WriteCOOMatrix(KG.ToCOO(), "C:/Users/alber/Desktop/matA.mtx");
            Console.WriteLine("------------------- Result Info -------------------");
            Console.WriteLine("Displacement[2].Y = " + sys.GetDisplacement()[2, 1].ToString());
            //FEPrint.PrintDisplacement(sys);
        }
示例#6
0
        //public static void TestRollerSupport()
        //{
        //    List<Node> nds = new List<Node>();
        //    List<Element> elems = new List<Element>();

        //    nds.Add(new Node(3, 1));
        //    nds.Add(new Node(3, 0));
        //    nds.Add(new Node(2, 1));
        //    nds.Add(new Node(2, 0));
        //    nds.Add(new Node(0, 1));
        //    nds.Add(new Node(1, 1));
        //    nds.Add(new Node(1, 0));
        //    nds.Add(new Node(0, 0));
        //    nds.Add(new Node(3, 2));
        //    nds.Add(new Node(2, 2));
        //    nds.Add(new Node(0, 2));
        //    nds.Add(new Node(1, 2));

        //    elems.Add(new Quadrilateral(new List<Node>(4) { nds[2], nds[0], nds[1], nds[3] }, new Material(1.0, 0.3)));
        //    elems.Add(new Quadrilateral(new List<Node>(4) { nds[5], nds[2], nds[3], nds[6] }, new Material(1.0, 0.3)));
        //    elems.Add(new Quadrilateral(new List<Node>(4) { nds[4], nds[5], nds[6], nds[7] }, new Material(1.0, 0.3)));
        //    elems.Add(new Quadrilateral(new List<Node>(4) { nds[9], nds[8], nds[0], nds[2] }, new Material(1.0, 0.3)));
        //    elems.Add(new Quadrilateral(new List<Node>(4) { nds[11], nds[9], nds[2], nds[5] }, new Material(1.0, 0.3)));
        //    elems.Add(new Quadrilateral(new List<Node>(4) { nds[10], nds[11], nds[5], nds[4] }, new Material(1.0, 0.3)));

        //    Model model = new Model(2, nds, elems,
        //        new List<Load>(1) { new Load(11, new Vector2D(0.0, -1.0)) },
        //        new List<Support>(2) { new Support(7, SupportType.Fixed), new Support(1, SupportType.Fixed) });
        //    FESystem sys = new FESystem(model, Solver.SimplicialLLT, false, false);
        //    Console.Write(sys.Model.ModelInfo());
        //    sys.Initialize();
        //    Console.Write(sys.MatrixInfo());

        //    var KG = sys.GetKG();
        //    sys.Solve();
        //    //FEIO.WriteKG(KG, "E:\\testKG.mtx", false);
        //    Console.Write(sys.SolvingInfo());
        //    Console.Write(sys.DisplacementInfo());
        //}
        public static void Test()
        {
            Model model2d = new Cantilever2D(ElementType.PixelElement, 1000, 1000).Model;

            Console.WriteLine("Read Model Successfully!");
            FESystem sys0 = new FESystem(model2d, Solver.PARDISO);

            sys0.Initialize();
            Console.WriteLine("Start to solve");
            sys0.Solve();

            //FEIO.WriteKG(sys0.GetKG(), "E:/test/test.mtx", true);

            Console.Write(sys0.Model.ModelInfo());
            Console.Write(sys0.MatrixInfo());


            Console.Write(sys0.SolvingInfo());
            //Console.WriteLine("Node Displacement 0: "+ sys0.Model.Nodes[0].Displacement);
            //Console.WriteLine("Node Displacement 9999: "+ sys0.Model.Nodes[9999].Displacement);
            //Console.Write(sys0.DisplacementInfo());
            //FEIO.WriteKG(sys0.GetKG(), "E:\\ALCoding\\ALFE\\topoptTest");
            Console.ReadLine();
        }
示例#7
0
        public static void TestAllSolver()
        {
            Model model2d = new Cantilever2D(ElementType.PixelElement, 500, 500).Model;

            //FESystem sys0 = new FESystem(model2d, Solver.PARDISO);
            //sys0.Initialize();
            //FEIO.WriteKG(sys0.GetKG(), "E:\\KG" + ".mtx");
            //sys0.Solve();

            //Console.Write(sys0.Model.ModelInfo());
            //Console.Write(sys0.MatrixInfo());

            //Console.WriteLine("------------------- Time Cost -------------------");
            //Console.WriteLine("Solver: " + sys0._Solver.ToString());
            //Console.WriteLine("Solving: " + sys0.TimeCost[3].ToString() + " ms");
            //Console.WriteLine();

            FESystem sys1 = new FESystem(model2d, Solver.SimplicialLLT);

            sys1.Initialize();
            sys1.Solve();

            Console.WriteLine("Solver: " + sys1._Solver.ToString());
            Console.WriteLine("Solving: " + sys1.TimeCost[3].ToString() + " ms");
            Console.WriteLine();

            FESystem sys2 = new FESystem(model2d, Solver.PARDISO);

            sys2.Initialize();
            sys2.Solve();


            Console.WriteLine("Solver: " + sys2._Solver.ToString());
            Console.WriteLine("Solving: " + sys2.TimeCost[3].ToString() + " ms");
            Console.WriteLine();

            FESystem sys3 = new FESystem(model2d, Solver.CG);

            sys3.Initialize();
            sys3.Solve();

            Console.WriteLine("Solver: " + sys3._Solver.ToString());
            Console.WriteLine("Solving: " + sys3.TimeCost[3].ToString() + " ms");
            Console.WriteLine();

            //FESystem sys4 = new FESystem(model2d, Solver
            //sys4.Initialize();
            //sys4.Solve();

            //Console.WriteLine("Solver: " + sys4._Solver.ToString());
            //Console.WriteLine("Solving: " + sys4.TimeCost[3].ToString() + " ms");
            //Console.WriteLine();

            //FESystem sys5 = new FESystem(model2d, false, Solver.CG);
            //sys5.Initialize();
            //sys5.Solve();

            //Console.WriteLine("Solver: " + sys5._Solver.ToString());
            //Console.WriteLine("Solving: " + sys5.TimeCost[3].ToString() + " ms");
            //Console.WriteLine();

            //FESystem sys4 = new FESystem(model2d, true, false, Solver.CG);
            //sys4.Initialize();
            //sys4.Solve();

            //Console.WriteLine("Solver: " + sys4._Solver.ToString());
            //Console.WriteLine("Solving: " + sys4.TimeCost[3].ToString() + " ms");
            //Console.WriteLine();

            //FESystem sys5 = new FESystem(model2d, true, false, Solver.AMG_CG);
            //sys5.Initialize();
            //sys5.Solve();

            //Console.WriteLine("Solver: " + sys5._Solver.ToString());
            //Console.WriteLine("Solving: " + sys5.TimeCost[3].ToString() + " ms");
            //Console.WriteLine();


            //FEIO.WriteKG(sys.GetKG(), @"E:\ALCoding\ALFE\topoptTest\KG.mtx");
            //FEPrint.PrintDisplacement(sys);
        }
示例#8
0
        public static void TestHexahedron()
        {
            List <Node> nodes = new List <Node>()
            {
                new Node(0.0, 0.0, 0.0),
                new Node(0.25, 0.0, 0.0),
                new Node(0.25, 0.25, 0.0),
                new Node(0.0, 0.25, 0.0),

                new Node(0.0, 0.0, 0.25),
                new Node(0.25, 0.0, 0.25),
                new Node(0.25, 0.25, 0.25),
                new Node(0.0, 0.25, 0.25),


                new Node(0.5, 0.0, 0.0),
                new Node(0.5, 0.0, 0.25),
                new Node(0.5, 0.25, 0.25),
                new Node(0.5, 0.25, 0.0)
            };

            var element0 = new Hexahedron(new List <Node>(8)
            {
                nodes[0], nodes[1], nodes[2], nodes[3], nodes[4], nodes[5], nodes[6], nodes[7]
            }, new Material(1, 0.3));
            //var element1 = new Hexahedron(new List<Node>(8) { nodes[4], nodes[5], nodes[6], nodes[7], nodes[8], nodes[9], nodes[10], nodes[11] }, new Material(1, 0.3));

            var elements = new List <Element>(1)
            {
                element0
            };

            //var loads = new List<Load>(4)
            //{
            //    new Load(8, 4.6875, 0.0,0.0),
            //    new Load(9, 4.6875, 0.0,0.0),
            //    new Load(10,4.6875, 0.0,0.0),
            //    new Load(11, 4.6875, 0.0,0.0)
            //};

            //var supports = new List<Support>(4)
            //{
            //    new Support(0, SupportType.Fixed),
            //    new Support(1, SupportType.Fixed),
            //    new Support(2, SupportType.Fixed),
            //    new Support(3, SupportType.Fixed)
            //};

            var model = new Model(3, nodes, elements);

            FESystem sys = new FESystem(model, Solver.SimplicialLLT);

            sys.Initialize();
            Console.WriteLine(model.Elements[0].Ke);
            Console.WriteLine(model.Elements[0].B);
            Console.WriteLine(model.Elements[0].D);
            //sys.Solve();
            Console.Write(sys.Model.ModelInfo());
            Console.Write(sys.MatrixInfo());
            Console.WriteLine("Solver: " + sys._Solver.ToString());
            Console.WriteLine("Solving: " + sys.TimeCost[3].ToString() + " ms");
            Console.WriteLine(sys.DisplacementInfo());
            FEIO.WriteKG(sys.GetKG(), "E:\\ALCoding\\ALFE\\topoptTest", false);
            Console.WriteLine();
        }
示例#9
0
 public static void PrintDisplacement(FESystem sys, int i)
 {
     Console.WriteLine("Node [" + i.ToString() + "] Displement is " + sys.Model.Nodes[i].Displacement.X.ToString() +
                       '\t' + sys.Model.Nodes[i].Displacement.Y.ToString() +
                       '\t' + sys.Model.Nodes[i].Displacement.Z.ToString());
 }
示例#10
0
        public static void Verifying()
        {
            string path  = @"E:\ALCoding\Verifying\cantileverModel.msh";
            var    model = FEIO.ReadTetrahedras(path);

            var supportIDs = new List <int>(458)
            {
                5, 6, 7, 8, 64, 65, 66, 67, 112, 113, 114, 115, 116, 117, 124, 177, 178, 181, 183,
                189, 190, 191, 228, 229, 230, 231, 238, 239, 242, 243, 244, 284, 285, 286, 287,
                356, 357, 358, 359, 417, 418, 420, 421, 422, 423, 424, 431, 432, 433, 434, 435,
                643, 644, 645, 646, 649, 650, 651, 653, 659, 660, 661, 662, 777, 778, 779, 780,
                781, 784, 795, 798, 799, 800, 801, 802, 805, 806, 807, 818, 819, 823, 824, 825,
                826, 868, 879, 904, 914, 943, 975, 976, 999, 1000, 1020, 1026, 1027, 1029, 1030,
                1033, 1036, 1039, 1041, 1042, 1257, 1259, 1260, 1261, 1263, 1274, 1278, 1279,
                1280, 1282, 1285, 1390, 1391, 1392, 1416, 1418, 1419, 1420, 1421, 1422, 1423,
                1448, 1452, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467,
                1468, 1469, 1470, 1471, 1472, 1473, 1474, 1503, 1519, 1520, 1522, 1544, 1545,
                1546, 1558, 1559, 1571, 1609, 1610, 1622, 1638, 1741
            };
            //var supportIDs = new List<int>(458)
            //{5,6,7,8,283,284,285,286,1510,1515,1567,1749,1863,1955,1956,5604,5622,5856,5857,6518,6863,6865,9097,
            //    64,65,66,67,371,372,373,374,1584,1585,1629,1837,1910,1993,1994,5899,6789,7031,7032,8925,
            //    7,8,116,117,229,284,285,286,464,465,466,467,468,469,1510,1511,1512,1513,1514,1515,1516,1517,1518,1519,1574,
            //    1955,1956,2070,2071,2094,2105,2106,5604,5605,5606,5607,5608,5609,5610,5611,5612,5613,5614,5615,5616,5617,
            //    5618,5619,5620,5621,5622,5857,5862,5867,5868,5869,5870,6290,6293,6294,6300,8878,8937,9038,9097,
            //    64,65,193,194,239,240,371,372,374,1170,1174,1175,1176,1177,1178,1577,1578,1579,1580,1581,1582,1583,1584,
            //    1585,1629,1632,1779,1993,1994,4495,4496,4497,4510,4511,5886,5887,5888,5889,5890,5891,5892,5893,5894,5895,
            //    5896,5897,5898,5899,5900,5901,6143,6145,6150,6152,6163,6178,6624,6628,6789,7149,8925,9414,
            //    112,113,124,181,182,185,230,231,244,245,449,450,451,452,453,454,462,486,487,488,489,490,491,492,493,494,495,
            //    1122,1123,1124,1125,1126,1127,1128,1129,1130,1131,1146,1147,1148,1149,1150,1151,1152,1520,1521,1522,1523,1525,
            //    1531,1591,1593,1594,1595,1596,1597,1645,1646,1647,1648,1649,1650,1651,1652,1653,1654,2030,2037,2042,2045,2122,2125,
            //    2143,2159,2160,4351,4373,4374,4377,4382,4402,4414,4443,4448,4449,4453,4455,4474,5623,5625,5627,5634,5903,5904,5906,
            //    5914,6196,6199,6200,6205,6208,6209,6210,6211,6212,6213,6214,6215,6216,6217,6218,6219,6220,6221,6222,6223,6224,6225,
            //    6226,6227,6228,6229,6230,6231,6232,6233,6234,6235,6236,6237,6238,6239,6240,6241,6242,6243,6244,6245,6246,6247,6248,
            //    6249,6250,6251,6252,6253,6254,6255,6256,6257,6258,6259,6260,6261,6262,6263,6264,6265,6266,6267,6268,6269,6270,6271,
            //    6272,6273,6274,6275,6276,6277,6278,6279,6280,6281,6282,6283,6284,6285,6286,6287,6288,6289,6602,6603,6604,6607,6608,
            //    6927,7096,9032,9143,9490,9530,5,6,8,115,116,283,284,285,286,463,464,468,1510,1863,1955,1956,2082,
            //    2083,2086,2105,5604,5622,6863,6864,6865,9097,5,6,114,115,283,284,286,463,464,485,1567,1749,1750,1863,
            //    1956,2082,2083,6518,6519,6863,6864,6865,65,66,67,194,195,371,372,373,374,1177,1178,1179,1585,1910,1993,
            //    1994,4496,4517,4520,4528,5887,5899,7031,7032,7033,8925,66,67,187,195,372,373,374,1161,1178,1179,1836,1837,
            //    1910,1993,4517,4520,6792,6794,7031,7032,7033};
            var disSup   = supportIDs.Distinct().ToList();
            var supports = new List <Support>(458);

            for (int i = 0; i < disSup.Count; i++)
            {
                supports.Add(new Support(disSup[i], SupportType.Fixed));
            }
            model.SetSupports(supports);
            var loads = new List <Load>(1)
            {
                new Load(128, new Vector3D(0, 0, -1))
            };

            //var loads = new List<Load>(1) { new Load(569, new Vector3D(0, 0, -1)) };
            model.SetLoads(loads);

            FESystem system = new FESystem(model, Solver.SimplicialLLT);

            system.Initialize();
            system.Solve();

            Console.WriteLine(model.Elements[0].Ke);
            Console.ReadKey();
        }