Beispiel #1
0
        /// <summary>
        /// Merges all nodes so that no two nodes are within the given tolerance.
        /// </summary>
        public void MergeNodes(double mergeTolerance)
        {
            Dictionary <Node, List <Node> > toMerge  = new Dictionary <Node, List <Node> >();
            Dictionary <Node, Node>         toRemove = new Dictionary <Node, Node>();

            foreach (Node n1 in Nodes)
            {
                if (toMerge.ContainsKey(n1))
                {
                    continue;
                }
                if (toRemove.ContainsKey(n1))
                {
                    continue;
                }

                foreach (Node n2 in Nodes)
                {
                    if (ReferenceEquals(n1, n2))
                    {
                        continue;
                    }
                    if (toMerge.ContainsKey(n1))
                    {
                        continue;
                    }
                    if (toRemove.ContainsKey(n1))
                    {
                        continue;
                    }

                    if (Node.Distance(n1, n2) < mergeTolerance)
                    {
                        List <Node> removeList;
                        if (toMerge.TryGetValue(n1, out removeList))
                        {
                            removeList.Add(n2);
                        }
                        else
                        {
                            toMerge[n1] = new List <Node>()
                            {
                                n2
                            };
                        }
                        toRemove[n2] = n1;
                    }
                }
            }

            // Arrange frame nodes
            foreach (Frame f in Frames)
            {
                Node n1;
                Node n2;

                if (toRemove.TryGetValue(f.NodeI, out n1))
                {
                    f.NodeI = n1;
                }
                if (toRemove.TryGetValue(f.NodeJ, out n2))
                {
                    f.NodeJ = n2;
                }
            }

            // Assemble node loads
            foreach (KeyValuePair <Node, List <Node> > pair in toMerge)
            {
                Node        master  = pair.Key;
                List <Node> removed = pair.Value;

                foreach (AnalysisCase analysisCase in AnalysisCases)
                {
                    // Assemble point loads
                    NodePointLoad assembledPointLoad = new NodePointLoad(analysisCase, 0, 0, 0);
                    foreach (NodeLoad masterLoad in master.Loads.FindAll((e) => e.AnalysisCase == analysisCase && e is NodePointLoad))
                    {
                        NodePointLoad masterPointLoad = masterLoad as NodePointLoad;
                        assembledPointLoad.FX += masterPointLoad.FX;
                        assembledPointLoad.FZ += masterPointLoad.FZ;
                        assembledPointLoad.MY += masterPointLoad.MY;
                    }

                    foreach (Node slave in removed)
                    {
                        foreach (NodeLoad slaveLoad in slave.Loads.FindAll((e) => e.AnalysisCase == analysisCase && e is NodePointLoad))
                        {
                            NodePointLoad slavePointLoad = slaveLoad as NodePointLoad;
                            assembledPointLoad.FX += slavePointLoad.FX;
                            assembledPointLoad.FZ += slavePointLoad.FZ;
                            assembledPointLoad.MY += slavePointLoad.MY;
                        }
                    }

                    master.Loads.RemoveAll((e) => e.AnalysisCase == analysisCase && e is NodePointLoad);
                    if (!MathNet.Numerics.Precision.AlmostEqual(assembledPointLoad.FX + assembledPointLoad.FZ + assembledPointLoad.MY, 0))
                    {
                        master.AddPointLoad(analysisCase, assembledPointLoad.FX, assembledPointLoad.FZ, assembledPointLoad.MY);
                    }
                }
            }

            // Remove nodes
            foreach (Node n in toRemove.Keys)
            {
                Nodes.Remove(n);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Adds a new node point load.
 /// </summary>
 public void AddNodePointLoad(AnalysisCase analysisCase, Node node, double fx, double fz, double my)
 {
     node.AddPointLoad(analysisCase, fx, fz, my);
 }
Beispiel #3
0
 /// <summary>
 /// Adds a new node point load.
 /// </summary>
 public void AddNodePointLoad(AnalysisCase analysisCase, Node node, double fx, double fz, double my)
 {
     node.AddPointLoad(analysisCase, fx, fz, my);
 }