Esempio n. 1
0
 public bool ChangePatchName(string oldName, string newName)
 {
     /*
      * FoamDictionaryListFile f = new FoamDictionaryListFile(FoamConst.GetBoundaryFileNameFromVxt(vxtFileName));
      * f.Read();
      * if (!f.Dictionary.IsNull)
      * {
      *   FoamDictionary d = f.Dictionary.Item(oldName);
      *   f.Dictionary.RemoveChild(oldName);
      *   f.Dictionary.SetChild(newName, d);
      * }
      * f.Write();
      */
     try
     {
         StreamReader sr   = new StreamReader(FoamConst.GetBoundaryFileNameFromVxt(vxtFileName));
         string       code = sr.ReadToEnd();
         sr.Close();
         code = code.Replace(oldName, newName);
         File.Delete(FoamConst.GetBoundaryFileNameFromVxt(vxtFileName));
         StreamWriter sw = new StreamWriter(FoamConst.GetBoundaryFileNameFromVxt(vxtFileName), false);
         sw.Write(code);
         sw.Close();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Esempio n. 2
0
        public List <string> GetAllPatchNames()
        {
            List <string>          names = new List <string>();
            FoamDictionaryListFile f     = new FoamDictionaryListFile(FoamConst.GetBoundaryFileNameFromVxt(vxtFileName));

            f.Read();
            if (!f.Dictionary.IsNull)
            {
                foreach (KeyValuePair <string, FoamDictionary> k in f.Dictionary)
                {
                    names.Add(k.Key);
                }
            }
            return(names);
        }
Esempio n. 3
0
        public void SetBoundaryType(string name, BoundaryType bt)
        {
            FoamDictionaryListFile f = new FoamDictionaryListFile(FoamConst.GetBoundaryFileNameFromVxt(vxtFileName));

            f.Read();
            if (!f.Dictionary.IsNull)
            {
                foreach (KeyValuePair <string, FoamDictionary> k in f.Dictionary)
                {
                    if (k.Key == name)
                    {
                        FoamDictionary cv = k.Value;
                        cv.SetChild("type", bt.ToString());
                        cv.RemoveChild("inGroups");
                    }
                }
            }
            f.Write();
        }
Esempio n. 4
0
        public List <string> GetPatchNamesByType(string typeName)
        {
            List <string>          names = new List <string>();
            FoamDictionaryListFile f     = new FoamDictionaryListFile(FoamConst.GetBoundaryFileNameFromVxt(vxtFileName));

            f.Read();
            if (!f.Dictionary.IsNull)
            {
                foreach (KeyValuePair <string, FoamDictionary> k in f.Dictionary)
                {
                    FoamDictionary cv = k.Value;
                    if (cv.Child("type").Data == typeName)
                    {
                        names.Add(k.Key);
                    }
                }
            }
            return(names);
        }