/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { string inputJson = null; var cpus = 4; var method = 0; var caseType = 0; var materials = new List <string>(); var epwFile = ""; string overrides = null; if (!DA.GetData(0, ref inputJson)) { return; } if (inputJson == "error") { return; } DA.GetData(1, ref cpus); DA.GetData(2, ref method); //DA.GetData(3, ref caseType); if (!DA.GetDataList(3, materials)) { return; } if (!DA.GetData(4, ref epwFile) && (method <= 1)) { return; } DA.GetData(5, ref overrides); try { var outputs = RadiationSolution.Setup( inputJson, ComponentUtils.ValidateCPUs(cpus), Methods[method], CaseTypes[caseType].ToLower(), materials, epwFile, overrides ); DA.SetData(0, outputs); } catch (Exception error) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, error.Message); } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { string inputJson = null; var cpus = 4; var solver = 0; var caseType = 0; var boundaryConditions = new List <string>(); var iterations = new List <int>(); var numberOfAngles = new GH_Structure <GH_Number>(); string overrides = null; if (!DA.GetData(0, ref inputJson)) { return; } if (!DA.GetData(1, ref cpus)) { return; } DA.GetData(2, ref solver); DA.GetData(3, ref caseType); if (!DA.GetDataList(4, boundaryConditions)) { return; } DA.GetDataList(5, iterations); DA.GetDataTree(6, out numberOfAngles); DA.GetData(7, ref overrides); var outputs = CFDSolution.Setup( inputJson, ComponentUtils.ValidateCPUs(cpus), Solvers[solver], CaseTypes[caseType], boundaryConditions, ConvertIterations(iterations), ConvertAnglesToList(numberOfAngles), overrides ); DA.SetData(0, outputs); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { string inputJson = null; var points = new GH_Structure <GH_Point>(); var names = new List <string>(); var fields = new List <string>(); var mesh = new GH_Structure <GH_Mesh>(); var cpus = 1; var dependentOn = "VirtualWindTunnel"; var caseDir = "VWT"; var overrides = ""; var create = false; if (!DA.GetData(0, ref inputJson)) { return; } if (!DA.GetDataTree(1, out points)) { return; } if (!DA.GetDataList(2, names)) { for (var i = 0; i < points.Branches.Count; i++) { names.Add($"set{i.ToString()}"); } } else { foreach (var name in names) { ValidateName(name); } } if (!DA.GetDataList(3, fields)) { fields.Add("U"); } DA.GetDataTree(4, out mesh); DA.GetData(5, ref cpus); DA.GetData(6, ref dependentOn); DA.GetData(7, ref caseDir); DA.GetData(8, ref overrides); DA.GetData(9, ref create); var convertedPoints = Geometry.ConvertPointsToList(points); caseDir = caseDir.TrimEnd('/'); // Get Cache to see if we already did this var cacheKey = inputJson + string.Join("", points) + string.Join("", fields) + string.Join("", names); var cachedValues = StringCache.getCache(cacheKey); DA.DisableGapLogic(); if (cachedValues == null || create) { var queueName = "probe"; // Get queue lock var queueLock = StringCache.getCache(queueName); if (queueLock != "true") { StringCache.setCache(queueName, "true"); StringCache.setCache(cacheKey, null); QueueManager.addToQueue(queueName, () => { try { var meshFile = Export.MeshToObj(mesh, names); var results = Probe.ProbePoints( inputJson, convertedPoints, fields, names, ComponentUtils.ValidateCPUs(cpus), meshFile, dependentOn, caseDir, overrides, create ); cachedValues = results; StringCache.setCache(cacheKey, cachedValues); if (create) { StringCache.setCache(cacheKey + "create", "true"); } } catch (NoObjectFoundException) { StringCache.setCache(cacheKey + "create", ""); } catch (Exception e) { StringCache.setCache(InstanceGuid.ToString(), e.Message); StringCache.setCache(cacheKey, "error"); StringCache.setCache(cacheKey + "create", ""); } ExpireSolutionThreadSafe(true); Thread.Sleep(2000); StringCache.setCache(queueName, ""); }); } } HandleErrors(); Message = ""; if (cachedValues != null) { DA.SetData(0, cachedValues); if (StringCache.getCache(cacheKey + "create") == "true") { Message = "Task Created"; } } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { string inputJson = null; var epwFile = ""; var patches = new List <string>(); var thresholds = new List <string>(); var cpus = 4; var dependentOn = "Probe"; var create = false; if (!DA.GetData(0, ref inputJson)) { return; } if (inputJson == "error") { return; } if (!DA.GetData(1, ref epwFile)) { return; } if (!DA.GetDataList(2, patches)) { patches.Add("set1"); } DA.GetDataList(3, thresholds); DA.GetData(4, ref cpus); DA.GetData(5, ref dependentOn); DA.GetData(6, ref create); // Get Cache to see if we already did this var cacheKey = string.Join("", patches) + epwFile + inputJson; var cachedValues = StringCache.getCache(cacheKey); DA.DisableGapLogic(); if (cachedValues == null || create) { var queueName = "windThreshold"; // Get queue lock var queueLock = StringCache.getCache(queueName); if (queueLock != "true") { StringCache.setCache(queueName, "true"); StringCache.setCache(InstanceGuid.ToString(), ""); StringCache.setCache(cacheKey, null); QueueManager.addToQueue(queueName, () => { try { var results = WindThreshold.ComputeWindThresholds( inputJson, epwFile, patches, thresholds, ComponentUtils.ValidateCPUs(cpus), dependentOn, create ); cachedValues = results; StringCache.setCache(cacheKey, cachedValues); if (create) { StringCache.setCache(cacheKey + "create", "true"); } } catch (NoObjectFoundException) { StringCache.setCache(cacheKey + "create", ""); } catch (Exception e) { StringCache.setCache(InstanceGuid.ToString(), e.Message); StringCache.setCache(cacheKey, "error"); StringCache.setCache(cacheKey + "create", ""); } ExpireSolutionThreadSafe(true); Thread.Sleep(2000); StringCache.setCache(queueName, ""); }); } } HandleErrors(); // Read from Cache if (cachedValues != null) { DA.SetData(0, cachedValues); Message = ""; if (StringCache.getCache(cacheKey + "create") == "true") { Message = "Task Created"; } } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { string inputJson = null; var epwFile = ""; var method = 0; var probes = new List <string>(); var thresholds = new List <string>(); var cpus = 4; var dependentOn = "Probe"; var create = false; if (!DA.GetData(0, ref inputJson)) { return; } if (inputJson == "error") { return; } if (!DA.GetData(1, ref epwFile)) { return; } DA.GetData(2, ref method); if (!DA.GetDataList(3, probes)) { return; } DA.GetDataList(4, thresholds); DA.GetData(5, ref cpus); DA.GetData(6, ref dependentOn); DA.GetData(8, ref create); // Get Cache to see if we already did this var cacheKey = string.Join("", probes) + epwFile + inputJson + method; var cachedValues = StringCache.getCache(cacheKey); DA.DisableGapLogic(); if (cachedValues == null || create) { const string queueName = "outdoorComfortSimulation"; // Get queue lock var queueLock = StringCache.getCache(queueName); if (queueLock != "true") { StringCache.setCache(queueName, "true"); StringCache.setCache(InstanceGuid.ToString(), ""); StringCache.setCache(cacheKey, null); QueueManager.addToQueue(queueName, () => { try { cachedValues = OutdoorComfort.CreateComfortTask( inputJson, epwFile, Presets[method], probes, thresholds, ComponentUtils.ValidateCPUs(cpus), dependentOn, create ); StringCache.setCache(cacheKey, cachedValues); if (create) { StringCache.setCache(cacheKey + "create", "true"); } } catch (NoObjectFoundException) { StringCache.setCache(cacheKey + "create", ""); } catch (Exception e) { StringCache.AppendCache(InstanceGuid.ToString(), e.Message + "\n"); StringCache.setCache(cacheKey, "error"); StringCache.setCache(cacheKey + "create", ""); } ExpireSolutionThreadSafe(true); Thread.Sleep(2000); StringCache.setCache(queueName, ""); }); } } HandleErrors(); // Read from Cache if (cachedValues != null) { DA.SetData(0, cachedValues); Message = ""; if (StringCache.getCache(cacheKey + "create") == "true") { Message = "Task Created"; } } }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { string inputJson = null; var overrides = ""; var caseDir = "metrics"; var preset_ = 0; var compute = false; var cpus = 1; if (!DA.GetData(0, ref inputJson)) { return; } if (inputJson == "error") { return; } if (!DA.GetData(1, ref preset_)) { return; } var preset = Presets[preset_]; if (!DA.GetData(2, ref overrides)) { return; } DA.GetData(3, ref cpus); DA.GetData(4, ref caseDir); DA.GetData(5, ref compute); // Get Cache to see if we already did this var cacheKey = inputJson; var cachedValues = StringCache.getCache(cacheKey); DA.DisableGapLogic(); if (cachedValues == null || compute) { var queueName = "daylightMetric" + cacheKey; StringCache.setCache(InstanceGuid.ToString(), ""); // Get queue lock var queueLock = StringCache.getCache(queueName); if (queueLock != "true") { StringCache.setCache(queueName, "true"); QueueManager.addToQueue(queueName, () => { try { cachedValues = DaylightMetrics.Create(inputJson, overrides, preset, ComponentUtils.ValidateCPUs(cpus), caseDir, compute); StringCache.setCache(cacheKey, cachedValues); if (compute) { StringCache.setCache(cacheKey + "create", "true"); } } catch (NoObjectFoundException) { StringCache.setCache(cacheKey + "create", ""); } catch (Exception e) { StringCache.setCache(InstanceGuid.ToString(), e.Message); StringCache.setCache(cacheKey, "error"); StringCache.setCache(cacheKey + "create", ""); } ExpireSolutionThreadSafe(true); Thread.Sleep(2000); StringCache.setCache(queueName, ""); }); } } HandleErrors(); // Read from Cache if (cachedValues != null) { var outputs = cachedValues; DA.SetData(0, outputs); Message = ""; if (StringCache.getCache(cacheKey + "create") == "true") { Message = "Task Created"; } } }