Exemple #1
0
        /***************************************************/

        private IEnumerable <IResult> ExtractMeshForce(List <int> ids, List <int> loadcaseIds)
        {
            List <MeshForce> meshForces = new List <MeshForce>();

            IFView           view           = m_LusasApplication.getCurrentView();
            IFResultsContext resultsContext = m_LusasApplication.newResultsContext(view);

            string entity   = "Force/Moment - Thick Shell";
            string location = "Feature extreme";

            foreach (int loadcaseId in loadcaseIds)
            {
                IFLoadset loadset = d_LusasData.getLoadset(loadcaseId);

                if (!loadset.needsAssociatedValues())
                {
                    resultsContext.setActiveLoadset(loadset);
                }

                IFUnitSet unitSet            = d_LusasData.getModelUnits();
                double    forceSIConversion  = 1 / unitSet.getForceFactor();
                double    lengthSIConversion = 1 / unitSet.getLengthFactor();

                List <string> components = new List <string>()
                {
                    "NX", "NY", "NXY", "MX", "MY", "MXY", "SX", "SY"
                };
                d_LusasData.startUsingScriptedResults();

                Dictionary <string, IFResultsComponentSet> resultsSets = GetResultsSets(entity, components, location, resultsContext);

                foreach (int meshId in ids)
                {
                    Dictionary <string, double> featureResults = GetFeatureResults(components, resultsSets, unitSet, meshId, "S", 6);

                    double nX = 0; double nY = 0; double nXY = 0; double mX = 0; double mY = 0; double mXY = 0; double sX = 0; double sY = 0;
                    featureResults.TryGetValue("NX", out nX); featureResults.TryGetValue("NY", out nY); featureResults.TryGetValue("NXY", out nXY);
                    featureResults.TryGetValue("MX", out mX); featureResults.TryGetValue("MY", out mY); featureResults.TryGetValue("MXY", out mXY);
                    featureResults.TryGetValue("SX", out sX); featureResults.TryGetValue("SY", out sY);
                    int       mode      = -1;
                    MeshForce meshForce = new MeshForce(
                        meshId, 0, 0, loadcaseId, mode, 0, MeshResultLayer.Middle, 0.5, MeshResultSmoothingType.ByPanel, null,
                        nX * forceSIConversion,
                        nY * forceSIConversion,
                        nXY * forceSIConversion,
                        mX * forceSIConversion,
                        mY * forceSIConversion,
                        mXY * forceSIConversion,
                        sX * forceSIConversion,
                        sY * forceSIConversion);

                    meshForces.Add(meshForce);
                }

                d_LusasData.stopUsingScriptedResults();
                d_LusasData.flushScriptedResults();
            }

            return(meshForces);
        }
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private IFBasicCombination CreateLoadCombination(LoadCombination loadCombination)
        {
            IFBasicCombination lusasLoadcombination;

            List <double> loadFactors = new List <double>();
            List <int>    loadcases   = new List <int>();

            if (d_LusasData.existsLoadset(loadCombination.Name))
            {
                lusasLoadcombination = (IFBasicCombination)d_LusasData.getLoadset(loadCombination.Name);
            }
            else
            {
                if (loadCombination.Number == 0)
                {
                    lusasLoadcombination = d_LusasData.createCombinationBasic(loadCombination.Name);
                    Compute.RecordWarning($"LoadCombination {loadCombination.Name} ID will be autogenerated by Lusas.");
                }
                else
                {
                    lusasLoadcombination = d_LusasData.createCombinationBasic(loadCombination.Name, "", loadCombination.Number);
                }
                foreach (Tuple <double, ICase> factoredLoad in loadCombination.LoadCases)
                {
                    double    factor        = factoredLoad.Item1;
                    IFLoadset lusasLoadcase = d_LusasData.getLoadset(factoredLoad.Item2.AdapterId <int>(typeof(LusasId)));
                    lusasLoadcombination.addEntry(factor, lusasLoadcase);
                }
            }

            return(lusasLoadcombination);
        }
