示例#1
0
        public MainViewModel()
        {
            linearModel = new LinearModel();
            linearModel.initTime(100000, 0.000001);
            linearModel.initTimeMoments(100000, 5, 6);
            linearModel.applyLoad();
            linearModel.calcMove();

            //PlotModel model = new PlotModel();
            //LineSeries s1 = new LineSeries();
            //s1.
            //AddPoints(s1.Points, 100000);
            //model.Series.Add(s1);

            //this.Measurements = new Collection<Measurement>();
            //for (int i = 0; i < linearModel.timeMoments.Length; i++)
            //{
            //    for (int j = 0; j < linearModel.timeMoments[i].Nodes.Length; j++)
            //    {
            //        this.Measurements.Add(new Measurement
            //        {
            //            Time = i,
            //            Value = (double)linearModel.timeMoments[i].Nodes[j].force[0],
            //            Maximum = 0,
            //            Minimum = 0
            //        });
            //    }
            //}
        }
示例#2
0
        private void launchthr()
        {
            foreach (plotxy pl in plotxys)
            {
                pl.Close();
            }

            point[] points;
            GC.Collect();
            LinearModel mosd = new LinearModel();

            mosd.initTimeMoments(100, 5, 6);
            mosd.calcMove();
            //mosd.timeMoments[0];
            double ro      = calc.StrPow(textBox_ro.Text, textBox_ropop.Text);
            double L       = calc.StrPow(textBox_L.Text, textBox_Lpop.Text);
            double h       = calc.StrPow(textBox_h.Text, textBox_hpop.Text);
            double b       = calc.StrPow(textBox_b.Text, textBox_bpop.Text);
            double D       = calc.StrPow(textBox_D.Text, textBox_Dpop.Text);
            double v0      = calc.StrPow(textBox_v0.Text, textBox_v0pop.Text);
            double vamp    = calc.StrPow(textBox_vamp.Text, textBox_vamppop.Text);
            int    numP    = Convert.ToInt32(textBox_numP.Text);
            double elastic = calc.StrPow(textBox_elas.Text, textBox_elaspop.Text);
            double Re      = calc.StrPow(textBox_Renum.Text, textBox_Renumpop.Text);
            string flname  = textBox_file.Text;

            ApplyEffect(this);
            thrdraw = new Thread(delegate()
            {
                if (flname != "")
                {
                    //string[] strLoads = new string[1];
                    //int res = myfuncs.getExtStr(flname, ref strLoads);
                    //if (res != 0)
                    //{
                    //    MessageBox.Show("Fail, Err#" + res);
                    //}
                    int[] findIndex = new int[1];
                    //res = myfuncs.getnumExtLoad(strLoads, ref findIndex);
                    //if (res != 0)
                    //{
                    //    MessageBox.Show("Fail, Err#" + res);
                    //}

                    if (findIndex.Length > 0)
                    {
                        //int numP_ext = Convert.ToInt32(strLoads[findIndex[findIndex.Length - 1]].Split(':')[1]);
                        //if (numP < numP_ext)
                        //{
                        //    MessageBoxResult messboxres_numP = MessageBox.Show("Выбрано меньше точек чем в файле эксперимента\r\n\r\nВзять число точек из файла?", "numP < countp", MessageBoxButton.YesNo);
                        //    switch (messboxres_numP)
                        //    {
                        //        case MessageBoxResult.No:
                        //            return;
                        //        case MessageBoxResult.Yes:
                        //            numP = numP_ext;
                        //            break;
                        //    }
                        //}
                        FileStream fs          = new FileStream(flname, FileMode.Open);
                        StreamReader sr        = new StreamReader(fs);
                        string strRead         = sr.ReadLine();
                        int countsExt          = Convert.ToInt32(strRead);
                        double[] time          = new double[countsExt];
                        double[][][] lstF      = new double[countsExt][][];
                        double[][][] lstFem1   = new double[countsExt][][];
                        double[][][] lstFep1   = new double[countsExt][][];
                        double[][][] lsta      = new double[countsExt][][];
                        double[][][] lstv      = new double[countsExt][][];
                        double[][][] lstdispla = new double[countsExt][][];
                        double[][][] lstcoords = new double[countsExt][][];
                        double[][][] lstb      = new double[countsExt][][];

                        double[][][] lstaAN      = new double[countsExt][][];
                        double[][][] lstvAN      = new double[countsExt][][];
                        double[][][] lstdisplAN  = new double[countsExt][][];
                        double[][][] lstcoordsAN = new double[countsExt][][];
                        double[][][] lstFAN      = new double[countsExt][][];

                        double[][][] lstVmp = new double[countsExt][][];

                        strRead              = sr.ReadLine();
                        double dtExt         = Convert.ToDouble(strRead);
                        string[] strload     = sr.ReadLine().Split(':');
                        points               = new point[numP];
                        ExtLoadType loadType = ExtLoad.getPoint(strload[2]);
                        if (Modeltype == Models.particle)
                        {
                            for (int np = 0; np < numP; np++)
                            {
                                points[np] = new point
                                {
                                    ExtLoad = loadType
                                };
                            }
                        }
                        else
                        {
                            for (int np = 0; np < numP; np++)
                            {
                                points[np]         = new point();
                                points[np].ExtLoad = ExtLoadType.none;
                            }
                        }
                        points[Convert.ToInt32(strload[1])].ExtLoad = ExtLoad.getPoint(strload[2]);
                        sr.Close();
                        fs.Close();
                        calc.t(countsExt, dtExt, ref time);
                        initArr._3d(numP, 3, ref lstF);
                        initArr._3d(numP, 3, ref lstdispla);
                        initArr._3d(numP, 3, ref lstcoords);
                        initArr.Coords(L / numP, points, ref lstcoords);
                        initArr._3d(numP, 3, ref lstFem1);
                        initArr._3d(numP, 3, ref lstFep1);
                        initArr._3d(numP, 3, ref lsta);
                        initArr._3d(numP, 3, ref lstv);
                        initArr._3d(numP, 3, ref lstb);
                        initArr._3d(numP, 3, ref lstaAN);
                        initArr._3d(numP, 3, ref lstvAN);
                        initArr._3d(numP, 3, ref lstdisplAN);
                        initArr._3d(numP, 3, ref lstcoordsAN);
                        initArr._3d(numP, 3, ref lstFAN);
                        initArr._3d(numP, 3, ref lstVmp);

                        if (CalcType == CalcTypes.statical)
                        {
                            calc.StaticMovement(flname, points, Modeltype, IntegShematype, CalcType, MaterialModeltype, Retype, IsConsoleOut,
                                                L, b, h, ro, numP, countsExt, elastic, v0, vamp, D, Re, time,
                                                ref lstF, ref lstFep1, ref lstFem1, ref lsta, ref lstb, ref lstv, ref lstdispla, ref lstcoords, ref lstvAN);
                        }
                        else
                        {
                            calc.Movement(flname, points, Modeltype, IntegShematype, CalcType, MaterialModeltype, Retype, IsConsoleOut,
                                          L, b, h, ro, numP, countsExt, elastic, v0, vamp, D, Re, time,
                                          ref lstF, ref lstFep1, ref lstFem1, ref lsta, ref lstb, ref lstv, ref lstdispla, ref lstcoords,
                                          ref lstaAN, ref lstvAN, ref lstdisplAN, ref lstcoordsAN, ref lstFAN, ref lstVmp);
                        }

                        Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            plotxy plot = new plotxy();

                            plot = new plotxy();
                            plot.Show();
                            plot.dt     = dtExt;
                            plot.time   = time;
                            plot.coords = lstcoords;
                            plot.draw2d(axistype.t, axistype.x, numP, 1, true, false, "x(t)", "Time", "X", false, System.Drawing.Color.Red);
                            plot.initControls();
                            plotxys.Add(plot);

                            if (Modeltype == Models.particle)
                            {
                                plot = new plotxy();
                                plot.Show();
                                plot.dt     = dtExt;
                                plot.time   = time;
                                plot.coords = lstdisplAN;
                                plot.draw2d(axistype.t, axistype.x, numP, 1, true, false, "displAN(t)", "t", "displAN", false, System.Drawing.Color.Red);
                                plot.initControls();
                                plot.coords = lstdispla;
                                plot.draw2d(axistype.t, axistype.x, numP, 1, true, false, "displ(t)", "t", "displ", true, System.Drawing.Color.Blue);
                                plot.initControls();
                                plotxys.Add(plot);

                                plot = new plotxy();
                                plot.Show();
                                plot.dt     = dtExt;
                                plot.time   = time;
                                plot.coords = lstvAN;
                                plot.draw2d(axistype.t, axistype.x, numP, 1, true, false, "vAN(t)", "t", "vAN", false, System.Drawing.Color.Red);
                                plot.initControls();
                                plot.coords = lstv;
                                plot.draw2d(axistype.t, axistype.x, numP, 1, true, false, "v(t)", "t", "v", true, System.Drawing.Color.Blue);
                                plot.initControls();
                                plotxys.Add(plot);

                                plot = new plotxy();
                                plot.Show();
                                plot.dt     = dtExt;
                                plot.time   = time;
                                plot.coords = lstaAN;
                                plot.draw2d(axistype.t, axistype.x, numP, 1, true, false, "aAN(t)", "t", "aAN", false, System.Drawing.Color.Red);
                                plot.initControls();
                                plot.coords = lsta;
                                plot.draw2d(axistype.t, axistype.x, numP, 1, true, false, "a(t)", "t", "a", true, System.Drawing.Color.Blue);
                                plot.initControls();
                                plotxys.Add(plot);

                                plot = new plotxy();
                                plot.Show();
                                plot.dt     = dtExt;
                                plot.time   = time;
                                plot.coords = lstFAN;
                                plot.draw2d(axistype.t, axistype.x, numP, 1, true, false, "Fan(t)", "t", "Fan", false, System.Drawing.Color.Red);
                                plot.initControls();
                                plot.coords = lstF;
                                plot.draw2d(axistype.t, axistype.x, numP, 1, true, false, "F(t)", "t", "F", true, System.Drawing.Color.Blue);
                                plot.initControls();
                                plotxys.Add(plot);

                                plot = new plotxy();
                                plot.Show();
                                plot.dt     = dtExt;
                                plot.time   = time;
                                plot.coords = lstVmp;
                                plot.draw2d(axistype.t, axistype.x, numP, 1, true, false, "Fan(t)", "t", "Fan", false, System.Drawing.Color.Red);
                                plot.initControls();
                                plotxys.Add(plot);
                            }
                            //plot.Show();
                            //plot.draw2d(axistype.t, axistype.x, lstFep1, time, numP, 1, false, false, "Fep1(x)", "t", "N");
                            //plotxys.Add(plot);
                        }));
                        ClearEffect(this);
                        //GC.Collect();
                    }
                }
                else
                {
                    MessageBox.Show("В файле нет нагруженных точек");
                }
            });
            thrdraw.Start();
        }