Esempio n. 1
0
        protected override double Function_Override()
        {
            Rhino_SendInputAndGetOutput();

            // Gets the grasshopper vars in the right cast
            List <double> bowLength = CurrentSolution.GetIntermediateValueByName <List <double> >("BowLength");

            List <Point3d> fixedSupport_1 = FeModel.AddJoints_IntermediateParameter("FixedSupportJoint_1");
            List <Point3d> fixedSupport_2 = FeModel.AddJoints_IntermediateParameter("FixedSupportJoint_2");

            List <Line> archLines_1 = FeModel.AddFrames_IntermediateParameter("ArchLines_1"); // The section is defined in the interface
            List <Line> archLines_2 = FeModel.AddFrames_IntermediateParameter("ArchLines_2"); // The section is defined in the interface

            // Loading of the model is set in the Problem object by the interface

            // The chosen result output given is only valid for the model runs that are *not* for section analysis
            FeModel.RunAnalysisAndGetResults(new List <ResultOutput>()
            {
                ResultOutput.Element_StrainEnergy,
                ResultOutput.SectionNode_Stress,
            });

            CurrentSolution.FillScreenShotData();

            double averageStrainEnergy = (from a in FeModel.MeshBeamElements select a.Value.ElementStrainEnergy.StrainEnergy).Average();
            double maxStrainEnergy     = (from a in FeModel.MeshBeamElements select a.Value.ElementStrainEnergy.StrainEnergy).Max();
            double StDevStrainEnergy   = (from a in FeModel.MeshBeamElements select a.Value.ElementStrainEnergy.StrainEnergy).StandardDeviation();

            CurrentSolution.SetFinalValueByName("MaximumStrainEnergy", maxStrainEnergy);

            CurrentSolution.Eval = CurrentSolution.GetSquareSumOfList(new[]
            {
                // Stores the solution result values

                CurrentSolution.SetFinalValueByName("AverageStrainEnergy", averageStrainEnergy),
                CurrentSolution.SetFinalValueByName("StDevStrainEnergy", StDevStrainEnergy),
            });

            return(CurrentSolution.Eval);
        }