private void FillExamples()
        {
            const int    n = 40;
            const double r = 8;

            void CentersToExapmles(Point[] Centers, ref List <Source> expls)
            {
                for (int i = 0; i < Centers.Length; i++)
                {
                    Waves.Circle     c    = new Waves.Circle(new МатКлассы.Point(Centers[i]), r);
                    Waves.Normal2D[] norm = c.GetNormalsOnCircle(n);
                    var fw = GetFmas();
                    expls.Add(new Source(c, norm, fw));
                }
            }

            void CentersToExapmlesDcircle(Point[] Centers, ref List <Source> expls)
            {
                for (int i = 0; i < Centers.Length; i++)
                {
                    Waves.DCircle c = new Waves.DCircle(Centers[i], 16, 5, arg: (135 * Math.PI / 180));
                    //  Waves.Normal2D[] norm = c.GetNormalsOnDCircle();
                    var fw = GetFmas();
                    expls.Add(new Source(c, fw));
                }
            }

            CentersToExapmles(centers, ref examples);
            CentersToExapmles(centers2, ref examples2);
            CentersToExapmlesDcircle(centers2, ref examples3);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            double x = textBox1.Text.ToDouble();
            double y = textBox4.Text.ToDouble();
            double r = textBox5.Text.ToDouble();
            int    n = numericUpDown2.Value.ToInt32();

            Waves.Circle     c    = new Waves.Circle(new МатКлассы.Point(x, y), r);
            Waves.Normal2D[] norm = c.GetNormalsOnCircle(n);

            Source s = new Source(c, norm, GetFmas());

            if (Get)
            {
                Forms.UG.SetSource(s);
            }
            else
            {
                Uxt.sources.Add(s);
                Uform.Recostract();
            }
            this.Close();
        }
Пример #3
0
        public async void button1_Click(object sender, EventArgs e)
        {
            HankelTuple = HankelTupleClear;
            ClearSeries();
            toolStripStatusLabel1.Text = "Чтение данных и генерация переменных";

            int k = Convert.ToInt32(numericUpDown1.Value);

            CreateArrays(k);

            double cor = GetCorner();

            beg = textBox2.Text.ToDouble();
            end = textBox3.Text.ToDouble();
            Waves.Circle circle = sourceIt.GetCircle;

            double h = (end - beg) / (k - 1);

            Waves.Normal2D[] norms = sourceIt.Norms;
            Waves.Normal2D   N     = circle.GetNormal(cor);
            double           w     = textBox7.Text.ToDouble();

            prbar = new int[k]; timer1.Enabled = true;
            int ind = listBox1.SelectedIndex;

            toolStripStatusLabel1.Text = "Мемоизация PMRSN (занимает неопределённое время)"; timer2.Start();
            DateTime t1 = DateTime.Now;

            ShowCancelControls();

            source = new System.Threading.CancellationTokenSource();
            System.Threading.CancellationToken token = source.Token;
            await Task.Run(() =>
            {
                for (int ie = 0; ie < xval.Length; ie++)
                {
                    xval[ie] = beg + ie *h;
                }

                switch (ind)
                {
                case 0:
                    Parallel.For(0, k, (int i) =>
                    {
                        if (token.IsCancellationRequested)
                        {
                            toolStripStatusLabel1.Text = "Асинхронная операция была отменена"; return;
                        }
                        SetIElemForAll(i, GetTupF(N.Position.x + N.n.x *xval[i], N.Position.y + N.n.y *xval[i], w, norms), cor);
                    });
                    break;

                case 1:
                    Parallel.For(0, k, (int i) =>
                    {
                        if (token.IsCancellationRequested)
                        {
                            toolStripStatusLabel1.Text = "Асинхронная операция была отменена"; return;
                        }
                        SetIElemForAll(i, GetTupF(N.Position.x + N.n.x *w, N.Position.y + N.n.y *w, xval[i], norms), cor);
                    });
                    break;

                case 3:
                    Parallel.For(0, k, (int i) =>
                    {
                        if (token.IsCancellationRequested)
                        {
                            toolStripStatusLabel1.Text = "Асинхронная операция была отменена"; return;
                        }
                        Complex[] tmp2 = u(N.Position.x + N.n.x *w, N.Position.y + N.n.y *w, xval[i] /** ThU / SpU*/, norms).ToComplex();
                        SetIElemForAll(i, new Complex[3], tmp2, cor);
                    });
                    Setzlim(uRvalRes, uRzRes);
                    break;

                default:
                    beg = 0;
                    end = pimult2;
                    Parallel.For(0, k, (int i) =>
                    {
                        if (token.IsCancellationRequested)
                        {
                            toolStripStatusLabel1.Text = "Асинхронная операция была отменена"; return;
                        }
                        xval[i] = beg + i *h;
                        SetIElemForAll(i, GetTupF(norms[i].Position.x, norms[i].Position.y, w, norms), norms[i].Corner);
                    });
                    break;
                }
            });

            if (ind == 3 && checkBox13.Checked)
            {
                DrawUXW(N.Position.x + N.n.x * w, N.Position.y + N.n.y * w, 0, norms, cor);
            }

            HideCancelControls();

            switch (ind)
            {
            case 0:
                chart1.Titles[0].Text = $"(x,y): [{N.Position.x}; {N.Position.y}]...[{N.Position.x + N.n.x * xval[k - 1]}; {N.Position.y + N.n.y * xval[k - 1]}], w = {w}";
                break;

            case 1:
                chart1.Titles[0].Text = $"(x,y) = ({N.Position.x + N.n.x * w}; {N.Position.y + N.n.y * w}), w = {beg} ... {end}";
                break;

            case 3:
                chart1.Titles[0].Text = $"(x,y) = ({N.Position.x + N.n.x * w}; {N.Position.y + N.n.y * w}), t = {beg} ... {end}";
                break;

            default:
                chart1.Titles[0].Text = $"(x,y) in ({sourceIt.Center}; {sourceIt.radius}), w = {w}";
                break;
            }

            timer2.Stop();
            timer1.Stop();
            toolStripStatusLabel1.Text = $"Вычисления закончены. Время: {DateTime.Now - t1}";
            Expendator.WriteInFile($"ur, uz (last)", new Vectors(xval), new Vectors(uRval), new Vectors(uIval), new Vectors(umodval), new Vectors(uRz), new Vectors(uIz), new Vectors(uAz));
            pictureBox1.Hide();
            progressBar1.Value = progressBar1.Maximum;
            ReDraw();

            HankelTuple = HankelTupleWith;
        }