예제 #1
0
        internal static double Integrate(CoordFunction func)
        {
            #region caching variables

            double halfPi = Math.PI * 0.5;
            double m = Common.Instance.M;
            double a = Common.Instance.A;
            double b = Common.Instance.B;
            double r = Common.Instance.R;
            double uinf = Common.Instance.Uinf;
            double NNGauss = Common.Instance.NNGauss;
            double c1 = Math.Sqrt(m + 1) + 1;
            double c2 = Math.Sqrt(m + 1) - 1;
            double multiplier = ((Math.Sqrt(m + 1) - 1) / 2) * halfPi;

            #endregion

            double sum = 0.0;
            for (int i = 0; i < NNGauss - 1; ++i)
            {
                for (int j = 0; j < NNGauss - 1; ++j)
                {
                    double value = func(c1 / 2 + c2 / 2 * T[i], halfPi + halfPi * T[j], a, b, m, r, uinf);
                    sum += CG[i] * CG[j] * value;
                }
            }

            return multiplier * sum;
        }
예제 #2
0
        public void DoLinear()
        {
            List<CoordFunction> simpleFunctions = Functions.GetCoordFunctions();
            List<CoordFunction> functions = Functions.GetOperatorCoordFunctions();
            int count = functions.Count;
            this.ActionsCount = count * count + count + 1; // nxn интегралов-левая часть, n интегралов-правая часть, 1-решение СЛАУ

            this.Worker.DoWork += new DoWorkEventHandler((object sender, DoWorkEventArgs e) =>
            {

                Task[] tasks = new Task[2];
                List<double> rhs = new List<double>(functions.Count);

                tasks[0] = Task.Factory.StartNew(() =>
                {
                    for (int i = 0; i < functions.Count; ++i)
                    {
                        function = simpleFunctions[i];
                        rhs.Add(-Integration.Integrate(makeRhs)); //минус-потому что потом переносим в правую часть системы
                        this.ReportProgress();
                    }
                });

                double[,] lhs = new double[count, count];

                tasks[1] = Task.Factory.StartNew(() =>
                {
                    for (int i = 0; i < count; ++i)
                    {
                        for (int j = 0; j < count; ++j)
                        {
                            currentI = simpleFunctions[i];
                            currentJ = functions[j];
                            lhs[i, j] = Integration.Integrate(makeLhs);
                            this.ReportProgress();
                        }
                    }
                });

                Task.WaitAll(tasks);

                int info;
                double[] alphas;
                alglib.densesolverreport report;
                alglib.rmatrixsolve(lhs, count, rhs.ToArray(), out info, out report, out alphas);
                this.Progress++;
                this.Worker.ReportProgress(this.Progress);
                // Chop
                for (int i = 0; i < count; ++i)
                {
                    if (Math.Abs(alphas[i]) < this.eps)
                    {
                        alphas[i] = 0;
                    }
                }

                this.Result = alphas;
            });
        }
예제 #3
0
 public double makeReplacement(double ro, double phi, CoordFunction target)
 {
     return target(ro * Math.Sqrt(Math.Pow(a, 2) * Math.Pow(Math.Cos(phi), 2) + Math.Pow(b, 2) * Math.Pow(Math.Sin(phi), 2)), Math.Atan2(b * Math.Sin(phi), a * Math.Cos(phi))
         ,Common.Instance.A, Common.Instance.B, Common.Instance.M, Common.Instance.R, Common.Instance.Uinf);
 }