示例#1
0
        public static void excel_batch_template(WSProject p)
        {
            string file = @"C:\Users\WindSim\Desktop\Francesco\WindSim_Projects\MoninObukhov\batch.xls";
            Workbook workbook = new Workbook();
            Worksheet worksheet = new Worksheet("Batch Data");

            // this cycle add some null cells because when on Windows 7 Office need at least 6000byte files.
            //----------------------------------------------
            for (var k = 0; k < 200; k++)
                worksheet.Cells[k, 0] = new Cell(null);
            // ---------------------------------------------

            XmlReader reader = XmlReader.Create(p.file.FullName);
            int i = 0;
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    worksheet.Cells[i, 0] = new Cell(reader.Name);
                    if (reader.Read())
                    {
                        worksheet.Cells[i, 1] = new Cell(reader.Value.Trim());

                    }
                    i++;
                }
            }

            workbook.Worksheets.Add(worksheet);

            workbook.Save(file);
        }
示例#2
0
        static void Main(string[] args)
        {
            string proj = Tools.SelectTextFile(@"C:\Users\WindSim\Desktop\Francesco\WindSim_Projects\", "ws");
            WSProject prova = new WSProject(proj);

            string excelfile_path = Tools.SelectTextFile(prova.file.Directory.Parent.FullName, "xls");
            FileInfo excelfile = new FileInfo(excelfile_path);

            ////prova.run_windfield_z0_conv(0.00001, 5, 5, 25, 2);
            ////RefinementGenerator.AritmeticalGrading test_grading = new RefinementGenerator.AritmeticalGrading(1.2,30,400);
            ////test_grading.Rectangle(prova, "sti_cazzi",3000,500,300,15);

            ExcelBatch battery = new ExcelBatch(prova, excelfile);

            //GwsGenerator griglie = new GwsGenerator();
            //griglie.plane(606, 101, 3000, 500);
            //griglie.plane(306, 51, 3000, 500);
            //griglie.plane(186, 31, 3000, 500);
            //griglie.plane(150, 25, 3000, 500);
        }
示例#3
0
        //        public double ucrt(int x, int y, int z)
        //{
        //    int ucrt_index = Array.IndexOf(variables_name, "UCRT");
        //    return vars_phi[x, y, z, ucrt_index];
        //}
        //public double[] ucrt(int x, int y)
        //{
        //    ///inserire exeptions
        //    int ucrt_index = Array.IndexOf(variables_name, "UCRT");
        //    double[] arr = new double[z_high_cell_face.Length];
        //    for (int i = 0; i < arr.Length; i++)
        //    {
        //        arr[i] = vars_phi[x, y, i, ucrt_index];
        //    }
        //    return arr;
        //}
        ////public double z0(int x, int y)
        ////{
        ////    int len = z_high_cell_face.Length;
        ////    double[] logz = new double[len];
        ////    double[] u = ucrt(x, y);
        ////    for (int i = 0; i < len; i++)
        ////    {
        ////        double zcen;
        ////        if (i == 0) zcen = z_high_cell_face[i] / 2;
        ////        else zcen = z_high_cell_face[i] - z_high_cell_face[i - 1];
        ////        logz[i] = Math.Log(zcen);
        ////    }
        ////}
        public WindField(WSProject project ,int settore)
        {
            // inistialize phi and xyz

            string  phi_file = project.file.DirectoryName + "\\windfield\\" + settore + "_red.phi";
            string  xyz_file = project.file.DirectoryName + "\\windfield\\" + settore + "_red.xyz";

            FileInfo phi_file_check = new FileInfo(phi_file);
            FileInfo xyz_file_check = new FileInfo(xyz_file);

            // check if required files exists

            if (phi_file_check.Exists && xyz_file_check.Exists)
            {
                phi = new PhiFile(phi_file);
                xyz = new XYZFile(xyz_file);
            }
            else
            {
                phi = null;
                xyz = null;
            }
        }
示例#4
0
 public void test_project_load_gws_proper_file_referencing_in_project_terrainRanOnCurrentGws()
 {
     WSProject project = new WSProject(project_file.FullName);
     string gws_filepath = "gws_test.gws";
     FileInfo gws_file = new FileInfo(gws_filepath);
     project.terrainRanOnCurrentGws = true;
     bool check = project.load_gws(gws_file.FullName);
     Assert.AreEqual(false, project.terrainRanOnCurrentGws);
 }
示例#5
0
 public void test_project_load_bws_proper_refinement_type_in_project_parameters()
 {
     WSProject project = new WSProject(project_file.FullName);
     string bws_filepath = "bws_test.bws";
     FileInfo bws_file = new FileInfo(bws_filepath);
     bool check = project.load_bws(bws_file.FullName);
     Assert.AreEqual(2,project.parameters.CFD.RefinementType);
 }
示例#6
0
 public void test_project_load_bws_proper_file_positioning()
 {
     WSProject project = new WSProject(project_file.FullName);
     string bws_filepath = "bws_test.bws";
     FileInfo bws_file = new FileInfo(bws_filepath);
     bool check = project.load_bws(bws_file.FullName);
     string expected_file_path = project.file.Directory.FullName + "\\dtm\\" + bws_file.Name;
     FileInfo expected_file = new FileInfo(expected_file_path);
     Assert.IsTrue(expected_file.Exists);
     //
 }
示例#7
0
 public void test_project_fill_xyz_on_construct()
 {
     WSProject project = new WSProject(project_file.FullName);
     XYZFile settore_270 = new XYZFile(xyzfile270_path);
     Assert.IsTrue(project.WField[270].xyz.Equals(settore_270)); //remeber that Phifile equals do not compare vars_phi[,,,] !
     // should test if the file do not exist project_fill_xyzfiles_on_construct()
 }
示例#8
0
        public ExcelBatch(WSProject referenceProject, FileInfo excelBatchFile)
        {
            // controllo l-esistenza del file excel
            if (verifyExcelFile(excelBatchFile) && verifyProjectFiles(excelBatchFile, referenceProject))
            {
                // setto la directory
                // riempo l'experimentBatch
                Workbook book = Workbook.Load(excelBatchFile.FullName);
                Worksheet sheet = book.Worksheets[0];
                string batteryName = sheet.Cells[0, 1].StringValue;
                double numberOfEsperiments = Convert.ToInt32(sheet.Cells[1, 1].Value);
                Worksheet results_geom = book.Worksheets[1];
                results_geom.Cells[0, 0] = new Cell("UCRT Profiles for Geometrical Grading");
                Worksheet results_ke_geom = book.Worksheets[2];
                results_ke_geom.Cells[0, 0] = new Cell("KE Profiles for Geometrical Grading");
                Worksheet results_zcen_geom = book.Worksheets[3];
                results_zcen_geom.Cells[0, 0] = new Cell("Z Profiles for Geometrical Grading");
                Worksheet results_arit = book.Worksheets[4];
                results_arit.Cells[0, 0] = new Cell("UCRT Profiles for Aritmetical Grading");
                Worksheet results_ke_arit = book.Worksheets[5];
                results_ke_arit.Cells[0, 0] = new Cell("KE Profiles for Aritmetical Grading");
                Worksheet results_zcen_arit = book.Worksheets[6];
                results_zcen_arit.Cells[0, 0] = new Cell("Z Profiles for Aritmetical Grading");
                Worksheet results_tem1_arit = book.Worksheets[7];
                results_tem1_arit.Cells[0, 0] = new Cell("TEM1 Profiles for Aritmetical Grading");
                Worksheet results_tem1_geom = book.Worksheets[8];
                results_tem1_geom.Cells[0, 0] = new Cell("TEM1 Profiles for Geometrical Grading");
                Console.WriteLine("Total simulations in the excel :"+ numberOfEsperiments);
                for (int i = 0; i < numberOfEsperiments; i++)
                {
                  int todo = Convert.ToInt32(sheet.Cells[6, i + 1].Value);

                  if (todo == 0)
                  {
                      Console.WriteLine("Skipping case : " + i);
                  }

                  if( todo == 1 || todo == 2)
                  {
                    Console.WriteLine("Running case : " + i + " todo " + todo);
                    WSProject testcase = null;
                    WSProject testcase_arit = null;

                    bool restart = false;
                    string testCasetargetDirectory = excelBatchFile.Directory.FullName + "\\" + batteryName + "_" + sheet.Cells[7, i + 1].StringValue;
                    double z0_convergence_treshold = Convert.ToDouble(sheet.Cells[14, i + 1].Value);
                    int z0_convergence_sweeps = Convert.ToInt32(sheet.Cells[15, i + 1].Value);
                    int z0_cycles_to_be_checked = Convert.ToInt32(sheet.Cells[16, i + 1].Value);

                    int z0_monitoring_x = Convert.ToInt32(sheet.Cells[17, i + 1].Value);
                    int z0_monioring_y = Convert.ToInt32(sheet.Cells[18, i + 1].Value);
                    int nx = Convert.ToInt32(sheet.Cells[8, i + 1].Value);
                    int nj = Convert.ToInt32(sheet.Cells[9, i + 1].Value);
                    int verticalResolution = Convert.ToInt32(sheet.Cells[10, i + 1].Value);
                    float totalHeight = (float)Convert.ToDouble(sheet.Cells[11, i + 1].Value);

                    float roughness = (float)Convert.ToDouble(sheet.Cells[12, i + 1].Value);

                    double heithFirstLayerGeometrical = Convert.ToDouble(sheet.Cells[21, i + 1].Value);

                    RefinementGenerator.GeometricalGrading geom_refinement = new RefinementGenerator.GeometricalGrading(heithFirstLayerGeometrical, totalHeight, verticalResolution);

                    if (todo == 1) {

                    testcase = new WSProject(referenceProject.file.FullName, testCasetargetDirectory+"_geom");
                    testcase.load_parameters_from_excel(sheet);
                    #region read batch case parameters

                    FileInfo gwsfile = new FileInfo(excelBatchFile.Directory.FullName + "\\gws_files\\" + sheet.Cells[12, i + 1].ToString());
                    testcase.parameters.CFD.Height = totalHeight;
                    testcase.parameters.DTM.Roughness = roughness;

                    testcase.save();
                    testcase.load_gws(gwsfile.FullName);
                    // run the case of geometrical grid..

                    geom_refinement.Rectangle(testcase,"autogenerated_geometrical_bws_"+nx+"_"+nj, testcase.parameters.DTM.XMax,testcase.parameters.DTM.YMax,nx,nj);
                    #endregion
                    testcase.run(1);
                    }
                   else if (todo == 2)
                    {
                       restart = true;
                       z0_convergence_treshold = Convert.ToDouble(sheet.Cells[37, i + 1].Value);
                       z0_convergence_sweeps = Convert.ToInt32(sheet.Cells[38, i + 1].Value);
                       z0_cycles_to_be_checked = Convert.ToInt32(sheet.Cells[39, i + 1].Value);
                       FileInfo geometrico = new FileInfo(testCasetargetDirectory + "_geom\\" + referenceProject.file.Name);
                       testcase = new WSProject(geometrico.FullName);
                   }

                    Console.WriteLine("...G");
                    double[] z0results_geom = testcase.run_windfield_z0_conv(z0_convergence_treshold,z0_convergence_sweeps,z0_cycles_to_be_checked,z0_monitoring_x,z0_monioring_y, restart);
                    int resultRowShift = 0;
                    if (todo == 2) { resultRowShift = 21;}
                    #region write results geometrical

                    // write results
                    sheet.Cells[20 + resultRowShift, i + 1] = new Cell(geom_refinement.expansionFactor);
                    //height first cell
                    sheet.Cells[21 + resultRowShift, i + 1] = new Cell(geom_refinement.heightFirstLayer);
                    //z0
                    ////  { z0 , (u*/k) , sigma, r2 , sigmaz0 }
                    sheet.Cells[22 + resultRowShift, i + 1] = new Cell(z0results_geom[0]);
                    //sigma z0
                    sheet.Cells[23 + resultRowShift, i + 1] = new Cell(z0results_geom[4]);
                    //r2
                    sheet.Cells[24 + resultRowShift, i + 1] = new Cell(z0results_geom[3]);

                    // add ustar
                    double ustar_geom = MyMath.ustar_neutral(testcase.parameters.WindField.VelocityBoundaryLayer, testcase.parameters.WindField.HeightBoundaryLayer, testcase.parameters.DTM.Roughness, 0.4);
                    if (testcase.parameters.WindField.Temperature == 1)
                    {
                        ustar_geom = MyMath.ustar_neutral(testcase.parameters.WindField.WindspeedInReferenceHeight, testcase.parameters.WindField.ReferenceHeight, testcase.parameters.DTM.Roughness, 0.4);
                    }
                    sheet.Cells[25 + resultRowShift, i + 1] = new Cell(ustar_geom);

                    //add the project to the dictionary

                    book.Save(excelBatchFile.FullName);
                    #endregion
                    #region write profiles geometrical

                    // write the profile in the profiles file
                    double[] profile_geom = testcase.WField[270].ucrt(z0_monitoring_x, z0_monioring_y);
                    double[] zcen_geom = testcase.WField[270].zcen(z0_monitoring_x, z0_monioring_y);
                    double[] profile_geom_ke = testcase.WField[270].ke(z0_monitoring_x, z0_monioring_y);
                    double[] theoretical_mo_neural_geom = MyMath.mo_neutral_u(zcen_geom, 0.4, ustar_geom, roughness);
                    double rmse_geom = MyMath.rmse(profile_geom, theoretical_mo_neural_geom);
                    sheet.Cells[26 + resultRowShift, i + 1] = new Cell(rmse_geom);

                    results_geom.Cells[1, i] = new Cell(i + 1);
                    results_zcen_geom.Cells[1, i] = new Cell(i + 1);
                    results_ke_geom.Cells[1, i] = new Cell(i + 1);
                    for (int count = 0; count < profile_geom.Length; count++)
                    {
                       results_geom.Cells[count+3, i] = new Cell(profile_geom[count]);
                       results_zcen_geom.Cells[count+3, i] = new Cell(zcen_geom[count]);
                       results_ke_geom.Cells[count + 3, i] = new Cell(profile_geom_ke[count]);
                    }
                    if (testcase.parameters.WindField.Temperature == 1)
                    {
                        double[] profile_geom_tem1 = testcase.WField[270].tem1(z0_monitoring_x, z0_monioring_y);
                        for (int count = 0; count < profile_geom.Length; count++)
                        {
                            results_tem1_geom.Cells[count + 3, i] = new Cell(profile_geom_tem1[count]);
                        }
                    }
                    book.Save(excelBatchFile.FullName);
                    #endregion

                    Console.WriteLine("...A");
                    RefinementGenerator.AritmeticalGrading arit_refinement = new RefinementGenerator.AritmeticalGrading(geom_refinement.expansionFactor, geom_refinement.numbersOfVericalLayer, geom_refinement.totalHeight);
                    if (todo == 1)
                    {
                        // duplicate the project
                        testcase_arit = new WSProject(testcase.file.FullName, testCasetargetDirectory + "_arit");
                        // create the bws
                        // assign the bws
                        arit_refinement.Rectangle(testcase_arit, "autogenerated_aritmeical_bws_" + nx + "_" + nj, testcase_arit.parameters.DTM.XMax, testcase_arit.parameters.DTM.YMax, nx, nj);
                        // run terrain
                        testcase_arit.run(1);
                        // run the project
                    }
                    else if (todo == 2)
                    {
                        z0_convergence_treshold = Convert.ToDouble(sheet.Cells[37, i + 1].Value);
                        z0_convergence_sweeps = Convert.ToInt32(sheet.Cells[38, i + 1].Value);
                        z0_cycles_to_be_checked = Convert.ToInt32(sheet.Cells[39, i + 1].Value);
                        FileInfo aritmetico = new FileInfo(testCasetargetDirectory + "_arit\\" + referenceProject.file.Name);
                        testcase_arit = new WSProject(aritmetico.FullName);
                    }

                    double[] z0results_arit = testcase_arit.run_windfield_z0_conv(z0_convergence_treshold, z0_convergence_sweeps, z0_cycles_to_be_checked, z0_monitoring_x, z0_monioring_y,restart);

                    #region write resuls aritmetical

                    // write he results z0
                    sheet.Cells[28 + resultRowShift, i + 1] = new Cell(arit_refinement.heightDistributionFactor);
                    //height first cell
                    sheet.Cells[29 + resultRowShift, i + 1] = new Cell(arit_refinement.heightFirstLayer);
                    //z0
                    ////  { z0 , (u*/k) , sigma, r2 , sigmaz0 }
                    sheet.Cells[30 + resultRowShift, i + 1] = new Cell(z0results_arit[0]);
                    //sigma z0
                    sheet.Cells[31 + resultRowShift, i + 1] = new Cell(z0results_arit[4]);
                    //r2
                    sheet.Cells[32 + resultRowShift, i + 1] = new Cell(z0results_arit[3]);

                    // add ustar
                    double ustar_arit = MyMath.ustar_neutral(testcase_arit.parameters.WindField.VelocityBoundaryLayer, testcase_arit.parameters.WindField.HeightBoundaryLayer, testcase_arit.parameters.DTM.Roughness, 0.4);
                    if (testcase.parameters.WindField.Temperature == 1)
                    {
                        ustar_arit = MyMath.ustar_neutral(testcase_arit.parameters.WindField.WindspeedInReferenceHeight, testcase_arit.parameters.WindField.ReferenceHeight, testcase_arit.parameters.DTM.Roughness, 0.4);
                    }
                    sheet.Cells[25 + resultRowShift, i + 1] = new Cell(ustar_geom);

                    sheet.Cells[33 + resultRowShift, i + 1] = new Cell(ustar_arit);

                    //add the project to the dictionary
                    book.Save(excelBatchFile.FullName);
                    #endregion

                    #region write profiles aritmetical

                    // write the profile in the profiles file
                    double[] profile_arit = testcase_arit.WField[270].ucrt(z0_monitoring_x, z0_monioring_y);
                    double[] zcen_arit = testcase_arit.WField[270].zcen(z0_monitoring_x, z0_monioring_y);
                    double[] profile_arit_ke = testcase_arit.WField[270].ke(z0_monitoring_x, z0_monioring_y);

                    // add rmse
                    double[] theoretical_mo_neural_arit = MyMath.mo_neutral_u(zcen_arit, 0.4, ustar_arit, roughness);
                    double rmse_arit = MyMath.rmse(profile_arit, theoretical_mo_neural_arit);
                    sheet.Cells[34 + resultRowShift, i + 1] = new Cell(rmse_arit);

                    results_arit.Cells[1, i] = new Cell(i + 1);
                    results_zcen_arit.Cells[1, i] = new Cell(i + 1);
                    results_ke_arit.Cells[1, i] = new Cell(i + 1);
                    for (int count = 0; count < profile_arit.Length; count++)
                    {
                        results_arit.Cells[count+3, i] = new Cell(profile_arit[count]);
                        results_zcen_arit.Cells[count+3, i] = new Cell(zcen_arit[count]);
                        results_ke_arit.Cells[count+3, i] = new Cell(profile_arit_ke[count]);

                    }

                    if (testcase.parameters.WindField.Temperature == 1)
                    {
                        double[] profile_arit_tem1 = testcase_arit.WField[270].tem1(z0_monitoring_x, z0_monioring_y);
                        for (int count = 0; count < profile_arit.Length; count++)
                        {
                            results_tem1_arit.Cells[count + 3, i] = new Cell(profile_arit_tem1[count]);
                        }
                    }
                    book.Save(excelBatchFile.FullName);
                    //add the project to the dictionary
                    #endregion

                 }
                }
              }

            else
            {
                throw new System.ArgumentException("Some error occurred regarding the excel file");
            }
        }
示例#9
0
 public void test_project_save()
 {
     WSProject project = new WSProject(project_file.FullName);
     project.parameters.DTM.Roughness = 912.1F;
     project.save();
     WSProject project2 = new WSProject(project_file.FullName);
     Assert.AreEqual(project2.parameters.DTM.Roughness, 912.1F);
 }
示例#10
0
 public void test_project_run_string_3_var()
 {
     WSProject project = new WSProject(project_file.FullName);
     Assert.AreEqual(project.run_string(4, "b", "m"), " \"" + project.file.FullName + "\"" + " \"Layout 1.lws\" \"C:\\Program Files\\WindSim\\WindSim 5.1.0\\Environment.xml\" 4 /b /m");
 }
示例#11
0
            //public bool SaveToBws(WSProject project, string bws_filename)
            //{
            //    StringBuilder sb = new StringBuilder();
            //    header(sb, xNodes, yNodes);
            //    verticalLayers(sb, zNodes);
            //    footer(sb, xmax, ymax);
            //    File.WriteAllText(project.file.Directory.FullName + "\\dtm\\" + bws_filename + ".bws", sb.ToString());
            //    project.parameters.CFD.RefinementFileName = bws_filename + ".bws";
            //    project.parameters.CFD.RefinementType = 2;
            //    project.save();
            //    return true;
            //}
            public bool SaveToBws(WSProject project, string bws_filename)
            {
                StringBuilder sb = new StringBuilder();
                header(sb);
                logicals(sb, xNodes - 1, yNodes - 1, slabs);
                junctions(sb, xNodes, yNodes);
                junctions_obstacles(sb, xNodes, yNodes, slabs);
                footer(sb, xmax, ymax);

                //File.WriteAllText("c:\\test.bws", sb.ToString());
                File.WriteAllText(project.file.Directory.FullName + "\\dtm\\" + bws_filename + ".bws", sb.ToString());
                project.parameters.CFD.RefinementFileName = bws_filename + ".bws";
                project.parameters.CFD.RefinementType = 2;
                project.save();
                return true;
            }
示例#12
0
        public static Worksheet excel_batch_worksheet(WSProject p)
        {
            Worksheet worksheet = new Worksheet("Run Parameters Data");

            // this cycle add some null cells because when on Windows 7 Office need at least 6000byte files.
            //----------------------------------------------
            for (var k = 0; k < 200; k++)
                worksheet.Cells[k, 0] = new Cell(null);
            // ---------------------------------------------

            XmlReader reader = XmlReader.Create(p.file.FullName);
            int i = 0;
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    worksheet.Cells[i, 0] = new Cell(reader.Name);
                    if (reader.Read())
                    {
                        worksheet.Cells[i, 1] = new Cell(reader.Value.Trim());
                    }
                    i++;
                }
            }

            return worksheet;
        }
 public void test_RefinementGenerator_write_the_bws_file_in_the_proper_Directory_aritm()
 {
     WSProject project = new WSProject(project_file.FullName);
     string bws_filename = "test_bws_position";
     RefinementGenerator.AritmeticalGrading test_grading = new RefinementGenerator.AritmeticalGrading(1.2,12,400.0);
     test_grading.Rectangle(project, bws_filename, 50, 50, 50, 50);
     string expected_file_path = project.file.Directory.FullName + "\\dtm\\" + "test_bws_position" + ".bws"; ;
     FileInfo expected_file = new FileInfo(expected_file_path);
     Assert.IsTrue(expected_file.Exists);
     //
 }
 public void test_RefinementGenerator_load__proper_bws_type_in_project_parameters()
 {
     WSProject project = new WSProject(project_file.FullName);
     string bws_filename = "test_bws_position";
     RefinementGenerator.GeometricalGrading test_grading = new RefinementGenerator.GeometricalGrading(0.02, 1000, 20);
     test_grading.Rectangle(project, bws_filename, 50, 50, 50, 50);
     Assert.AreEqual(2, project.parameters.CFD.RefinementType);
 }
