Ejemplo n.º 1
0
        List <KeyValuePair <string, string> > GetPatchs()
        {
            List <KeyValuePair <string, string> > patches = new List <KeyValuePair <string, string> >();
            FoamDictionaryFile f = new FoamDictionaryFile(boundaryFile, monitor);

            f.Read();
            FoamDictionary d = f.Dictionary.LookupByUrl("");

            return(patches);
        }
Ejemplo n.º 2
0
        public bool Write(string foamRootPathName, IMonitor monitor)
        {
            var f = new FoamDictionaryFile(FoamConst.GetConstantChildPathName(foamRootPathName, "tracerProperties"), monitor);

            f.Read();
            var d = f.Dictionary;

            d.SetChild("Sc", "Sc [0 0 0 0 0 0 0] " + Sc.ToString());
            d.SetChild("tracerPhaseName", "steel");
            f.Write();
            f = new FoamDictionaryFile(FoamConst.GetFvSolutionFileName(foamRootPathName), monitor);
            f.Read();
            d = f.Dictionary.Child("PIMPLE");
            d.SetChild("solveTracer", SolveTracer ? "yes" : "no");
            f.Write();
            foreach (var inj in Injects)
            {
                inj.Write(foamRootPathName, monitor);
            }
            return(true);
        }
Ejemplo n.º 3
0
        public bool Write(string foamRootPathName, IMonitor monitor)
        {
            FoamDictionaryFile f = new FoamDictionaryFile(FoamConst.GetFvOptionsPath(foamRootPathName), monitor);

            f.Read();
            var d = f.Dictionary.GetByUrl("options").AddChild(Name);

            d.SetChild("type", "scalarSemiImplicitSource");
            d.SetChild("timeStart", StartTime);
            d.SetChild("duration", Duration);
            d.SetChild("selectionMode", "points");
            FoamDictionary points = new FoamDictionary(true, monitor);

            points.SetChild("0", Location.ToString());
            d.SetChild("points", points);
            d.SetChild("volumeMode", "absolute");
            FoamDictionary injectionRateSuSp = new FoamDictionary(monitor);

            injectionRateSuSp.SetChild("tracer", "(1 0)");
            d.SetChild("injectionRateSuSp", injectionRateSuSp);
            f.Write();
            return(true);
        }
Ejemplo n.º 4
0
        public override bool Write(string foamRootPathName, IMonitor monitor)
        {
            base.Write(foamRootPathName, monitor);
            FoamDictionaryFile controlFile = new FoamDictionaryFile(FoamConst.GetControlDictFileName(foamRootPathName), monitor);

            controlFile.Read();
            FoamDictionary dfun = controlFile.Dictionary.GetByUrl("functions");
            FoamDictionary m    = new FoamDictionary(monitor);

            m.SetChild("type", "probes");
            m.SetChild("functionObjectLibs", "(\"libsampling.dll\")");
            m.SetChild("probeLocations", string.Format("({0})", Location.ToString()));
            FoamDictionary fields = new FoamDictionary(true, monitor);

            foreach (var f in Fields)
            {
                fields.SetChild(f, f);
            }
            m.SetChild("fields", fields);
            dfun.SetChild(Name, m);
            controlFile.Write();
            return(true);
        }
Ejemplo n.º 5
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);
     }
 }
Ejemplo n.º 6
0
        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);
        }