public static BarDifferentialTemperatureLoad BarDifferentialTemperatureLoad(Loadcase loadcase, List <double> positions, List <double> temperatures, DifferentialTemperatureLoadDirection localLoadDirection, IEnumerable <Bar> objects, string name = "")
        {
            if (loadcase.IsNull() || positions.IsNullOrEmpty() || temperatures.IsNullOrEmpty())
            {
                return(null);
            }

            //Checks for positions and profiles
            if (positions.Count != temperatures.Count)
            {
                Reflection.Compute.RecordError("Number of positions and temperatures provided are not equal");
                return(null);
            }
            else if (positions.Exists((double d) => { return(d > 1); }) || positions.Exists((double d) => { return(d < 0); }))
            {
                Reflection.Compute.RecordError("Positions must exist between 0 and 1 (inclusive)");
                return(null);
            }

            // Check that top and bottom positions are included
            if (!(positions.Contains(0) && positions.Contains(1)))
            {
                Reflection.Compute.RecordError("Positions must inlude the bottom (0) and top (1) position.");
                return(null);
            }

            if (positions.Zip(positions.Skip(1), (a, b) => new { a, b }).Any(p => p.a > p.b))
            {
                Reflection.Compute.RecordError("Positions must be sorted in ascending order.");
                return(null);
            }

            //Create ditionary for TaperedProfile
            Dictionary <Double, Double> temperatureProfile = positions.Zip(temperatures, (z, t) => new { z, t })
                                                             .ToDictionary(x => x.z, x => x.t);

            BHoMGroup <Bar> group = new BHoMGroup <Bar>();

            if (objects == null)
            {
                group = null;
            }
            else
            {
                group.Elements = objects.ToList();
            }

            return(new BarDifferentialTemperatureLoad
            {
                Loadcase = loadcase,
                TemperatureProfile = temperatureProfile,
                LoadDirection = localLoadDirection,
                Objects = group,
                Name = name
            });
        }
示例#2
0
        public static BarUniformTemperatureLoad BarUniformTemperatureLoad(Loadcase loadcase, double temperatureChange, IEnumerable <Bar> objects, LoadAxis axis = LoadAxis.Global, bool projected = false, string name = "")
        {
            BHoMGroup <Bar> group = new BHoMGroup <Bar>();

            if (objects == null)
            {
                group = null;
            }
            else
            {
                group.Elements = objects.ToList();
            }

            return(loadcase.IsNull() ? null : new BarUniformTemperatureLoad
            {
                Loadcase = loadcase,
                TemperatureChange = temperatureChange,
                Objects = group,
                Axis = axis,
                Projected = projected,
                Name = name
            });
        }