示例#15
0
 public void test_project_load_gws_proper_file_renaming_2()
 {
     WSProject project = new WSProject(project_file.FullName);
     string gws_filepath = "gws_test.gws";
     FileInfo bws_file = new FileInfo(gws_filepath);
     bool check = project.load_gws(bws_file.FullName);
     bool check2 = project.load_gws(bws_file.FullName);
     string expected_file_path = project.file.Directory.FullName + "\\dtm\\grid.backup_fbatch_1.gws";
     FileInfo expected_file = new FileInfo(expected_file_path);
     Assert.IsTrue(expected_file.Exists);
     //
 }
示例#16
0
 public void test_new_project_RanOnCurrentGws_false()
 {
     WSProject project = new WSProject(project_file.FullName);
     Assert.AreEqual(false, project.terrainRanOnCurrentGws);
 }
示例#17
0
 public void test_project_properly_load_gws_file()
 {
     WSProject project = new WSProject(project_file.FullName);
     string gws_filepath = "gws_test.gws";
     FileInfo gws_file = new FileInfo(gws_filepath);
     bool check = project.load_gws(gws_file.FullName);
     string expected_file_path = project.file.Directory.FullName + "\\dtm\\grid.gws";
     string sourceContent = File.ReadAllText(gws_file.FullName);
     string destinationContent = File.ReadAllText(expected_file_path);
     Assert.AreEqual(sourceContent, destinationContent);
     //
 }
