コード例 #1
0
        public static double[,] CalculateBoundaryMatrix(Area Area)
        {
            double[,] matrix = new double[Area.NumberOfCollocationPoints, Area.NumberOfCollocationPoints];
            double denominator1 = Function_T.denominator1(Area.configurationData.GetDiffusionCoefficient(), Area.configurationData.iterationProcess.TimeStep);
            double denominator2 = Function_T.denominator2(Area.configurationData.GetThermalConductivity());

            int r = 0, i = 0;


            foreach (var segmentR in Area.Segments)
            // Parallel.ForEach(Area.Segments, (segmentR) =>
            {
                foreach (var collPointR in segmentR.CollocationPoints)
                {
                    foreach (var segmentI in Area.Segments)
                    {
                        foreach (var collPointI in segmentI.CollocationPoints)
                        {
                            r = Area.Segments.Where(x => x.Index < segmentR.Index).Sum(x => x.CollocationPoints.Count) + collPointR.Index;
                            i = Area.Segments.Where(x => x.Index < segmentI.Index).Sum(x => x.CollocationPoints.Count) + collPointI.Index;

                            double value = 0.0;

                            if (Area.configurationData.arePropertiesTimeDependent())
                            {
                                denominator1 = Function_T.denominator1(Area.configurationData.GetDiffusionCoefficient(segmentI.TemperatureValue), Area.configurationData.iterationProcess.TimeStep);
                                denominator2 = Function_T.denominator2(Area.configurationData.GetThermalConductivity(segmentI.TemperatureValue));
                            }

                            if (segmentI.Index != segmentR.Index)
                            {
                                foreach (var integrationPoint in segmentI.BoundaryIntegrationPoints)
                                {
                                    value -= (double)(CalculateCore(collPointR.RealPosition, integrationPoint, denominator1, denominator2, segmentI, collPointI));
                                }
                            }
                            else
                            {
                                value -= SingularSeparate(denominator1, denominator2, collPointR, segmentI, collPointI);

                              //  value -= SigularAnalitycalMajchrzak(denominator1, denominator2, segmentR, collPointR, segmentI, collPointI);
                            }
                            matrix[r, i] = value;
                        }
                    }
                }
            }//);
            return matrix;
        }
コード例 #2
0
         public static double CalculateAreaValue(RealPoint resultPoint, Segment segmentI, CollocationPoint collPointI, ConfigurationData configurationData)
        {
            double result = 0.0;
            double denominator1 = Function_T.denominator1(configurationData.GetDiffusionCoefficient(), configurationData.iterationProcess.TimeStep);
            double denominator2 = Function_T.denominator2(configurationData.GetThermalConductivity());

            if (configurationData.arePropertiesTimeDependent())
            {
                denominator1 = Function_T.denominator1(configurationData.GetDiffusionCoefficient(segmentI.TemperatureValue), configurationData.iterationProcess.TimeStep);
                denominator2 = Function_T.denominator2(configurationData.GetThermalConductivity(segmentI.TemperatureValue));
            }

            foreach (var integrationPoint in segmentI.SingularBoundaryIntegrationPointsForArea)
            {
                result += CalculateCore(resultPoint, integrationPoint, denominator1, denominator2, segmentI, collPointI);
            }
            return result;
        }
コード例 #3
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]);
        }
コード例 #4
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];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }