public JsonResult SimulationStart() { var solverData = GetSolverData(); var job = new Job { Id = Guid.NewGuid(), Started = DateTime.UtcNow, Owner = User.Identity.Name, Name = StandardCases.CfdCase, State = JobState.Started, }; var jobZip = CreateJobPath(job.Owner, job.Id); var jobPath = jobZip.Replace(".zip", ""); solverData.MakeJobFS(jobPath); SharpZipUtils.CompressFolder(jobPath, jobZip, null); new JobsController().AddJobManually(job); _procTime = (solverData.ControlDict.endTime - solverData.ControlDict.startTime).ToString( CultureInfo.InvariantCulture); SetCaseJob(job.Id); return(Json(new object[] { job.Id, _procTime })); }
public FileResult SimulationPreview() { var dCase = GetCase(); var jobZip = CreateJobPath(User.Identity.Name, dCase.Id); var jobPath = jobZip.Replace(".zip", ""); var solverData = GetSolverData(); solverData.MakeJobFS(jobPath); SharpZipUtils.CompressFolder(jobPath, jobZip, null); return(File(jobZip, "application/octet-stream", "preview.zip")); }
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); return(Json("OK", JsonRequestBehavior.AllowGet)); }