Пример #1
0
        public void SetValues(string path, List <EnvironmentItem> values)
        {
            FoamDictionary d = Dict.GetByUrl(path);

            d.Clear();
            foreach (EnvironmentItem p in values)
            {
                d.SetChild(p.Name, p.Value);
            }
            ConfigFile.Write();
        }
Пример #2
0
 public bool Write(string foamRootPathName, IMonitor monitor = null)
 {
     try
     {
         string             dictFileName = FoamConst.GetCfMeshDictFileName(foamRootPathName);
         FoamDictionaryFile f            = new FoamDictionaryFile(dictFileName, monitor);
         f.Read();
         f.Dictionary.SetChild("surfaceFile", "\"surface.stl\"");
         f.Dictionary.SetChild("maxCellSize", MaxCellSize);
         f.Dictionary.SetChild("minCellSize", MinCellSize);
         f.Dictionary.SetChild("boundaryCellSize", BoundaryCellSize);
         f.Dictionary.SetChild("enforceGeometryConstraints", EnforceGeometryConstraints ? "1" : "0");
         FoamDictionary dLocalRefine = f.Dictionary.GetByUrl("localRefinement");
         dLocalRefine.Clear();
         foreach (LocalRefinementSubDict l in LocalRefine)
         {
             l.ToFoamDictionary(dLocalRefine);
         }
         FoamDictionary dObjectRefine = f.Dictionary.GetByUrl("objectRefinements");
         dObjectRefine.Clear();
         foreach (ObjectRefinementSubDict o in ObjectRefine)
         {
             o.ToFoamDictionary(dObjectRefine);
         }
         FoamDictionary dSurfaceRefine = f.Dictionary.GetByUrl("surfaceMeshRefinement");
         dSurfaceRefine.Clear();
         foreach (SurfaceRefinementSubDict s in SurfaceRefine)
         {
             s.ToFoamDictionary(dSurfaceRefine);
         }
         FoamDictionary dPatchName = f.Dictionary.GetByUrl("renameBoundary");
         dPatchName.Clear();
         dPatchName.SetChild("defaultName", "walls");
         dPatchName.SetChild("defaultType", "wall");
         FoamDictionary dNewPatchNames = dPatchName.GetByUrl("newPatchNames");
         dNewPatchNames.Clear();
         foreach (PatchConfigSubDict p in PatchConfig)
         {
             p.ToFoamDictionary(dNewPatchNames);
         }
         FoamDictionary dBoundaryLayers = f.Dictionary.GetByUrl("boundaryLayers");
         dBoundaryLayers.Clear();
         if (GlobalBoundaryLayerParameters.NLayers != 0)
         {
             GlobalBoundaryLayerParameters.ToFoamDictionary(dBoundaryLayers);
         }
         FoamDictionary dPatchBoundaryLayers = dBoundaryLayers.GetByUrl("patchBoundaryLayers");
         dPatchBoundaryLayers.Clear();
         foreach (PatchBoundaryLayerSubDict p in PatchBoundaryLayerParameters)
         {
             p.ToFoamDictionary(dPatchBoundaryLayers);
         }
         f.Write(dictFileName);
         return(true);
     }
     catch (Exception e)
     {
         if (monitor != null)
         {
             monitor.ErrorLine(e.Message);
         }
         return(false);
     }
 }