protected override void SolveInstance(IGH_DataAccess DA) { // Indata WR_Structure structure = null; List<WR_LoadCombination> loadCombinations = new List<WR_LoadCombination>(); bool go = false; bool check = true; System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); if (!DA.GetData(0, ref structure)) { return; } if (!DA.GetDataList(1, loadCombinations)) { return; } if (!DA.GetData(2, ref go)) { return; } if (!DA.GetData(3, ref check)) { return; } if (go) { _resElems = new List<ResultElement>(); _log.Clear(); watch.Restart(); // Solve WR_LinearSolver solver = new WR_LinearSolver(structure); foreach (WR_LoadCombination lc in loadCombinations) { solver.AddLoadCombination(lc); } watch.Stop(); _log.Add(String.Format("Initialising: {0}ms", watch.ElapsedMilliseconds)); watch.Restart(); // Check structure if (check) { solver.CheckStructure(); if (!structure.IsValidForLinearSolver()) return; } watch.Stop(); _log.Add(String.Format("Check of structure: {0}ms", watch.ElapsedMilliseconds)); watch.Restart(); // Solve try { solver.Solve(); } catch (Exception e) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); return; } watch.Stop(); _log.Add(String.Format("Solve system: {0}ms", watch.ElapsedMilliseconds)); watch.Restart(); // Extract results List<WR_IElement> elems = structure.GetAllElements(); for (int i = 0; i < elems.Count; i++) { if (elems[i] is WR_Element3d) { WR_Element3d el3d = (WR_Element3d)elems[i]; ResultElement re = new ResultElement(el3d); _resElems.Add(re); } } watch.Stop(); _log.Add(String.Format("Extract results: {0}ms", watch.ElapsedMilliseconds)); } DA.SetDataList(0, _log); DA.SetDataList(1, _resElems); }
protected override void SolveInstance(IGH_DataAccess DA) { // Indata WR_Structure structure = null; List <WR_LoadCombination> loadCombinations = new List <WR_LoadCombination>(); bool go = false; bool check = true; System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); if (!DA.GetData(0, ref structure)) { return; } if (!DA.GetDataList(1, loadCombinations)) { return; } if (!DA.GetData(2, ref go)) { return; } if (!DA.GetData(3, ref check)) { return; } if (go) { _resElems = new List <ResultElement>(); _log.Clear(); watch.Restart(); // Solve WR_LinearSolver solver = new WR_LinearSolver(structure); foreach (WR_LoadCombination lc in loadCombinations) { solver.AddLoadCombination(lc); } watch.Stop(); _log.Add(String.Format("Initialising: {0}ms", watch.ElapsedMilliseconds)); watch.Restart(); // Check structure if (check) { solver.CheckStructure(); if (!structure.IsValidForLinearSolver()) { return; } } watch.Stop(); _log.Add(String.Format("Check of structure: {0}ms", watch.ElapsedMilliseconds)); watch.Restart(); // Solve try { solver.Solve(); } catch (Exception e) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.Message); return; } watch.Stop(); _log.Add(String.Format("Solve system: {0}ms", watch.ElapsedMilliseconds)); watch.Restart(); // Extract results List <WR_IElement> elems = structure.GetAllElements(); for (int i = 0; i < elems.Count; i++) { if (elems[i] is WR_Element3d) { WR_Element3d el3d = (WR_Element3d)elems[i]; ResultElement re = new ResultElement(el3d); _resElems.Add(re); } } watch.Stop(); _log.Add(String.Format("Extract results: {0}ms", watch.ElapsedMilliseconds)); } DA.SetDataList(0, _log); DA.SetDataList(1, _resElems); }
protected override void SolveInstance(IGH_DataAccess DA) { // Indata bool go = false; List<WR_Node3d> nodes = new List<WR_Node3d>(); List<WR_IElemRcp> beams = new List<WR_IElemRcp>(); if (!DA.GetDataList(0, nodes)) { return; } if (!DA.GetDataList(1, beams)) { return; } if (!DA.GetData(2, ref go)) { return; } if (go) { resElems = new List<ResultElement>(); log.Clear(); log.Add("Structure invokation started"); // Create structure wrapper WR_Structure structure = new WR_Structure(); // Add restraint nodes foreach (WR_Node3d n in nodes) structure.AddNode(n); log.Add("" + nodes.Count + " nodes added to structure"); // Add elements foreach (WR_Elem3dRcp e in beams) structure.AddElementRcp(e); log.Add("" + beams.Count + " elements added to structure"); // Add forces // Solve WR_LinearSolver solver = new WR_LinearSolver(structure, true); solver.Solve(); // Extract results List<WR_IElement> elems = structure.GetAllElements(); for (int i = 0; i < elems.Count; i++) { if (elems[i] is WR_Element3d) { WR_Element3d el3d = (WR_Element3d)elems[i]; ResultElement re = new ResultElement(el3d); resElems.Add(re); } } //Extract Points pts = new List<Rhino.Geometry.Point3d>(); List<WR_XYZ> xyzs = structure.GetAllPoints(); for (int i = 0; i < xyzs.Count; i++) { pts.Add(new Rhino.Geometry.Point3d(xyzs[i].X, xyzs[i].Y, xyzs[i].Z)); } } DA.SetData(0, log); DA.SetDataList(1, resElems); DA.SetDataList(2, pts); }
protected override void SolveInstance(IGH_DataAccess DA) { // Indata bool go = false; List <WR_Node3d> nodes = new List <WR_Node3d>(); List <WR_IElemRcp> beams = new List <WR_IElemRcp>(); if (!DA.GetDataList(0, nodes)) { return; } if (!DA.GetDataList(1, beams)) { return; } if (!DA.GetData(2, ref go)) { return; } if (go) { resElems = new List <ResultElement>(); log.Clear(); log.Add("Structure invokation started"); // Create structure wrapper WR_Structure structure = new WR_Structure(); // Add restraint nodes foreach (WR_Node3d n in nodes) { structure.AddNode(n); } log.Add("" + nodes.Count + " nodes added to structure"); // Add elements foreach (WR_Elem3dRcp e in beams) { structure.AddElementRcp(e); } log.Add("" + beams.Count + " elements added to structure"); // Add forces // Solve WR_LinearSolver solver = new WR_LinearSolver(structure, true); solver.Solve(); // Extract results List <WR_IElement> elems = structure.GetAllElements(); for (int i = 0; i < elems.Count; i++) { if (elems[i] is WR_Element3d) { WR_Element3d el3d = (WR_Element3d)elems[i]; ResultElement re = new ResultElement(el3d); resElems.Add(re); } } //Extract Points pts = new List <Rhino.Geometry.Point3d>(); List <WR_XYZ> xyzs = structure.GetAllPoints(); for (int i = 0; i < xyzs.Count; i++) { pts.Add(new Rhino.Geometry.Point3d(xyzs[i].X, xyzs[i].Y, xyzs[i].Z)); } } DA.SetData(0, log); DA.SetDataList(1, resElems); DA.SetDataList(2, pts); }