Ejemplo n.º 1
0
        void ComputeViewFactor()
        {
            // Components
            SatComponent Source     = Model.Components[RadSourceIdx];
            SatComponent Target     = Model.Components[RadTargetIdx];
            AAFace       SourceFace = FaceList[RadSourceFaceIdx];
            // Areas
            float SourceArea      = Source.GetBBoxTotalArea();
            float SourceFaceArea  = Source.GetBBoxFaceArea(SourceFace);
            float TargetArea      = Target.GetBBoxTotalArea();
            float AreaRatioSource = SourceFaceArea / SourceArea;
            // Adjust for large sources (since only looking from one position)
            float AreaRatioSourceTarget = SourceArea / TargetArea > 1 ? SourceArea / TargetArea : 1;
            // View factor F_s->t
            float Factor = GetPixelSum(RTViewFactor) / AreaRatioSourceTarget;
            // Area-weighted view factors
            float WeightedFactor = Factor * AreaRatioSource; // * AreaRatioTarget;
                                                             // Save results
            string SourceName = Source.Name;
            string TargetName = Target.Name;

            VFPerFace.Add(new ViewFactorPerFace(SourceName, TargetName, SourceFace, WeightedFactor));
            // Text output
            if (!Settings.f_ComputationRunning || Settings.f_Verbose)
            {
                Console.Write("From (" + SourceName + "," + SourceFace + ")");
                Console.WriteLine(" to (" + TargetName + ")");
                Console.Write("\t Weighted view factor = " + WeightedFactor.ToString("F6", Settings.Format));
                Console.WriteLine(" (" + Factor.ToString("F3", Settings.Format) + ")");
                Console.WriteLine("\t Source area ratio = " + AreaRatioSource.ToString("F4", Settings.Format));
            }
            Settings.f_ComputeArea = false;
            // Save values for verification
            if (f_StartVerification)
            {
                v_Results.Add(v_StepNum * v_DistStep, Factor);
            }
            // Progress
            if (Settings.f_ComputationRunning)
            {
                if ((CurrentCalc % (int)Math.Ceiling(MaxCalc / 10.0f)) == 0)
                {
                    Console.Write('.');
                }
            }
        }
Ejemplo n.º 2
0
        Dictionary <ViewFactorCoordinate, float> FindInconsistencies(Dictionary <ViewFactorCoordinate, float> toCheck)
        {
            Dictionary <ViewFactorCoordinate, float> Results = new Dictionary <ViewFactorCoordinate, float>();

            foreach (KeyValuePair <ViewFactorCoordinate, float> p in toCheck)
            {
                // If zero value, check reciprocal
                if (p.Value == 0)
                {
                    ViewFactorCoordinate CRec = p.Key.Swap();
                    if (toCheck.TryGetValue(CRec, out float VFRec))
                    {
                        SatComponent Source = Model.Components.Find(x => string.Compare(x.Name, p.Key.SourceName, true) == 0);
                        SatComponent Target = Model.Components.Find(x => string.Compare(x.Name, p.Key.TargetName, true) == 0);

                        if (Source != null && Target != null)
                        {
                            float AreaSource = Source.GetBBoxTotalArea();
                            float AreaTarget = Target.GetBBoxTotalArea();

                            try
                            {
                                VFRec = AreaTarget / AreaSource * VFRec;
                                if (Settings.f_Verbose)
                                {
                                    Console.WriteLine("\tChanging VF from " + p.Value.ToString("F4", Settings.Format) + " to " + VFRec.ToString("F4", Settings.Format));
                                }
                            }
                            catch
                            {
                                VFRec = p.Value;
                            }
                        }
                    }
                    Results.Add(p.Key, VFRec);
                }
                else
                {
                    Results.Add(p.Key, p.Value);
                }
            }
            return(Results);
        }