Beispiel #1
0
        private static Dictionary <IFiniteElementNode, ForceVector> AddWindLoad(PixelStructure structure, FiniteElementModel model)
        {
            Dictionary <IFiniteElementNode, ForceVector> map = new Dictionary <IFiniteElementNode, ForceVector>();


            if (structure.WindLoad != null)
            {
                if (structure.WindLoad.Activated)
                {
                    double forceX = structure.WindLoad.Direction.X;
                    double forceY = structure.WindLoad.Direction.Y;
                    foreach (var i in structure.WindLoad.NodeIndices)
                    {
                        var node = model.Nodes.ElementAt(i);

                        if (!map.ContainsKey(node))
                        {
                            map.Add(node, new ForceVector(0, 0, 0));
                        }

                        map[node] = new ForceVector(
                            map[node].X + forceX,
                            0,
                            map[node].Z + forceY
                            );
                    }
                }
            }
            return(map);
        }
Beispiel #2
0
        public AnalysisResults Optimize(PixelStructure structure)
        {
            var chromosome = new StructuralChromosome(structure.Pixels.Count);

            var population = new Population(5, 10, chromosome);

            var fitness = new StructuralFitness(structure);

            var selection   = new EliteSelection();
            var crossover   = new UniformCrossover(0.5f);
            var mutation    = new UniformMutation(); //FlipBitMutation();
            var termination = new FitnessStagnationTermination(10);

            var ga = new GeneticAlgorithm(
                population,
                fitness,
                selection,
                crossover,
                mutation);

            ga.Termination = termination;

            ga.GenerationRan += GenerationRan;

            ga.Start();

            var structRes = ga.BestChromosome as StructuralChromosome;

            return(structRes.Results);
        }
Beispiel #3
0
        public AnalysisResults Analyze(PixelStructure pixelStructure)
        {
            var model = BuildModel(pixelStructure);

            var results = AnalyzeModel(model);

            return(results);
        }
Beispiel #4
0
 public FrixelReferenceData(PixelStructure pixelStructure, MassingStructure massingStructure)
 {
     this.Structure        = pixelStructure;
     this.MassingStructure = massingStructure;
     this.ActualShape      = massingStructure.Outline;
     this.BoundingBox      = massingStructure.BoundingBox;
     this.ActualXSize      = massingStructure.xSpacing;
     this.ActuveYSize      = massingStructure.ySpacing;
 }
Beispiel #5
0
 private void SetUpdated(FrixelReferenceData refData)
 {
     if (refData == null)
     {
         return;
     }
     this._pixelStructure  = refData.Structure;
     this._actualOutline   = refData.ActualShape;
     this._massingDomain   = refData.BoundingBox;
     this.tb_GridSize.Text = refData.ActualXSize.RoundTo(2) + "', " + refData.ActuveYSize.RoundTo(2) + "'";
 }
Beispiel #6
0
 public MainWindow(PixelStructure pixelStructure)
 {
     InitializeComponent();
     WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
     _pixelStructure       = pixelStructure;
     _sliderMappingDomains = new Tuple <Domain, Domain>(new Domain(0, 1), new Domain(SliderMin, SliderMax));
     _xGridSize            = GridSize(sld_GridX.Value);
     _yGridSize            = GridSize(sld_GridY.Value);
     DrawGridSize();
     Redraw();
     Subscribe();
 }
Beispiel #7
0
        private static Dictionary <IFiniteElementNode, ForceVector> AddGravityLoad(PixelStructure structure, FiniteElementModel model)
        {
            Dictionary <IFiniteElementNode, ForceVector> map = new Dictionary <IFiniteElementNode, ForceVector>();

            if (structure.GravityLoad != null)
            {
                if (structure.GravityLoad.Activated)
                {
                    double amp = structure.GravityLoad.Amplification;
                    map = model.AddGravityLoad(amp);
                }
            }
            return(map);
        }
