コード例 #1
0
        public Area CalculateIterationForSingleArea()
        {
            this.Problem.Areas[0].calculateVariableBoundaryConditions();
            this.Problem.Areas[0].CalculateBoundaryTemperature();

            this.vectorF = this.Problem.Areas[0].GetKnownBoundaryVector();

            if (this.Problem.IterationProcess.CurrentIteration == 1 || this.Problem.Areas[0].configurationData.arePropertiesTimeDependent())
            {
                this.matrixT = Function_T.CalculateBoundaryMatrix(this.Problem.Areas[0]);
                this.matrixq = Function_q.CalculateBoundaryMatrix(this.Problem.Areas[0]);
            }

            if (Problem.IterationProcess.CurrentIteration == 1)
            {
                Problem.CalculateCollocationPointsConstants();
                Problem.CalculateSurfaceIntegrationPointsConstants();
            }
            this.SeparateKnownFromUnknownForSingleArea();
            this.CalculateKnownVectorForSingleArea();

            //To tradycyjnie
            this.initialCondition = InitialCondition.CalculateBoundaryVector(this.Problem.Areas[0]);
            //To w przypadku przechowywania parametrów
            //this.GetInitialConditionVectorFromCollocationPointsConstants();
            this.AddInitialConditionForSingleArea();

            if (this.Problem.Areas[0].configurationData.addHeatSource)
            {
                if (this.Problem.Areas[0].configurationData.isHeatSourceTimeDependent || this.Problem.IterationProcess.CurrentIteration == 1)
                {
                    this.heatSource = HeatSource.CalculateBoundaryVector(this.Problem.Areas[0]);
                }
                this.AddHeatSource();
            }

            this.SolveEquations();
            this.SetUnknownBoundaryConditionsForSingleArea();

            return(this.Problem.Areas[0]);
        }