Exemple #3
0
        /***************************************************/
        /**** Private  Methods                          ****/
        /***************************************************/

        private IEnumerable <IResult> ExtractMeshDisplacement(List <int> ids, List <int> loadcaseIds)
        {
            List <MeshDisplacement> meshDisplacements = new List <MeshDisplacement>();

            IFView           view           = m_LusasApplication.getCurrentView();
            IFResultsContext resultsContext = m_LusasApplication.newResultsContext(view);

            string entity   = "Displacement";
            string location = "Feature extreme";

            foreach (int loadcaseId in loadcaseIds)
            {
                IFLoadset loadset = d_LusasData.getLoadset(loadcaseId);

                if (!loadset.needsAssociatedValues())
                {
                    resultsContext.setActiveLoadset(loadset);
                }

                IFUnitSet unitSet            = d_LusasData.getModelUnits();
                double    lengthSIConversion = 1 / unitSet.getLengthFactor();

                List <string> components = new List <string>()
                {
                    "DX", "DY", "DZ", "THX", "THY", "THZ"
                };
                d_LusasData.startUsingScriptedResults();

                Dictionary <string, IFResultsComponentSet> resultsSets = GetResultsSets(entity, components, location, resultsContext);

                foreach (int meshId in ids)
                {
                    Dictionary <string, double> featureResults = GetFeatureResults(components, resultsSets, unitSet, meshId, "S", 6);

                    double uX = 0; double uY = 0; double uZ = 0; double rX = 0; double rY = 0; double rZ = 0;
                    featureResults.TryGetValue("DX", out uX); featureResults.TryGetValue("DY", out uY); featureResults.TryGetValue("DZ", out uZ);
                    featureResults.TryGetValue("THX", out rX); featureResults.TryGetValue("THY", out rY); featureResults.TryGetValue("THZ", out rZ);
                    int mode = -1;
                    MeshDisplacement meshDisplacement = new MeshDisplacement
                                                        (
                        meshId, 0, 0, loadcaseId, mode, 0, MeshResultLayer.Middle, 0.5, MeshResultSmoothingType.ByPanel, null,
                        uX * lengthSIConversion,
                        uY * lengthSIConversion,
                        uZ * lengthSIConversion,
                        rX,
                        rY,
                        rZ
                                                        );

                    meshDisplacements.Add(meshDisplacement);
                }

                d_LusasData.stopUsingScriptedResults();
                d_LusasData.flushScriptedResults();
            }

            return(meshDisplacements);
        }
Exemple #4
0
        /***************************************************/
        /**** Private  Methods                          ****/
        /***************************************************/

        private IEnumerable <IResult> ExtractNodeReaction(List <int> ids, List <int> loadcaseIds)
        {
            List <NodeReaction> nodeReactions = new List <NodeReaction>();

            IFView           view           = m_LusasApplication.getCurrentView();
            IFResultsContext resultsContext = m_LusasApplication.newResultsContext(view);

            string entity   = "Reaction";
            string location = "Nodal";

            foreach (int loadcaseId in loadcaseIds)
            {
                IFLoadset loadset = d_LusasData.getLoadset(loadcaseId);

                if (!loadset.needsAssociatedValues())
                {
                    resultsContext.setActiveLoadset(loadset);
                }

                IFUnitSet unitSet            = d_LusasData.getModelUnits();
                double    forceSIConversion  = 1 / unitSet.getForceFactor();
                double    lengthSIConversion = 1 / unitSet.getLengthFactor();

                List <string> components = new List <string>()
                {
                    "Fx", "Fy", "Fz", "Mx", "My", "Mz"
                };
                d_LusasData.startUsingScriptedResults();

                Dictionary <string, IFResultsComponentSet> resultsSets = GetResultsSets(entity, components, location, resultsContext);

                foreach (int nodeId in ids)
                {
                    Dictionary <string, double> featureResults = GetFeatureResults(components, resultsSets, unitSet, nodeId, "P", 6);

                    double fX = 0; double fY = 0; double fZ = 0; double mX = 0; double mY = 0; double mZ = 0;
                    featureResults.TryGetValue("Fx", out fX); featureResults.TryGetValue("Fy", out fY); featureResults.TryGetValue("Fz", out fZ);
                    featureResults.TryGetValue("Mx", out mX); featureResults.TryGetValue("My", out mY); featureResults.TryGetValue("Mz", out mZ);

                    List <double> results = new List <double>();

                    //TODO: resolve below identifiers extractable through the API
                    int    mode     = -1;
                    double timeStep = 0;

                    NodeReaction nodeReaction = new NodeReaction(
                        nodeId,
                        Adapters.Lusas.Convert.GetName(loadset.getName()),
                        mode,
                        timeStep,
                        oM.Geometry.Basis.XY,
                        fX * forceSIConversion,
                        fY * forceSIConversion,
                        fZ * forceSIConversion,
                        mX * forceSIConversion * lengthSIConversion,
                        mY * forceSIConversion * lengthSIConversion,
                        mZ * forceSIConversion * lengthSIConversion
                        );

                    nodeReactions.Add(nodeReaction);
                }

                d_LusasData.stopUsingScriptedResults();
                d_LusasData.flushScriptedResults();
            }

            return(nodeReactions);
        }
