//        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;
            }
        }
 public void WindField_zcen_top()
 {
     FileInfo xyz_file = new FileInfo(xyz_file270_path);
     XYZFile expected = new XYZFile(xyz_file.FullName);
     double expected_value = expected.values[1, 1, (target.xyz.nk - 2), 2] + ((expected.values[1, 1, (target.xyz.nk - 1), 2] - expected.values[1, 1, (target.xyz.nk - 2), 2]) / 2);
     Assert.AreEqual(expected_value, target.zcen(2,2)[(target.xyz.nk - 2)]);
 }
 public void WindField_zcen_length()
 {
     FileInfo xyz_file = new FileInfo(xyz_file270_path);
     XYZFile expected = new XYZFile(xyz_file.FullName);
     Assert.AreEqual(expected.nk-1, target.ucrt(1,1).Length);
 }
 public void WindField_constructor_xyz()
 {
     FileInfo xyz_file = new FileInfo(xyz_file270_path);
     XYZFile expected = new XYZFile(xyz_file.FullName);
     Assert.IsTrue(target.xyz.Equals(expected));
 }
 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()
 }
Exemple #6
0
 //(object obj)
 private bool Equal_dimensions(XYZFile other)
 {
     return (FileName.FullName == other.FileName.FullName) &&
            (ni == other.ni) &&
            (nj == other.nj) &&
            (nk == other.nk);
 }
Exemple #7
0
        public bool Equals(XYZFile other)
        {
            int err = 0;
            if (this.Equal_dimensions(other))
            {
                for (int i = 0; i < ni; i++)
                {
                    for (int j = 0; j < nj; j++)
                    {
                        for (int k = 0; k < nk; k++)
                        {
                            for (int var = 0; var < 3; var++)
                            {
                                if (values[i, j, k, var] != other.values[i, j, k, var]) { err++; }
                            }
                        }
                    }
                }

            }
            else
            {
                err++;
            }

            if (err == 0) { return true; } else { return false; }
        }