コード例 #2
0
        private void BuildMatrixesForMultipleAreas()
        {
            var matrixT0 = Function_T.CalculateBoundaryMatrix(this.Problem.Areas[0]);
            var matrixq0 = Function_q.CalculateBoundaryMatrix(this.Problem.Areas[0]);
            var matrixT1 = Function_T.CalculateBoundaryMatrix(this.Problem.Areas[1]);
            var matrixq1 = Function_q.CalculateBoundaryMatrix(this.Problem.Areas[1]);

            foreach (var areaR in this.Problem.Areas)
            {
                foreach (var segmentR in areaR.Segments)
                {
                    foreach (var collPointR in segmentR.CollocationPoints)
                    {
                        foreach (var areaI in this.Problem.Areas)
                        {
                            foreach (var segmentI in areaI.Segments)
                            {
                                foreach (var collPointI in segmentI.CollocationPoints)
                                {
                                    var r = this.Problem.Areas.Where(x => x.Index < areaR.Index).Sum(x => x.NumberOfCollocationPoints)
                                            + areaR.Segments.Where(x => x.Index < segmentR.Index).Sum(x => x.CollocationPoints.Count)
                                            + collPointR.Index;
                                    var i = this.Problem.Areas.Where(x => x.Index < areaI.Index).Sum(x => x.NumberOfCollocationPoints)
                                            + areaI.Segments.Where(x => x.Index < segmentI.Index).Sum(x => x.CollocationPoints.Count)
                                            + collPointI.Index;
                                    //var r2 = areaR.Index * areaR.NumberOfCollocationPoints + segmentR.Index * segmentR.CollocationPoints.Count() + collPointR.Index;
                                    //var i2 = areaI.Index * areaI.NumberOfCollocationPoints + segmentI.Index * segmentI.CollocationPoints.Count() + collPointI.Index;

                                    var rx = areaR.Segments.Where(x => x.Index < segmentR.Index).Sum(x => x.CollocationPoints.Count) + collPointR.Index;
                                    var ix = areaI.Segments.Where(x => x.Index < segmentI.Index).Sum(x => x.CollocationPoints.Count) + collPointI.Index;
                                    //var rx2 = segmentR.Index * segmentR.CollocationPoints.Count() + collPointR.Index;
                                    //var ix2 = segmentI.Index * segmentI.CollocationPoints.Count() + collPointI.Index;

                                    this.matrixT[r, i] = 0.0;
                                    this.matrixq[r, i] = 0.0;

                                    if (areaR.Index == 0)
                                    {
                                        if (areaI.Index == 0 && !segmentI.isConnectionBoundary)
                                        {
                                            this.matrixT[r, i] = -matrixT0[rx, ix];
                                            this.matrixq[r, i] = -matrixq0[rx, ix];
                                        }
                                        if (areaI.Index == 0 && segmentI.isConnectionBoundary)
                                        {
                                            var iy = this.Problem.Areas[0].Segments.Where(x => x.Index < this.Problem.Areas[0].Segments.Where(y => y.isConnectionBoundary).First().Index).Sum(x => x.CollocationPoints.Count) + collPointI.Index;
                                            //var iy2 = this.Problem.Areas[0].Segments.Where(x => x.isConnectionBoundary).First().Index * segmentI.CollocationPoints.Count() + collPointI.Index;
                                            this.matrixq[r, i] = -matrixq0[rx, iy];
                                        }
                                        if (areaI.Index == 1 && segmentI.isConnectionBoundary)
                                        {
                                            var iy = this.Problem.Areas[0].Segments.Where(x => x.Index < this.Problem.Areas[0].Segments.Where(y => y.isConnectionBoundary).First().Index).Sum(x => x.CollocationPoints.Count) + collPointI.Index;
                                            // var iy2 = this.Problem.Areas[0].Segments.Where(x => x.isConnectionBoundary).First().Index * segmentI.CollocationPoints.Count() + collPointI.Index;
                                            this.matrixq[r, i] = matrixT0[rx, iy];
                                        }
                                    }
                                    if (areaR.Index == 1)
                                    {
                                        if (areaI.Index == 1 && !segmentI.isConnectionBoundary)
                                        {
                                            this.matrixT[r, i] = matrixT1[rx, ix];
                                        }

                                        if (segmentR.isConnectionBoundary)
                                        {
                                            if (areaI.Index == 0 && segmentI.isConnectionBoundary)
                                            {
                                                var ry = this.Problem.Areas[1].Segments.Where(x => x.Index < this.Problem.Areas[1].Segments.Where(y => y.isConnectionBoundary).First().Index).Sum(x => x.CollocationPoints.Count)
                                                         + segmentR.CollocationPoints.Count() - 1 - collPointR.Index;
                                                var iy = this.Problem.Areas[1].Segments.Where(x => x.Index < this.Problem.Areas[1].Segments.Where(y => y.isConnectionBoundary).First().Index).Sum(x => x.CollocationPoints.Count) + collPointI.Index;
                                                //var ry2 = this.Problem.Areas[1].Segments.Where(x => x.isConnectionBoundary).First().Index * segmentR.CollocationPoints.Count()
                                                //   + segmentR.CollocationPoints.Count() - 1 - collPointR.Index;
                                                // var iy2 = this.Problem.Areas[1].Segments.Where(x => x.isConnectionBoundary).First().Index + collPointI.Index;
                                                this.matrixq[r, i] = matrixq1[ry, iy];
                                            }
                                            if (areaI.Index == 1 && segmentI.isConnectionBoundary)
                                            {
                                                var ry = this.Problem.Areas[1].Segments.Where(x => x.Index < this.Problem.Areas[1].Segments.Where(y => y.isConnectionBoundary).First().Index).Sum(x => x.CollocationPoints.Count)
                                                         + segmentR.CollocationPoints.Count() - 1 - collPointR.Index;
                                                var iy = this.Problem.Areas[1].Segments.Where(x => x.Index < this.Problem.Areas[1].Segments.Where(y => y.isConnectionBoundary).First().Index).Sum(x => x.CollocationPoints.Count) + collPointI.Index;
                                                //var ry2 = this.Problem.Areas[1].Segments.Where(x => x.isConnectionBoundary).First().Index * segmentR.CollocationPoints.Count() + segmentR.CollocationPoints.Count() - 1 - collPointR.Index;
                                                //var iy2 = this.Problem.Areas[1].Segments.Where(x => x.isConnectionBoundary).First().Index + collPointI.Index;
                                                this.matrixq[r, i] = matrixT1[ry, iy];
                                            }
                                            if (areaI.Index == 1 && !segmentI.isConnectionBoundary)
                                            {
                                                this.matrixq[r, i] = matrixq1[rx, ix];
                                            }
                                        }
                                        if (!segmentR.isConnectionBoundary)
                                        {
                                            if (areaI.Index == 0 && segmentI.isConnectionBoundary)
                                            {
                                                var ry = areaR.Segments.Where(x => x.Index < (areaR.Segments.Count() - segmentR.Index)).Sum(x => x.CollocationPoints.Count)
                                                         + segmentR.CollocationPoints.Count() - 1 - collPointR.Index;
                                                var iy = this.Problem.Areas[1].Segments.Where(x => x.Index < this.Problem.Areas[1].Segments.Where(y => y.isConnectionBoundary).First().Index).Sum(x => x.CollocationPoints.Count) + collPointI.Index;
                                                //var ry2 = (areaR.Segments.Count() - segmentR.Index) * segmentR.CollocationPoints.Count() + segmentR.CollocationPoints.Count() - 1 - collPointR.Index;
                                                // var iy2 = this.Problem.Areas[1].Segments.Where(x => x.isConnectionBoundary).First().Index * segmentI.CollocationPoints.Count() + collPointI.Index;
                                                this.matrixq[r, i] = matrixq1[ry, iy];
                                            }
                                            if (areaI.Index == 1 && segmentI.isConnectionBoundary)
                                            {
                                                var ry = areaR.Segments.Where(x => x.Index < (areaR.Segments.Count() - segmentR.Index)).Sum(x => x.CollocationPoints.Count)
                                                         + segmentR.CollocationPoints.Count() - 1 - collPointR.Index;
                                                var iy = this.Problem.Areas[1].Segments.Where(x => x.Index < this.Problem.Areas[1].Segments.Where(y => y.isConnectionBoundary).First().Index).Sum(x => x.CollocationPoints.Count) + collPointI.Index;
                                                //var ry2 = (areaR.Segments.Count() - segmentR.Index) * segmentR.CollocationPoints.Count() + segmentR.CollocationPoints.Count() - 1 - collPointR.Index;
                                                //var iy2 = this.Problem.Areas[1].Segments.Where(x => x.isConnectionBoundary).First().Index * segmentI.CollocationPoints.Count() + collPointI.Index;
                                                this.matrixq[r, i] = matrixT1[ry, iy];
                                            }
                                            if (areaI.Index == 1 && !segmentI.isConnectionBoundary)
                                            {
                                                this.matrixq[r, i] = matrixq1[rx, ix];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }