private void OnOpenMesh(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.OK) { if (!FoamMeshVerifier.VerifyDirectory(fbd.SelectedPath)) { MessageBox.Show("网格验证失败,路径:\n" + fbd.SelectedPath, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ErrorLine("网格验证失败,路径: " + fbd.SelectedPath); return; } else { CaseModified = true; currentMeshFileName = FoamConst.GetVxtFilePath(fbd.SelectedPath); File.Create(currentMeshFileName); FillBoundaryTreeNode(); InitCaseBoundary(); foamViewer_main.SetMeshFileName(currentMeshFileName); } } }
public bool Write(string foamRootPathName, IMonitor monitor) { bool res = true; try { Dictionary <string, FoamDictionary> boundaryFieldDict = new Dictionary <string, FoamDictionary>(); Dictionary <string, FoamDictionaryFile> fieldFoamFile = new Dictionary <string, FoamDictionaryFile>(); boundaryFieldDict.Clear(); fieldFoamFile.Clear(); foreach (string field in GlobalModelObject.fieldNames) { FoamDictionaryFile f = new FoamDictionaryFile(FoamConst.GetZeroFieldFileName(foamRootPathName, field), monitor); f.Read(); fieldFoamFile.Add(field, f); boundaryFieldDict.Add(field, f.Dictionary.GetByUrl("boundaryField")); } foreach (BoundaryBase b in Boundarys) { PolyMesh mesh = new PolyMesh(FoamConst.GetVxtFilePath(foamRootPathName)); if (b is Inlet || b is Outlet) { mesh.SetBoundaryType(b.PatchName, PolyMesh.BoundaryType.patch); } else if (b is Tplc.Model.Boundary.Wall) { mesh.SetBoundaryType(b.PatchName, PolyMesh.BoundaryType.wall); } res = b.Update(boundaryFieldDict); if (!res) { if (monitor != null) { monitor.ErrorLine("Write boundary to foam error, boundary: " + b.PatchName); } return(false); } } foreach (FoamDictionaryFile f in fieldFoamFile.Values) { f.Write(); } res = MaterialProperty.Write(foamRootPathName, monitor); if (!res) { if (monitor != null) { monitor.ErrorLine("Write gas proprety to foam error !"); } return(false); } res = InitlizeValue.Write(foamRootPathName, monitor); if (!res) { if (monitor != null) { monitor.ErrorLine("Write initlize value to foam error !"); } return(false); } res = ResidualContorl.Write(foamRootPathName, monitor); if (!res) { if (monitor != null) { monitor.ErrorLine("Write residual control to foam error !"); } return(false); } res = SolveContorl.Write(foamRootPathName, monitor); if (!res) { if (monitor != null) { monitor.ErrorLine("Write solve control to foam error !"); } return(false); } res = RelaxationFactors.Write(foamRootPathName, monitor); if (!res) { if (monitor != null) { monitor.ErrorLine("Write Relaxation factors to foam error !"); } return(false); } } catch (Exception e) { if (monitor != null) { monitor.ErrorLine("Update case error : " + e.Message); } return(false); } return(true); }