diff --git a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs index 214edfa1..aeba99d2 100644 --- a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs +++ b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Geometry/Panel/Panel.cs @@ -116,12 +116,12 @@ public void InitializeOpenings() public void PushPullPanel() { - adapter.Push(new List() { panel1}); + //adapter.Push(new List() { panel1}); //// Pull it - //FilterRequest panelFilter = new FilterRequest() { Type = typeof(Panel) }; - //var panelPulled = adapter.Pull(panelFilter).ToList(); - //Panel pp = (Panel)panelPulled[0]; + FilterRequest panelFilter = new FilterRequest() { Type = typeof(Panel) }; + var panelPulled = adapter.Pull(panelFilter).ToList(); + Panel pp = (Panel)panelPulled[0]; //// Check //Assert.IsNotNull(pp); diff --git a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs index 5d1cb238..62b61e10 100644 --- a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs +++ b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Loading/UniformlyDistributedAreaLoad.cs @@ -142,7 +142,7 @@ public void InitializeOpenings() [SetUp] public void SetUp() { - adapter.Push(new List() { panel1, panel2, panel3 }); + //adapter.Push(new List() { panel1, panel2, panel3 }); } @@ -268,7 +268,19 @@ public void PushOfReversedAreaUniformlyDistributedLoad() Assert.True(this.reverseAreaLoadList[i].Axis.Equals(areaLoadList[i].Axis)); } + [Test] + public void PullUniformlyDistributedLoad() + { + + //Act + + // Push + // Pull + FilterRequest loadFilter = new FilterRequest() { Type = typeof(AreaUniformlyDistributedLoad) }; + List areaLoadList = adapter.Pull(loadFilter).ToList().Select(p => (AreaUniformlyDistributedLoad)p).ToList(); + var a = areaLoadList.First(); + } } diff --git a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Result/BarResults.cs b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Result/BarResults.cs index f1dfd6c4..a2a7bbb8 100644 --- a/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Result/BarResults.cs +++ b/.ci/unit-tests/RFEM_Toolkit_Test/BHoMDataStructure/Result/BarResults.cs @@ -36,52 +36,74 @@ namespace RFEM_Toolkit_Test.Elements { - public class BarResultTestClass + public class BarResultTestClass - { + { - RFEM6Adapter adapter; + RFEM6Adapter adapter; - //[TearDown] - //public void TearDown() - //{ - // adapter.Wipeout(); - //} + //[TearDown] + //public void TearDown() + //{ + // adapter.Wipeout(); + //} - [OneTimeSetUp] - public void InitializeRFEM6Adapter() - { - adapter = new RFEM6Adapter(active:true); + [OneTimeSetUp] + public void InitializeRFEM6Adapter() + { + adapter = new RFEM6Adapter(active: true); - } + } - [Test] - public void ReadResult() - { - List loadCombList = adapter.Pull(new FilterRequest() { Type = typeof(LoadCombination) }).Select(l=> l as LoadCombination).ToList(); + [Test] + public void ReadResult() + { + List loadCombList = adapter.Pull(new FilterRequest() { Type = typeof(LoadCombination) }).Select(l => l as LoadCombination).ToList(); - Loadcase loadcase1 = new Loadcase() { Name = "LC1", Nature = LoadNature.Dead, Number = 1 }; - LoadCombination loadCombination = new LoadCombination { Name = "LoadCombination1", Number = 1 }; + Loadcase loadcase1 = new Loadcase() { Name = "LC1", Nature = LoadNature.Dead, Number = 1 }; + LoadCombination loadCombination = new LoadCombination { Name = "LoadCombination1", Number = 1 }; - BarResultRequest request = new BarResultRequest(); + BarResultRequest request = new BarResultRequest(); - request.ResultType = BarResultType.BarForce; - request.DivisionType = DivisionType.EvenlyDistributed; - request.Divisions = 3; - request.Cases = new List { loadCombList.First() }; - //request.Cases = new List {1}; - request.Modes = new List(); - request.ObjectIds = new List {1}; - //request.ObjectIds = new List {1,2,3,4}; + request.ResultType = BarResultType.BarForce; + request.DivisionType = DivisionType.EvenlyDistributed; + request.Divisions = 3; + request.Cases = new List { loadCombList.First() }; + //request.Cases = new List {1}; + request.Modes = new List(); + request.ObjectIds = new List { 1 }; + //request.ObjectIds = new List {1,2,3,4}; - var obj = adapter.Pull(request); + var obj = adapter.Pull(request); - obj.First(); + obj.First(); - } + } + [Test] + public void ReadResult2() + { + List loadCombList = adapter.Pull(new FilterRequest() { Type = typeof(LoadCombination) }).Select(l => l as LoadCombination).ToList(); + List relevantLoadComb = loadCombList.Take(38).ToList(); + BarResultRequest request = new BarResultRequest(); - } + request.ResultType = BarResultType.BarForce; + request.DivisionType = DivisionType.EvenlyDistributed; + request.Divisions = 2; + request.Cases = new List {relevantLoadComb.First()}; + request.Modes = new List(); + //request.ObjectIds = new List { 1 }; + //request.ObjectIds = new List {1,2,3,4}; + + var obj = adapter.Pull(request); + + + var obj_first = obj.First(); + } + + + + } } diff --git a/.ci/unit-tests/RFEM_Toolkit_Test/RFEM_Toolkit_Test.csproj b/.ci/unit-tests/RFEM_Toolkit_Test/RFEM_Toolkit_Test.csproj index cd7e64a8..3202aa0e 100644 --- a/.ci/unit-tests/RFEM_Toolkit_Test/RFEM_Toolkit_Test.csproj +++ b/.ci/unit-tests/RFEM_Toolkit_Test/RFEM_Toolkit_Test.csproj @@ -2,14 +2,14 @@ net6.0 - 8.0.0.0 + 9.0.0.0 https://github.com/BHoM/RFEM6_Toolkit enable enable false true - 8.3.0.0 + 9.0.0.0 diff --git a/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs index 1a9ce6de..9659a7c9 100644 --- a/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs @@ -61,6 +61,10 @@ private bool CreateCollection(IEnumerable bhLoads) if (bhLoad is AreaUniformlyDistributedLoad) { + if (bhLoad.CustomData.Values.Any(l=>l is Polygon)) { + CreateLoad_Polygon(bhLoad as AreaUniformlyDistributedLoad); + continue; + } CreateLoad(bhLoad as AreaUniformlyDistributedLoad); continue; } @@ -233,6 +237,24 @@ private void CreateLoad(AreaUniformlyDistributedLoad bhLoad) } + private void CreateLoad_Polygon(AreaUniformlyDistributedLoad bhLoad) + { + try + { + UpdateLoadIdDictionary(bhLoad); + //Call Panel Load Methond to update the Panel ID Dictionary + this.GetCachedOrReadAsDictionary(); + int id = m_LoadcaseLoadIdDict[bhLoad.Loadcase][bhLoad.GetType().Name]; + free_polygon_load rfemAreaLoad = (bhLoad as AreaUniformlyDistributedLoad).ToRFEM6_Polygon(id); + var currrSurfaceIds = (bhLoad as AreaUniformlyDistributedLoad).Objects.Elements.ToList().Select(e => m_PanelIDdict[e as Panel]).ToArray(); + rfemAreaLoad.surfaces = currrSurfaceIds; + m_Model.set_free_polygon_load(bhLoad.Loadcase.Number, rfemAreaLoad); + + } catch (Exception ex) { + BH.Engine.Base.Compute.RecordError($"The creation of {bhLoad} failed.\nA potential cause is that the applied polygon is non-planar or not parallel to the XY, YZ, or ZX plane.\nException: {ex.Message}\nStackTrace: {ex.StackTrace}"); + } + } + private void CreateLoad(BarUniformlyDistributedLoad bhLoad) { diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Geometry/Bar.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Geometry/Bar.cs index 54a30e6e..bc98d71d 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Geometry/Bar.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Geometry/Bar.cs @@ -63,11 +63,12 @@ private List ReadBars(List ids = null) foreach (var rfMember in allRfMembers) { + Node node0 = null; - nodes.TryGetValue(rfMember.nodes[0], out node0); + nodes.TryGetValue(rfMember.node_start, out node0); Node node1 = null; - nodes.TryGetValue(rfMember.nodes[1], out node1); + nodes.TryGetValue(rfMember.node_end, out node1); ISectionProperty section = null; sections.TryGetValue(rfMember.section_end, out section); diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs index ea43e64b..4175c759 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs @@ -117,6 +117,7 @@ private List ReadPointLoad(List ids = null) private List ReadAreaLoad(List ids = null) { + List loads = new List(); //Find all possible Load cases @@ -136,7 +137,7 @@ private List ReadAreaLoad(List ids = null) if (!(surfaceLoad.load_distribution is rfModel.surface_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) { - Engine.Base.Compute.RecordNote("The current RFEM6 includes Surfaceloads with a non-uniformal load distributeion, these Loads will not be pulled."); + Engine.Base.Compute.RecordNote("The current RFEM6 includes Surface loads with a non-uniformal load distributeion, these Loads will not be pulled."); continue; } @@ -144,10 +145,33 @@ private List ReadAreaLoad(List ids = null) } - return loads; + + rfModel.object_with_children[] numbers_ = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_FREE_POLYGON_LOAD); + + //IEnumerable foundSurfaceLoad = numbers.ToList().Select(n => m_Model.get_surface_load(n.children[0], n.no)); + IEnumerable foundPolygonLoad_ = numbers_.SelectMany(n => n.children.Select(child => m_Model.get_free_polygon_load(child, n.no))); + + foundPolygonLoad_ = foundPolygonLoad_.OrderBy(n => n.load_case).ThenBy(t => t.no); + foreach (rfModel.free_polygon_load polygonLoad in foundPolygonLoad_) + { + List panels = polygonLoad.surfaces.ToList().Select(s => panelMap[s]).ToList(); + if (!(polygonLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM)) + { + Engine.Base.Compute.RecordNote("The current RFEM6 includes Surface loads with a non-uniformal load distributeion, these Loads will not be pulled."); + continue; + } + + loads.Add(polygonLoad.FromRFEM(loadCaseMap[polygonLoad.load_case], panels)); + + } + + + return loads; } - private List ReadFreeLineLoad(List ids = null) + + + private List ReadFreeLineLoad(List ids = null) { List loads = new List(); diff --git a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Result/BarResults.cs b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Result/BarResults.cs index fce63245..48800d2c 100644 --- a/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Result/BarResults.cs +++ b/RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Result/BarResults.cs @@ -19,171 +19,191 @@ * You should have received a copy of the GNU Lesser General Public License * along with this code. If not, see . */ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - +using BH.Engine.Base; +using BH.Engine.Spatial; using BH.oM.Adapter; -using BH.oM.Structure.Elements; -using BH.oM.Structure.Constraints; - -using rfModel = Dlubal.WS.Rfem6.Model; using BH.oM.Adapters.RFEM6; -using BH.oM.Structure.Loads; -using Dlubal.WS.Rfem6.Model; -using System.Xml.Linq; -using BH.Engine.Base; using BH.oM.Analytical.Results; +using BH.oM.Structure.Constraints; +using BH.oM.Structure.Elements; +using BH.oM.Structure.Loads; +using BH.oM.Structure.MaterialFragments; using BH.oM.Structure.Requests; using BH.oM.Structure.Results; +using Dlubal.WS.Rfem6.Model; +using System; +using System.Collections.Generic; +using System.ComponentModel; using System.Configuration; using System.Globalization; -using System.ComponentModel; +using System.Linq; using System.Linq.Expressions; +using System.Text; +using System.Xml.Linq; +using rfModel = Dlubal.WS.Rfem6.Model; namespace BH.Adapter.RFEM6 { - public partial class RFEM6Adapter - { - - public IEnumerable ReadResults(BarResultRequest request, ActionConfig actionConfig) - { - - - //Warnings - BH.Engine.Base.Compute.RecordWarning($"Divisions are set to {request.Divisions}. Division functionality has not been implemented yet in RFEM6_Toolkit. Currently, the number of divisions depends solely on what RFEM6 provides and can vary significantly based on the load type on the corresponding Bar/Member and the DivisionType."); - - if (request.Cases.Where(c=> c is string).ToList().Count>0) { BH.Engine.Base.Compute.RecordWarning("At least one instance of the Case input is neither of type LoadCase nor LoadCombination. The set CaseIds will be assumed to be LoadCase IDs for now."); }; - - //RFEM Specific Stuff - m_Model.use_detailed_member_results(true); + public partial class RFEM6Adapter + { - // Loading of Member And LoadCase Ids - List memberIds = request.ObjectIds.Select(s => Int32.Parse(s.ToString())).ToList(); + public IEnumerable ReadResults(BarResultRequest request, ActionConfig actionConfig) + { + - // Definition of Object Locations for Members - object_location[] objectLocations = memberIds.Select(n => new object_location() { type = object_types.E_OBJECT_TYPE_MEMBER, no = n, parent_no = 0 }).ToArray(); + //Warnings + BH.Engine.Base.Compute.RecordWarning($"Divisions are set to {request.Divisions}. Division functionality has not been implemented yet in RFEM6_Toolkit. Currently, the number of divisions depends solely on what RFEM6 provides and can vary significantly based on the load type on the corresponding Bar/Member and the DivisionType."); - //ResultList - List resultList = new List(); + if (request.Cases.Where(c => c is string).ToList().Count > 0) { BH.Engine.Base.Compute.RecordWarning("At least one instance of the Case input is neither of type LoadCase nor LoadCombination. The set CaseIds will be assumed to be LoadCase IDs for now."); } + ; + //RFEM Specific Stuff + m_Model.use_detailed_member_results(true); - foreach (var c in request.Cases) - { - int cId = 0; + // Loading of Member And LoadCase Ids + List memberIds = request.ObjectIds.Select(s => Int32.Parse(s.ToString())).ToList(); - if (c is Loadcase) - { - cId = (c as Loadcase).Number; + // Definition of Object Locations for Members + object_location[] objectLocations = memberIds.Select(n => new object_location() { type = object_types.E_OBJECT_TYPE_MEMBER, no = n, parent_no = 0 }).ToArray(); - } - else if (c is LoadCombination) - { + //ResultList + List resultList = new List(); - cId = (c as LoadCombination).Number; - } - else - { + foreach (var c in request.Cases) + { + int cId = 0; - cId = Int32.Parse(c.ToString()); - } + if (c is Loadcase) + { + cId = (c as Loadcase).Number; + } + else if (c is LoadCombination) + { + cId = (c as LoadCombination).Number; - //Loading resulst from RFEM - INotifyPropertyChanged[] barResults = new INotifyPropertyChanged[1]; + } + else + { - var loadingType = c is LoadCombination ? case_object_types.E_OBJECT_TYPE_LOAD_COMBINATION : case_object_types.E_OBJECT_TYPE_LOAD_CASE; - switch (request.ResultType) - { + cId = Int32.Parse(c.ToString()); + } - case BarResultType.BarForce: - barResults = m_Model.get_results_for_members_internal_forces(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); - break; - case BarResultType.BarDisplacement: - barResults = m_Model.get_results_for_members_global_deformations(loadingType, cId, objectLocations); - break; - case BarResultType.BarDeformation: - barResults = m_Model.get_results_for_members_local_deformations(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); - break; - case BarResultType.BarStrain: - barResults = m_Model.get_results_for_members_strains(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); - break; - default: - BH.Engine.Base.Compute.RecordError($"The pull result types of type {request.ResultType} has not been developed Yet"); - return null; - } - //Grouping of Internal Forces grouped by Member No - var memberInternalForceGroup = barResults.GroupBy(r => Int32.Parse(r.PropertyValue("row.member_no").ToString())); + //Loading resulst from RFEM + INotifyPropertyChanged[] barResults = new INotifyPropertyChanged[1]; + var loadingType = c is LoadCombination ? case_object_types.E_OBJECT_TYPE_LOAD_COMBINATION : case_object_types.E_OBJECT_TYPE_LOAD_CASE; + switch (request.ResultType) + { + + case BarResultType.BarForce: + barResults = m_Model.get_results_for_members_internal_forces(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); + break; + case BarResultType.BarDisplacement: + barResults = m_Model.get_results_for_members_global_deformations(loadingType, cId, objectLocations); + break; + case BarResultType.BarDeformation: + barResults = m_Model.get_results_for_members_local_deformations(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); + break; + case BarResultType.BarStrain: + barResults = m_Model.get_results_for_members_strains(loadingType, cId, objectLocations, axes_type.MEMBER_AXES); + break; + default: + BH.Engine.Base.Compute.RecordError($"The pull result types of type {request.ResultType} has not been developed Yet"); + return null; - //Results processing memberwise - foreach (IGrouping member in memberInternalForceGroup) - { - //Ignore Results that do now have a valied ID - if (member.Key == 0) continue; + } - //Determine Member length - String lengthAsString = member.ToList()[0].PropertyValue("row.specification").ToString().Split(new[] { "L : ", " m" }, StringSplitOptions.None)[1]; - double memberLength = double.Parse(lengthAsString, CultureInfo.InvariantCulture);// Member Length in SI unit m; + //Grouping of Internal Forces grouped by Member No + var memberInternalForceGroup = barResults.GroupBy(r => Int32.Parse(r.PropertyValue("row.member_no").ToString())); - var memberSegmentValues = member.ToList(); - //If we are looking for exterme Values - if (request.DivisionType == DivisionType.ExtremeValues) - { + //Results processing memberwise + foreach (IGrouping member in memberInternalForceGroup) + { + //Ignore Results that do now have a valied ID + if (member.Key == 0) continue; - memberSegmentValues = member.SkipWhile(m => !m.PropertyValue("description").ToString().Contains("Extremes")).ToList(); - memberSegmentValues = memberSegmentValues.TakeWhile(m => !m.PropertyValue("description").ToString().Contains("Total")).ToList(); + //Determine Member length + Dictionary barDictionary = new Dictionary(); + double memberLength = 0; + try + { - } + if (barDictionary.Keys.Contains(member.Key)) + { + memberLength = barDictionary[member.Key].Length(); + continue; + } - else - { - memberSegmentValues = memberSegmentValues.TakeWhile(m => !m.PropertyValue("description").ToString().Contains("Extremes")).ToList(); + String lengthAsString = member.ToList()[0].PropertyValue("row.specification").ToString().Split(new[] { "L : ", " m" }, StringSplitOptions.None)[1]; + memberLength = double.Parse(lengthAsString, CultureInfo.InvariantCulture);// Member Length in SI unit m; + } + catch + { + barDictionary = this.GetCachedOrReadAsDictionary(); + memberLength = barDictionary[member.Key].Length(); + } - } - int corrective = (request.ResultType == BarResultType.BarDisplacement || request.ResultType == BarResultType.BarDeformation) ? 0 : 2; - // important do to enable processing of Deformations due to the |u| - if (memberSegmentValues?.First()?.PropertyValue("row.deformation_label")?.ToString()?.Contains("|u|") ?? false) - { - memberSegmentValues = memberSegmentValues.Skip(2).ToList(); - //corrective = 0; - } - //Conversion for every segment of member - foreach (var e in memberSegmentValues) - { + var memberSegmentValues = member.ToList(); - var location = Double.Parse(e.PropertyValue("row.location").ToString()); - var memberNumber = Int32.Parse(e.PropertyValue("row.member_no").ToString()); - var props = e.PropertyValue("row").GetType().GetProperties(); - List accesList = new List() { 10 - corrective, 12 - corrective, 14 - corrective, 16 - corrective, 18 - corrective, 20 - corrective }; - var accessedlist = accesList.Select(a => props.ToList()[a]); - Dictionary val = new[] { - (10-corrective, "x"), (12-corrective, "y"), (14-corrective, "z"), - (16-corrective, "rx"), (18-corrective, "ry"), (20-corrective, "rz") - }.ToDictionary(p => p.Item2, p => Double.Parse( - e.PropertyValue($"row.{props[p.Item1].Name}").ToString() - )); + //If we are looking for exterme Values + if (request.DivisionType == DivisionType.ExtremeValues) + { - var result = val.Values.ToList().FromRFEM(cId, memberLength, location, memberNumber, request.ResultType); - resultList.Add(result); - } + memberSegmentValues = member.SkipWhile(m => !m.PropertyValue("description").ToString().Contains("Extremes")).ToList(); + memberSegmentValues = memberSegmentValues.TakeWhile(m => !m.PropertyValue("description").ToString().Contains("Total")).ToList(); - } - } + } - return resultList; + else + { + memberSegmentValues = memberSegmentValues.TakeWhile(m => !m.PropertyValue("description").ToString().Contains("Extremes")).ToList(); - } + } - } + int corrective = (request.ResultType == BarResultType.BarDisplacement || request.ResultType == BarResultType.BarDeformation) ? 0 : 2; + // important do to enable processing of Deformations due to the |u| + if (memberSegmentValues?.First()?.PropertyValue("row.deformation_label")?.ToString()?.Contains("|u|") ?? false) + { + memberSegmentValues = memberSegmentValues.Skip(2).ToList(); + //corrective = 0; + } + + //Conversion for every segment of member + foreach (var e in memberSegmentValues) + { + + var location = Double.Parse(e.PropertyValue("row.location").ToString()); + var memberNumber = Int32.Parse(e.PropertyValue("row.member_no").ToString()); + var props = e.PropertyValue("row").GetType().GetProperties(); + List accesList = new List() { 10 - corrective, 12 - corrective, 14 - corrective, 16 - corrective, 18 - corrective, 20 - corrective }; + var accessedlist = accesList.Select(a => props.ToList()[a]); + Dictionary val = new[] { + (10-corrective, "x"), (12-corrective, "y"), (14-corrective, "z"), + (16-corrective, "rx"), (18-corrective, "ry"), (20-corrective, "rz") + }.ToDictionary(p => p.Item2, p => Double.Parse( + e.PropertyValue($"row.{props[p.Item1].Name}").ToString() + )); + + var result = val.Values.ToList().FromRFEM(cId, memberLength, location, memberNumber, request.ResultType); + resultList.Add(result); + } + + } + } + + return resultList; + + } + + } } diff --git a/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs b/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs index 188a1a96..b35d04c8 100644 --- a/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs +++ b/RFEM6_Adapter/CRUD/Read/IntermediateDatastructure/RFEMLine.cs @@ -43,7 +43,7 @@ private List ReadLines(List ids = null) List lineList = new List(); - var lineNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE); + var lineNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE).Where(l => l.no > 0); var allRfLInes = lineNumbers.ToList().Select(n => m_Model.get_line(n.no)); //var lineSupportNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE); diff --git a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs index a5033c4b..72c76db5 100644 --- a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs +++ b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Geometry/Panel.cs @@ -45,10 +45,6 @@ public static partial class Convert public static Panel FromRFEM(this rfModel.surface rfSurface, Dictionary edgeDict, Dictionary surfaceProperty, HashSet openingIDs, Dictionary surfaceOpening) { - //HashSet openingIDs = new HashSet(); - - //openingIDDict.TryGetValue(rfPanelNo,out openingIDs); - List rfEdgeNumbers = rfSurface.boundary_lines.ToList(); List bhEdges = rfEdgeNumbers.Select(n => edgeDict[n]).ToList(); diff --git a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs index 82220a9e..7486cffe 100644 --- a/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs @@ -185,6 +185,121 @@ public static PointLoad FromRFEM(this rfModel.nodal_load nodeLoad, List bh return bhLoad; } + public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.free_polygon_load polygonLoad, Loadcase loadcase, List panels) + { + + Vector forceDirection; + bool isProjected = false; + LoadAxis axis = LoadAxis.Global; + List firstCoordinate = polygonLoad.load_location.ToList().Select(r => r.row.first_coordinate).ToList(); + List secondCoordinate = polygonLoad.load_location.ToList().Select(r => r.row.second_coordinate).ToList(); + List thirdCoordinate = Enumerable.Repeat(0.0, firstCoordinate.Count).ToList(); + List loadPolygon; + + switch (polygonLoad.load_projection) + { + case free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV: + + loadPolygon = firstCoordinate.Select((x, i) => new Point() + { + X = x, + Y = secondCoordinate[i], + Z = thirdCoordinate[i] + }).ToList(); + + + break; + + case free_polygon_load_load_projection.LOAD_PROJECTION_YZ_OR_VW: + + loadPolygon = firstCoordinate.Select((x, i) => new Point() + { + X = thirdCoordinate[i], + Y = x, + Z = secondCoordinate[i] + }).ToList(); + + break; + + default: + + loadPolygon = firstCoordinate.Select((x, i) => new Point() + { + X = secondCoordinate[i], + Y = thirdCoordinate[i], + Z = x + }).ToList(); + + break; + + + } + + var polygon = BH.Engine.Geometry.Create.Polygon(loadPolygon); + + switch (polygonLoad.load_direction) + { + //case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE: + case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_TRUE: + forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0); + break; + //case surface_load_load_direction.LOAD_DIRECTION_LOCAL_X: + case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_X: + forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0); + axis = LoadAxis.Local; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_TRUE: + case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_TRUE: + forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0); + break; + //case surface_load_load_direction.LOAD_DIRECTION_LOCAL_Y: + case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Y: + forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0); + axis = LoadAxis.Local; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_TRUE: + case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_TRUE: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + break; + //case surface_load_load_direction.LOAD_DIRECTION_LOCAL_Z: + case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Z: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + axis = LoadAxis.Local; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_PROJECTED: + case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_U_PROJECTED: + forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0); + isProjected = true; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_PROJECTED: + case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_V_PROJECTED: + forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0); + isProjected = true; + break; + + //case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_PROJECTED: + case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_W_PROJECTED: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + isProjected = true; + break; + + default: + forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform); + break; + } + + + AreaUniformlyDistributedLoad bhAreaload = BH.Engine.Structure.Create.AreaUniformlyDistributedLoad(loadcase, forceDirection, panels, axis, isProjected, polygonLoad.comment); + bhAreaload = bhAreaload.SetHashFragment("Polygon"); + bhAreaload.SetPropertyValue("Polygon", polygon); + + return bhAreaload; + } + public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.surface_load surfaceload, Loadcase loadcase, List panels) { diff --git a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs index 6c4b2380..e53c1f81 100644 --- a/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs +++ b/RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs @@ -36,6 +36,7 @@ using Dlubal.WS.Rfem6.Model; using BH.Engine.Geometry; using BH.oM.Geometry; +using BH.Engine.Spatial; namespace BH.Adapter.RFEM6 { @@ -47,7 +48,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar //var i = bhBarLoad.Objects.Elements.ToList().Select(x => x.GetRFEM6ID()).ToList(); - double loadMagintude; + double loadMagnitude; member_load_load_direction loadDirecteion; Vector orientationVector = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force : bhBarLoad.Moment; @@ -72,7 +73,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar { loadDirecteion = member_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE; } - loadMagintude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.X : bhBarLoad.Moment.X; + loadMagnitude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.X : bhBarLoad.Moment.X; } @@ -90,7 +91,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar { loadDirecteion = member_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_TRUE; } - loadMagintude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Y : bhBarLoad.Moment.Y; + loadMagnitude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Y : bhBarLoad.Moment.Y; } else @@ -107,7 +108,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar { loadDirecteion = member_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_TRUE; } - loadMagintude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Z : bhBarLoad.Moment.Z; + loadMagnitude = loadType == member_load_load_type.LOAD_TYPE_FORCE ? bhBarLoad.Force.Z : bhBarLoad.Moment.Z; } member_load rfLoadCase = new rfModel.member_load() @@ -121,7 +122,7 @@ public static rfModel.member_load ToRFEM6(this BarUniformlyDistributedLoad bhBar load_typeSpecified = true, load_direction = loadDirecteion, load_directionSpecified = true, - magnitude = loadMagintude, + magnitude = loadMagnitude, magnitudeSpecified = true, load_is_over_total_length = true, load_is_over_total_lengthSpecified = true, @@ -174,7 +175,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { - double loadMagintude; + double loadMagnitude; surface_load_load_direction loadDirection; Vector orientationVector = bhAreaLoad.Pressure; @@ -199,7 +200,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { loadDirection = surface_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE; } - loadMagintude = orientationVector.X; + loadMagnitude = orientationVector.X; } else if (orientationVector.Y != 0) @@ -216,7 +217,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { loadDirection = surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_TRUE; } - loadMagintude = orientationVector.Y; + loadMagnitude = orientationVector.Y; } else @@ -233,7 +234,7 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA { loadDirection = surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_TRUE; } - loadMagintude = orientationVector.Z; + loadMagnitude = orientationVector.Z; } @@ -246,9 +247,9 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA load_caseSpecified = true, load_distribution = surface_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM, load_distributionSpecified = true, - magnitude_force_u = loadMagintude, + magnitude_force_u = loadMagnitude, magnitude_force_uSpecified = true, - uniform_magnitude = loadMagintude, + uniform_magnitude = loadMagnitude, uniform_magnitudeSpecified = true, is_generated = false, is_generatedSpecified = true, @@ -263,6 +264,149 @@ public static rfModel.surface_load ToRFEM6(this AreaUniformlyDistributedLoad bhA } + public static rfModel.free_polygon_load ToRFEM6_Polygon(this AreaUniformlyDistributedLoad bhAreaLoad, int loadCaseSpecificLoadId) + { + free_polygon_load_load_projection loadProjection; + + if (bhAreaLoad.Pressure.IsParallel(BH.oM.Geometry.Vector.XAxis)==0 + && bhAreaLoad.Pressure.IsParallel(BH.oM.Geometry.Vector.YAxis) == 0 + && bhAreaLoad.Pressure.IsParallel(BH.oM.Geometry.Vector.ZAxis) == 0) + { + BH.Engine.Base.Compute.RecordWarning($"Please make sure that the direction of {bhAreaLoad} is axis-aligned."); + } + + Polygon polygon = (Polygon)bhAreaLoad.CustomData.Values.First(p => p is Polygon); + List polygonValues; + var fitPlane=polygon.IFitPlane(); + if (fitPlane.Normal.CrossProduct(Plane.XY.Normal).Length() < 0.01) + { + polygonValues= polygon.Vertices.Select(v => new double[] { v.X, v.Y }).ToList(); + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV; + } + else if (fitPlane.Normal.CrossProduct(Plane.XZ.Normal).Length() < 0.01) + { + polygonValues= polygon.Vertices.Select(v => new double[] { v.X, v.Z }).ToList(); + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_XZ_OR_UW; + } + else { + polygonValues= polygon.Vertices.Select(v => new double[] { v.Y, v.Z }).ToList(); + loadProjection = free_polygon_load_load_projection.LOAD_PROJECTION_YZ_OR_VW; + + } + + free_polygon_load_load_location_row[] locationPolygons = polygonValues.Select((v, i) => new free_polygon_load_load_location_row() + { + no = (i+1), + description=(i+1)+"", + row = new free_polygon_load_load_location() + { + magnitude=0, + magnitudeSpecified=false, + first_coordinate = v[0], + first_coordinateSpecified = true, + second_coordinate = v[1], + second_coordinateSpecified = true + + } + } + + ).ToArray(); + + double loadMagnitude; + free_polygon_load_load_direction loadDirection; + Vector orientationVector = bhAreaLoad.Pressure; + + if (bhAreaLoad.Projected && bhAreaLoad.Axis == LoadAxis.Local) + { + BH.Engine.Base.Compute.RecordWarning("Projected Area Load is not supported for Local Axis. The Load will be projected to the Global Axis"); + } + + // Checkinf if Load is Orientied in X directin + if (orientationVector.X != 0) + { + // If the load Axis in slocal the load direction is local x + if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_X; + if (bhAreaLoad.Projected) BH.Engine.Base.Compute.RecordWarning($"The 'Projected' option for {bhAreaLoad} is not supported when the Axis is set to Local and will therefore be ignored."); + + } + else if (bhAreaLoad.Projected) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_PROJECTED; + } + else + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_TRUE; + } + loadMagnitude = orientationVector.X; + + } + else if (orientationVector.Y != 0) + { + if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Y; + if (bhAreaLoad.Projected) BH.Engine.Base.Compute.RecordWarning($"The 'Projected' option for {bhAreaLoad} is not supported when the Axis is set to Local and will therefore be ignored."); + } + else if (bhAreaLoad.Projected) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_PROJECTED; + } + else + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_TRUE; + } + loadMagnitude = orientationVector.Y; + + } + else + { + if (bhAreaLoad.Axis.Equals(LoadAxis.Local)) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Z; + if (bhAreaLoad.Projected) BH.Engine.Base.Compute.RecordWarning($"The 'Projected' option for {bhAreaLoad} is not supported when the Axis is set to Local and will therefore be ignored."); + } + else if (bhAreaLoad.Projected) + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_PROJECTED; + } + else + { + loadDirection = free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_TRUE; + } + loadMagnitude = orientationVector.Z; + } + + + + free_polygon_load rfSurfaceLoad = new rfModel.free_polygon_load() + { + no = loadCaseSpecificLoadId, + comment = bhAreaLoad.Name, + surfaces = bhAreaLoad.Objects.Elements.ToList().Select(x => (x as Panel).GetRFEM6ID()).ToArray(), + load_case = bhAreaLoad.Loadcase.Number, + load_caseSpecified = true, + load_distribution = free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM, + load_distributionSpecified = true, + magnitude_linear_1 = loadMagnitude, + magnitude_linear_1Specified = true, + magnitude_uniform = loadMagnitude, + magnitude_uniformSpecified = true, + is_generated = false, + is_generatedSpecified = true, + load_direction = loadDirection, + load_directionSpecified = true, + load_location = locationPolygons, + load_projection = loadProjection, + load_projectionSpecified = true + }; + + + return rfSurfaceLoad; + + } + public static rfModel.free_line_load ToRFEM6(this GeometricalLineLoad bhLineLoad, int loadCaseSpecificID, int[] surfaceIds) { diff --git a/RFEM6_Adapter/RFEM6Adapter.cs b/RFEM6_Adapter/RFEM6Adapter.cs index 6d61bcb7..c6e45271 100644 --- a/RFEM6_Adapter/RFEM6Adapter.cs +++ b/RFEM6_Adapter/RFEM6Adapter.cs @@ -60,7 +60,6 @@ public partial class RFEM6Adapter : BHoMAdapter [Description("Adapter for RFEM6.")] [Input("filePath", "Input the optional file path to RFEM model. Default is to use the currently running instance")] [Output("The created RFEM6 adapter.")] - [PreviousVersion("8.3", "BH.Adapter.RFEM6.RFEM6Adapter(System.Boolean)")] public RFEM6Adapter(string filePath = "", bool active = false) { diff --git a/RFEM6_Adapter/RFEM6_Adapter.csproj b/RFEM6_Adapter/RFEM6_Adapter.csproj index 2d20a6dc..252e52e5 100644 --- a/RFEM6_Adapter/RFEM6_Adapter.csproj +++ b/RFEM6_Adapter/RFEM6_Adapter.csproj @@ -2,12 +2,12 @@ net48 - 8.0.0.0 + 9.0.0.0 https://github.com/BHoM/RFEM6_Toolkit RFEM6_Adapter BH.Adapter.RFEM6 true - 8.3.0.0 + 9.0.0.0 ..\Build\ diff --git a/RFEM6_Engine/RFEM6_Engine.csproj b/RFEM6_Engine/RFEM6_Engine.csproj index 072506d0..bba3994a 100644 --- a/RFEM6_Engine/RFEM6_Engine.csproj +++ b/RFEM6_Engine/RFEM6_Engine.csproj @@ -2,12 +2,12 @@ net48 - 8.0.0.0 + 9.0.0.0 https://github.com/BHoM/RFEM6_Toolkit 5.0.0 Copyright © https://github.com/BHoM BH.Engine.Adapters.RFEM6 - 8.3.0.0 + 9.0.0.0 diff --git a/RFEM6_oM/RFEM6_oM.csproj b/RFEM6_oM/RFEM6_oM.csproj index 0fec6ffd..199dc305 100644 --- a/RFEM6_oM/RFEM6_oM.csproj +++ b/RFEM6_oM/RFEM6_oM.csproj @@ -2,12 +2,12 @@ net48 - 8.0.0.0 + 9.0.0.0 https://github.com/BHoM/RFEM6_Toolkit 5.0.0 Copyright © https://github.com/BHoM BH.oM.Adapters.RFEM6 - 8.3.0.0 + 9.0.0.0