Esempio n. 1
0
        /***************************************************/

        internal static string GetName(IFLoadcase lusasLoadcase)
        {
            string loadcaseName = "";

            if (lusasLoadcase.getName().Contains("/"))
            {
                loadcaseName = lusasLoadcase.getName().Substring(
                    lusasLoadcase.getName().LastIndexOf("/") + 1);
            }
            else
            {
                loadcaseName = lusasLoadcase.getName();
            }

            return(loadcaseName);
        }
Esempio n. 2
0
        /***************************************************/

        internal static int GetAdapterID(IFLoadcase lusasLoadcase, char lastCharacter)
        {
            int adapterID = 0;

            lusasLoadcase.getName();

            if (lusasLoadcase.getName().Contains("/"))
            {
                adapterID = int.Parse(lusasLoadcase.getName().Split(lastCharacter, '/')[1]);
            }
            else
            {
                adapterID = lusasLoadcase.getID();
            }

            return(adapterID);
        }
Esempio n. 3
0
        /***************************************************/
        /**** Private helper methods                    ****/
        /***************************************************/

        private bool Analyse(IEnumerable <object> cases = null)
        {
            d_LusasData.closeAllResults();
            d_LusasData.updateMesh();
            string filename = d_LusasData.getDBFilename();

            if (filename == "")
            {
                Engine.Base.Compute.RecordError("Model has not been saved with a filename, please SaveAs with a filename");
                return(false);
            }
            d_LusasData.save();

            IFLusasRunOptionsObj solverOptions = m_LusasApplication.solverOptions();
            IFTabulateDataObj    solverExport  = m_LusasApplication.solverExport();

            solverOptions.setAllDefaults();
            solverExport.setFilename("%DBFolder%\\%ModelName%~Analysis 1.dat");
            solverExport.setAnalysis("Analysis 1");

            if (cases == null || cases.Count() == 0)
            {
                solverExport.setSolveAllLoadcases(true);
            }
            else
            {
                //Disable setSolveAllLoadcases, this overrides the setDoSolve on individual loadcases
                solverExport.setSolveAllLoadcases(false);

                List <string> names = new List <string>();

                //Select provided cases
                foreach (object item in cases)
                {
                    string name;
                    if (item == null)
                    {
                        continue;
                    }
                    if (item is string)
                    {
                        name = item as string;
                    }
                    else if (item is ICase)
                    {
                        name = (item as ICase).Name;
                    }
                    else
                    {
                        Engine.Base.Compute.RecordWarning("Can not set up cases for running of type " + item.GetType().Name + ". Item " + item.ToString() + " will be ignored. Please provide case names or BHoM cases to be run");
                        continue;
                    }
                    names.Add(name);
                }

                object[] loadcases = d_LusasData.getLoadsets("loadcase", "all");

                for (int i = 0; i < loadcases.Count(); i++)
                {
                    IFLoadcase loadcase = (IFLoadcase)loadcases[i];
                    if (names.Contains(loadcase.getName()))
                    {
                        loadcase.setDoSolve(true);
                    }
                    else
                    {
                        loadcase.setDoSolve(false);
                    }
                }
            }

            int exportError = d_LusasData.exportSolver(solverExport, solverOptions);

            //Did any calls to exportSolver and solve produce errors?
            bool exportErrors = false;
            bool solveErrors  = false;

            //Any non-zero value for solveError or ExportError indicates an error
            int solveError;

            if (exportError != 0)
            {
                exportErrors = true;
            }
            else
            {
                solveError = m_LusasApplication.solve("%DBFolder%\\%ModelName%~Analysis 1.dat", solverOptions);
                if (solveError != 0)
                {
                    solveErrors = true;
                }
                m_LusasApplication.fileOpen("%PerMachineAppDataPlatform%\\config\\AfterSolve");
                m_LusasApplication.scanout("%DBFolder%\\%ModelName%~Analysis 1.out");
            }

            m_LusasApplication.processSolveErrors(exportErrors, solveErrors);
            d_LusasData.openResults("%DBFolder%\\%ModelName%~Analysis 1.mys", "Analysis 1", false, 0, false, false);

            return(!(exportErrors & solveErrors));
        }