示例#18
0
 public void test_project_constructor_with_target_directory_create_same_size_project_dir()
 {
     string target_directory_for_testing = "temp_project_test";
     WSProject project = new WSProject(project_file.FullName, target_directory_for_testing);
     Assert.AreEqual(Tools.GetDirectorySize(dir_name), Tools.GetDirectorySize(target_directory_for_testing));
     //DirectoryInfo target_dir_obj = new DirectoryInfo(target_directory_for_testing);
     //target_dir_obj.Delete();
 }
示例#19
0
 public void test_project_run_terrain_set_RanOnCurrentGws_true()
 {
     WSProject project = new WSProject(project_file.FullName);
     project.run(1);
     Assert.AreEqual(true,project.terrainRanOnCurrentGws);
 }
示例#20
0
 public void test_project_constructor_with_target_directory_refer_to_the_right_project_file()
 {
     string target_directory_string_for_testing = "temp_project_test";
     WSProject project = new WSProject(project_file.FullName, target_directory_string_for_testing);
     DirectoryInfo target_dir_obj = new DirectoryInfo(target_directory_string_for_testing);
     Assert.AreEqual(project.file.FullName, target_dir_obj.FullName + "\\" + project.file.Name);
     //DirectoryInfo target_dir_obj = new DirectoryInfo(target_directory_for_testing);
     //target_dir_obj.Delete();
 }
            public bool Rectangle(WSProject project, string bws_filename, double xmax, double ymax, int nx,int nj)
            {
                StringBuilder sb = new StringBuilder();

                header(sb,nx,nj);
                verticalLayers(sb, numbersOfVericalLayer);
                footer(sb,xmax,ymax);

                File.WriteAllText(project.file.Directory.FullName + "\\dtm\\" + bws_filename + ".bws", sb.ToString());
                project.parameters.CFD.RefinementFileName = bws_filename + ".bws";
                project.parameters.CFD.RefinementType = 2;
                project.save();
                return true;
            }