Exemple #5
0
        private IEnumerable <IResult> ExtractNodeDisplacement(List <int> ids, List <int> loadcaseIds)
        {
            List <NodeDisplacement> nodeDisplacements = new List <NodeDisplacement>();

            IFView           view           = m_LusasApplication.getCurrentView();
            IFResultsContext resultsContext = m_LusasApplication.newResultsContext(view);

            string entity   = "Displacement";
            string location = "Nodal";

            foreach (int loadcaseId in loadcaseIds)
            {
                IFLoadset loadset = d_LusasData.getLoadset(loadcaseId);

                if (!loadset.needsAssociatedValues())
                {
                    resultsContext.setActiveLoadset(loadset);
                }

                IFUnitSet unitSet            = d_LusasData.getModelUnits();
                double    forceSIConversion  = 1 / unitSet.getForceFactor();
                double    lengthSIConversion = 1 / unitSet.getLengthFactor();

                List <string> components = new List <string>()
                {
                    "DX", "DY", "DZ", "THX", "THY", "THZ"
                };
                d_LusasData.startUsingScriptedResults();

                Dictionary <string, IFResultsComponentSet> resultsSets = GetResultsSets(entity, components, location, resultsContext);

                foreach (int nodeId in ids)
                {
                    Dictionary <string, double> featureResults = GetFeatureResults(components, resultsSets, unitSet, nodeId, "P", 6);

                    double uX = 0; double uY = 0; double uZ = 0; double rX = 0; double rY = 0; double rZ = 0;
                    featureResults.TryGetValue("DX", out uX); featureResults.TryGetValue("DY", out uY); featureResults.TryGetValue("DZ", out uZ);
                    featureResults.TryGetValue("THX", out rX); featureResults.TryGetValue("THY", out rY); featureResults.TryGetValue("THZ", out rZ);

                    //TODO: resolve below identifiers extractable through the API
                    int    mode     = -1;
                    double timeStep = 0;

                    NodeDisplacement nodeDisplacement = new NodeDisplacement(
                        nodeId,
                        Adapters.Lusas.Convert.GetName(loadset.getName()),
                        mode,
                        timeStep,
                        oM.Geometry.Basis.XY,
                        uX * lengthSIConversion,
                        uY * lengthSIConversion,
                        uZ * lengthSIConversion,
                        rX,
                        rY,
                        rZ
                        );

                    nodeDisplacements.Add(nodeDisplacement);
                }

                d_LusasData.stopUsingScriptedResults();
                d_LusasData.flushScriptedResults();
            }

            return(nodeDisplacements);
        }
Exemple #6
0
        private IEnumerable <IResult> ExtractMeshVonMises(List <int> ids, List <int> loadcaseIds, MeshResultLayer meshResultLayer)
        {
            List <MeshVonMises> meshStresses = new List <MeshVonMises>();

            IFView           view           = m_LusasApplication.getCurrentView();
            IFResultsContext resultsContext = m_LusasApplication.newResultsContext(view);

            string entity;

            switch (meshResultLayer)
            {
            case MeshResultLayer.Lower:
                entity = "Stress (bottom) - Thick Shell";
                break;

            case MeshResultLayer.Middle:
                entity = "Stress (middle) - Thick Shell";
                break;

            case MeshResultLayer.Upper:
                entity = "Stress (top) - Thick Shell";
                break;

            default:
                entity = "Stress (middle) - Thick Shell";
                Engine.Base.Compute.RecordWarning("No valid MeshLayerPosition provided, therefore it has defaulted to middle (i.e. 0.5).");
                break;
            }
            string location = "Feature extreme";

            foreach (int loadcaseId in loadcaseIds)
            {
                IFLoadset loadset = d_LusasData.getLoadset(loadcaseId);

                if (!loadset.needsAssociatedValues())
                {
                    resultsContext.setActiveLoadset(loadset);
                }

                IFUnitSet unitSet            = d_LusasData.getModelUnits();
                double    forceSIConversion  = 1 / unitSet.getForceFactor();
                double    lengthSIConversion = 1 / unitSet.getLengthFactor();

                List <string> components = new List <string>()
                {
                    "SE"
                };
                d_LusasData.startUsingScriptedResults();

                Dictionary <string, IFResultsComponentSet> resultsSets = GetResultsSets(entity, components, location, resultsContext);

                foreach (int meshId in ids)
                {
                    Dictionary <string, double> featureResults = GetFeatureResults(components, resultsSets, unitSet, meshId, "S", 6);

                    double sE = 0;
                    featureResults.TryGetValue("SE", out sE);
                    int          mode       = -1;
                    MeshVonMises meshStress = new MeshVonMises(
                        meshId, 0, 0, loadcaseId, mode, 0, MeshResultLayer.Middle, 0.5, MeshResultSmoothingType.ByPanel, null,
                        sE * forceSIConversion / (lengthSIConversion * lengthSIConversion), 0, 0);

                    meshStresses.Add(meshStress);
                }

                d_LusasData.stopUsingScriptedResults();
                d_LusasData.flushScriptedResults();
            }

            return(meshStresses);
        }
Exemple #7
0
        /***************************************************/
        /**** Private  Methods                          ****/
        /***************************************************/

        private IEnumerable <IResult> ExtractBarForce(List <int> ids, List <int> loadcaseIds)
        {
            List <BarForce> barForces = new List <BarForce>();

            IFView           view           = m_LusasApplication.getCurrentView();
            IFResultsContext resultsContext = m_LusasApplication.newResultsContext(view);

            string entity   = "Force/Moment - Thick 3D Beam";
            string location = "Feature extreme";

            foreach (int loadcaseId in loadcaseIds)
            {
                IFLoadset loadset = d_LusasData.getLoadset(loadcaseId);

                if (!loadset.needsAssociatedValues())
                {
                    resultsContext.setActiveLoadset(loadset);
                }

                IFUnitSet unitSet            = d_LusasData.getModelUnits();
                double    forceSIConversion  = 1 / unitSet.getForceFactor();
                double    lengthSIConversion = 1 / unitSet.getLengthFactor();

                List <string> components = new List <string>()
                {
                    "Fx", "Fy", "Fz", "Mx", "My", "Mz"
                };
                d_LusasData.startUsingScriptedResults();

                Dictionary <string, IFResultsComponentSet> resultsSets = GetResultsSets(entity, components, location, resultsContext);

                foreach (int barId in ids)
                {
                    Dictionary <string, double> featureResults = GetFeatureResults(components, resultsSets, unitSet, barId, "L", 6);

                    double fX = 0; double fY = 0; double fZ = 0; double mX = 0; double mY = 0; double mZ = 0;
                    featureResults.TryGetValue("Fx", out fX); featureResults.TryGetValue("Fy", out fY); featureResults.TryGetValue("Fz", out fZ);
                    featureResults.TryGetValue("Mx", out mX); featureResults.TryGetValue("My", out mY); featureResults.TryGetValue("Mz", out mZ);

                    //TODO: resolve below identifiers extractable through the API
                    int    mode      = -1;
                    double timeStep  = 0;
                    double position  = 0;
                    int    divisions = 0;

                    BarForce barForce = new BarForce(
                        barId,
                        Adapters.Lusas.Convert.GetName(loadset.getName()),
                        mode,
                        timeStep,
                        position,
                        divisions,
                        fX * forceSIConversion,
                        fY * forceSIConversion,
                        fZ * forceSIConversion,
                        mX * forceSIConversion * lengthSIConversion,
                        mY * forceSIConversion * lengthSIConversion,
                        mZ * forceSIConversion * lengthSIConversion
                        );
                    barForces.Add(barForce);
                }

                d_LusasData.stopUsingScriptedResults();
                d_LusasData.flushScriptedResults();
            }

            return(barForces);
        }
Exemple #8
0
        /***************************************************/

        private IEnumerable <IResult> ExtractBarStrain(List <int> ids, List <int> loadcaseIds)
        {
            List <BarStrain> barStrains = new List <BarStrain>();

            IFView           view           = m_LusasApplication.getCurrentView();
            IFResultsContext resultsContext = m_LusasApplication.newResultsContext(view);

            string entity   = "Strain - Thick 3D Beam";
            string location = "Feature extreme";

            foreach (int loadcaseId in loadcaseIds)
            {
                IFLoadset loadset = d_LusasData.getLoadset(loadcaseId);

                if (!loadset.needsAssociatedValues())
                {
                    resultsContext.setActiveLoadset(loadset);
                }

                IFUnitSet unitSet            = d_LusasData.getModelUnits();
                double    forceSIConversion  = 1 / unitSet.getForceFactor();
                double    lengthSIConversion = 1 / unitSet.getLengthFactor();

                List <string> components = new List <string>()
                {
                    "Ex", "Ey", "Ez", "Bx", "By", "Bz"
                };
                d_LusasData.startUsingScriptedResults();

                Dictionary <string, IFResultsComponentSet> resultsSets = GetResultsSets(entity, components, location, resultsContext);

                foreach (int barId in ids)
                {
                    Dictionary <string, double> featureResults = GetFeatureResults(components, resultsSets, unitSet, barId, "L", 6);
                    List <string> keys = featureResults.Keys.ToList();

                    double eX = 0; double eY = 0; double eZ = 0; double bX = 0; double bY = 0; double bZ = 0;
                    featureResults.TryGetValue("Ex", out eX); featureResults.TryGetValue("Ey", out eY); featureResults.TryGetValue("Ez", out eZ);
                    featureResults.TryGetValue("Bx", out bX); featureResults.TryGetValue("By", out bY); featureResults.TryGetValue("Bz", out bZ);

                    //TODO: resolve below identifiers extractable through the API
                    int    mode      = -1;
                    double timeStep  = 0;
                    double position  = 0;
                    int    divisions = 0;

                    BarStrain barStrain = new BarStrain(
                        barId,
                        Adapters.Lusas.Convert.GetName(loadset.getName()),
                        mode,
                        timeStep,
                        position,
                        divisions,
                        eX,
                        eY,
                        eZ,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0);

                    BH.Engine.Base.Compute.RecordWarning("Please note only axial and shear strains will be returned when pulling BarStrain results.");

                    barStrains.Add(barStrain);
                }

                d_LusasData.stopUsingScriptedResults();
                d_LusasData.flushScriptedResults();
            }

            return(barStrains);
        }