Beispiel #8
0
        private void MainWindow_BakeStructure(PixelStructure pixelStructure)
        {
            // Bake designed structure
            var rhLines = pixelStructure.GetAllEdges().Select(e =>
            {
                return(new Rhino.Geometry.Line(pixelStructure.Nodes[e.Start].ToRhinoPoint(),
                                               pixelStructure.Nodes[e.End].ToRhinoPoint()));
            }).ToList();
            var attr = SetUpAttr("Designed_Structure", System.Drawing.Color.White);

            rhLines.ForEach(l => Rhino.RhinoDoc.ActiveDoc.Objects.Add(l.ToNurbsCurve(), attr));
            RhinoDoc.ActiveDoc.Views.Redraw();

            // Bake analytical curves with their colors
            if (!pixelStructure.HasAnalysisValues() | !pixelStructure.HasEdgeColors())
            {
                return;
            }
            var rhAnalyticalLines = pixelStructure.GetAllLines(true).Select(l =>
                                                                            new Rhino.Geometry.Line(l.Start.ToRhinoPoint(), l.End.ToRhinoPoint())
                                                                            ).ToList();
            var analBaseAttr = SetUpAttr("Analyzed_Structure", System.Drawing.Color.Gray);
            var analAttrs    = pixelStructure.AllEdgeColors.Select(c =>
            {
                return(new ObjectAttributes()
                {
                    LayerIndex = analBaseAttr.LayerIndex,
                    ObjectColor = System.Drawing.Color.FromArgb(
                        System.Convert.ToByte(c.A),
                        System.Convert.ToByte(c.R),
                        System.Convert.ToByte(c.G),
                        System.Convert.ToByte(c.B)
                        ),
                    ObjectId = new Guid(),
                    ColorSource = ObjectColorSource.ColorFromObject
                });
            }).ToList();

            for (int i = 0; i < rhAnalyticalLines.Count; i++)
            {
                RhinoDoc.ActiveDoc.Objects.Add(rhAnalyticalLines[i].ToNurbsCurve(), analAttrs[i]);
            }
            RhinoDoc.ActiveDoc.Views.Redraw();
        }
Beispiel #9
0
        public AnalysisSummary(AnalysisResults results, PixelStructure structure)
        {
            foreach (var node in structure.Nodes)
            {
                if (node.IsLocked)
                {
                    Supports++;
                }
                if (node.IsPixeled)
                {
                    Connections++;
                }
            }
            Elements  = structure.Edges.Count;
            NetLength = structure.Edges.Select(e => structure.Nodes[e.Start].DistanceTo(structure.Nodes[e.End])).Sum();
            IEnumerable <double> displacements = results.NodeResults.Values.Select(n => Math.Sqrt(Math.Pow(n.DispX, 2) + Math.Pow(n.DispY, 2))).Where(x => x != 0);

            MaxDisplacement = displacements.Max();
            MinDisplacement = displacements.Min();
        }
Beispiel #10
0
        public SharpFE.FiniteElementModel BuildModel(PixelStructure structure)
        {
            FiniteElementModel model    = new FiniteElementModel(ModelType.Truss2D);
            IMaterial          material = new GenericElasticMaterial(7700, 210.0e9, 0.3, 210.0e9 / 2.69);

            ICrossSection section = new SolidRectangle(0.03, 0.01);

            foreach (var node in structure.Nodes)
            {
                var feNode = model.NodeFactory.CreateFor2DTruss(node.X, node.Y);

                //lock the supports
                if (node.IsLocked)
                {
                    model.ConstrainNode(feNode, DegreeOfFreedom.X);
                    model.ConstrainNode(feNode, DegreeOfFreedom.Z);
                }
            }

            foreach (var edge in structure.Edges)
            {
                int s = edge.Start;
                int e = edge.End;

                var sNode = model.Nodes.ElementAt(s);
                var eNode = model.Nodes.ElementAt(e);

                model.ElementFactory.CreateLinearTruss(sNode, eNode, material, section);
            }

            foreach (var pix in structure.Pixels)
            {
                var bracing = pix.GetBracing();
                foreach (var brace in bracing)
                {
                    int s = brace.Start;
                    int e = brace.End;

                    var sNode = model.Nodes.ElementAt(s);
                    var eNode = model.Nodes.ElementAt(e);

                    model.ElementFactory.CreateLinearTruss(sNode, eNode, material, section);
                }
            }

            var wind = AddWindLoad(structure, model);
            var grav = AddGravityLoad(structure, model);

            var combined = CombineDict(wind, grav);

            foreach (var pair in combined)
            {
                ForceVector force100Z;
                if (!model.Forces.Contains(pair.Value))
                {
                    force100Z = model.ForceFactory.CreateForTruss(pair.Value.X, pair.Value.Z);
                }
                else
                {
                    force100Z = pair.Value;
                }

                model.ApplyForceToNode(force100Z, pair.Key);
            }

            return(model);
        }
Beispiel #11
0
 public StructuralFitness(PixelStructure structure)
 {
     //_model = model;
     _structure = structure;
 }