From 75be916422a01daa8090f77bb8e753c474ad6f08 Mon Sep 17 00:00:00 2001 From: Tilman Reinhardt Date: Tue, 10 Oct 2023 16:48:58 +0200 Subject: [PATCH] GSAGH-367 set EntityType correctly --- .../3_Loads/CreateBeamThermalLoad.cs | 2 ++ GsaGH/Components/3_Loads/CreateGravityLoad.cs | 8 +++++ .../Parameters/3_Loads/GsaFaceThermalLoad.cs | 2 +- GsaGH/Parameters/3_Loads/GsaGravityLoad.cs | 1 + .../3_Loads/CreateBeamLoadTests.cs | 34 ++++++++++++++++++ .../3_Loads/CreateBeamThermalLoadTests.cs | 34 ++++++++++++++++++ .../3_Loads/CreateFaceLoadTests.cs | 34 ++++++++++++++++++ .../3_Loads/CreateFaceThermalLoadTests.cs | 35 +++++++++++++++++++ .../3_Loads/CreateGravityLoadTests.cs | 33 +++++++++++++++++ 9 files changed, 182 insertions(+), 1 deletion(-) diff --git a/GsaGH/Components/3_Loads/CreateBeamThermalLoad.cs b/GsaGH/Components/3_Loads/CreateBeamThermalLoad.cs index bb71183d7..07e729a9d 100644 --- a/GsaGH/Components/3_Loads/CreateBeamThermalLoad.cs +++ b/GsaGH/Components/3_Loads/CreateBeamThermalLoad.cs @@ -148,11 +148,13 @@ protected override void SolveInternal(IGH_DataAccess da) { case GsaElement1dGoo element1dGoo: beamThermalLoad.RefObjectGuid = element1dGoo.Value.Guid; beamThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element; + beamThermalLoad.ReferenceType = ReferenceType.Element; break; case GsaMember1dGoo member1dGoo: beamThermalLoad.RefObjectGuid = member1dGoo.Value.Guid; beamThermalLoad.ApiLoad.EntityType = GsaAPI.EntityType.Member; + beamThermalLoad.ReferenceType = ReferenceType.Member; break; case GsaMaterialGoo materialGoo: diff --git a/GsaGH/Components/3_Loads/CreateGravityLoad.cs b/GsaGH/Components/3_Loads/CreateGravityLoad.cs index df830f1ff..f11784f2d 100644 --- a/GsaGH/Components/3_Loads/CreateGravityLoad.cs +++ b/GsaGH/Components/3_Loads/CreateGravityLoad.cs @@ -83,21 +83,25 @@ protected override void SolveInstance(IGH_DataAccess da) { case GsaElement2dGoo value: { gravityLoad.RefObjectGuid = value.Value.Guid; gravityLoad.ReferenceType = ReferenceType.Element; + gravityLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element; break; } case GsaMember1dGoo value: { gravityLoad.RefObjectGuid = value.Value.Guid; gravityLoad.ReferenceType = ReferenceType.Member; + gravityLoad.ApiLoad.EntityType = GsaAPI.EntityType.Member; break; } case GsaMember2dGoo value: { gravityLoad.RefObjectGuid = value.Value.Guid; gravityLoad.ReferenceType = ReferenceType.Member; + gravityLoad.ApiLoad.EntityType = GsaAPI.EntityType.Member; break; } case GsaMember3dGoo value: { gravityLoad.RefObjectGuid = value.Value.Guid; gravityLoad.ReferenceType = ReferenceType.Member; + gravityLoad.ApiLoad.EntityType = GsaAPI.EntityType.Member; break; } case GsaMaterialGoo value: { @@ -108,21 +112,25 @@ protected override void SolveInstance(IGH_DataAccess da) { } gravityLoad.RefObjectGuid = value.Value.Guid; gravityLoad.ReferenceType = ReferenceType.Property; + gravityLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element; break; } case GsaSectionGoo value: { gravityLoad.RefObjectGuid = value.Value.Guid; gravityLoad.ReferenceType = ReferenceType.Property; + gravityLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element; break; } case GsaProperty2dGoo value: { gravityLoad.RefObjectGuid = value.Value.Guid; gravityLoad.ReferenceType = ReferenceType.Property; + gravityLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element; break; } case GsaProperty3dGoo value: { gravityLoad.RefObjectGuid = value.Value.Guid; gravityLoad.ReferenceType = ReferenceType.Property; + gravityLoad.ApiLoad.EntityType = GsaAPI.EntityType.Element; break; } default: { diff --git a/GsaGH/Parameters/3_Loads/GsaFaceThermalLoad.cs b/GsaGH/Parameters/3_Loads/GsaFaceThermalLoad.cs index 4d1dadf95..0a23892d5 100644 --- a/GsaGH/Parameters/3_Loads/GsaFaceThermalLoad.cs +++ b/GsaGH/Parameters/3_Loads/GsaFaceThermalLoad.cs @@ -18,7 +18,7 @@ public string Name { set => ApiLoad.Name = value; } public GsaFaceThermalLoad() { - ApiLoad = new FaceThermalLoad (); + ApiLoad = new FaceThermalLoad(); } public IGsaLoad Duplicate() { diff --git a/GsaGH/Parameters/3_Loads/GsaGravityLoad.cs b/GsaGH/Parameters/3_Loads/GsaGravityLoad.cs index 3a4892e7c..ff37e9682 100644 --- a/GsaGH/Parameters/3_Loads/GsaGravityLoad.cs +++ b/GsaGH/Parameters/3_Loads/GsaGravityLoad.cs @@ -33,6 +33,7 @@ public IGsaLoad Duplicate() { ApiLoad = { Case = ApiLoad.Case, EntityList = ApiLoad.EntityList.ToString(), + EntityType = ApiLoad.EntityType, Nodes = ApiLoad.Nodes.ToString(), Name = ApiLoad.Name.ToString(), Factor = ApiLoad.Factor, diff --git a/GsaGHTests/3_Components/3_Loads/CreateBeamLoadTests.cs b/GsaGHTests/3_Components/3_Loads/CreateBeamLoadTests.cs index 83292f24c..66d15ab85 100644 --- a/GsaGHTests/3_Components/3_Loads/CreateBeamLoadTests.cs +++ b/GsaGHTests/3_Components/3_Loads/CreateBeamLoadTests.cs @@ -1,7 +1,9 @@ using GsaGH.Components; using GsaGH.Parameters; using GsaGH.Parameters.Enums; +using GsaGHTests.Components.Geometry; using GsaGHTests.Helpers; +using OasysGH.Components; using Xunit; namespace GsaGHTests.Components.Loads { @@ -163,5 +165,37 @@ public void EntityListTypeErrorTest() { comp.Params.Output[0].CollectData(); Assert.Single(comp.RuntimeMessages(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error)); } + + [Fact] + public void CreateElement1dLoadTest() { + var comp = new CreateBeamLoad(); + GH_OasysComponent element1dComp = CreateElement1dTests.ComponentMother(); + var element1dGoo = (GsaElement1dGoo)ComponentTestHelper.GetOutput(element1dComp); + + ComponentTestHelper.SetInput(comp, element1dGoo, 1); + ComponentTestHelper.SetInput(comp, -5, 6); + + var output = (GsaLoadGoo)ComponentTestHelper.GetOutput(comp); + var load = (GsaBeamLoad)output.Value; + Assert.Equal(-5000, load.ApiLoad.Value(0)); + Assert.Equal(ReferenceType.Element, load.ReferenceType); + Assert.Equal(GsaAPI.EntityType.Element, load.ApiLoad.EntityType); + } + + [Fact] + public void CreateMember1dLoadTest() { + var comp = new CreateBeamLoad(); + GH_OasysComponent member1dComp = CreateMember1dTests.ComponentMother(); + var member1dGoo = (GsaMember1dGoo)ComponentTestHelper.GetOutput(member1dComp); + + ComponentTestHelper.SetInput(comp, member1dGoo, 1); + ComponentTestHelper.SetInput(comp, -5, 6); + + var output = (GsaLoadGoo)ComponentTestHelper.GetOutput(comp); + var load = (GsaBeamLoad)output.Value; + Assert.Equal(-5000, load.ApiLoad.Value(0)); + Assert.Equal(ReferenceType.Member, load.ReferenceType); + Assert.Equal(GsaAPI.EntityType.Member, load.ApiLoad.EntityType); + } } } diff --git a/GsaGHTests/3_Components/3_Loads/CreateBeamThermalLoadTests.cs b/GsaGHTests/3_Components/3_Loads/CreateBeamThermalLoadTests.cs index 7decc59ea..5b0fffb87 100644 --- a/GsaGHTests/3_Components/3_Loads/CreateBeamThermalLoadTests.cs +++ b/GsaGHTests/3_Components/3_Loads/CreateBeamThermalLoadTests.cs @@ -1,7 +1,9 @@ using GsaGH.Components; using GsaGH.Parameters; using GsaGH.Parameters.Enums; +using GsaGHTests.Components.Geometry; using GsaGHTests.Helpers; +using OasysGH.Components; using Xunit; namespace GsaGHTests.Components.Loads { @@ -35,5 +37,37 @@ public void EntityListTypeErrorTest() { comp.Params.Output[0].CollectData(); Assert.Single(comp.RuntimeMessages(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error)); } + + [Fact] + public void CreateElement1dLoadTest() { + var comp = new CreateBeamThermalLoad(); + GH_OasysComponent element1dComp = CreateElement1dTests.ComponentMother(); + var element1dGoo = (GsaElement1dGoo)ComponentTestHelper.GetOutput(element1dComp); + + ComponentTestHelper.SetInput(comp, element1dGoo, 1); + ComponentTestHelper.SetInput(comp, -5, 3); + + var output = (GsaLoadGoo)ComponentTestHelper.GetOutput(comp); + var load = (GsaBeamThermalLoad)output.Value; + Assert.Equal(-5, load.ApiLoad.UniformTemperature); + Assert.Equal(ReferenceType.Element, load.ReferenceType); + Assert.Equal(GsaAPI.EntityType.Element, load.ApiLoad.EntityType); + } + + [Fact] + public void CreateMember1dLoadTest() { + var comp = new CreateBeamThermalLoad(); + GH_OasysComponent member1dComp = CreateMember1dTests.ComponentMother(); + var member1dGoo = (GsaMember1dGoo)ComponentTestHelper.GetOutput(member1dComp); + + ComponentTestHelper.SetInput(comp, member1dGoo, 1); + ComponentTestHelper.SetInput(comp, -5, 3); + + var output = (GsaLoadGoo)ComponentTestHelper.GetOutput(comp); + var load = (GsaBeamThermalLoad)output.Value; + Assert.Equal(-5, load.ApiLoad.UniformTemperature); + Assert.Equal(ReferenceType.Member, load.ReferenceType); + Assert.Equal(GsaAPI.EntityType.Member, load.ApiLoad.EntityType); + } } } diff --git a/GsaGHTests/3_Components/3_Loads/CreateFaceLoadTests.cs b/GsaGHTests/3_Components/3_Loads/CreateFaceLoadTests.cs index 9d46a9a16..619ecb6ee 100644 --- a/GsaGHTests/3_Components/3_Loads/CreateFaceLoadTests.cs +++ b/GsaGHTests/3_Components/3_Loads/CreateFaceLoadTests.cs @@ -1,7 +1,9 @@ using GsaGH.Components; using GsaGH.Parameters; using GsaGH.Parameters.Enums; +using GsaGHTests.Components.Geometry; using GsaGHTests.Helpers; +using OasysGH.Components; using Xunit; namespace GsaGHTests.Components.Loads { @@ -131,5 +133,37 @@ public void EntityListTypeErrorTest() { comp.Params.Output[0].CollectData(); Assert.Single(comp.RuntimeMessages(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error)); } + + [Fact] + public void CreateElement2dLoadTest() { + var comp = new CreateFaceLoad(); + GH_OasysComponent element2dComp = CreateElement2dTests.ComponentMother(); + var element2dGoo = (GsaElement2dGoo)ComponentTestHelper.GetOutput(element2dComp); + + ComponentTestHelper.SetInput(comp, element2dGoo, 1); + ComponentTestHelper.SetInput(comp, -5, 6); + + var output = (GsaLoadGoo)ComponentTestHelper.GetOutput(comp); + var load = (GsaFaceLoad)output.Value; + Assert.Equal(-5000, load.ApiLoad.Value(0)); + Assert.Equal(ReferenceType.Element, load.ReferenceType); + Assert.Equal(GsaAPI.EntityType.Element, load.ApiLoad.EntityType); + } + + [Fact] + public void CreateMember2dLoadTest() { + var comp = new CreateFaceLoad(); + GH_OasysComponent member2dComp = CreateMember2dTests.ComponentMother(); + var member2dGoo = (GsaMember2dGoo)ComponentTestHelper.GetOutput(member2dComp); + + ComponentTestHelper.SetInput(comp, member2dGoo, 1); + ComponentTestHelper.SetInput(comp, -5, 6); + + var output = (GsaLoadGoo)ComponentTestHelper.GetOutput(comp); + var load = (GsaFaceLoad)output.Value; + Assert.Equal(-5000, load.ApiLoad.Value(0)); + Assert.Equal(ReferenceType.Member, load.ReferenceType); + Assert.Equal(GsaAPI.EntityType.Member, load.ApiLoad.EntityType); + } } } diff --git a/GsaGHTests/3_Components/3_Loads/CreateFaceThermalLoadTests.cs b/GsaGHTests/3_Components/3_Loads/CreateFaceThermalLoadTests.cs index ce41eedbd..307faefaa 100644 --- a/GsaGHTests/3_Components/3_Loads/CreateFaceThermalLoadTests.cs +++ b/GsaGHTests/3_Components/3_Loads/CreateFaceThermalLoadTests.cs @@ -1,7 +1,9 @@ using GsaGH.Components; using GsaGH.Parameters; using GsaGH.Parameters.Enums; +using GsaGHTests.Components.Geometry; using GsaGHTests.Helpers; +using OasysGH.Components; using Xunit; namespace GsaGHTests.Components.Loads { @@ -35,5 +37,38 @@ public void EntityListTypeErrorTest() { comp.Params.Output[0].CollectData(); Assert.Single(comp.RuntimeMessages(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error)); } + + + [Fact] + public void CreateElement2dLoadTest() { + var comp = new CreateFaceThermalLoad(); + GH_OasysComponent element2dComp = CreateElement2dTests.ComponentMother(); + var element2dGoo = (GsaElement2dGoo)ComponentTestHelper.GetOutput(element2dComp); + + ComponentTestHelper.SetInput(comp, element2dGoo, 1); + ComponentTestHelper.SetInput(comp, -5, 3); + + var output = (GsaLoadGoo)ComponentTestHelper.GetOutput(comp); + var load = (GsaFaceThermalLoad)output.Value; + Assert.Equal(-5, load.ApiLoad.UniformTemperature); + Assert.Equal(ReferenceType.Element, load.ReferenceType); + Assert.Equal(GsaAPI.EntityType.Element, load.ApiLoad.EntityType); + } + + [Fact] + public void CreateMember2dLoadTest() { + var comp = new CreateFaceThermalLoad(); + GH_OasysComponent member2dComp = CreateMember2dTests.ComponentMother(); + var member2dGoo = (GsaMember2dGoo)ComponentTestHelper.GetOutput(member2dComp); + + ComponentTestHelper.SetInput(comp, member2dGoo, 1); + ComponentTestHelper.SetInput(comp, -5, 3); + + var output = (GsaLoadGoo)ComponentTestHelper.GetOutput(comp); + var load = (GsaFaceThermalLoad)output.Value; + Assert.Equal(-5, load.ApiLoad.UniformTemperature); + Assert.Equal(ReferenceType.Member, load.ReferenceType); + Assert.Equal(GsaAPI.EntityType.Member, load.ApiLoad.EntityType); + } } } diff --git a/GsaGHTests/3_Components/3_Loads/CreateGravityLoadTests.cs b/GsaGHTests/3_Components/3_Loads/CreateGravityLoadTests.cs index a870b5391..ce0ed9701 100644 --- a/GsaGHTests/3_Components/3_Loads/CreateGravityLoadTests.cs +++ b/GsaGHTests/3_Components/3_Loads/CreateGravityLoadTests.cs @@ -1,7 +1,9 @@ using GsaGH.Components; using GsaGH.Parameters; using GsaGH.Parameters.Enums; +using GsaGHTests.Components.Geometry; using GsaGHTests.Helpers; +using OasysGH.Components; using Rhino.Geometry; using Xunit; @@ -26,6 +28,37 @@ public void CreateLoadTest() { Assert.Equal(ReferenceType.None, load.ReferenceType); } + [Fact] + public void CreateMember1dLoadTest() { + var comp = new CreateGravityLoad(); + GH_OasysComponent member1dComp = CreateMember1dTests.ComponentMother(); + var member1dGoo = (GsaMember1dGoo)ComponentTestHelper.GetOutput(member1dComp); + + ComponentTestHelper.SetInput(comp, 7, 0); + ComponentTestHelper.SetInput(comp, member1dGoo, 1); + + var output = (GsaLoadGoo)ComponentTestHelper.GetOutput(comp); + var load = (GsaGravityLoad)output.Value; + Assert.Equal(ReferenceType.Member, load.ReferenceType); + Assert.Equal(GsaAPI.EntityType.Member, load.ApiLoad.EntityType); + } + + [Fact] + public void CreateMember2dLoadTest() { + var comp = new CreateGravityLoad(); + GH_OasysComponent member2dComp = CreateMember2dTests.ComponentMother(); + var member2dGoo = (GsaMember2dGoo)ComponentTestHelper.GetOutput(member2dComp); + + ComponentTestHelper.SetInput(comp, 7, 0); + ComponentTestHelper.SetInput(comp, member2dGoo, 1); + + var output = (GsaLoadGoo)ComponentTestHelper.GetOutput(comp); + var load = (GsaGravityLoad)output.Value; + Assert.Equal(7, load.LoadCase.Id); + Assert.Equal(ReferenceType.Member, load.ReferenceType); + Assert.Equal(GsaAPI.EntityType.Member, load.ApiLoad.EntityType); + } + [Fact] public void EntityListTypeErrorTest() { var comp = new CreateGravityLoad();