Beispiel #1
0
        public static AdjacencyCluster ToSAM(this BuildingData buildingData, IEnumerable <SpaceDataType> spaceDataTypes = null, IEnumerable <PanelDataType> panelDataTypes = null)
        {
            if (buildingData == null)
            {
                return(null);
            }

            List <ZoneData> zoneDatas = buildingData.ZoneDatas();

            if (zoneDatas == null)
            {
                return(null);
            }

            AdjacencyCluster result = new AdjacencyCluster();

            foreach (ZoneData zoneData in zoneDatas)
            {
                if (zoneData == null)
                {
                    continue;
                }

                Space space = zoneData.ToSAM(spaceDataTypes);
                if (space != null)
                {
                    result.AddObject(space);
                }

                List <SurfaceData> surfaceDatas = zoneData.SurfaceDatas();
                if (surfaceDatas == null)
                {
                    continue;
                }

                foreach (SurfaceData surfaceData in surfaceDatas)
                {
                    if (surfaceData == null)
                    {
                        continue;
                    }

                    Panel panel = surfaceData.ToSAM(panelDataTypes);
                    if (panel == null)
                    {
                        continue;
                    }

                    result.AddObject(panel);

                    if (space != null)
                    {
                        result.AddRelation(space, panel);
                    }
                }
            }

            return(result);
        }
