From c2b9fcf13eb8c201f9a6a681166c89f99ccbe400 Mon Sep 17 00:00:00 2001 From: Kristjan Nielsen Date: Wed, 15 Nov 2023 12:22:44 +0100 Subject: [PATCH] more tests --- GsaGH/Components/2_Geometry/Edit1dMember.cs | 20 ++++++++- .../3_Caches/NodeSpringForceCache.cs | 44 ++++++++++++++++--- .../3_Components/GH_OasysComponentTest.cs | 6 ++- .../AppendAdditionalMenuItemsTests.cs | 1 - .../CreateEditBucklingFactorsTest.cs | 5 --- 5 files changed, 61 insertions(+), 15 deletions(-) diff --git a/GsaGH/Components/2_Geometry/Edit1dMember.cs b/GsaGH/Components/2_Geometry/Edit1dMember.cs index 7f3c04b17..bb8f02ccf 100644 --- a/GsaGH/Components/2_Geometry/Edit1dMember.cs +++ b/GsaGH/Components/2_Geometry/Edit1dMember.cs @@ -23,7 +23,7 @@ namespace GsaGH.Components { /// /// Component to edit a 1D Member /// - public class Edit1dMember : Section3dPreviewComponent { + public class Edit1dMember : Section3dPreviewComponent, IGH_VariableParameterComponent { public override Guid ComponentGuid => new Guid("32e744e5-7352-4308-81d0-13bf06db5e82"); public override GH_Exposure Exposure => GH_Exposure.tertiary | GH_Exposure.obscure; public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; @@ -40,6 +40,24 @@ protected override void BeforeSolveInstance() { } } + bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) { + return false; + } + + bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) { + return false; + } + + IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) { + return null; + } + + bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) { + return false; + } + + public void VariableParameterMaintenance() { } + protected override void RegisterInputParams(GH_InputParamManager pManager) { pManager.AddParameter(new GsaMember1dParameter(), GsaMember1dGoo.Name, GsaMember1dGoo.NickName, diff --git a/GsaGH/Parameters/5_Results/3_Caches/NodeSpringForceCache.cs b/GsaGH/Parameters/5_Results/3_Caches/NodeSpringForceCache.cs index 876d1d775..67977fd91 100644 --- a/GsaGH/Parameters/5_Results/3_Caches/NodeSpringForceCache.cs +++ b/GsaGH/Parameters/5_Results/3_Caches/NodeSpringForceCache.cs @@ -29,9 +29,13 @@ public INodeResultSubset> ResultSu switch (ApiResult.Result) { case AnalysisCaseResult analysisCase: ReadOnlyDictionary aCaseResults = analysisCase.NodeResults(nodelist); - Parallel.ForEach(aCaseResults.Keys, nodeId => { - var res = new ReactionForce(aCaseResults[nodeId].SpringForce); - Cache.TryAdd(nodeId, new Collection() { + Parallel.ForEach(aCaseResults, resultKvp => { + if (!HasValues(resultKvp)) { + return; + } + + var res = new ReactionForce(resultKvp.Value.SpringForce); + Cache.TryAdd(resultKvp.Key, new Collection() { res, }); }); @@ -40,19 +44,47 @@ public INodeResultSubset> ResultSu case CombinationCaseResult combinationCase: ReadOnlyDictionary> cCaseResults = combinationCase.NodeResults(nodelist); - Parallel.ForEach(cCaseResults.Keys, nodeId => { + Parallel.ForEach(cCaseResults, resultKvp => { + if (!HasValues(resultKvp)) { + return; + } + var permutationResults = new Collection(); - foreach (NodeResult permutationResult in cCaseResults[nodeId]) { + foreach (NodeResult permutationResult in resultKvp.Value) { permutationResults.Add(new ReactionForce(permutationResult.SpringForce)); } - Cache.TryAdd(nodeId, permutationResults); + Cache.TryAdd(resultKvp.Key, permutationResults); }); break; + } } return new NodeForceSubset(Cache.GetSubset(nodeIds)); } + + private bool HasValues(KeyValuePair kvp) { + return HasValues(kvp.Value.SpringForce); + } + + private bool HasValues(KeyValuePair> kvp) { + foreach (NodeResult res in kvp.Value) { + if (HasValues(res.SpringForce)) { + return true; + } + } + + return false; + } + + private bool HasValues(Double6 values) { + return HasValue(values.X) || HasValue(values.Y) || HasValue(values.Z) + || HasValue(values.XX) || HasValue(values.YY) || HasValue(values.ZZ); + } + + private bool HasValue(double value) { + return !double.IsNaN(value) && value != 0; + } } } diff --git a/GsaGHTests/3_Components/GH_OasysComponentTest.cs b/GsaGHTests/3_Components/GH_OasysComponentTest.cs index a59376457..44f75e249 100644 --- a/GsaGHTests/3_Components/GH_OasysComponentTest.cs +++ b/GsaGHTests/3_Components/GH_OasysComponentTest.cs @@ -27,7 +27,6 @@ public class GH_OasysComponentTests { [InlineData(typeof(SaveGsaModel))] [InlineData(typeof(ModelTitles))] [InlineData(typeof(CreateBool6))] - [InlineData(typeof(CreateBucklingFactors))] [InlineData(typeof(CreateCustomMaterial))] [InlineData(typeof(CreateMaterial))] [InlineData(typeof(CreateOffset))] @@ -37,7 +36,6 @@ public class GH_OasysComponentTests { [InlineData(typeof(CreateSection))] [InlineData(typeof(CreateSectionModifier))] [InlineData(typeof(EditBool6))] - [InlineData(typeof(EditBucklingFactors))] [InlineData(typeof(EditMaterial))] [InlineData(typeof(EditOffset))] [InlineData(typeof(EditProfile))] @@ -66,6 +64,10 @@ public class GH_OasysComponentTests { [InlineData(typeof(EditNode))] [InlineData(typeof(Create2dElementsFromBrep))] [InlineData(typeof(CreateElementsFromMembers))] + [InlineData(typeof(CreateEffectiveLength))] + [InlineData(typeof(EffectiveLengthInfo))] + [InlineData(typeof(CreateMemberEndRestraint))] + [InlineData(typeof(MemberEndRestraintInfo))] [InlineData(typeof(LocalAxes))] [InlineData(typeof(SectionAlignment))] [InlineData(typeof(Annotate))] diff --git a/GsaGHTests/4_CustomUIComponents/AppendAdditionalMenuItemsTests.cs b/GsaGHTests/4_CustomUIComponents/AppendAdditionalMenuItemsTests.cs index 8b85de0b3..71b2f8edc 100644 --- a/GsaGHTests/4_CustomUIComponents/AppendAdditionalMenuItemsTests.cs +++ b/GsaGHTests/4_CustomUIComponents/AppendAdditionalMenuItemsTests.cs @@ -20,7 +20,6 @@ public class AppendAdditionalMenuItemsTests { [InlineData(typeof(SectionProperties), 2)] [InlineData(typeof(Create2dElementsFromBrep), 2)] [InlineData(typeof(CreateElementsFromMembers), 2)] - [InlineData(typeof(Edit1dMember), 3)] [InlineData(typeof(GridPlaneSurfaceProperties), 2)] [InlineData(typeof(AnalyseModel), 2)] // AppendAdditionalComponentMenuItems diff --git a/IntegrationTests/2_Parameters/1_Properties/CreateEditBucklingFactorsTest.cs b/IntegrationTests/2_Parameters/1_Properties/CreateEditBucklingFactorsTest.cs index da6e80640..2073be63e 100644 --- a/IntegrationTests/2_Parameters/1_Properties/CreateEditBucklingFactorsTest.cs +++ b/IntegrationTests/2_Parameters/1_Properties/CreateEditBucklingFactorsTest.cs @@ -10,11 +10,6 @@ public class CreateEditBucklingFactorsTest { private static GH_Document Document => document ?? (document = OpenDocument()); private static GH_Document document = null; - [Fact] - public void NoRuntimeErrorTest() { - Helper.TestNoRuntimeMessagesInDocument(Document, GH_RuntimeMessageLevel.Error); - } - [Fact] public void NoRuntimeWarningTest() { Helper.TestNoRuntimeMessagesInDocument(Document, GH_RuntimeMessageLevel.Warning);