示例#1
0
        public static List <Units> GetUnits(UnitResults unitResult)
        {
            // Define the Units for some output
            // the schema has been discussed in the following issue
            // https://github.com/strusoft/femdesign-api/issues/375

            var unitsObj = new List <Units>()
            {
                new Units(0, 0),
                new Units(1, (int)unitResult.Angle),
                new Units(2, (int)unitResult.Length),
                new Units(3, (int)unitResult.Force),
                new Units(4, (int)unitResult.Mass),
                new Units(5, (int)unitResult.SectionalData),
                new Units(6, (int)unitResult.Displacement),
                new Units(7, (int)unitResult.Stress),
            };

            // the object between 8 and 63 are not implemented yet

            for (int i = 8; i <= 63; i++)
            {
                unitsObj.Add(new Units(i, 0));
            }

            return(unitsObj);
        }
示例#2
0
        public static Dictionary <string, object> ReadStr(string strPath, List <Results.ResultType> resultTypes, Results.UnitResults units)
        {
            Results.FDfea fdFeaModel = null;

            // It needs to check if model has been runned
            // Always Return the FeaNode Result
            resultTypes.Insert(0, Results.ResultType.FeaNode);
            resultTypes.Insert(1, Results.ResultType.FeaBar);
            resultTypes.Insert(2, Results.ResultType.FeaShell);


            // Create Bsc files from resultTypes
            var bscPathsFromResultTypes = Calculate.Bsc.BscPathFromResultTypes(resultTypes, strPath, units);

            // Create FdScript
            var fdScript = FemDesign.Calculate.FdScript.ReadStr(strPath, bscPathsFromResultTypes);

            // Run FdScript
            var  app       = new FemDesign.Calculate.Application();
            bool hasExited = app.RunFdScript(fdScript, false, true, false);

            // Read model and results
            var model = Model.DeserializeFromFilePath(fdScript.StruxmlPath);

            IEnumerable <Results.IResult> results = Enumerable.Empty <Results.IResult>();

            List <Results.FeaNode>  feaNodeRes  = new List <Results.FeaNode>();
            List <Results.FeaBar>   feaBarRes   = new List <Results.FeaBar>();
            List <Results.FeaShell> feaShellRes = new List <Results.FeaShell>();

            if (resultTypes != null && resultTypes.Any())
            {
                foreach (var cmd in fdScript.CmdListGen)
                {
                    string path = cmd.OutFile;
                    try
                    {
                        if (path.Contains("FeaNode"))
                        {
                            feaNodeRes = Results.ResultsReader.Parse(path).Cast <Results.FeaNode>().ToList();
                        }
                        else if (path.Contains("FeaBar"))
                        {
                            feaBarRes = Results.ResultsReader.Parse(path).Cast <Results.FeaBar>().ToList();
                        }
                        else if (path.Contains("FeaShell"))
                        {
                            feaShellRes = Results.ResultsReader.Parse(path).Cast <Results.FeaShell>().ToList();
                        }
                        else
                        {
                            var _results = Results.ResultsReader.Parse(path);
                            results = results.Concat(_results);
                        }
                    }
                    catch (Exception e)
                    {
                        throw new Exception(e.InnerException.Message);
                    }
                }
            }

            fdFeaModel = new FemDesign.Results.FDfea(feaNodeRes, feaBarRes, feaShellRes);

            var resultGroups = results.GroupBy(t => t.GetType()).ToList();

            // Convert Data in DataTree structure
            var resultsTree = new List <List <Results.IResult> >();

            var i = 0;

            foreach (var resGroup in resultGroups)
            {
                resultsTree.Add(resGroup.ToList());
                i++;
            }

            // Output
            return(new Dictionary <string, object>
            {
                { "Model", model },
                { "FdFeaModel", fdFeaModel },
                { "Results", results }
            });
        }