Beispiel #2
0
        public static List <Core.Result> AddResults(this SimulationData simulationData, AdjacencyCluster adjacencyCluster)
        {
            if (simulationData == null || adjacencyCluster == null)
            {
                return(null);
            }

            List <Core.Result> result = null;

            //get simulaton data from Tas for individal SAM Space
            List <Core.Result> results = Convert.ToSAM(simulationData);

            if (results == null)
            {
                return(result);
            }

            result = new List <Core.Result>(results);

            Dictionary <Guid, List <SpaceSimulationResult> > dictionary = new Dictionary <Guid, List <SpaceSimulationResult> >();
            List <Space> spaces = adjacencyCluster.GetSpaces();

            if (spaces != null && spaces.Count > 0)
            {
                foreach (Space space in spaces)
                {
                    List <SpaceSimulationResult> spaceSimulationResults_Space = results.FindAll(x => x is SpaceSimulationResult && space.Name.Equals(x.Name)).ConvertAll(x => (SpaceSimulationResult)x);
                    dictionary[space.Guid] = spaceSimulationResults_Space;
                    if (spaceSimulationResults_Space != null && spaceSimulationResults_Space.Count != 0)
                    {
                        foreach (SpaceSimulationResult spaceSimulationResult in spaceSimulationResults_Space)
                        {
                            List <SpaceSimulationResult> spaceSimulationResults_Existing = adjacencyCluster.GetResults <SpaceSimulationResult>(space, Query.Source())?.FindAll(x => x.LoadType() == spaceSimulationResult.LoadType());
                            if (spaceSimulationResults_Existing != null && spaceSimulationResults_Existing.Count != 0)
                            {
                                adjacencyCluster.Remove(spaceSimulationResults_Existing);
                                if (spaceSimulationResults_Existing[0].TryGetValue(Analytical.SpaceSimulationResultParameter.DesignLoad, out double designLoad))
                                {
                                    spaceSimulationResult.SetValue(Analytical.SpaceSimulationResultParameter.DesignLoad, designLoad);
                                }
                            }

                            adjacencyCluster.AddObject(spaceSimulationResult);
                            adjacencyCluster.AddRelation(space, spaceSimulationResult);
                        }
                    }

                    foreach (Core.Result result_Temp in results)
                    {
                        PanelSimulationResult panelSimulationResult = result_Temp as PanelSimulationResult;
                        if (panelSimulationResult == null)
                        {
                            continue;
                        }

                        if (!panelSimulationResult.TryGetValue(PanelSimulationResultParameter.ZoneName, out string zoneName) || !space.Name.Equals(zoneName))
                        {
                            continue;
                        }

                        adjacencyCluster.AddObject(panelSimulationResult);
                        adjacencyCluster.AddRelation(space, panelSimulationResult);
                    }
                }
            }

            // get data data about SAM Zones like space GUID, Zone Category etc.
            List <Zone> zones = adjacencyCluster.GetZones();

            if (zones != null && zones.Count > 0)
            {
                //  Query Tas Zones,  that can be linked with SAM Spaces
                BuildingData buildingData = simulationData.GetBuildingData();
                Dictionary <string, ZoneData> dictionary_ZoneData = Query.ZoneDataDictionary(buildingData);

                // Our SAM Zones(list of Space GUIDs)
                foreach (Zone zone in zones)
                {
                    List <Space> spaces_Zone = adjacencyCluster.GetSpaces(zone);
                    if (spaces_Zone == null || spaces_Zone.Count == 0)
                    {
                        continue;
                    }

                    double area      = adjacencyCluster.Sum(zone, SpaceParameter.Area);
                    double volume    = adjacencyCluster.Sum(zone, SpaceParameter.Volume);
                    double occupancy = adjacencyCluster.Sum(zone, SpaceParameter.Occupancy);

                    List <ZoneData> zoneDatas = new List <ZoneData>();
                    foreach (Space space in spaces_Zone)
                    {
                        string name = space?.Name;
                        if (string.IsNullOrWhiteSpace(name))
                        {
                            continue;
                        }

                        List <SpaceSimulationResult> spaceSimulationResults_Space;
                        if (!dictionary.TryGetValue(space.Guid, out spaceSimulationResults_Space) || spaceSimulationResults_Space == null || spaceSimulationResults_Space.Count == 0)
                        {
                            continue;
                        }

                        SpaceSimulationResult spaceSimulationResult = spaceSimulationResults_Space[0];
                        if (spaceSimulationResult == null || string.IsNullOrWhiteSpace(spaceSimulationResult.Reference))
                        {
                            continue;
                        }

                        ZoneData zoneData = dictionary_ZoneData[spaceSimulationResult.Reference];
                        if (zoneData == null)
                        {
                            continue;
                        }

                        zoneDatas.Add(zoneData);
                    }

                    int    index;
                    double max;

                    //Cooling
                    ZoneSimulationResult zoneSimulationResult_Cooling = null;
                    if (buildingData.TryGetMax(zoneDatas.ConvertAll(x => x.zoneGUID), tsdZoneArray.coolingLoad, out index, out max) && index != -1 && !double.IsNaN(max))
                    {
                        zoneSimulationResult_Cooling = new ZoneSimulationResult(zone.Name, Assembly.GetExecutingAssembly().GetName()?.Name, zone.Guid.ToString());
                        zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.MaxSensibleLoad, max);
                        zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.MaxSensibleLoadIndex, index);
                        zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.LoadType, LoadType.Cooling.Text());

                        List <SpaceSimulationResult> spaceSimulationResults_Zone = new List <SpaceSimulationResult>();
                        foreach (ZoneData zoneData in zoneDatas)
                        {
                            SpaceSimulationResult spaceSimulationResult_Temp = Create.SpaceSimulationResult(zoneData, index, LoadType.Cooling, SizingMethod.Simulation);
                            if (spaceSimulationResult_Temp == null)
                            {
                                continue;
                            }

                            spaceSimulationResults_Zone.Add(spaceSimulationResult_Temp);
                        }

                        if (spaceSimulationResults_Zone != null && spaceSimulationResults_Zone.Count != 0)
                        {
                            double airMovementGain = spaceSimulationResults_Zone.Sum(Analytical.SpaceSimulationResultParameter.AirMovementGain);
                            if (!double.IsNaN(airMovementGain))
                            {
                                zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.AirMovementGain, airMovementGain);
                            }

                            double buildingHeatTransfer = spaceSimulationResults_Zone.Sum(Analytical.SpaceSimulationResultParameter.BuildingHeatTransfer);
                            if (!double.IsNaN(buildingHeatTransfer))
                            {
                                zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.BuildingHeatTransfer, buildingHeatTransfer);
                            }

                            double equipmentSensibleGain = spaceSimulationResults_Zone.Sum(Analytical.SpaceSimulationResultParameter.EquipmentSensibleGain);
                            if (!double.IsNaN(equipmentSensibleGain))
                            {
                                zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.EquipmentSensibleGain, equipmentSensibleGain);
                            }

                            double glazingExternalConduction = spaceSimulationResults_Zone.Sum(Analytical.SpaceSimulationResultParameter.GlazingExternalConduction);
                            if (!double.IsNaN(glazingExternalConduction))
                            {
                                zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.GlazingExternalConduction, glazingExternalConduction);
                            }

                            double lightingGain = spaceSimulationResults_Zone.Sum(Analytical.SpaceSimulationResultParameter.LightingGain);
                            if (!double.IsNaN(lightingGain))
                            {
                                zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.LightingGain, lightingGain);
                            }

                            double infiltrationGain = spaceSimulationResults_Zone.Sum(Analytical.SpaceSimulationResultParameter.InfiltrationGain);
                            if (!double.IsNaN(infiltrationGain))
                            {
                                zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.InfiltrationGain, infiltrationGain);
                            }

                            double occupancySensibleGain = spaceSimulationResults_Zone.Sum(Analytical.SpaceSimulationResultParameter.OccupancySensibleGain);
                            if (!double.IsNaN(occupancySensibleGain))
                            {
                                zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.OccupancySensibleGain, occupancySensibleGain);
                            }

                            double opaqueExternalConduction = spaceSimulationResults_Zone.Sum(Analytical.SpaceSimulationResultParameter.OpaqueExternalConduction);
                            if (!double.IsNaN(opaqueExternalConduction))
                            {
                                zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.OpaqueExternalConduction, opaqueExternalConduction);
                            }

                            double solarGain = spaceSimulationResults_Zone.Sum(Analytical.SpaceSimulationResultParameter.SolarGain);
                            if (!double.IsNaN(solarGain))
                            {
                                zoneSimulationResult_Cooling.SetValue(ZoneSimulationResultParameter.SolarGain, solarGain);
                            }
                        }
                    }

                    if (!double.IsNaN(occupancy))
                    {
                        zoneSimulationResult_Cooling?.SetValue(ZoneSimulationResultParameter.Occupancy, occupancy);
                    }

                    if (!double.IsNaN(area))
                    {
                        zoneSimulationResult_Cooling?.SetValue(ZoneSimulationResultParameter.Area, area);
                    }

                    if (!double.IsNaN(volume))
                    {
                        zoneSimulationResult_Cooling?.SetValue(ZoneSimulationResultParameter.Volume, volume);
                    }


                    if (zoneSimulationResult_Cooling != null)
                    {
                        adjacencyCluster.AddObject(zoneSimulationResult_Cooling);
                        adjacencyCluster.AddRelation(zone, zoneSimulationResult_Cooling);
                        result.Add(zoneSimulationResult_Cooling);
                    }

                    //Heating
                    //ZoneSimulationResult zoneSimulationResult_Heating = null;
                    //if (buildingData.TryGetMax(zoneDatas.ConvertAll(x => x.zoneGUID), tsdZoneArray.heatingLoad, out index, out max) && index != -1 && !double.IsNaN(max))
                    //{
                    //zoneSimulationResult_Heating = new ZoneSimulationResult(zone.Name, Assembly.GetExecutingAssembly().GetName()?.Name, zone.Guid.ToString());
                    //zoneSimulationResult_Heating.SetValue(ZoneSimulationResultParameter.MaxSensibleLoad, max);
                    //zoneSimulationResult_Heating.SetValue(ZoneSimulationResultParameter.MaxSensibleLoadIndex, index);
                    //zoneSimulationResult_Heating.SetValue(ZoneSimulationResultParameter.LoadType, LoadType.Heating.Text());

                    //List<SpaceSimulationResult> spaceSimulationResults_Zone = new List<SpaceSimulationResult>();
                    //foreach (ZoneData zoneData in zoneDatas)
                    //{
                    //    SpaceSimulationResult spaceSimulationResult_Temp = spaceSimulationResults.FindAll(x => x.LoadType() == LoadType.Heating).Find(x => x.Reference == zoneData.zoneGUID);
                    //    if (spaceSimulationResult_Temp == null)
                    //        continue;

                    //    spaceSimulationResults_Zone.Add(spaceSimulationResult_Temp);
                    //}

                    //if (spaceSimulationResults_Zone != null && spaceSimulationResults_Zone.Count != 0)
                    //{
                    //    //double senisbleLoad = spaceSimulationResults_Zone.Sum(SpaceSimulationResultParameter.Load);
                    //    //if (!double.IsNaN(senisbleLoad))
                    //    //    zoneSimulationResult_Heating.SetValue(ZoneSimulationResultParameter.MaxSensibleLoad, senisbleLoad);

                    //    //double airMovementGain = spaceSimulationResults_Zone.Sum(SpaceSimulationResultParameter.AirMovementGain);
                    //    //if (!double.IsNaN(airMovementGain))
                    //    //    zoneSimulationResult_Heating.SetValue(ZoneSimulationResultParameter.AirMovementGain, airMovementGain);

                    //    //double buildingHeatTransfer = spaceSimulationResults_Zone.Sum(SpaceSimulationResultParameter.BuildingHeatTransfer);
                    //    //if (!double.IsNaN(buildingHeatTransfer))
                    //    //    zoneSimulationResult_Heating.SetValue(ZoneSimulationResultParameter.BuildingHeatTransfer, buildingHeatTransfer);

                    //    //double glazingExternalConduction = spaceSimulationResults_Zone.Sum(SpaceSimulationResultParameter.GlazingExternalConduction);
                    //    //if (!double.IsNaN(glazingExternalConduction))
                    //    //    zoneSimulationResult_Heating.SetValue(ZoneSimulationResultParameter.GlazingExternalConduction, glazingExternalConduction);

                    //    //double infiltrationGain = spaceSimulationResults_Zone.Sum(SpaceSimulationResultParameter.InfiltrationGain);
                    //    //if (!double.IsNaN(infiltrationGain))
                    //    //    zoneSimulationResult_Heating.SetValue(ZoneSimulationResultParameter.InfiltrationGain, infiltrationGain);

                    //    //double opaqueExternalConduction = spaceSimulationResults_Zone.Sum(SpaceSimulationResultParameter.OpaqueExternalConduction);
                    //    //if (!double.IsNaN(opaqueExternalConduction))
                    //    //    zoneSimulationResult_Heating.SetValue(ZoneSimulationResultParameter.OpaqueExternalConduction, opaqueExternalConduction);
                    //}
                    //}

                    //if (!double.IsNaN(occupancy))
                    //    zoneSimulationResult_Heating?.SetValue(ZoneSimulationResultParameter.Occupancy, occupancy);

                    //if (!double.IsNaN(area))
                    //    zoneSimulationResult_Heating?.SetValue(ZoneSimulationResultParameter.Area, area);

                    //if (!double.IsNaN(volume))
                    //    zoneSimulationResult_Heating?.SetValue(ZoneSimulationResultParameter.Volume, volume);


                    //if (zoneSimulationResult_Heating != null)
                    //{
                    //    adjacencyCluster.AddObject(zoneSimulationResult_Heating);
                    //    adjacencyCluster.AddRelation(zone, zoneSimulationResult_Heating);
                    //    result.Add(zoneSimulationResult_Heating);
                    //}
                }
            }

            return(result);
        }
        public static AdjacencyCluster AdjacencyCluster(IEnumerable <Space> spaces, IEnumerable <Panel> panels, out List <Topology> topologies, out List <Panel> redundantPanels, double minArea = Tolerance.MacroDistance, bool updatePanels = true, bool tryCellComplexByCells = true, Log log = null, double silverSpacing = Tolerance.MacroDistance, double tolerance = Tolerance.Distance)
        {
            Core.Modify.Add(log, "Method Name: {0}, Tolerance: {1}, Update Panels: {2}", "SAM.Analytical.Topologic.Create.AdjacencyCluster", tolerance, updatePanels);

            topologies      = null;
            redundantPanels = null;

            AdjacencyCluster result = new AdjacencyCluster();

            result.AddObjects(spaces);
            result.AddObjects(panels);

            List <Face> faces = new List <Face>();

            int index = 1;

            foreach (Panel panel in result.GetObjects <Panel>())
            {
                if (panel == null)
                {
                    continue;
                }

                Face face = Convert.ToTopologic(panel);
                if (face == null)
                {
                    continue;
                }

                faces.Add(face);
                Core.Modify.Add(log, "Face {0:D4} added. Panel [{1}]", index, panel.Guid);
                index++;
            }

            if (faces == null || faces.Count == 0)
            {
                return(null);
            }

            topologies = new List <Topology>();
            List <Cell> cells = null;

            if (tryCellComplexByCells)
            {
                try
                {
                    Core.Modify.Add(log, "Trying to make CellComplex By Cells");
                    Cluster cluster = Cluster.ByTopologies(faces as IList <Topology>);
                    Core.Modify.Add(log, "Cluster.ByTopologies Done");
                    Topology topology = cluster.SelfMerge();
                    Core.Modify.Add(log, "Cluster SelfMerge Done");
                    if (topology.Cells != null && topology.Cells.Count != 0)
                    {
                        cells = topology.Cells?.ToList();
                        CellComplex cellComplex = null;
                        try
                        {
                            cellComplex = CellComplex.ByCells(cells);
                        }
                        catch (Exception exception)
                        {
                            Core.Modify.Add(log, "Cells could not be taken from CellComplex");
                            Core.Modify.Add(log, "Exception Message: {0}", exception.Message);
                        }

                        if (cellComplex != null && cellComplex.Cells != null && cellComplex.Cells.Count != 0)
                        {
                            topologies.Add(cellComplex);

                            cells = cellComplex.Cells?.ToList();
                        }
                        else
                        {
                            topologies.Add(topology);
                            Core.Modify.Add(log, "Cells taken from Cluster");
                        }
                    }
                }
                catch (Exception exception)
                {
                    Core.Modify.Add(log, "Cannot create CellComplex By Cells or Cells form Cluster SelfMerge");
                    Core.Modify.Add(log, "Exception Message: {0}", exception.Message);
                    cells = null;
                }
            }

            if (cells == null)
            {
                try
                {
                    Core.Modify.Add(log, "Trying to make CellComplex By Faces");
                    CellComplex cellComplex = CellComplex.ByFaces(faces, tolerance);
                    topologies.Add(cellComplex);
                    cells = cellComplex.Cells?.ToList();
                    Core.Modify.Add(log, "CellComplex By Faces Created");
                }
                catch (Exception exception)
                {
                    Core.Modify.Add(log, "Cannot create CellComplex By Faces");
                    Core.Modify.Add(log, "Exception Message: {0}", exception.Message);

                    cells = null;
                }
            }

            if (cells == null || cells.Count == 0)
            {
                Core.Modify.Add(log, "No cells found");
                return(null);
            }

            List <Geometry.Spatial.Shell> shells = cells.ToSAM();

            Core.Modify.Add(log, "Single CellComplex converted to shells");

            if (shells == null)
            {
                return(null);
            }

            //Matching spaces with shells
            Dictionary <Geometry.Spatial.Shell, List <Space> > dictionary_Spaces = new Dictionary <Geometry.Spatial.Shell, List <Space> >();

            if (spaces != null)
            {
                foreach (Space space in spaces)
                {
                    if (space == null || space.Location == null || !space.IsPlaced())
                    {
                        continue;
                    }

                    List <Geometry.Spatial.Shell> shells_Temp = Analytical.Query.SpaceShells(shells, space.Location, silverSpacing, tolerance);
                    if (shells_Temp == null || shells_Temp.Count == 0)
                    {
                        continue;
                    }

                    foreach (Geometry.Spatial.Shell shell in shells_Temp)
                    {
                        if (!dictionary_Spaces.TryGetValue(shell, out List <Space> spaces_Shell))
                        {
                            spaces_Shell             = new List <Space>();
                            dictionary_Spaces[shell] = spaces_Shell;
                        }
                        spaces_Shell.Add(space);
                    }
                }
            }

            HashSet <Guid> guids_Updated = new HashSet <Guid>();

            Dictionary <Panel, Face3D> dictionary_Panel_Face3D = new Dictionary <Panel, Face3D>();

            result.GetObjects <Panel>().ForEach(x => dictionary_Panel_Face3D[x] = x.GetFace3D());

            index = 1;
            List <Tuple <Panel, Point3D> > tuples_InternalPoint3D = new List <Tuple <Panel, Point3D> >();

            for (int i = 0; i < shells.Count; i++)
            {
                Geometry.Spatial.Shell shell = shells[i];
                if (shell == null)
                {
                    return(null);
                }

                Core.Modify.Add(log, "Simplifying shell");
                //shell.Simplify(tolerance); // Low tolerance cause of rounding issues
                shell.Simplify();

                Core.Modify.Add(log, "Extracting faces from shell");
                List <Face3D> face3Ds = shell?.Face3Ds;
                if (face3Ds == null)
                {
                    Core.Modify.Add(log, "No face2Ds found in Shell");
                    continue;
                }

                dictionary_Spaces.TryGetValue(shell, out List <Space> spaces_Shell);

                if (spaces_Shell == null || spaces_Shell.Count == 0)
                {
                    Core.Modify.Add(log, "Creating new Space");

                    Point3D location = shell.CalculatedInternalPoint3D(silverSpacing, tolerance);
                    if (location == null)
                    {
                        continue;
                    }

                    Space space = new Space("Cell " + index, location);
                    index++;

                    if (!result.AddObject(space))
                    {
                        continue;
                    }

                    spaces_Shell = new List <Space>()
                    {
                        space
                    };
                    dictionary_Spaces[shell] = spaces_Shell;
                }

                if (spaces_Shell == null || spaces_Shell.Count == 0)
                {
                    continue;
                }

                double volume = double.NaN;
                if (cells[i] != null)
                {
                    Core.Modify.Add(log, "Calculating Volume");
                    volume = CellUtility.Volume(cells[i]);

                    foreach (Space space_Shell in spaces_Shell)
                    {
                        space_Shell.SetValue(SpaceParameter.Volume, volume);
                    }
                }

                Core.Modify.Add(log, "Upadting Panels");
                foreach (Face3D face3D in face3Ds)
                {
                    if (minArea != 0 && face3D.GetArea() <= minArea)
                    {
                        Core.Modify.Add(log, "Face3D is too small");
                        continue;
                    }

                    Core.Modify.Add(log, "Looking for existing Panel");
                    Tuple <Panel, Point3D> tuple_InternalPoint3D = tuples_InternalPoint3D.Find(x => face3D.Inside(x.Item2, tolerance));
                    if (tuple_InternalPoint3D != null)
                    {
                        Core.Modify.Add(log, "Existing Panel found: {0}", tuple_InternalPoint3D.Item1.Guid);
                        foreach (Space space in spaces_Shell)
                        {
                            if (result.AddRelation(space, tuple_InternalPoint3D.Item1))
                            {
                                Core.Modify.Add(log, "Space [{0}] and Panel [{1}] relation added", space.Guid, tuple_InternalPoint3D.Item1.Guid);
                            }
                        }
                        continue;
                    }

                    Core.Modify.Add(log, "Looking for old Panel");
                    //Panel panel_Old = Query.SimilarPanel(face3D, dictionary_Panel_Face3D);
                    //if (panel_Old == null)
                    //    continue;

                    List <Panel> panels_Old = Query.SimilarPanels(face3D, dictionary_Panel_Face3D);
                    if (panels_Old == null || panels_Old.Count == 0)
                    {
                        continue;
                    }

                    Panel panel_Old = panels_Old.First();
                    if (panels_Old.Count > 1)
                    {
                        if (redundantPanels == null)
                        {
                            redundantPanels = new List <Panel>();
                        }

                        panels_Old.RemoveAt(0);
                        redundantPanels.AddRange(panels_Old);
                    }

                    Core.Modify.Add(log, "Old Panel found: {0}", panel_Old.Guid);

                    Panel panel_New = null;

                    if (updatePanels)
                    {
                        if (guids_Updated.Contains(panel_Old.Guid))
                        {
                            panel_New = Analytical.Create.Panel(Guid.NewGuid(), panel_Old, face3D);
                            Core.Modify.Add(log, "Creating new Panel for Old Panel [{0}]. New Panel [{1}]", panel_Old.Guid, panel_New.Guid);
                        }
                        else
                        {
                            panel_New = Analytical.Create.Panel(panel_Old.Guid, panel_Old, face3D);
                            guids_Updated.Add(panel_Old.Guid);
                            Core.Modify.Add(log, "Updating Panel [{0}] with new geometry", panel_New.Guid);
                        }

                        result.AddObject(panel_New);
                    }
                    else
                    {
                        panel_New = Analytical.Create.Panel(panel_Old.Guid, panel_Old, face3D);
                        Core.Modify.Add(log, "Creating temporary Panel for Panel [{0}]", panel_New.Guid);
                    }

                    if (panel_New == null)
                    {
                        continue;
                    }

                    tuples_InternalPoint3D.Add(new Tuple <Panel, Point3D>(panel_New, face3D.InternalPoint3D(tolerance)));

                    foreach (Space space in spaces_Shell)
                    {
                        if (result.AddRelation(space, panel_New))
                        {
                            Core.Modify.Add(log, "Space [{0}] and Panel [{1}] relation added", space.Guid, panel_New.Guid);
                        }
                    }

                    Core.Modify.Add(log, "Adding face finished");
                }
            }

            if (redundantPanels != null && redundantPanels.Count != 0)
            {
                Core.Modify.Add(log, "Solving Redundant Panels");
                foreach (Panel panel in redundantPanels)
                {
                    result.RemoveObject <Panel>(panel.Guid);
                }
            }

            List <Panel> panels_Shading = Analytical.Query.CutShading(result.GetPanels(), panels, tolerance);

            if (panels_Shading != null || panels_Shading.Count != 0)
            {
                foreach (Panel panel_Shading in panels_Shading)
                {
                    result.AddObject(panel_Shading);
                }
            }

            Core.Modify.Add(log, "AdjacencyCluster verification");
            Log log_AdjacencyCluster = Analytical.Create.Log(result);

            if (log != null)
            {
                log.AddRange(log_AdjacencyCluster);
            }

            Core.Modify.Add(log, "Process completed");
            return(result);
        }
