public JsonResult Run() { var randomDir = Guid.NewGuid().ToString(); Session["WakeSimDir"] = randomDir; var modelGeneral = GetModelGeneral(); var modelTurbines = GetModelTurbines(); string dir = WebConfigurationManager.AppSettings["WakeSimulationDir"]; dir = Path.Combine(dir, randomDir); // root temp dir Directory.CreateDirectory(dir); var resultDir = Path.Combine(dir, "output"); Directory.CreateDirectory(resultDir); var calcData = new CalcData(); var generalData = new GeneralData(); var dataWriter = new DataWriter(); var calc = new WakeCalc(); generalData.GridPointsX = modelGeneral.GridPointsX; generalData.GridPointsY = modelGeneral.GridPointsY; generalData.TurbinesAmount = modelTurbines.Turbines.Count; generalData.RotationAngle = (double)modelGeneral.RotationAngle; generalData.x_turb = new double[modelTurbines.Turbines.Count]; generalData.y_turb = new double[modelTurbines.Turbines.Count]; for (var i = 0; i < modelTurbines.Turbines.Count; i++) { var t = modelTurbines.Turbines[i]; generalData.x_turb[i] = (double) t.X; generalData.y_turb[i] = (double) t.Y; } generalData.TurbineDiameter = (double)modelGeneral.TurbineDiameter; generalData.TurbineHeight = (double)modelGeneral.TurbineHeight; generalData.TurbineThrust = (double)modelGeneral.TurbineThrust; generalData.WakeDecay = (double)modelGeneral.WakeDecay; generalData.VelocityAtHub = (double)modelGeneral.VelocityAtHub; generalData.AirDensity = (double)modelGeneral.AirDensity; generalData.PowerDistance = (double)modelGeneral.PowerDistance; calc.Initialize(generalData, calcData); calc.Run(generalData, calcData); dataWriter.Write(generalData, calcData, resultDir); dataWriter.WritePower(generalData, calcData, resultDir); SharpZipUtils.CompressFolder(resultDir, Path.Combine(dir, "output.zip"), null); System.Drawing.Image resultImage = null; try { resultImage = ResultDrawer.ProcessResult(generalData, calcData, Math.Min(480, generalData.GridPointsX), Math.Min(320, generalData.GridPointsY)); } catch { } Session["WakeSimImage"] = resultImage; return Json("OK", JsonRequestBehavior.AllowGet); }
private static void Main(string[] args) { var dir = ""; if (args.Length > 0) { dir = args[0]; } var generalData = new GeneralData(); var calcData = new CalcData(); var dataReader = new DataReader(); var dataWriter = new DataWriter(); var calc = new WakeCalc(); dataReader.Read(generalData, dir); calc.Initialize(generalData, calcData); calc.Run(generalData, calcData); dataWriter.Write(generalData, calcData, dir); dataWriter.WritePower(generalData, calcData, dir); }