コード例 #1
0
        public virtual void FillData()
        {
            int step = View.Model.Step;
            List <SolutionItemColoredModel> solutionItems = View.Model.SolutionItems;

            View.FillListView(solutionItems);

            View.Model.CurveGroups.Clear();
            using (CalculationDbContext db = new CalculationDbContext())
            {
                foreach (var solutionItemColored in solutionItems)
                {
                    var  solutionItem = solutionItemColored.Item;
                    var  bundle       = db.GetBundle(solutionItem.Id);
                    var  grid         = bundle.GetGrid();
                    bool isPeriodic   = bundle.IsPeriodic();

                    List <Array> layers = isPeriodic ?
                                          bundle.GetLastPeriodLayers(step) :
                                          bundle.GetSeparatedArrays(step);
                    List <Curve2D> curves =
                        layers.Select(l => new Curve2D(l.Values, grid.Values, solutionItemColored.Color)).ToList();
                    View.Model.CurveGroups.Add(Guid.NewGuid().ToString(), curves);
                }
            }
        }
コード例 #2
0
        public override void FillData()
        {
            List <SolutionItemColoredModel> solutionItems = View.Model.SolutionItems;

            View.FillListView(solutionItems);

            View.Model.Curves.Clear();
            string exactSolverType = typeof(PulsationLaminarExactSolver).Name;

            using (CalculationDbContext db = new CalculationDbContext())
            {
                var exactSolution = solutionItems.FirstOrDefault(s => s.Item.SolverType == exactSolverType);
                if (exactSolution == null)
                {
                    return;
                }

                int            exactSolutionId = exactSolution.Item.Id;
                var            exactBundle     = db.GetBundle(exactSolutionId);
                var            exactLayers     = exactBundle.GetAllArrays();
                List <Curve2D> curves          = new List <Curve2D>();
                foreach (var solutionItemColored in solutionItems)
                {
                    var solutionItem = solutionItemColored.Item;
                    var bundle       = db.GetBundle(exactSolutionId);
                    if (solutionItem.SolverType != exactSolverType)
                    {
                        var     layers = bundle.GetAllArrays();
                        Curve2D curve  = new Curve2D(solutionItemColored.Color);
                        double  t      = 0;
                        for (int i = 0; i < exactSolution.Item.Count; i++)
                        {
                            double max = exactLayers[i].Subtract(layers[i]).NormInf();
                            curve.Add(t, max);
                            t += solutionItem.dt;
                        }
                        curves.Add(curve);
                        View.Model.Curves.Add(solutionItem.Name, curve);
                    }
                }
            }
        }
コード例 #3
0
        private void OnCalculateAlphaClicked(object sender, EventArgs e)
        {
            var solutionItem = View.SelectedItem;

            if (solutionItem != null)
            {
                PulsationAlphaSolver solver = new PulsationAlphaSolver();
                using (CalculationDbContext db = new CalculationDbContext())
                {
                    var group               = db.GetBundle(solutionItem.Id);
                    var pulsationData       = group.GetData <PulsationData>();
                    PulsationAlphaData data = new PulsationAlphaData(pulsationData, group);
                    solver.Solve("Alpha", data);
                }
            }
        }
コード例 #4
0
        public void Solve(string name, PulsationAlphaData data)
        {
            using (CalculationDbContext context = new CalculationDbContext())
            {
                var bundle = context.GetBundle(data.GroupId);

                int NPeriod = bundle.PeriodN();

                var grid = bundle.GetGrid();

                var alphaGroup = new Bundle("Нахождение коэффициентов alpha", data);

                int Nt = bundle.GetCount();

                context.SaveChanges();

                try
                {
                    IIntegrator integrator = new SimpsonIntegrator();

                    var lastPeriodLayers = bundle.GetArrays(Nt - NPeriod, NPeriod);
                    int number           = 0;
                    for (int deg = 2; deg <= 3; deg++)
                    {
                        double[] alphaValues = new double[NPeriod];
                        for (int i = 0; i < NPeriod; i++)
                        {
                            alphaValues[i] = CalculateAlpha(integrator, deg, lastPeriodLayers[i], grid.Values, grid.h, NPeriod);
                        }
                        alphaGroup.AddArray(string.Format("alpha{0}", number + 1), number, alphaValues);
                        number++;
                    }
                    OnSolved(true);
                }
                catch (Exception exception)
                {
                    OnSolved(false, exception);
                }
            }
        }
コード例 #5
0
 private void OnExportClicked(object sender, EventArgs e)
 {
     if (View.SelectedItem != null)
     {
         var            item           = View.SelectedItem;
         SaveFileDialog saveFileDialog = new SaveFileDialog
         {
             Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
         };
         if (saveFileDialog.ShowDialog() == DialogResult.OK)
         {
             string         filename = saveFileDialog.FileName;
             ArraysExporter exporter = new ArraysExporter();
             using (CalculationDbContext db = new CalculationDbContext())
             {
                 var bundle = db.GetBundle(item.Id);
                 var arrays = bundle.GetAllArrays();
                 exporter.ExportToFile(filename, bundle.GetData <PulsationData>(), arrays);
             }
         }
     }
 }
コード例 #6
0
        public virtual void FillData()
        {
            List <SolutionItemColoredModel> solutionItems = View.Model.SolutionItems;

            View.FillListView(solutionItems);

            View.Model.Curves.Clear();

            using (CalculationDbContext db = new CalculationDbContext())
            {
                foreach (var solutionItemColored in solutionItems)
                {
                    var solutionItem = solutionItemColored.Item;
                    var bundle       = db.GetBundle(solutionItem.Id);
                    var grid         = bundle.GetGrid();
                    if (!bundle.IsSequence)
                    {
                        var     array = bundle.GetArray(0);
                        Curve2D curve = new Curve2D(grid.Values, array.Values, solutionItemColored.Color);
                        View.Model.Curves.Add(Guid.NewGuid().ToString(), curve);
                    }
                }
            }
        }