Beispiel #4
0
        public static AdjacencyCluster ToSAM(this TBD.Building building)
        {
            if (building == null)
            {
                return(null);
            }

            AdjacencyCluster adjacencyCluster = new AdjacencyCluster();

            Dictionary <string, Construction> dictionary_Construction = new Dictionary <string, Construction>();

            foreach (TBD.Construction construction_TBD in building.Constructions())
            {
                Construction construction = construction_TBD.ToSAM();
                if (construction == null)
                {
                    continue;
                }

                dictionary_Construction[construction_TBD.GUID] = construction;
                adjacencyCluster.AddObject(construction);
            }

            foreach (TBD.zone zone in building.Zones())
            {
                Space space = zone.ToSAM(out List <InternalCondition> internalConditions);
                if (space == null)
                {
                    continue;
                }

                adjacencyCluster.AddObject(space);

                foreach (TBD.IZoneSurface zoneSurface in zone.ZoneSurfaces())
                {
                    TBD.buildingElement buildingElement  = zoneSurface.buildingElement;
                    TBD.Construction    construction_TBD = buildingElement.GetConstruction();

                    PanelType panelType = Query.PanelType(buildingElement.BEType);

                    Construction construction = null;
                    if (construction_TBD != null)
                    {
                        construction = dictionary_Construction[construction_TBD.GUID];
                    }

                    foreach (TBD.IRoomSurface roomSurface in zoneSurface.RoomSurfaces())
                    {
                        Geometry.Spatial.Polygon3D polygon3D = Geometry.Tas.Convert.ToSAM(roomSurface?.GetPerimeter()?.GetFace());
                        if (polygon3D == null)
                        {
                            continue;
                        }

                        Panel panel = Analytical.Create.Panel(construction, panelType, new Geometry.Spatial.Face3D(polygon3D));
                        if (panel == null)
                        {
                            continue;
                        }

                        adjacencyCluster.AddObject(panel);
                        adjacencyCluster.AddRelation(panel, space);
                    }
                }

                if (internalConditions != null)
                {
                    foreach (InternalCondition internalCondition in internalConditions)
                    {
                        adjacencyCluster.AddObject(internalCondition);
                        adjacencyCluster.AddRelation(space, internalCondition);
                    }
                }
            }

            return(adjacencyCluster);
        }
        public static AnalyticalModel ToSAM(this Model model)
        {
            if (model == null)
            {
                return(null);
            }

            MaterialLibrary             materialLibrary       = null;
            ProfileLibrary              profileLibrary        = null;
            List <Construction>         constructions         = null;
            List <ApertureConstruction> apertureConstructions = null;
            List <InternalCondition>    internalConditions    = null;

            ModelEnergyProperties modelEnergyProperties = model.Properties?.Energy;

            if (modelEnergyProperties != null)
            {
                materialLibrary       = modelEnergyProperties.ToSAM_MaterialLibrary();
                constructions         = modelEnergyProperties.ToSAM_Constructions();
                apertureConstructions = modelEnergyProperties.ToSAM_ApertureConstructions();
                internalConditions    = modelEnergyProperties.ToSAM_InternalConditions();
                profileLibrary        = modelEnergyProperties.ToSAM_ProfileLibrary();
            }

            if (materialLibrary == null)
            {
                materialLibrary = new MaterialLibrary(string.Empty);
            }

            if (constructions == null)
            {
                constructions = new List <Construction>();
            }

            if (apertureConstructions == null)
            {
                apertureConstructions = new List <ApertureConstruction>();
            }

            List <Tuple <Panel, Geometry.Spatial.BoundingBox3D> > tuples = new List <Tuple <Panel, Geometry.Spatial.BoundingBox3D> >();

            AdjacencyCluster adjacencyCluster = new AdjacencyCluster();
            List <Room>      rooms            = model.Rooms;

            if (rooms != null)
            {
                foreach (Room room in rooms)
                {
                    room.IndoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x));
                    room.OutdoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x));

                    List <Face> faces = room.Faces;
                    if (faces == null)
                    {
                        continue;
                    }

                    List <Panel> panels = new List <Panel>();
                    foreach (Face face in faces)
                    {
                        Panel panel = face.ToSAM(constructions, apertureConstructions);
                        if (panel == null)
                        {
                            continue;
                        }

                        Geometry.Spatial.Point3D point3D = panel.GetFace3D().GetInternalPoint3D();
                        if (point3D == null)
                        {
                            continue;
                        }

                        Panel panel_Existing = tuples.FindAll(x => x.Item2.Inside(point3D, true))?.Find(x => x.Item1.GetFace3D().On(point3D))?.Item1;
                        if (panel_Existing != null)
                        {
                            panel = panel_Existing;
                        }
                        else
                        {
                            tuples.Add(new Tuple <Panel, Geometry.Spatial.BoundingBox3D>(panel, panel.GetFace3D().GetBoundingBox()));

                            face.IndoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x));
                            face.OutdoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x));

                            Construction construction = panel.Construction;
                            if (construction != null)
                            {
                                if (constructions.Find(x => x.Name.Equals(construction.Name)) == null)
                                {
                                    constructions.Add(construction);
                                }

                                materialLibrary.AddDefaultMaterials(construction);
                            }

                            List <Aperture> apertures = panel.Apertures;
                            if (apertures != null)
                            {
                                foreach (Aperture aperture in apertures)
                                {
                                    ApertureConstruction apertureConstruction = aperture.ApertureConstruction;
                                    if (apertureConstruction != null)
                                    {
                                        if (apertureConstructions.Find(x => x.Name.Equals(apertureConstruction.Name)) == null)
                                        {
                                            apertureConstructions.Add(apertureConstruction);
                                        }

                                        materialLibrary.AddDefaultMaterials(apertureConstruction);
                                    }
                                }
                            }

                            List <HoneybeeSchema.Aperture> apertures_HoneybeeSchema = face.Apertures;
                            if (apertures_HoneybeeSchema != null)
                            {
                                foreach (HoneybeeSchema.Aperture aperture_HoneybeeSchema in apertures_HoneybeeSchema)
                                {
                                    aperture_HoneybeeSchema.IndoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x));
                                    aperture_HoneybeeSchema.OutdoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x));
                                }
                            }

                            List <HoneybeeSchema.Door> doors_HoneybeeSchema = face.Doors;
                            if (doors_HoneybeeSchema != null)
                            {
                                foreach (HoneybeeSchema.Door door_HoneybeeSchema in doors_HoneybeeSchema)
                                {
                                    door_HoneybeeSchema.IndoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x));
                                    door_HoneybeeSchema.OutdoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x));
                                }
                            }
                        }

                        panels.Add(panel);
                    }

                    Space space = room.ToSAM(internalConditions);
                    adjacencyCluster.AddObject(space);

                    if (panels != null)
                    {
                        foreach (Panel panel in panels)
                        {
                            adjacencyCluster.AddObject(panel);
                            adjacencyCluster.AddRelation(space, panel);
                        }
                    }
                }
            }

            List <Shade> shades = model.OrphanedShades;

            if (shades != null && shades.Count != 0)
            {
                foreach (Shade shade in shades)
                {
                    Panel panel = shade?.ToSAM(constructions);
                    if (panel != null)
                    {
                        Construction construction = panel.Construction;
                        if (construction != null)
                        {
                            if (constructions.Find(x => x.Name.Equals(construction.Name)) == null)
                            {
                                constructions.Add(construction);
                            }

                            materialLibrary.AddDefaultMaterials(construction);
                        }

                        List <Aperture> apertures = panel.Apertures;
                        if (apertures != null)
                        {
                            foreach (Aperture aperture in apertures)
                            {
                                ApertureConstruction apertureConstruction = aperture.ApertureConstruction;
                                if (apertureConstruction != null)
                                {
                                    if (apertureConstructions.Find(x => x.Name.Equals(apertureConstruction.Name)) == null)
                                    {
                                        apertureConstructions.Add(apertureConstruction);
                                    }

                                    materialLibrary.AddDefaultMaterials(apertureConstruction);
                                }
                            }
                        }

                        adjacencyCluster.AddObject(panel);
                    }
                }
            }

            AnalyticalModel result = new AnalyticalModel(model.DisplayName, null, null, null, adjacencyCluster, materialLibrary, profileLibrary);

            return(result);
        }
