Exemple #1
0
        public static double CalculateAreaValue(RealPoint resultPoint, Segment segmentI, CollocationPoint collPointI, ConfigurationData configurationData)
        {
            double result       = 0.0;
            double denominator2 = Function_q.denominator2(configurationData.GetDiffusionCoefficient(segmentI.TemperatureValue), configurationData.iterationProcess.TimeStep);

            foreach (var integrationPoint in segmentI.SingularBoundaryIntegrationPointsForArea)
            {
                result += CalculateCore(denominator2, resultPoint, integrationPoint, segmentI, collPointI);
            }
            return(result);
        }
Exemple #2
0
        public static double[,] CalculateBoundaryMatrix(Area Area)
        {
            double[,] matrix = matrix = new double[Area.NumberOfCollocationPoints, Area.NumberOfCollocationPoints];
            double denominator2 = Function_q.denominator2(Area.configurationData.GetDiffusionCoefficient(0), Area.configurationData.iterationProcess.TimeStep);
            int    r = 0, i = 0;

            //Parallel.ForEach(Area.Segments, (segmentR) =>
            foreach (var segmentR in Area.Segments)
            {
                foreach (var collPointR in segmentR.CollocationPoints)
                {
                    foreach (var segmentI in Area.Segments)
                    {
                        if (Area.configurationData.arePropertiesTimeDependent())
                        {
                            denominator2 = Function_q.denominator2(Area.configurationData.GetDiffusionCoefficient(segmentI.TemperatureValue), Area.configurationData.iterationProcess.TimeStep);
                        }

                        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 (segmentI.Index != segmentR.Index)
                            {
                                foreach (var integrationPoint in segmentI.BoundaryIntegrationPoints)
                                {
                                    value -= (double)(CalculateCore(denominator2, collPointR.RealPosition, integrationPoint, segmentI, collPointI));
                                }
                            }
                            else
                            {
                                if (segmentR.DistanceFromSingularPoint == 0.0)
                                {
                                    value -= SigularSeparate(denominator2, segmentR, collPointR, segmentI, collPointI);
                                }
                                else
                                {
                                    value -= SigularSeparateWithAnalitycal(denominator2, segmentR, collPointR, segmentI, collPointI);
                                }
                                //value = -SigularAnalitycalMajchrzak(denominator2, segmentR, collPointR, segmentI, collPointI);
                            }
                            matrix[r, i] = value;
                        }
                    }
                }
            }//);
            return(matrix);
        }
        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]);
        }
        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];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }