예제 #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);
        }
예제 #2
0
        protected override double Function_Override()
        {
            Rhino_SendInputAndGetOutput();

            // Gets the input vars in the right cast
            List <Line>    triangleLines    = CurrentSolution.GetIntermediateValueByName <List <Line> >("InnerLines");
            List <Point3d> triangleVertices = CurrentSolution.GetIntermediateValueByName <List <Point3d> >("InnerPoints");
            List <Point3d> centroid         = CurrentSolution.GetIntermediateValueByName <List <Point3d> >("InnerCentroid");

            CurrentSolution.FillScreenShotData();

            double L1Length = triangleLines[0].Length;
            double L2Length = triangleLines[1].Length;
            double L3Length = triangleLines[2].Length;

            double centroidDelta = centroid[0].DistanceTo(Point3d.Origin);

            double MinAngleToX = (from a in triangleLines
                                  select RhinoMath.ToDegrees(Vector3d.VectorAngle(a.Direction, Vector3d.XAxis) > 90d ? 180d - Vector3d.VectorAngle(a.Direction, Vector3d.XAxis) : Vector3d.VectorAngle(a.Direction, Vector3d.XAxis))).Min();

            double P1Height = triangleVertices[0].Z;
            double P2Height = triangleVertices[1].Z;
            double P3Height = triangleVertices[2].Z;

            CurrentSolution.Eval = CurrentSolution.GetSquareSumOfList(new []
            {
                // Stores the solution result values
                CurrentSolution.SetFinalValueByName("L1 Side Length", L1Length),
                CurrentSolution.SetFinalValueByName("L2 Side Length", L2Length),
                CurrentSolution.SetFinalValueByName("L3 Side Length", L3Length),
                CurrentSolution.SetFinalValueByName("Delta Of Centroid to Origin", centroidDelta),
                CurrentSolution.SetFinalValueByName("Minimum Angle To X", MinAngleToX),
                CurrentSolution.SetFinalValueByName("P1 Height", P1Height),
                CurrentSolution.SetFinalValueByName("P2 Height", P2Height),
                CurrentSolution.SetFinalValueByName("P3 Height", P3Height),
            });

            return(CurrentSolution.Eval);
        }