Beispiel #6
0
        public static AnalyticalModel ToSAM_AnalyticalModel(this Document document, ConvertSettings convertSettings)
        {
            if (document == null)
            {
                return(null);
            }

            ProjectInfo projectInfo = document.ProjectInformation;

            AnalyticalModel result = convertSettings?.GetObject <AnalyticalModel>(projectInfo?.Id);

            if (result != null)
            {
                return(result);
            }

            Core.Location location = Core.Revit.Query.Location(document);
            Address       address  = null;

            if (projectInfo != null)
            {
                address = new Address(Guid.NewGuid(), projectInfo.BuildingName, projectInfo.Address, null, null, CountryCode.Undefined);
            }

            AdjacencyCluster adjacencyCluster = new AdjacencyCluster();

            EnergyAnalysisDetailModelOptions energyAnalysisDetailModelOptions = new EnergyAnalysisDetailModelOptions();

            energyAnalysisDetailModelOptions.Tier                   = EnergyAnalysisDetailModelTier.SecondLevelBoundaries;
            energyAnalysisDetailModelOptions.EnergyModelType        = EnergyModelType.SpatialElement;
            energyAnalysisDetailModelOptions.ExportMullions         = true;
            energyAnalysisDetailModelOptions.IncludeShadingSurfaces = true;
            energyAnalysisDetailModelOptions.SimplifyCurtainSystems = false;

            EnergyDataSettings energyDataSettings = EnergyDataSettings.GetFromDocument(document);

            energyDataSettings.ExportComplexity = gbXMLExportComplexity.ComplexWithMullionsAndShadingSurfaces;
            energyDataSettings.ExportDefaults   = false;
#if Revit2017 || Revit2018 || Revit2019 || Revit2020
            energyDataSettings.SliverSpaceTolerance = UnitUtils.ConvertToInternalUnits(0.005, DisplayUnitType.DUT_METERS);
#else
            energyDataSettings.SliverSpaceTolerance = UnitUtils.ConvertToInternalUnits(0.005, UnitTypeId.Meters);
#endif
            energyDataSettings.AnalysisType = AnalysisMode.BuildingElements;
            energyDataSettings.EnergyModel  = false;

            //Reseting Project Base Point
            IEnumerable <Element> elements = new FilteredElementCollector(document).OfCategory(BuiltInCategory.OST_ProjectBasePoint);
            foreach (Element element in elements)
            {
                if (element.Pinned)
                {
                    element.Pinned = false;
                }

                Parameter parameter = null;

                parameter = element.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM);
                if (parameter != null && !parameter.IsReadOnly)
                {
                    parameter.Set(0.0);
                }

                parameter = element.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM);
                if (parameter != null && !parameter.IsReadOnly)
                {
                    parameter.Set(0.0);
                }

                parameter = element.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM);
                if (parameter != null && !parameter.IsReadOnly)
                {
                    parameter.Set(0.0);
                }

                parameter = element.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM);
                if (parameter != null && !parameter.IsReadOnly)
                {
                    parameter.Set(0.0);
                }

                parameter = element.get_Parameter(BuiltInParameter.BASEPOINT_ANGLETON_PARAM);
                if (parameter != null && !parameter.IsReadOnly)
                {
                    parameter.Set(0.0);
                }
            }

            //AnalyticalSpaces
            EnergyAnalysisDetailModel   energyAnalysisDetailModel         = EnergyAnalysisDetailModel.Create(document, energyAnalysisDetailModelOptions);
            IList <EnergyAnalysisSpace> energyAnalysisSpaces              = energyAnalysisDetailModel.GetAnalyticalSpaces();
            Dictionary <string, Tuple <Panel, List <Space> > > dictionary = new Dictionary <string, Tuple <Panel, List <Space> > >();
            foreach (EnergyAnalysisSpace energyAnalysisSpace in energyAnalysisSpaces)
            {
                try
                {
                    if (energyAnalysisSpace.Area <= Core.Tolerance.MacroDistance)
                    {
                        continue;
                    }

                    Space space = energyAnalysisSpace.ToSAM(convertSettings);
                    if (space == null)
                    {
                        continue;
                    }

                    Shell shell = Geometry.Revit.Convert.ToSAM(energyAnalysisSpace.GetClosedShell());
                    if (shell == null)
                    {
                        continue;
                    }

                    adjacencyCluster.AddObject(space);

                    foreach (EnergyAnalysisSurface energyAnalysisSurface in energyAnalysisSpace.GetAnalyticalSurfaces())
                    {
                        Tuple <Panel, List <Space> > tuple;
                        if (!dictionary.TryGetValue(energyAnalysisSurface.SurfaceName, out tuple))
                        {
                            Panel panel = energyAnalysisSurface.ToSAM(convertSettings, shell);
                            if (panel == null)
                            {
                                continue;
                            }

                            tuple = new Tuple <Panel, List <Space> >(panel, new List <Space>());
                            dictionary[energyAnalysisSurface.SurfaceName] = tuple;
                        }

                        tuple.Item2.Add(space);
                    }
                }
                catch
                {
                }
            }

            #region Additional Checks (WIP)
            //Additional Check for wrongly recoginzed internal panels (WIP)
            List <Tuple <string, Panel, Space, Face3D> > tuples_External = new List <Tuple <string, Panel, Space, Face3D> >();
            foreach (KeyValuePair <string, Tuple <Panel, List <Space> > > keyValuePair in dictionary)
            {
                Tuple <Panel, List <Space> > tuple = keyValuePair.Value;
                if (tuple.Item1 != null && tuple.Item2 != null && tuple.Item2.Count == 1)
                {
                    Face3D face3D = tuple.Item1.GetFace3D();
                    if (face3D != null)
                    {
                        tuples_External.Add(new Tuple <string, Panel, Space, Face3D>(keyValuePair.Key, tuple.Item1, tuple.Item2[0], face3D));
                    }
                }
            }

            while (tuples_External.Count > 0)
            {
                Tuple <string, Panel, Space, Face3D> tuple = tuples_External[0];
                tuples_External.RemoveAt(0);

                Point3D point3D = tuple.Item4.InternalPoint3D();
                if (point3D == null)
                {
                    continue;
                }

                List <Tuple <string, Panel, Space, Face3D> > tuples_Overlap = tuples_External.FindAll(x => x.Item4.Inside(point3D));
                if (tuples_Overlap.Count != 1)
                {
                    continue;
                }

                tuples_Overlap.Add(tuple);

                tuples_Overlap.Sort((x, y) => y.Item4.GetArea().CompareTo(x.Item4.GetArea()));

                tuple = tuples_Overlap[0];
                Tuple <string, Panel, Space, Face3D> tuple_Overlap = tuples_Overlap[1];

                dictionary[tuple.Item1].Item2.Add(tuple_Overlap.Item3);
                dictionary[tuple_Overlap.Item1] = new Tuple <Panel, List <Space> >(Analytical.Create.Panel(dictionary[tuple_Overlap.Item1].Item1, PanelType.Shade), null);
                int index = tuples_External.IndexOf(tuple_Overlap);
                if (index != -1)
                {
                    tuples_External.RemoveAt(index);
                }
            }
            #endregion

            foreach (Tuple <Panel, List <Space> > tuple in dictionary.Values)
            {
                Panel panel = tuple.Item1;

                adjacencyCluster.AddObject(panel);
                tuple.Item2?.ForEach(x => adjacencyCluster.AddRelation(x, panel));
            }

            //AnalyticalShadingSurfaces
            IList <EnergyAnalysisSurface> analyticalShadingSurfaces = energyAnalysisDetailModel.GetAnalyticalShadingSurfaces();
            foreach (EnergyAnalysisSurface energyAnalysisSurface in analyticalShadingSurfaces)
            {
                try
                {
                    Panel panel = energyAnalysisSurface.ToSAM(convertSettings);
                    if (panel == null)
                    {
                        continue;
                    }

                    panel = Analytical.Create.Panel(panel, PanelType.Shade);

                    adjacencyCluster.AddObject(panel);
                }
                catch
                {
                }
            }

            adjacencyCluster.MapZones();

            IEnumerable <IMaterial> materials       = Analytical.Query.Materials(adjacencyCluster, Analytical.ActiveSetting.Setting.GetValue <MaterialLibrary>(AnalyticalSettingParameter.DefaultMaterialLibrary));
            MaterialLibrary         materialLibrary = Core.Create.MaterialLibrary("Default Material Library", materials);

            IEnumerable <Profile> profiles       = Analytical.Query.Profiles(adjacencyCluster, Analytical.ActiveSetting.Setting.GetValue <ProfileLibrary>(AnalyticalSettingParameter.DefaultProfileLibrary));
            ProfileLibrary        profileLibrary = new ProfileLibrary("Default Profile Library", profiles);

            result = new AnalyticalModel(document.Title, null, location, address, adjacencyCluster, materialLibrary, profileLibrary);
            result.UpdateParameterSets(document.ProjectInformation, ActiveSetting.Setting.GetValue <TypeMap>(Core.Revit.ActiveSetting.Name.ParameterMap));

            convertSettings?.Add(projectInfo.Id, result);

            return(result);
        }
        public static AnalyticalModel ToSAM(this Campus campus, double silverSpacing = Tolerance.MacroDistance, double tolerance = Tolerance.MicroDistance)
        {
            Address address = campus.Location.ToSAM_Address();

            Core.Location location = campus.Location.ToSAM(tolerance);

            AdjacencyCluster adjacencyCluster = new AdjacencyCluster();

            Dictionary <string, Space> dictionary_Space = new Dictionary <string, Space>();

            Building[] buildings = campus.Buildings;
            if (buildings != null)
            {
                foreach (Building building in buildings)
                {
                    gbXMLSerializer.Space[] spaces = building.Spaces;
                    if (spaces != null)
                    {
                        foreach (gbXMLSerializer.Space space_gbXML in spaces)
                        {
                            if (space_gbXML == null)
                            {
                                continue;
                            }

                            Space space_SAM = space_gbXML.ToSAM(silverSpacing, tolerance);
                            if (space_SAM == null)
                            {
                                continue;
                            }

                            dictionary_Space[space_gbXML.id] = space_SAM;

                            adjacencyCluster.AddObject(space_SAM);
                        }
                    }
                }
            }

            Surface[] surfaces = campus.Surface;
            if (surfaces != null)
            {
                foreach (Surface surface in surfaces)
                {
                    if (surface == null)
                    {
                        continue;
                    }

                    Panel panel = surface.ToSAM(tolerance);
                    if (panel == null)
                    {
                        continue;
                    }

                    adjacencyCluster.AddObject(panel);

                    AdjacentSpaceId[] adjacentSpaceIds = surface.AdjacentSpaceId;
                    if (adjacentSpaceIds == null || adjacentSpaceIds.Length == 0)
                    {
                        continue;
                    }

                    foreach (AdjacentSpaceId adjacentSpaceId in adjacentSpaceIds)
                    {
                        string id = adjacentSpaceId?.spaceIdRef;
                        if (string.IsNullOrWhiteSpace(id))
                        {
                            continue;
                        }

                        Space space = null;

                        if (!dictionary_Space.TryGetValue(id, out space))
                        {
                            continue;
                        }

                        adjacencyCluster.AddRelation(panel, space);
                    }
                }
            }

            AnalyticalModel result = new AnalyticalModel(string.Empty, string.Empty, location, address, adjacencyCluster);

            return(result);
        }
Beispiel #8
0
        public static AdjacencyCluster UpdateDesignLoads(this TBDDocument tBDDocument, AdjacencyCluster adjacencyCluster)
        {
            if (tBDDocument == null || adjacencyCluster == null)
            {
                return(null);
            }

            Building building = tBDDocument.Building;

            if (building == null)
            {
                return(null);
            }

            AdjacencyCluster result = new AdjacencyCluster(adjacencyCluster);

            List <Space> spaces = result.GetSpaces();

            if (spaces == null || spaces.Count == 0)
            {
                return(result);
            }

            Dictionary <string, zone> zones = building.ZoneDictionary();

            if (zones == null)
            {
                return(null);
            }

            foreach (Space space in spaces)
            {
                string name = space?.Name;
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                zone zone;
                if (!zones.TryGetValue(name, out zone) || zone == null)
                {
                    continue;
                }

                space.SetValue(SpaceParameter.DesignHeatingLoad, zone.maxHeatingLoad);
                space.SetValue(SpaceParameter.DesignCoolingLoad, zone.maxCoolingLoad);

                result.AddObject(space);

                List <SpaceSimulationResult> spaceSimulationResults = result.GetResults <SpaceSimulationResult>(space, Query.Source());
                foreach (LoadType loadType in new LoadType[] { LoadType.Heating, LoadType.Cooling })
                {
                    SpaceSimulationResult spaceSimulationResult = spaceSimulationResults?.Find(x => x.LoadType() == loadType);
                    if (spaceSimulationResult == null)
                    {
                        spaceSimulationResult = Create.SpaceSimulationResult(zone, loadType);
                    }
                    else
                    {
                        spaceSimulationResult = new SpaceSimulationResult(spaceSimulationResult);
                        spaceSimulationResult.SetValue(Analytical.SpaceSimulationResultParameter.Area, zone.floorArea);
                        spaceSimulationResult.SetValue(Analytical.SpaceSimulationResultParameter.Volume, zone.volume);
                        spaceSimulationResult.SetValue(Analytical.SpaceSimulationResultParameter.DesignLoad, loadType == LoadType.Cooling ? zone.maxCoolingLoad : zone.maxHeatingLoad);
                    }

                    if (spaceSimulationResult != null)
                    {
                        result.AddObject(spaceSimulationResult);
                        result.AddRelation(space, spaceSimulationResult);
                    }
                }
            }

            return(result);
        }