示例#22
0
        public bool verifyProjectFiles(FileInfo file, WSProject reference)
        {
            if (file.Exists)
            {
                int counter = 0;
                Workbook book = Workbook.Load(file.FullName);
                Worksheet sheet = book.Worksheets[0];
                int numberOfEsperiments = Convert.ToInt32(sheet.Cells[1, 1].Value);
                int rerun_cases = 0;
                for (int i = 0; i < numberOfEsperiments; i++)
                {
                    string batteryName = sheet.Cells[0, 1].StringValue;
                    string testCasetargetDirectory = file.Directory.FullName + "\\" + batteryName + "_" + sheet.Cells[7, i + 1].StringValue;
                    // se il caso e' re-run
                    int todo = Convert.ToInt32(sheet.Cells[6, i + 1].Value);
                    if (todo == 2)
                    {
                        rerun_cases++;
                        FileInfo geometrico = new FileInfo(testCasetargetDirectory + "_geom\\" + reference.file.Name);
                        FileInfo aritmetico = new FileInfo(testCasetargetDirectory + "_arit\\" + reference.file.Name);
                        // allora verifica che esista sia l'aritmetica che la geometrica
                        if (aritmetico.Exists && geometrico.Exists) { counter++; }
                    }

                }
                if (counter == rerun_cases) return true;
                else return false;
            }
            else
            {
                return false;
            }
        }