From edd5aec1ef0aa1f195d52618306f5db8e21e9890 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Mon, 10 Mar 2025 18:10:26 +0530 Subject: [PATCH 01/14] feat(SlsResulFunction.cs): add function class for SLS result component --- AdSecCore/Functions/IFunction.cs | 2 + AdSecCore/Functions/ParametersGeneric.cs | 9 +- AdSecCore/Functions/SlsResulFunction.cs | 188 +++++++++++++++++++++++ 3 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 AdSecCore/Functions/SlsResulFunction.cs diff --git a/AdSecCore/Functions/IFunction.cs b/AdSecCore/Functions/IFunction.cs index 95469d32..a0bc6648 100644 --- a/AdSecCore/Functions/IFunction.cs +++ b/AdSecCore/Functions/IFunction.cs @@ -16,6 +16,8 @@ public interface IFunction { public abstract class Function : IFunction { public List WarningMessages { get; set; } = new List(); + public List RemarkMessages { get; set; } = new List(); + public List ErrorMessages { get; set; } = new List(); public abstract FuncAttribute Metadata { get; set; } public abstract Organisation Organisation { get; set; } public virtual Attribute[] GetAllInputAttributes() { return Array.Empty(); } diff --git a/AdSecCore/Functions/ParametersGeneric.cs b/AdSecCore/Functions/ParametersGeneric.cs index 6dab079b..8656f1a4 100644 --- a/AdSecCore/Functions/ParametersGeneric.cs +++ b/AdSecCore/Functions/ParametersGeneric.cs @@ -1,4 +1,6 @@ -using Oasys.AdSec; +using System; + +using Oasys.AdSec; using Oasys.AdSec.DesignCode; using Oasys.AdSec.Mesh; using Oasys.Profiles; @@ -53,6 +55,11 @@ public class LoadSurfaceParameter : ParameterAttribute { } public class IntegerParameter : ParameterAttribute { } public class LoadParameter : ParameterAttribute { } public class CrackParameter : ParameterAttribute { } + public class DeformationParameter : ParameterAttribute { } + public class LoadGenericParameter : ParameterAttribute { } + public class CrackArrayParameter : BaseArrayParameter { } + public class SecantStiffnessParameter : ParameterAttribute { } + public class IntervalArrayParameter : BaseArrayParameter> { } } diff --git a/AdSecCore/Functions/SlsResulFunction.cs b/AdSecCore/Functions/SlsResulFunction.cs new file mode 100644 index 00000000..730474ed --- /dev/null +++ b/AdSecCore/Functions/SlsResulFunction.cs @@ -0,0 +1,188 @@ + +using System; +using System.Collections.Generic; +using System.Linq; + +using AdSecGHCore.Constants; + +using Oasys.AdSec; + +using OasysUnits; +using OasysUnits.Units; + +namespace AdSecCore.Functions { + public class SlsResultFunction : Function { + + public SectionSolutionParameter SolutionInput { get; set; } = new SectionSolutionParameter { + Name = "Results", + NickName = "Res", + Description = "AdSec Results to perform serviceability check", + Access = Access.Item, + Optional = false, + }; + + public LoadGenericParameter LoadInput { get; set; } = new LoadGenericParameter { + Name = "Load", + NickName = "Ld", + Description = "AdSec Load (Load or Deformation) for which the strength results are to be calculated.", + Access = Access.Item, + Optional = false, + }; + + public LoadParameter LoadOutput { get; set; } = new LoadParameter { + Name = "Load", + NickName = "Ld", + Description = $"The section load under the applied action.{Environment.NewLine}If the applied deformation is outside the capacity range of the section, the returned load will be zero.", + Access = Access.Item, + Optional = false, + }; + + public CrackArrayParameter CrackOutput { get; set; } = new CrackArrayParameter { + Name = "Cracks", + NickName = "Crk", + Description = $"Crack results are calculated at bar positions or section surfaces depending on the Design Code specifications.{Environment.NewLine}If the applied action is outside the capacity range of the section, the returned list will be empty. See MaximumCrack output for the crack result corresponding to the maximum crack width.", + Access = Access.Item, + }; + + public CrackParameter MaximumCrackOutput { get; set; } = new CrackParameter { + Name = "MaximumCrack", + NickName = "Crk", + Description = $"Crack results are calculated at bar positions or section surfaces depending on the Design Code specifications.{Environment.NewLine}If the applied action is outside the capacity range of the section, the returned list will be empty. See MaximumCrack output for the crack result corresponding to the maximum crack width.", + Access = Access.Item, + }; + + public DoubleParameter CrackUtilOutput { get; set; } = new DoubleParameter { + Name = "CrackUtil", + NickName = "Uc", + Description = $"The ratio of the applied load (moment and axial) to the load (moment and axial) in the same direction that would cause the section to crack. Ratio > 1 means section is cracked.{Environment.NewLine}The section is cracked when the cracking utilisation ratio is greater than 1. If the applied load is outside the capacity range of the section, the cracking utilisation will be maximum double value.", + Access = Access.Item, + }; + + public DeformationParameter DeformationOutput { get; set; } = new DeformationParameter { + Name = "Deformation", + NickName = "Def", + Description = "The section deformation under the applied action", + Access = Access.Item, + }; + + public SecantStiffnessParameter SecantStiffnessOutput { get; set; } = new SecantStiffnessParameter { + Name = "SecantStiffness", + NickName = "Es", + Description = "The secant stiffness under the applied action", + Access = Access.Item, + }; + + public IntervalArrayParameter UncrackedMomentRangesOutput { get; set; } = new IntervalArrayParameter { + Name = "Uncracked Moment Ranges", + NickName = "Mrs", + Description = "The range of moments", + Access = Access.Item, + }; + + public override FuncAttribute Metadata { get; set; } = new FuncAttribute { + Name = "Find Crack Load", + NickName = "CrackLd", + Description = "Increases the load until set crack width is reached", + }; + + public override Organisation Organisation { get; set; } = new Organisation { + Category = CategoryName.Name(), + SubCategory = SubCategoryName.Cat7(), + }; + + + public override Attribute[] GetAllInputAttributes() { + return new Attribute[] { + SolutionInput, + LoadInput, + }; + + } + + public override Attribute[] GetAllOutputAttributes() { + return new Attribute[] { + LoadOutput, + CrackOutput, + MaximumCrackOutput, + CrackUtilOutput, + DeformationOutput, + SecantStiffnessOutput, + UncrackedMomentRangesOutput + }; + } + + private static string StrainUnitAbbreviation(StrainUnit unit) { + return Strain.GetAbbreviation(unit); + } + + private static string CurvatureUnitAbbreviation(CurvatureUnit unit) { + var curvature = new Curvature(0, unit); + return string.Concat(curvature.ToString().Where(char.IsLetter)); + } + + private static string AxialUnitAbbreviation(AxialStiffnessUnit unit) { + var axial = new AxialStiffness(0, unit); + return string.Concat(axial.ToString().Where(char.IsLetter)); + + } + + private static string BendingUnitAbbreviation(BendingStiffnessUnit unit) { + var bending = new BendingStiffness(0, unit); + return string.Concat(bending.ToString().Where(char.IsLetter)); + } + + public void RefreshDeformation(StrainUnit strainUnit, CurvatureUnit curvatureUnit) { + DeformationOutput.Description = $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{StrainUnitAbbreviation(strainUnit)}]{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{CurvatureUnitAbbreviation(curvatureUnit)}]{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{CurvatureUnitAbbreviation(curvatureUnit)}]"; + } + + public void RefreshSecantStiffness(AxialStiffnessUnit axialUnit, BendingStiffnessUnit bendingUnit) { + SecantStiffnessOutput.Description = $"The secant stiffness under the applied action. The output is a vector representing:{Environment.NewLine}X: Axial stiffness [{AxialUnitAbbreviation(axialUnit)}],{Environment.NewLine}Y: The bending stiffness about the y-axis in the local coordinate system [{BendingUnitAbbreviation(bendingUnit)}],{Environment.NewLine}Z: The bending stiffness about the z-axis in the local coordinate system [{BendingUnitAbbreviation(bendingUnit)}]"; + } + + public override void Compute() { + var momentUnit = ContextUnits.Instance.MomentUnit; + // get solution input + var solution = SolutionInput.Value; + IServiceabilityResult sls = null; + switch (LoadInput.Value) { + case ILoad load: + sls = solution.Serviceability.Check(load); + break; + case IDeformation deformation: + sls = solution.Serviceability.Check(deformation); + break; + default: + throw new ArgumentException("Invalid Load Input"); + } + + LoadOutput.Value = sls.Load; + DeformationOutput.Value = sls.Deformation; + + + var cracks = new List(); + foreach (var crack in sls.Cracks) { + cracks.Add(crack); + } + CrackOutput.Value = cracks.ToArray(); + + MaximumCrackOutput.Value = sls.MaximumWidthCrack; + CrackUtilOutput.Value = sls.CrackingUtilisation.As(RatioUnit.DecimalFraction); + if (CrackUtilOutput.Value > 1) { + if (CrackOutput.Value.Length == 0) { + WarningMessages.Add("The section is failing and the cracks are so large we can't even compute them!"); + } else { + RemarkMessages.Add("The section is cracked"); + } + } + DeformationOutput.Value = sls.Deformation; + SecantStiffnessOutput.Value = sls.SecantStiffness; + + var momentRanges = new List>(); + foreach (var mrng in sls.UncrackedMomentRanges) { + var interval = new Tuple(mrng.Min.As(momentUnit), mrng.Max.As(momentUnit)); + momentRanges.Add(interval); + } + } + } + +} From 75217d7a5cb7b20491d53e95261496985b7ae6e0 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Tue, 11 Mar 2025 11:21:37 +0530 Subject: [PATCH 02/14] feat(ResultsSLS.cs): component migrated to use new approach --- AdSecCore/Functions/FindCrackLoadFunction.cs | 2 +- AdSecCore/Functions/IFunction.cs | 30 ++++- AdSecCore/Functions/ParametersGeneric.cs | 11 +- AdSecCore/Functions/SlsResulFunction.cs | 47 +++---- AdSecGH/Components/6_Results/ResultsSLS.cs | 125 ++---------------- AdSecGH/Helpers/BusinessExtensions.cs | 52 ++++++++ AdSecGH/Helpers/ComponentAdapter.cs | 3 + .../Helpers/Extensions/CoreToGhExtensions.cs | 20 +++ AdSecGH/Parameters/AdSecCrackGoo.cs | 55 ++++---- 9 files changed, 170 insertions(+), 175 deletions(-) diff --git a/AdSecCore/Functions/FindCrackLoadFunction.cs b/AdSecCore/Functions/FindCrackLoadFunction.cs index 4b6c37db..874570bb 100644 --- a/AdSecCore/Functions/FindCrackLoadFunction.cs +++ b/AdSecCore/Functions/FindCrackLoadFunction.cs @@ -167,7 +167,7 @@ public void Compute() { sls = solution.Solution.Serviceability.Check(baseLoad); SectionLoad.Value = sls.Load; - MaximumCracking.Value = sls.MaximumWidthCrack; + MaximumCracking.Value = new CrackLoad() { Load = sls.MaximumWidthCrack, Plane = solution.SectionDesign.LocalPlane }; } } diff --git a/AdSecCore/Functions/IFunction.cs b/AdSecCore/Functions/IFunction.cs index a0bc6648..04d91c64 100644 --- a/AdSecCore/Functions/IFunction.cs +++ b/AdSecCore/Functions/IFunction.cs @@ -1,5 +1,9 @@ using System; using System.Collections.Generic; +using System.Linq; + +using OasysUnits; +using OasysUnits.Units; namespace AdSecCore.Functions { @@ -17,7 +21,31 @@ public interface IFunction { public abstract class Function : IFunction { public List WarningMessages { get; set; } = new List(); public List RemarkMessages { get; set; } = new List(); - public List ErrorMessages { get; set; } = new List(); + public static string StrainUnitAbbreviation(StrainUnit unit) { + return Strain.GetAbbreviation(unit); + } + + public static string CurvatureUnitAbbreviation(CurvatureUnit unit) { + var curvature = new Curvature(0, unit); + return string.Concat(curvature.ToString().Where(char.IsLetter)); + } + + public static string AxialUnitAbbreviation(AxialStiffnessUnit unit) { + var axial = new AxialStiffness(0, unit); + return string.Concat(axial.ToString().Where(char.IsLetter)); + + } + + public static string BendingStiffnessUnitAbbreviation(BendingStiffnessUnit unit) { + var bending = new BendingStiffness(0, unit); + return string.Concat(bending.ToString().Where(char.IsLetter)); + } + + public static string MomentUnitAbbreviation(MomentUnit unit) { + var bending = new Moment(0, unit); + return string.Concat(bending.ToString().Where(char.IsLetter)); + } + public abstract FuncAttribute Metadata { get; set; } public abstract Organisation Organisation { get; set; } public virtual Attribute[] GetAllInputAttributes() { return Array.Empty(); } diff --git a/AdSecCore/Functions/ParametersGeneric.cs b/AdSecCore/Functions/ParametersGeneric.cs index 8656f1a4..b9d2aef0 100644 --- a/AdSecCore/Functions/ParametersGeneric.cs +++ b/AdSecCore/Functions/ParametersGeneric.cs @@ -40,6 +40,11 @@ public class SectionSolution { public IServiceability Serviceability => Solution.Serviceability; } + public class CrackLoad { + public ICrack Load { get; set; } + public OasysPlane Plane { get; set; } = OasysPlane.PlaneYZ; + } + public class DoubleParameter : ParameterAttribute { } public class DoubleArrayParameter : BaseArrayParameter { } public class IntegerArrayParameter : BaseArrayParameter { } @@ -54,10 +59,10 @@ public class LoadSurfaceParameter : ParameterAttribute { } public class IntegerParameter : ParameterAttribute { } public class LoadParameter : ParameterAttribute { } - public class CrackParameter : ParameterAttribute { } + public class CrackParameter : ParameterAttribute { } public class DeformationParameter : ParameterAttribute { } - public class LoadGenericParameter : ParameterAttribute { } - public class CrackArrayParameter : BaseArrayParameter { } + public class GenericParameter : ParameterAttribute { } + public class CrackArrayParameter : BaseArrayParameter { } public class SecantStiffnessParameter : ParameterAttribute { } public class IntervalArrayParameter : BaseArrayParameter> { } diff --git a/AdSecCore/Functions/SlsResulFunction.cs b/AdSecCore/Functions/SlsResulFunction.cs index 730474ed..6f0df42c 100644 --- a/AdSecCore/Functions/SlsResulFunction.cs +++ b/AdSecCore/Functions/SlsResulFunction.cs @@ -21,7 +21,7 @@ public class SlsResultFunction : Function { Optional = false, }; - public LoadGenericParameter LoadInput { get; set; } = new LoadGenericParameter { + public GenericParameter LoadInput { get; set; } = new GenericParameter { Name = "Load", NickName = "Ld", Description = "AdSec Load (Load or Deformation) for which the strength results are to be calculated.", @@ -39,14 +39,14 @@ public class SlsResultFunction : Function { public CrackArrayParameter CrackOutput { get; set; } = new CrackArrayParameter { Name = "Cracks", - NickName = "Crk", + NickName = "Crks", Description = $"Crack results are calculated at bar positions or section surfaces depending on the Design Code specifications.{Environment.NewLine}If the applied action is outside the capacity range of the section, the returned list will be empty. See MaximumCrack output for the crack result corresponding to the maximum crack width.", - Access = Access.Item, + Access = Access.List, }; public CrackParameter MaximumCrackOutput { get; set; } = new CrackParameter { Name = "MaximumCrack", - NickName = "Crk", + NickName = "MaxCrk", Description = $"Crack results are calculated at bar positions or section surfaces depending on the Design Code specifications.{Environment.NewLine}If the applied action is outside the capacity range of the section, the returned list will be empty. See MaximumCrack output for the crack result corresponding to the maximum crack width.", Access = Access.Item, }; @@ -76,7 +76,7 @@ public class SlsResultFunction : Function { Name = "Uncracked Moment Ranges", NickName = "Mrs", Description = "The range of moments", - Access = Access.Item, + Access = Access.List, }; public override FuncAttribute Metadata { get; set; } = new FuncAttribute { @@ -111,32 +111,16 @@ public override Attribute[] GetAllOutputAttributes() { }; } - private static string StrainUnitAbbreviation(StrainUnit unit) { - return Strain.GetAbbreviation(unit); - } - - private static string CurvatureUnitAbbreviation(CurvatureUnit unit) { - var curvature = new Curvature(0, unit); - return string.Concat(curvature.ToString().Where(char.IsLetter)); - } - - private static string AxialUnitAbbreviation(AxialStiffnessUnit unit) { - var axial = new AxialStiffness(0, unit); - return string.Concat(axial.ToString().Where(char.IsLetter)); - - } - - private static string BendingUnitAbbreviation(BendingStiffnessUnit unit) { - var bending = new BendingStiffness(0, unit); - return string.Concat(bending.ToString().Where(char.IsLetter)); - } - public void RefreshDeformation(StrainUnit strainUnit, CurvatureUnit curvatureUnit) { DeformationOutput.Description = $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{StrainUnitAbbreviation(strainUnit)}]{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{CurvatureUnitAbbreviation(curvatureUnit)}]{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{CurvatureUnitAbbreviation(curvatureUnit)}]"; } public void RefreshSecantStiffness(AxialStiffnessUnit axialUnit, BendingStiffnessUnit bendingUnit) { - SecantStiffnessOutput.Description = $"The secant stiffness under the applied action. The output is a vector representing:{Environment.NewLine}X: Axial stiffness [{AxialUnitAbbreviation(axialUnit)}],{Environment.NewLine}Y: The bending stiffness about the y-axis in the local coordinate system [{BendingUnitAbbreviation(bendingUnit)}],{Environment.NewLine}Z: The bending stiffness about the z-axis in the local coordinate system [{BendingUnitAbbreviation(bendingUnit)}]"; + SecantStiffnessOutput.Description = $"The secant stiffness under the applied action. The output is a vector representing:{Environment.NewLine}X: Axial stiffness [{AxialUnitAbbreviation(axialUnit)}],{Environment.NewLine}Y: The bending stiffness about the y-axis in the local coordinate system [{BendingStiffnessUnitAbbreviation(bendingUnit)}],{Environment.NewLine}Z: The bending stiffness about the z-axis in the local coordinate system [{BendingStiffnessUnitAbbreviation(bendingUnit)}]"; + } + + public void RefreshUncrackedMomentRanges(MomentUnit momentUnit) { + UncrackedMomentRangesOutput.Description = $"The range of moments (in the direction of the applied moment, assuming constant axial force) over which the section remains uncracked. Moment values are in [{MomentUnitAbbreviation(momentUnit)}]"; } public override void Compute() { @@ -159,13 +143,13 @@ public override void Compute() { DeformationOutput.Value = sls.Deformation; - var cracks = new List(); + var cracks = new List(); foreach (var crack in sls.Cracks) { - cracks.Add(crack); + cracks.Add(new CrackLoad() { Load = crack, Plane = solution.SectionDesign.LocalPlane }); } CrackOutput.Value = cracks.ToArray(); - MaximumCrackOutput.Value = sls.MaximumWidthCrack; + MaximumCrackOutput.Value = new CrackLoad() { Load = sls.MaximumWidthCrack, Plane = solution.SectionDesign.LocalPlane }; CrackUtilOutput.Value = sls.CrackingUtilisation.As(RatioUnit.DecimalFraction); if (CrackUtilOutput.Value > 1) { if (CrackOutput.Value.Length == 0) { @@ -178,10 +162,11 @@ public override void Compute() { SecantStiffnessOutput.Value = sls.SecantStiffness; var momentRanges = new List>(); - foreach (var mrng in sls.UncrackedMomentRanges) { - var interval = new Tuple(mrng.Min.As(momentUnit), mrng.Max.As(momentUnit)); + foreach (var range in sls.UncrackedMomentRanges) { + var interval = new Tuple(range.Min.As(momentUnit), range.Max.As(momentUnit)); momentRanges.Add(interval); } + UncrackedMomentRangesOutput.Value = momentRanges.ToArray(); } } diff --git a/AdSecGH/Components/6_Results/ResultsSLS.cs b/AdSecGH/Components/6_Results/ResultsSLS.cs index ab206711..3bf4669f 100644 --- a/AdSecGH/Components/6_Results/ResultsSLS.cs +++ b/AdSecGH/Components/6_Results/ResultsSLS.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Linq; +using AdSecCore.Functions; + using AdSecGH.Helpers; using AdSecGH.Parameters; using AdSecGH.Properties; @@ -13,6 +15,7 @@ using Grasshopper.Kernel.Types; using Oasys.AdSec; +using Oasys.GH.Helpers; using OasysGH; using OasysGH.Components; @@ -24,125 +27,19 @@ using Rhino.Geometry; namespace AdSecGH.Components { - public class ResultsSLS : GH_OasysComponent { - - public ResultsSLS() : base("Serviceability Result", "SLS", - "Performs serviceability analysis (SLS), for a given Load or Deformation.", CategoryName.Name(), - SubCategoryName.Cat7()) { - Hidden = false; // sets the initial state of the component to hidden + public class ResultsSlsGh : SlsResultFunction { + public ResultsSlsGh() { + RefreshDeformation(DefaultUnits.StrainUnitResult, DefaultUnits.CurvatureUnit); + RefreshSecantStiffness(DefaultUnits.AxialStiffnessUnit, DefaultUnits.BendingStiffnessUnit); } + } - // This region handles how the component in displayed on the ribbon including name, exposure level and icon + public class ResultsSls : ComponentAdapter { + public ResultsSls() { Hidden = true; Category = CategoryName.Name(); SubCategory = SubCategoryName.Cat7(); } public override Guid ComponentGuid => new Guid("27ba3ec5-b94c-43ad-8623-087540413628"); public override GH_Exposure Exposure => GH_Exposure.primary; public override OasysPluginInfo PluginInfo => AdSecGH.PluginInfo.Instance; protected override Bitmap Icon => Resources.SLS; - - protected override void RegisterInputParams(GH_InputParamManager pManager) { - pManager.AddGenericParameter("Results", "Res", "AdSec Results to perform serviceability check on.", - GH_ParamAccess.item); - pManager.AddGenericParameter("Load", "Ld", - "AdSec Load (Load or Deformation) for which the strength results are to be calculated.", GH_ParamAccess.item); - } - - protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - string strainUnitAbbreviation = Strain.GetAbbreviation(DefaultUnits.StrainUnitResult); - IQuantity curvature = new Curvature(0, DefaultUnits.CurvatureUnit); - string curvatureUnitAbbreviation = string.Concat(curvature.ToString().Where(char.IsLetter)); - IQuantity axial = new AxialStiffness(0, DefaultUnits.AxialStiffnessUnit); - string axialUnitAbbreviation = string.Concat(axial.ToString().Where(char.IsLetter)); - IQuantity bending = new BendingStiffness(0, DefaultUnits.BendingStiffnessUnit); - string bendingUnitAbbreviation = string.Concat(bending.ToString().Where(char.IsLetter)); - IQuantity moment = new Moment(0, DefaultUnits.MomentUnit); - string momentUnitAbbreviation = string.Concat(moment.ToString().Where(char.IsLetter)); - - pManager.AddGenericParameter("Load", "Ld", - $"The section load under the applied action.{Environment.NewLine}If the applied deformation is outside the capacity range of the section, the returned load will be zero.", - GH_ParamAccess.item); - pManager.AddGenericParameter("Cracks", "Cks", - $"Crack results are calculated at bar positions or section surfaces depending on the Design Code specifications.{Environment.NewLine}If the applied action is outside the capacity range of the section, the returned list will be empty. See MaximumCrack output for the crack result corresponding to the maximum crack width.", GH_ParamAccess.item); - - pManager.AddGenericParameter("MaximumCrack", "Crk", - $"The crack result from Cracks that corresponds to the maximum crack width.{Environment.NewLine}If the applied action is outside the capacity range of the section, the returned maximum width crack result will be maximum double value.", GH_ParamAccess.item); - - pManager.AddNumberParameter("CrackUtil", "Uc", - $"The ratio of the applied load (moment and axial) to the load (moment and axial) in the same direction that would cause the section to crack. Ratio > 1 means section is cracked.{Environment.NewLine}The section is cracked when the cracking utilisation ratio is greater than 1. If the applied load is outside the capacity range of the section, the cracking utilisation will be maximum double value.", GH_ParamAccess.item); - - pManager.AddVectorParameter("Deformation", "Def", - $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{strainUnitAbbreviation}],{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{curvatureUnitAbbreviation}],{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{curvatureUnitAbbreviation}]", GH_ParamAccess.item); - - pManager.AddVectorParameter("SecantStiffness", "Es", - $"The secant stiffness under the applied action. The output is a vector representing:{Environment.NewLine}X: Axial stiffness [{axialUnitAbbreviation}],{Environment.NewLine}Y: The bending stiffness about the y-axis in the local coordinate system [{bendingUnitAbbreviation}],{Environment.NewLine}Z: The bending stiffness about the z-axis in the local coordinate system [{bendingUnitAbbreviation}]", GH_ParamAccess.item); - - pManager.AddIntervalParameter("Uncracked Moment Ranges", "MRs", - $"The range of moments (in the direction of the applied moment, assuming constant axial force) over which the section remains uncracked. Moment values are in [{momentUnitAbbreviation}]", - GH_ParamAccess.list); - } - - protected override void SolveInstance(IGH_DataAccess DA) { - // get solution input - var solution = this.GetSolutionGoo(DA, 0); - - IServiceabilityResult sls = null; - - // get load - can be either load or deformation - var gh_typ = new GH_ObjectWrapper(); - if (DA.GetData(1, ref gh_typ)) { - // try cast directly to quantity type - if (gh_typ.Value is AdSecLoadGoo load) { - sls = solution.Value.Serviceability.Check(load.Value); - } else if (gh_typ.Value is AdSecDeformationGoo def) { - sls = solution.Value.Serviceability.Check(def.Value); - } else { - AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"Unable to convert {Params.Input[1].NickName} to AdSec Load"); - return; - } - } else { - AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, - $"Input parameter {Params.Input[1].NickName} failed to collect data!"); - return; - } - - DA.SetData(0, new AdSecLoadGoo(sls.Load, solution.LocalPlane)); - - var cracks = new List(); - foreach (var crack in sls.Cracks) { - cracks.Add(new AdSecCrackGoo(crack, solution.LocalPlane)); - } - - DA.SetDataList(1, cracks); - - if (sls.MaximumWidthCrack != null && sls.MaximumWidthCrack.Width.Meters < 1) { - DA.SetData(2, new AdSecCrackGoo(sls.MaximumWidthCrack, solution.LocalPlane)); - } - - double util = sls.CrackingUtilisation.As(RatioUnit.DecimalFraction); - DA.SetData(3, util); - if (util > 1) { - if (cracks.Count == 0) { - AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, - "The section is failing and the cracks are so large we can't even compute them!"); - } else { - AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, "The section is cracked"); - } - } - - DA.SetData(4, - new Vector3d(sls.Deformation.X.As(DefaultUnits.StrainUnitResult), - sls.Deformation.YY.As(DefaultUnits.CurvatureUnit), sls.Deformation.ZZ.As(DefaultUnits.CurvatureUnit))); - - DA.SetData(5, - new Vector3d(sls.SecantStiffness.X.As(DefaultUnits.AxialStiffnessUnit), - sls.SecantStiffness.YY.As(DefaultUnits.BendingStiffnessUnit), - sls.SecantStiffness.ZZ.As(DefaultUnits.BendingStiffnessUnit))); - - var momentRanges = new List(); - foreach (var mrng in sls.UncrackedMomentRanges) { - var interval = new Interval(mrng.Min.As(DefaultUnits.MomentUnit), mrng.Max.As(DefaultUnits.MomentUnit)); - momentRanges.Add(new GH_Interval(interval)); - } - - DA.SetDataList(6, momentRanges); - } } + } diff --git a/AdSecGH/Helpers/BusinessExtensions.cs b/AdSecGH/Helpers/BusinessExtensions.cs index 50337bb3..6f7874ba 100644 --- a/AdSecGH/Helpers/BusinessExtensions.cs +++ b/AdSecGH/Helpers/BusinessExtensions.cs @@ -129,6 +129,31 @@ private static readonly Dictionary> ToGhParam a => new Param_Integer { Name = a.Name, NickName = a.NickName, Description = a.Description, Access = GetAccess(a), } + }, { + typeof(DeformationParameter), + a => new Param_GenericObject { + Name = a.Name, NickName = a.NickName, Description = a.Description, Access = GetAccess(a), + } + },{ + typeof(GenericParameter), + a => new Param_GenericObject { + Name = a.Name, NickName = a.NickName, Description = a.Description, Access = GetAccess(a), + } + },{ + typeof(CrackArrayParameter), + a => new Param_GenericObject { + Name = a.Name, NickName = a.NickName, Description = a.Description, Access = GetAccess(a), + } + },{ + typeof(SecantStiffnessParameter), + a => new Param_GenericObject { + Name = a.Name, NickName = a.NickName, Description = a.Description, Access = GetAccess(a), + } + },{ + typeof(IntervalArrayParameter), + a => new Param_GenericObject { + Name = a.Name, NickName = a.NickName, Description = a.Description, Access = GetAccess(a), + } } }; @@ -169,6 +194,33 @@ private static readonly Dictionary> ToGoo var load = (a as LoadParameter).Value; return new AdSecLoadGoo(load); } + },{ typeof(IntervalArrayParameter), a => { + var intervals = (a as IntervalArrayParameter).Value; + var ranges = new List(); + foreach (var interval in intervals) { + ranges.Add(new GH_Interval(new Interval(interval.Item1, interval.Item2))); + } + return ranges; + } + },{ typeof(SecantStiffnessParameter), a => { + var stiffness = (a as SecantStiffnessParameter).Value; + return new Vector3d(stiffness.X.As(DefaultUnits.AxialStiffnessUnit), + stiffness.YY.As(DefaultUnits.BendingStiffnessUnit), + stiffness.ZZ.As(DefaultUnits.BendingStiffnessUnit)); + } + } + ,{ typeof(CrackArrayParameter), a => { + var cracks = (a as CrackArrayParameter).Value; + var cracksGoo = new List(); + foreach (var crack in cracks) { + cracksGoo.Add(new AdSecCrackGoo(crack)); + } + return cracksGoo; + } + },{ typeof(DeformationParameter), a => { + var deformation = (a as DeformationParameter).Value; + return new AdSecDeformationGoo(deformation); + } } }; diff --git a/AdSecGH/Helpers/ComponentAdapter.cs b/AdSecGH/Helpers/ComponentAdapter.cs index 0d17c775..90f8f0bc 100644 --- a/AdSecGH/Helpers/ComponentAdapter.cs +++ b/AdSecGH/Helpers/ComponentAdapter.cs @@ -37,6 +37,9 @@ protected override void SolveInstance(IGH_DataAccess DA) { foreach (var warning in function.WarningMessages) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, warning); } + foreach (var remark in function.RemarkMessages) { + AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, remark); + } } BusinessComponent.SetOutputValues(this, DA); diff --git a/AdSecGH/Helpers/Extensions/CoreToGhExtensions.cs b/AdSecGH/Helpers/Extensions/CoreToGhExtensions.cs index b6a826e0..a30ebd0e 100644 --- a/AdSecGH/Helpers/Extensions/CoreToGhExtensions.cs +++ b/AdSecGH/Helpers/Extensions/CoreToGhExtensions.cs @@ -12,6 +12,26 @@ public static Plane ToGh(this OasysPlane plane) { return new Plane(origin, x, y); } + public static OasysPlane ToOasys(this Plane plane) { + var oasysPlane = new OasysPlane(); + oasysPlane.Origin = new OasysPoint { + X = plane.Origin.X, + Y = plane.Origin.Y, + Z = plane.Origin.Z + }; + oasysPlane.XAxis = new OasysPoint { + X = plane.XAxis.X, + Y = plane.XAxis.Y, + Z = plane.XAxis.Z + }; + oasysPlane.YAxis = new OasysPoint { + X = plane.YAxis.X, + Y = plane.YAxis.Y, + Z = plane.YAxis.Z + }; + return oasysPlane; + } + public static Point3d ToGhPoint(this OasysPoint point) { return new Point3d(point.X, point.Y, point.Z); } diff --git a/AdSecGH/Parameters/AdSecCrackGoo.cs b/AdSecGH/Parameters/AdSecCrackGoo.cs index 02e2146c..67eb3371 100644 --- a/AdSecGH/Parameters/AdSecCrackGoo.cs +++ b/AdSecGH/Parameters/AdSecCrackGoo.cs @@ -1,6 +1,10 @@ using System; using System.Drawing; +using AdSecCore.Functions; + +using AdSecGH.Helpers; + using Grasshopper; using Grasshopper.Kernel; using Grasshopper.Kernel.Types; @@ -11,9 +15,8 @@ using OasysGH.Parameters; using Rhino.Geometry; - namespace AdSecGH.Parameters { - public class AdSecCrackGoo : GH_OasysGeometricGoo, IGH_PreviewData { + public class AdSecCrackGoo : GH_OasysGeometricGoo, IGH_PreviewData { public static string Description => "AdSec Crack Parameter"; public static string Name => "Crack"; public static string NickName => "Cr"; @@ -32,34 +35,36 @@ public override BoundingBox Boundingbox { public override BoundingBox ClippingBox => Boundingbox; public override OasysPluginInfo PluginInfo => AdSecGH.PluginInfo.Instance; private Line m_line; - private Plane m_plane; - private Point3d m_point = Point3d.Unset; + private Point3d m_point; - public AdSecCrackGoo(ICrack item) : base(item) { + public AdSecCrackGoo(ICrack crackLoad, Plane plane) : base(new CrackLoad() { Load = crackLoad, Plane = plane.ToOasys() }) { + Initialize(Value.Plane); + } + public AdSecCrackGoo(CrackLoad crackLoad) : base(crackLoad) { + Initialize(Value.Plane); } - public AdSecCrackGoo(ICrack crack, Plane local) : base(crack) { - m_value = crack; - m_plane = local; + public void Initialize(OasysPlane OasysPlane) { + var plane = OasysPlane.ToGh(); // create point from crack position in global axis var point = new Point3d( - crack.Position.Y.Value, - crack.Position.Z.Value, + m_value.Load.Position.Y.Value, + m_value.Load.Position.Z.Value, 0); // remap to local coordinate system - var mapFromLocal = Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, local); + var mapFromLocal = Rhino.Geometry.Transform.PlaneToPlane(Plane.WorldXY, plane); point.Transform(mapFromLocal); m_point = point; // move starting point of line by half the width - var halfCrack = new Vector3d(local.ZAxis); + var halfCrack = new Vector3d(plane.ZAxis); halfCrack.Unitize(); halfCrack = new Vector3d( - halfCrack.X * crack.Width.Value / 2, - halfCrack.Y * crack.Width.Value / 2, - halfCrack.Z * crack.Width.Value / 2); + halfCrack.X * m_value.Load.Width.Value / 2, + halfCrack.Y * m_value.Load.Width.Value / 2, + halfCrack.Z * m_value.Load.Width.Value / 2); var move = Rhino.Geometry.Transform.Translation(halfCrack); var crackStart = new Point3d(m_point); @@ -69,9 +74,9 @@ public AdSecCrackGoo(ICrack crack, Plane local) : base(crack) { var crackWidth = new Vector3d(halfCrack); crackWidth.Unitize(); crackWidth = new Vector3d( - crackWidth.X * crack.Width.Value * -1, - crackWidth.Y * crack.Width.Value * -1, - crackWidth.Z * crack.Width.Value * -1); + crackWidth.X * m_value.Load.Width.Value * -1, + crackWidth.Y * m_value.Load.Width.Value * -1, + crackWidth.Z * m_value.Load.Width.Value * -1); m_line = new Line(crackStart, crackWidth); } @@ -85,7 +90,7 @@ public override bool CastFrom(object source) { public override bool CastTo(out Q target) { if (typeof(Q).IsAssignableFrom(typeof(AdSecCrackGoo))) { - target = (Q)(object)new AdSecCrackGoo(Value, m_plane); + target = (Q)(object)new AdSecCrackGoo(Value); return true; } @@ -100,12 +105,12 @@ public override bool CastTo(out Q target) { } if (typeof(Q).IsAssignableFrom(typeof(Vector3d))) { - target = (Q)(object)new Vector3d(Value.Width.Value, m_point.Y, m_point.Z); + target = (Q)(object)new Vector3d(Value.Load.Width.Value, m_point.Y, m_point.Z); return true; } if (typeof(Q).IsAssignableFrom(typeof(GH_Vector))) { - target = (Q)(object)new GH_Vector(new Vector3d(Value.Width.Value, m_point.Y, m_point.Z)); + target = (Q)(object)new GH_Vector(new Vector3d(Value.Load.Width.Value, m_point.Y, m_point.Z)); return true; } @@ -120,12 +125,12 @@ public override bool CastTo(out Q target) { } if (typeof(Q).IsAssignableFrom(typeof(GH_UnitNumber))) { - target = (Q)(object)new GH_UnitNumber(Value.Width); + target = (Q)(object)new GH_UnitNumber(Value.Load.Width); return true; } if (typeof(Q).IsAssignableFrom(typeof(GH_Number))) { - target = (Q)(object)new GH_Number(Value.Width.Value); + target = (Q)(object)new GH_Number(Value.Load.Width.Value); return true; } @@ -153,7 +158,7 @@ public override IGH_GeometricGoo Duplicate() { } public override IGH_GeometricGoo DuplicateGeometry() { - var dup = new AdSecCrackGoo(Value, m_plane); + var dup = new AdSecCrackGoo(Value); return dup; } @@ -178,7 +183,7 @@ public override IGH_GeometricGoo Morph(SpaceMorph xmorph) { public override string ToString() { return - $"AdSec {TypeName} {{Y:{Math.Round(Value.Position.Y.Value, 4)}{Value.Position.Y.Unit}, Z:{Math.Round(Value.Position.Z.Value, 4)}{Value.Position.Z.Unit}, Width:{Math.Round(Value.Width.Value, 4)}{Value.Width.Unit}}}"; + $"AdSec {TypeName} {{Y:{Math.Round(Value.Load.Position.Y.Value, 4)}{Value.Load.Position.Y.Unit}, Z:{Math.Round(Value.Load.Position.Z.Value, 4)}{Value.Load.Position.Z.Unit}, Width:{Math.Round(Value.Load.Width.Value, 4)}{Value.Load.Width.Unit}}}"; } public override IGH_GeometricGoo Transform(Transform xform) { From 72ac17dea2db51d19e1842b6ee6461d6acbcf8a8 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Tue, 11 Mar 2025 13:28:10 +0530 Subject: [PATCH 03/14] feat(SlsResultFunctionTest): test for SLS results --- AdSecCoreTests/SlsResultsFunctionTests.cs | 99 +++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 AdSecCoreTests/SlsResultsFunctionTests.cs diff --git a/AdSecCoreTests/SlsResultsFunctionTests.cs b/AdSecCoreTests/SlsResultsFunctionTests.cs new file mode 100644 index 00000000..6f43acad --- /dev/null +++ b/AdSecCoreTests/SlsResultsFunctionTests.cs @@ -0,0 +1,99 @@ +using AdSecCore; +using AdSecCore.Builders; +using AdSecCore.Functions; + +using Oasys.AdSec; + +using OasysUnits; +using OasysUnits.Units; + +namespace AdSecCoreTests.Functions { + public class SlsResultFunctionTest { + private readonly SlsResultFunction _component; + private static SectionSolution? Solution { get; set; } = null; + public SlsResultFunctionTest() { + _component = new SlsResultFunction(); + if (Solution == null) { + Solution = new SolutionBuilder().Build(); + } + _component.SolutionInput.Value = Solution; + _component.LoadInput.Value = ILoad.Create(Force.FromKilonewtons(100), Moment.FromKilonewtonMeters(100), Moment.Zero); + } + + [Fact] + public void ShouldHaveCorrectMetadata() { + Assert.Equal("Find Crack Load", _component.Metadata.Name); + Assert.Equal("CrackLd", _component.Metadata.NickName); + Assert.Equal("Increases the load until set crack width is reached", _component.Metadata.Description); + } + + + [Fact] + public void ShouldHaveCorrectInputAttributes() { + var inputs = _component.GetAllInputAttributes(); + Assert.Equal(2, inputs.Length); + Assert.IsType(inputs[0]); + Assert.IsType(inputs[1]); + } + + [Fact] + public void ShouldHaveCorrectOutputAttributes() { + var outputs = _component.GetAllOutputAttributes(); + Assert.Equal(7, outputs.Length); + Assert.IsType(outputs[0]); + Assert.IsType(outputs[1]); + Assert.IsType(outputs[2]); + Assert.IsType(outputs[3]); + Assert.IsType(outputs[4]); + Assert.IsType(outputs[5]); + Assert.IsType(outputs[6]); + } + + [Fact] + public void ShouldRefreshDeformationDescription() { + _component.RefreshDeformation(StrainUnit.Ratio, CurvatureUnit.PerMeter); + Assert.Contains("Strain [ε]", _component.DeformationOutput.Description); + Assert.Contains("Curvature around zz (so in local y-direction) [m]", _component.DeformationOutput.Description); + Assert.Contains("Curvature around yy (so in local z-direction) [m]", _component.DeformationOutput.Description); + } + + [Fact] + public void ShouldRefreshSecantStiffnessDescription() { + _component.RefreshSecantStiffness(AxialStiffnessUnit.Newton, BendingStiffnessUnit.NewtonSquareMeter); + Assert.Contains("Axial stiffness [N]", _component.SecantStiffnessOutput.Description); + Assert.Contains("The bending stiffness about the y-axis in the local coordinate system [Nm]", _component.SecantStiffnessOutput.Description); + Assert.Contains("The bending stiffness about the z-axis in the local coordinate system [Nm]", _component.SecantStiffnessOutput.Description); + } + + [Fact] + public void ShouldRefreshUncrackedMomentRangesDescription() { + _component.RefreshUncrackedMomentRanges(MomentUnit.NewtonMeter); + Assert.Contains("Moment values are in [Nm]", _component.UncrackedMomentRangesOutput.Description); + } + + [Fact] + public void ShouldComputeCorrectly() { + _component.Compute(); + var expectedLoad = ILoad.Create(Force.FromKilonewtons(100), Moment.FromKilonewtonMeters(100), Moment.Zero); + var expectedDeformation = IDeformation.Create(Strain.FromRatio(0.0014), Curvature.FromPerMeters(0.0064), Curvature.FromPerMeters(0.0029)); + Assert.True(IsLoadEqual(expectedLoad, _component.LoadOutput.Value)); + Assert.True(IsDeformationEqual(expectedDeformation, _component.DeformationOutput.Value)); + Assert.Equal(0.00208, _component.MaximumCrackOutput.Value.Load.Width.Value, new DoubleComparer()); + Assert.Equal(5.8156, _component.CrackUtilOutput.Value, new DoubleComparer()); + Assert.Single(_component.RemarkMessages); + Assert.Equal(69, _component.CrackOutput.Value.Length); + } + + private static bool IsLoadEqual(ILoad expected, ILoad calculated) { + return expected.X.Value.Equals(calculated.X.Value) && expected.YY.Value.Equals(calculated.YY.Value) && expected.ZZ.Value.Equals(calculated.ZZ.Value); + } + + private static bool IsDeformationEqual(IDeformation expected, IDeformation calculated) { + var tolernaceStrain = Strain.FromRatio(0.00001); + var tolernaceCurvature = Curvature.FromPerMeters(0.0001); + return expected.X.Equals(calculated.X, tolernaceStrain) && expected.YY.Equals(calculated.YY, tolernaceCurvature) && expected.ZZ.Equals(calculated.ZZ, tolernaceCurvature); + } + + + } +} From 4e0e1b5df0a952ed2bc4d3bc1b6aad219956b9ca Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Tue, 11 Mar 2025 17:34:48 +0530 Subject: [PATCH 04/14] test(ResultsSLS.cs): code refactored and test added --- AdSecCore/Functions/IFunction.cs | 1 + AdSecCore/Functions/SlsResulFunction.cs | 5 +- AdSecGH/Components/6_Results/ResultsSLS.cs | 12 -- AdSecGH/Helpers/ComponentAdapter.cs | 6 + .../Helpers/Extensions/CoreToGhExtensions.cs | 20 --- AdSecGH/Parameters/AdSecCrackGoo.cs | 13 +- .../Components/6_Results/ResultsSlsTests.cs | 114 ++++++++++++++++++ AdSecGHTests/Helpers/ComponentTestHelper.cs | 2 +- 8 files changed, 125 insertions(+), 48 deletions(-) create mode 100644 AdSecGHTests/Components/6_Results/ResultsSlsTests.cs diff --git a/AdSecCore/Functions/IFunction.cs b/AdSecCore/Functions/IFunction.cs index 04d91c64..ccddb3a2 100644 --- a/AdSecCore/Functions/IFunction.cs +++ b/AdSecCore/Functions/IFunction.cs @@ -19,6 +19,7 @@ public interface IFunction { } public abstract class Function : IFunction { + public List ErrorMessages { get; set; } = new List(); public List WarningMessages { get; set; } = new List(); public List RemarkMessages { get; set; } = new List(); public static string StrainUnitAbbreviation(StrainUnit unit) { diff --git a/AdSecCore/Functions/SlsResulFunction.cs b/AdSecCore/Functions/SlsResulFunction.cs index 6f0df42c..7737cb15 100644 --- a/AdSecCore/Functions/SlsResulFunction.cs +++ b/AdSecCore/Functions/SlsResulFunction.cs @@ -1,13 +1,11 @@  using System; using System.Collections.Generic; -using System.Linq; using AdSecGHCore.Constants; using Oasys.AdSec; -using OasysUnits; using OasysUnits.Units; namespace AdSecCore.Functions { @@ -136,7 +134,8 @@ public override void Compute() { sls = solution.Serviceability.Check(deformation); break; default: - throw new ArgumentException("Invalid Load Input"); + ErrorMessages.Add("Invalid Load Input"); + return; } LoadOutput.Value = sls.Load; diff --git a/AdSecGH/Components/6_Results/ResultsSLS.cs b/AdSecGH/Components/6_Results/ResultsSLS.cs index 3bf4669f..ff2333ce 100644 --- a/AdSecGH/Components/6_Results/ResultsSLS.cs +++ b/AdSecGH/Components/6_Results/ResultsSLS.cs @@ -1,31 +1,19 @@ using System; -using System.Collections.Generic; using System.Drawing; -using System.Linq; using AdSecCore.Functions; -using AdSecGH.Helpers; -using AdSecGH.Parameters; using AdSecGH.Properties; using AdSecGHCore.Constants; using Grasshopper.Kernel; -using Grasshopper.Kernel.Types; -using Oasys.AdSec; using Oasys.GH.Helpers; using OasysGH; -using OasysGH.Components; using OasysGH.Units; -using OasysUnits; -using OasysUnits.Units; - -using Rhino.Geometry; - namespace AdSecGH.Components { public class ResultsSlsGh : SlsResultFunction { public ResultsSlsGh() { diff --git a/AdSecGH/Helpers/ComponentAdapter.cs b/AdSecGH/Helpers/ComponentAdapter.cs index 90f8f0bc..75fab8cb 100644 --- a/AdSecGH/Helpers/ComponentAdapter.cs +++ b/AdSecGH/Helpers/ComponentAdapter.cs @@ -40,6 +40,12 @@ protected override void SolveInstance(IGH_DataAccess DA) { foreach (var remark in function.RemarkMessages) { AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, remark); } + + foreach (var error in function.ErrorMessages) { + AddRuntimeMessage(GH_RuntimeMessageLevel.Error, error); + } + + if (function.ErrorMessages.Count > 0) { return; } } BusinessComponent.SetOutputValues(this, DA); diff --git a/AdSecGH/Helpers/Extensions/CoreToGhExtensions.cs b/AdSecGH/Helpers/Extensions/CoreToGhExtensions.cs index a30ebd0e..b6a826e0 100644 --- a/AdSecGH/Helpers/Extensions/CoreToGhExtensions.cs +++ b/AdSecGH/Helpers/Extensions/CoreToGhExtensions.cs @@ -12,26 +12,6 @@ public static Plane ToGh(this OasysPlane plane) { return new Plane(origin, x, y); } - public static OasysPlane ToOasys(this Plane plane) { - var oasysPlane = new OasysPlane(); - oasysPlane.Origin = new OasysPoint { - X = plane.Origin.X, - Y = plane.Origin.Y, - Z = plane.Origin.Z - }; - oasysPlane.XAxis = new OasysPoint { - X = plane.XAxis.X, - Y = plane.XAxis.Y, - Z = plane.XAxis.Z - }; - oasysPlane.YAxis = new OasysPoint { - X = plane.YAxis.X, - Y = plane.YAxis.Y, - Z = plane.YAxis.Z - }; - return oasysPlane; - } - public static Point3d ToGhPoint(this OasysPoint point) { return new Point3d(point.X, point.Y, point.Z); } diff --git a/AdSecGH/Parameters/AdSecCrackGoo.cs b/AdSecGH/Parameters/AdSecCrackGoo.cs index 67eb3371..2f82670a 100644 --- a/AdSecGH/Parameters/AdSecCrackGoo.cs +++ b/AdSecGH/Parameters/AdSecCrackGoo.cs @@ -9,8 +9,6 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Types; -using Oasys.AdSec; - using OasysGH; using OasysGH.Parameters; @@ -37,16 +35,8 @@ public override BoundingBox Boundingbox { private Line m_line; private Point3d m_point; - public AdSecCrackGoo(ICrack crackLoad, Plane plane) : base(new CrackLoad() { Load = crackLoad, Plane = plane.ToOasys() }) { - Initialize(Value.Plane); - } public AdSecCrackGoo(CrackLoad crackLoad) : base(crackLoad) { - Initialize(Value.Plane); - } - - public void Initialize(OasysPlane OasysPlane) { - var plane = OasysPlane.ToGh(); - + var plane = Value.Plane.ToGh(); // create point from crack position in global axis var point = new Point3d( m_value.Load.Position.Y.Value, @@ -80,7 +70,6 @@ public void Initialize(OasysPlane OasysPlane) { m_line = new Line(crackStart, crackWidth); } - public override bool CastFrom(object source) { if (source == null) { return false; diff --git a/AdSecGHTests/Components/6_Results/ResultsSlsTests.cs b/AdSecGHTests/Components/6_Results/ResultsSlsTests.cs new file mode 100644 index 00000000..ce1e8c5c --- /dev/null +++ b/AdSecGHTests/Components/6_Results/ResultsSlsTests.cs @@ -0,0 +1,114 @@ +using System; + +using AdSecCore.Builders; +using AdSecCore.Functions; + +using AdSecGH.Components; +using AdSecGH.Properties; + +using AdSecGHCore.Constants; + +using AdSecGHTests.Helpers; + +using Grasshopper.Kernel; + +using Oasys.AdSec; + +using OasysUnits; + +using Xunit; + +namespace AdSecGHTests.Components { + [Collection("GrasshopperFixture collection")] + public class ResultsSlsTest { + private readonly ResultsSls _component; + private static SectionSolution Solution { get; set; } = null; + + public ResultsSlsTest() { + _component = new ResultsSls(); + if (Solution == null) { + Solution = new SolutionBuilder().Build(); + } + ComponentTestHelper.SetInput(_component, Solution, 0); + } + + private void SetLoad(bool correctLoad = true) { + if (correctLoad) { + ComponentTestHelper.SetInput(_component, ILoad.Create(Force.FromKilonewtons(100), Moment.FromKilonewtonMeters(100), Moment.Zero), 1); + + } else { + ComponentTestHelper.SetInput(_component, string.Empty, 1); + } + ComponentTestHelper.ComputeData(_component); + } + + private void SetDeformation() { + ComponentTestHelper.SetInput(_component, IDeformation.Create(Strain.FromRatio(0.00001), Curvature.Zero, Curvature.Zero), 1); + } + + private void SetLargeLoad() { + ComponentTestHelper.SetInput(_component, ILoad.Create(Force.FromKilonewtons(-100), Moment.FromKilonewtonMeters(900), Moment.Zero), 1); + ComponentTestHelper.GetOutput(_component); + } + + [Fact] + public void ComponentGuid_IsCorrect() { + Assert.Equal(new Guid("27ba3ec5-b94c-43ad-8623-087540413628"), _component.ComponentGuid); + } + + [Fact] + public void Exposure_IsPrimary() { + Assert.Equal(GH_Exposure.primary, _component.Exposure); + } + + [Fact] + public void PluginInfo_IsCorrect() { + Assert.Equal(AdSecGH.PluginInfo.Instance, _component.PluginInfo); + } + + [Fact] + public void Icon_IsCorrect() { + Assert.Equal(Resources.SLS.ToString(), _component.Icon_24x24.ToString()); + } + + [Fact] + public void Category_IsCorrect() { + Assert.Equal(CategoryName.Name(), _component.Category); + } + + [Fact] + public void SubCategory_IsCorrect() { + Assert.Equal(SubCategoryName.Cat7(), _component.SubCategory); + } + + [Fact] + public void Hidden_IsTrue() { + Assert.True(_component.Hidden); + } + + [Fact] + public void ShouldHaveRemarkWhenUtiliztionIsGreaterThanOne() { + SetLoad(); + Assert.Single(_component.RuntimeMessages(GH_RuntimeMessageLevel.Remark)); + } + + [Fact] + public void ShouldHaveErrorForWrongLoad() { + SetLoad(false); + Assert.Single(_component.RuntimeMessages(GH_RuntimeMessageLevel.Error)); + } + + [Fact] + public void ShouldHaveWarningForHighLoad() { + SetLargeLoad(); + Assert.Single(_component.RuntimeMessages(GH_RuntimeMessageLevel.Warning)); + } + + [Fact] + public void ShouldCalculateCrackForGivenDeformation() { + SetDeformation(); + ComponentTestHelper.GetOutput(_component, 3); + Assert.NotNull(ComponentTestHelper.GetOutput(_component, 3)); + } + } +} diff --git a/AdSecGHTests/Helpers/ComponentTestHelper.cs b/AdSecGHTests/Helpers/ComponentTestHelper.cs index 113743df..baf1cd55 100644 --- a/AdSecGHTests/Helpers/ComponentTestHelper.cs +++ b/AdSecGHTests/Helpers/ComponentTestHelper.cs @@ -9,7 +9,7 @@ namespace AdSecGHTests.Helpers { public class ComponentTestHelper { - + private ComponentTestHelper() { } public static object GetOutput(GH_Component component, int index = 0, int branch = 0, int item = 0, bool forceUpdate = false) { if (forceUpdate || component.Params.Output[index].VolatileDataCount == 0) { component.ExpireSolution(true); From 256185adcbbc534ed085c68258bfe10d8a89d4b9 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Wed, 12 Mar 2025 09:40:40 +0530 Subject: [PATCH 05/14] fix(SlsResultFunction): file name corrected --- AdSecCore/Functions/{SlsResulFunction.cs => SlsResultFunction.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename AdSecCore/Functions/{SlsResulFunction.cs => SlsResultFunction.cs} (100%) diff --git a/AdSecCore/Functions/SlsResulFunction.cs b/AdSecCore/Functions/SlsResultFunction.cs similarity index 100% rename from AdSecCore/Functions/SlsResulFunction.cs rename to AdSecCore/Functions/SlsResultFunction.cs From 92cef00f71defef698018a3791b7b5d384927494 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Wed, 12 Mar 2025 09:44:47 +0530 Subject: [PATCH 06/14] fix(SlsResultFunctionTests.cs): make file name singular --- .../{SlsResultsFunctionTests.cs => SlsResultFunctionTests.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename AdSecCoreTests/{SlsResultsFunctionTests.cs => SlsResultFunctionTests.cs} (100%) diff --git a/AdSecCoreTests/SlsResultsFunctionTests.cs b/AdSecCoreTests/SlsResultFunctionTests.cs similarity index 100% rename from AdSecCoreTests/SlsResultsFunctionTests.cs rename to AdSecCoreTests/SlsResultFunctionTests.cs From 9bec26a3f90971fae6b689981a2da079342c0f59 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Wed, 12 Mar 2025 10:04:43 +0530 Subject: [PATCH 07/14] refactor(IFunction): remove abbreviation related function --- AdSecCore/Functions/IFunction.cs | 24 ------------------------ AdSecCore/Functions/SlsResultFunction.cs | 7 ++++--- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/AdSecCore/Functions/IFunction.cs b/AdSecCore/Functions/IFunction.cs index ccddb3a2..249f1799 100644 --- a/AdSecCore/Functions/IFunction.cs +++ b/AdSecCore/Functions/IFunction.cs @@ -22,30 +22,6 @@ public abstract class Function : IFunction { public List ErrorMessages { get; set; } = new List(); public List WarningMessages { get; set; } = new List(); public List RemarkMessages { get; set; } = new List(); - public static string StrainUnitAbbreviation(StrainUnit unit) { - return Strain.GetAbbreviation(unit); - } - - public static string CurvatureUnitAbbreviation(CurvatureUnit unit) { - var curvature = new Curvature(0, unit); - return string.Concat(curvature.ToString().Where(char.IsLetter)); - } - - public static string AxialUnitAbbreviation(AxialStiffnessUnit unit) { - var axial = new AxialStiffness(0, unit); - return string.Concat(axial.ToString().Where(char.IsLetter)); - - } - - public static string BendingStiffnessUnitAbbreviation(BendingStiffnessUnit unit) { - var bending = new BendingStiffness(0, unit); - return string.Concat(bending.ToString().Where(char.IsLetter)); - } - - public static string MomentUnitAbbreviation(MomentUnit unit) { - var bending = new Moment(0, unit); - return string.Concat(bending.ToString().Where(char.IsLetter)); - } public abstract FuncAttribute Metadata { get; set; } public abstract Organisation Organisation { get; set; } diff --git a/AdSecCore/Functions/SlsResultFunction.cs b/AdSecCore/Functions/SlsResultFunction.cs index 7737cb15..b08357ae 100644 --- a/AdSecCore/Functions/SlsResultFunction.cs +++ b/AdSecCore/Functions/SlsResultFunction.cs @@ -6,6 +6,7 @@ using Oasys.AdSec; +using OasysUnits; using OasysUnits.Units; namespace AdSecCore.Functions { @@ -110,15 +111,15 @@ public override Attribute[] GetAllOutputAttributes() { } public void RefreshDeformation(StrainUnit strainUnit, CurvatureUnit curvatureUnit) { - DeformationOutput.Description = $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{StrainUnitAbbreviation(strainUnit)}]{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{CurvatureUnitAbbreviation(curvatureUnit)}]{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{CurvatureUnitAbbreviation(curvatureUnit)}]"; + DeformationOutput.Description = $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{Strain.GetAbbreviation(strainUnit)}]{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{Curvature.GetAbbreviation(curvatureUnit)}]{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{Curvature.GetAbbreviation(curvatureUnit)}]"; } public void RefreshSecantStiffness(AxialStiffnessUnit axialUnit, BendingStiffnessUnit bendingUnit) { - SecantStiffnessOutput.Description = $"The secant stiffness under the applied action. The output is a vector representing:{Environment.NewLine}X: Axial stiffness [{AxialUnitAbbreviation(axialUnit)}],{Environment.NewLine}Y: The bending stiffness about the y-axis in the local coordinate system [{BendingStiffnessUnitAbbreviation(bendingUnit)}],{Environment.NewLine}Z: The bending stiffness about the z-axis in the local coordinate system [{BendingStiffnessUnitAbbreviation(bendingUnit)}]"; + SecantStiffnessOutput.Description = $"The secant stiffness under the applied action. The output is a vector representing:{Environment.NewLine}X: Axial stiffness [{AxialStiffness.GetAbbreviation(axialUnit)}],{Environment.NewLine}Y: The bending stiffness about the y-axis in the local coordinate system [{BendingStiffness.GetAbbreviation(bendingUnit)}],{Environment.NewLine}Z: The bending stiffness about the z-axis in the local coordinate system [{BendingStiffness.GetAbbreviation(bendingUnit)}]"; } public void RefreshUncrackedMomentRanges(MomentUnit momentUnit) { - UncrackedMomentRangesOutput.Description = $"The range of moments (in the direction of the applied moment, assuming constant axial force) over which the section remains uncracked. Moment values are in [{MomentUnitAbbreviation(momentUnit)}]"; + UncrackedMomentRangesOutput.Description = $"The range of moments (in the direction of the applied moment, assuming constant axial force) over which the section remains uncracked. Moment values are in [{Moment.GetAbbreviation(momentUnit)}]"; } public override void Compute() { From 05272839f4b6eb23c109dfea66a5252c2b52f329 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Wed, 12 Mar 2025 12:00:33 +0530 Subject: [PATCH 08/14] fix(SlsResultFunction): update function to use correct unit --- AdSecCore/Functions/SlsResultFunction.cs | 4 +++- AdSecCoreTests/SlsResultFunctionTests.cs | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/AdSecCore/Functions/SlsResultFunction.cs b/AdSecCore/Functions/SlsResultFunction.cs index b08357ae..efe6910b 100644 --- a/AdSecCore/Functions/SlsResultFunction.cs +++ b/AdSecCore/Functions/SlsResultFunction.cs @@ -111,7 +111,9 @@ public override Attribute[] GetAllOutputAttributes() { } public void RefreshDeformation(StrainUnit strainUnit, CurvatureUnit curvatureUnit) { - DeformationOutput.Description = $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{Strain.GetAbbreviation(strainUnit)}]{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{Curvature.GetAbbreviation(curvatureUnit)}]{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{Curvature.GetAbbreviation(curvatureUnit)}]"; + var strainAbbreviation = Strain.GetAbbreviation(strainUnit); + var curvatureAbbreviation = $"{strainAbbreviation}{Curvature.GetAbbreviation(curvatureUnit)}"; + DeformationOutput.Description = $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{strainAbbreviation}]{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{curvatureAbbreviation}]{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{curvatureAbbreviation}]"; } public void RefreshSecantStiffness(AxialStiffnessUnit axialUnit, BendingStiffnessUnit bendingUnit) { diff --git a/AdSecCoreTests/SlsResultFunctionTests.cs b/AdSecCoreTests/SlsResultFunctionTests.cs index 6f43acad..cb3a7703 100644 --- a/AdSecCoreTests/SlsResultFunctionTests.cs +++ b/AdSecCoreTests/SlsResultFunctionTests.cs @@ -53,22 +53,22 @@ public void ShouldHaveCorrectOutputAttributes() { public void ShouldRefreshDeformationDescription() { _component.RefreshDeformation(StrainUnit.Ratio, CurvatureUnit.PerMeter); Assert.Contains("Strain [ε]", _component.DeformationOutput.Description); - Assert.Contains("Curvature around zz (so in local y-direction) [m]", _component.DeformationOutput.Description); - Assert.Contains("Curvature around yy (so in local z-direction) [m]", _component.DeformationOutput.Description); + Assert.Contains("Curvature around zz (so in local y-direction) [εm⁻¹]", _component.DeformationOutput.Description); + Assert.Contains("Curvature around yy (so in local z-direction) [εm⁻¹]", _component.DeformationOutput.Description); } [Fact] public void ShouldRefreshSecantStiffnessDescription() { _component.RefreshSecantStiffness(AxialStiffnessUnit.Newton, BendingStiffnessUnit.NewtonSquareMeter); Assert.Contains("Axial stiffness [N]", _component.SecantStiffnessOutput.Description); - Assert.Contains("The bending stiffness about the y-axis in the local coordinate system [Nm]", _component.SecantStiffnessOutput.Description); - Assert.Contains("The bending stiffness about the z-axis in the local coordinate system [Nm]", _component.SecantStiffnessOutput.Description); + Assert.Contains("The bending stiffness about the y-axis in the local coordinate system [N·m²]", _component.SecantStiffnessOutput.Description); + Assert.Contains("The bending stiffness about the z-axis in the local coordinate system [N·m²]", _component.SecantStiffnessOutput.Description); } [Fact] public void ShouldRefreshUncrackedMomentRangesDescription() { _component.RefreshUncrackedMomentRanges(MomentUnit.NewtonMeter); - Assert.Contains("Moment values are in [Nm]", _component.UncrackedMomentRangesOutput.Description); + Assert.Contains("Moment values are in [N·m]", _component.UncrackedMomentRangesOutput.Description); } [Fact] From edf3463e134de504b6ad874aacb44732502c0f37 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Wed, 12 Mar 2025 17:12:32 +0530 Subject: [PATCH 09/14] refactor(ComponentAdapter): Refactor code to refresh component --- AdSecCoreTests/SlsResultFunctionTests.cs | 14 +++++++------- AdSecGH/Components/6_Results/ResultsSLS.cs | 19 +++++++++++++------ AdSecGH/Helpers/ComponentAdapter.cs | 19 +++++++++++++++++++ .../{ResultsSlsTests.cs => SlsResultTests.cs} | 8 ++++---- 4 files changed, 43 insertions(+), 17 deletions(-) rename AdSecGHTests/Components/6_Results/{ResultsSlsTests.cs => SlsResultTests.cs} (95%) diff --git a/AdSecCoreTests/SlsResultFunctionTests.cs b/AdSecCoreTests/SlsResultFunctionTests.cs index cb3a7703..3eb6e381 100644 --- a/AdSecCoreTests/SlsResultFunctionTests.cs +++ b/AdSecCoreTests/SlsResultFunctionTests.cs @@ -52,23 +52,23 @@ public void ShouldHaveCorrectOutputAttributes() { [Fact] public void ShouldRefreshDeformationDescription() { _component.RefreshDeformation(StrainUnit.Ratio, CurvatureUnit.PerMeter); - Assert.Contains("Strain [ε]", _component.DeformationOutput.Description); - Assert.Contains("Curvature around zz (so in local y-direction) [εm⁻¹]", _component.DeformationOutput.Description); - Assert.Contains("Curvature around yy (so in local z-direction) [εm⁻¹]", _component.DeformationOutput.Description); + Assert.Contains("[ε]", _component.DeformationOutput.Description); + Assert.Contains("[εm⁻¹]", _component.DeformationOutput.Description); + Assert.Contains("[εm⁻¹]", _component.DeformationOutput.Description); } [Fact] public void ShouldRefreshSecantStiffnessDescription() { _component.RefreshSecantStiffness(AxialStiffnessUnit.Newton, BendingStiffnessUnit.NewtonSquareMeter); - Assert.Contains("Axial stiffness [N]", _component.SecantStiffnessOutput.Description); - Assert.Contains("The bending stiffness about the y-axis in the local coordinate system [N·m²]", _component.SecantStiffnessOutput.Description); - Assert.Contains("The bending stiffness about the z-axis in the local coordinate system [N·m²]", _component.SecantStiffnessOutput.Description); + Assert.Contains("[N]", _component.SecantStiffnessOutput.Description); + Assert.Contains("[N·m²]", _component.SecantStiffnessOutput.Description); + Assert.Contains("[N·m²]", _component.SecantStiffnessOutput.Description); } [Fact] public void ShouldRefreshUncrackedMomentRangesDescription() { _component.RefreshUncrackedMomentRanges(MomentUnit.NewtonMeter); - Assert.Contains("Moment values are in [N·m]", _component.UncrackedMomentRangesOutput.Description); + Assert.Contains("[N·m]", _component.UncrackedMomentRangesOutput.Description); } [Fact] diff --git a/AdSecGH/Components/6_Results/ResultsSLS.cs b/AdSecGH/Components/6_Results/ResultsSLS.cs index ff2333ce..c8189263 100644 --- a/AdSecGH/Components/6_Results/ResultsSLS.cs +++ b/AdSecGH/Components/6_Results/ResultsSLS.cs @@ -1,5 +1,6 @@ using System; using System.Drawing; +using System.Linq; using AdSecCore.Functions; @@ -15,15 +16,21 @@ using OasysGH.Units; namespace AdSecGH.Components { - public class ResultsSlsGh : SlsResultFunction { - public ResultsSlsGh() { - RefreshDeformation(DefaultUnits.StrainUnitResult, DefaultUnits.CurvatureUnit); - RefreshSecantStiffness(DefaultUnits.AxialStiffnessUnit, DefaultUnits.BendingStiffnessUnit); + public class SlsResultGh : SlsResultFunction { + public SlsResultGh() { + } } - public class ResultsSls : ComponentAdapter { - public ResultsSls() { Hidden = true; Category = CategoryName.Name(); SubCategory = SubCategoryName.Cat7(); } + public class SlsResult : ComponentAdapter { + protected override void BeforeSolveInstance() { + BusinessComponent.RefreshDeformation(DefaultUnits.StrainUnitResult, DefaultUnits.CurvatureUnit); + BusinessComponent.RefreshSecantStiffness(DefaultUnits.AxialStiffnessUnit, DefaultUnits.BendingStiffnessUnit); + BusinessComponent.RefreshUncrackedMomentRanges(DefaultUnits.MomentUnit); + RefreshParameters(); + } + + public SlsResult() { Hidden = true; Category = CategoryName.Name(); SubCategory = SubCategoryName.Cat7(); } public override Guid ComponentGuid => new Guid("27ba3ec5-b94c-43ad-8623-087540413628"); public override GH_Exposure Exposure => GH_Exposure.primary; public override OasysPluginInfo PluginInfo => AdSecGH.PluginInfo.Instance; diff --git a/AdSecGH/Helpers/ComponentAdapter.cs b/AdSecGH/Helpers/ComponentAdapter.cs index 75fab8cb..01ecea06 100644 --- a/AdSecGH/Helpers/ComponentAdapter.cs +++ b/AdSecGH/Helpers/ComponentAdapter.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using AdSecCore.Functions; @@ -7,6 +8,7 @@ using OasysGH; using OasysGH.Components; +using Attribute = AdSecCore.Functions.Attribute; namespace Oasys.GH.Helpers { public abstract class ComponentAdapter : GH_OasysComponent, IDefaultValues where T : IFunction { @@ -50,6 +52,23 @@ protected override void SolveInstance(IGH_DataAccess DA) { BusinessComponent.SetOutputValues(this, DA); } + + public void RefreshParameters() { + BusinessComponent.GetAllInputAttributes().ToList().ForEach(UpdateInputFrom); + BusinessComponent.GetAllOutputAttributes().ToList().ForEach(UpdateOutputFrom); + } + + private void UpdateInputFrom(Attribute attribute) { + var param = Params.Input.Where(x => x.NickName == attribute.NickName).First(); + param.Name = attribute.Name; + param.Description = attribute.Description; + } + + private void UpdateOutputFrom(Attribute attribute) { + var param = Params.Output.Where(x => x.NickName == attribute.NickName).First(); + param.Name = attribute.Name; + param.Description = attribute.Description; + } } public interface IDefaultValues { diff --git a/AdSecGHTests/Components/6_Results/ResultsSlsTests.cs b/AdSecGHTests/Components/6_Results/SlsResultTests.cs similarity index 95% rename from AdSecGHTests/Components/6_Results/ResultsSlsTests.cs rename to AdSecGHTests/Components/6_Results/SlsResultTests.cs index ce1e8c5c..8abd8fe9 100644 --- a/AdSecGHTests/Components/6_Results/ResultsSlsTests.cs +++ b/AdSecGHTests/Components/6_Results/SlsResultTests.cs @@ -20,12 +20,12 @@ namespace AdSecGHTests.Components { [Collection("GrasshopperFixture collection")] - public class ResultsSlsTest { - private readonly ResultsSls _component; + public class SlsResultTests { + private readonly SlsResult _component; private static SectionSolution Solution { get; set; } = null; - public ResultsSlsTest() { - _component = new ResultsSls(); + public SlsResultTests() { + _component = new SlsResult(); if (Solution == null) { Solution = new SolutionBuilder().Build(); } From ba26520e4205db0610f314d02a6d59cab20c2d7d Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Wed, 12 Mar 2025 18:15:02 +0530 Subject: [PATCH 10/14] test(SlsResultTests): test that units refresh correctly --- AdSecGHTests/Components/6_Results/SlsResultTests.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/AdSecGHTests/Components/6_Results/SlsResultTests.cs b/AdSecGHTests/Components/6_Results/SlsResultTests.cs index 8abd8fe9..d22fb721 100644 --- a/AdSecGHTests/Components/6_Results/SlsResultTests.cs +++ b/AdSecGHTests/Components/6_Results/SlsResultTests.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using AdSecCore.Builders; using AdSecCore.Functions; @@ -14,7 +15,10 @@ using Oasys.AdSec; +using OasysGH.Units; + using OasysUnits; +using OasysUnits.Units; using Xunit; @@ -92,6 +96,15 @@ public void ShouldHaveRemarkWhenUtiliztionIsGreaterThanOne() { Assert.Single(_component.RuntimeMessages(GH_RuntimeMessageLevel.Remark)); } + [Fact] + public void ShouldRefreshComponent() { + var originalUnit = DefaultUnits.StrainUnitResult; + DefaultUnits.StrainUnitResult = StrainUnit.MicroStrain; + SetLoad(); + Assert.Contains("[µε]", _component.Params.Output[4].Description); + DefaultUnits.StrainUnitResult = originalUnit; + } + [Fact] public void ShouldHaveErrorForWrongLoad() { SetLoad(false); From 1bf429e051a9b8ce7f8bbbeda30294cb184f23d6 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Wed, 12 Mar 2025 18:46:38 +0530 Subject: [PATCH 11/14] refactor(ComponentAdapter): include case when nick name has been changed --- AdSecGH/Helpers/ComponentAdapter.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/AdSecGH/Helpers/ComponentAdapter.cs b/AdSecGH/Helpers/ComponentAdapter.cs index 01ecea06..4e744f58 100644 --- a/AdSecGH/Helpers/ComponentAdapter.cs +++ b/AdSecGH/Helpers/ComponentAdapter.cs @@ -59,13 +59,21 @@ public void RefreshParameters() { } private void UpdateInputFrom(Attribute attribute) { - var param = Params.Input.Where(x => x.NickName == attribute.NickName).First(); + var list = Params.Input.Where(x => x.NickName == attribute.NickName); + if (!list.Any()) { + return; + } + var param = list.First(); param.Name = attribute.Name; param.Description = attribute.Description; } private void UpdateOutputFrom(Attribute attribute) { - var param = Params.Output.Where(x => x.NickName == attribute.NickName).First(); + var list = Params.Output.Where(x => x.NickName == attribute.NickName); + if (!list.Any()) { + return; + } + var param = list.First(); param.Name = attribute.Name; param.Description = attribute.Description; } From e02cc9b362cc5d5519bf31041ae1b17b1a3233f4 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Thu, 13 Mar 2025 12:34:48 +0530 Subject: [PATCH 12/14] refactor(ResultsSLS.cs): refactor to update parameter on pre-solve instance --- AdSecCore/Functions/IFunction.cs | 9 ++++--- AdSecCore/Functions/SlsResultFunction.cs | 16 +++++++----- AdSecCoreTests/SlsResultFunctionTests.cs | 26 +++++++++---------- AdSecGH/Components/6_Results/ResultsSLS.cs | 11 +++++--- AdSecGH/Helpers/ComponentAdapter.cs | 29 ++++------------------ 5 files changed, 40 insertions(+), 51 deletions(-) diff --git a/AdSecCore/Functions/IFunction.cs b/AdSecCore/Functions/IFunction.cs index 249f1799..060a7062 100644 --- a/AdSecCore/Functions/IFunction.cs +++ b/AdSecCore/Functions/IFunction.cs @@ -1,12 +1,13 @@ using System; using System.Collections.Generic; -using System.Linq; - -using OasysUnits; -using OasysUnits.Units; namespace AdSecCore.Functions { + public struct OutputAttributeInfo { + public int Id { get; set; } + public string Description { get; set; } + } + public interface IFunction { FuncAttribute Metadata { get; set; } diff --git a/AdSecCore/Functions/SlsResultFunction.cs b/AdSecCore/Functions/SlsResultFunction.cs index efe6910b..9bbb7215 100644 --- a/AdSecCore/Functions/SlsResultFunction.cs +++ b/AdSecCore/Functions/SlsResultFunction.cs @@ -110,18 +110,22 @@ public override Attribute[] GetAllOutputAttributes() { }; } - public void RefreshDeformation(StrainUnit strainUnit, CurvatureUnit curvatureUnit) { + public static OutputAttributeInfo DeformationDescription(StrainUnit strainUnit, CurvatureUnit curvatureUnit) { var strainAbbreviation = Strain.GetAbbreviation(strainUnit); var curvatureAbbreviation = $"{strainAbbreviation}{Curvature.GetAbbreviation(curvatureUnit)}"; - DeformationOutput.Description = $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{strainAbbreviation}]{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{curvatureAbbreviation}]{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{curvatureAbbreviation}]"; + return new OutputAttributeInfo() { Id = 4, Description = $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{strainAbbreviation}]{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{curvatureAbbreviation}]{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{curvatureAbbreviation}]" }; } - public void RefreshSecantStiffness(AxialStiffnessUnit axialUnit, BendingStiffnessUnit bendingUnit) { - SecantStiffnessOutput.Description = $"The secant stiffness under the applied action. The output is a vector representing:{Environment.NewLine}X: Axial stiffness [{AxialStiffness.GetAbbreviation(axialUnit)}],{Environment.NewLine}Y: The bending stiffness about the y-axis in the local coordinate system [{BendingStiffness.GetAbbreviation(bendingUnit)}],{Environment.NewLine}Z: The bending stiffness about the z-axis in the local coordinate system [{BendingStiffness.GetAbbreviation(bendingUnit)}]"; + public static OutputAttributeInfo SecantStiffnessDescription(AxialStiffnessUnit axialUnit, BendingStiffnessUnit bendingUnit) { + return new OutputAttributeInfo() { + Id = 5, Description = $"The secant stiffness under the applied action. The output is a vector representing:{Environment.NewLine}X: Axial stiffness [{AxialStiffness.GetAbbreviation(axialUnit)}],{Environment.NewLine}Y: The bending stiffness about the y-axis in the local coordinate system [{BendingStiffness.GetAbbreviation(bendingUnit)}],{Environment.NewLine}Z: The bending stiffness about the z-axis in the local coordinate system [{BendingStiffness.GetAbbreviation(bendingUnit)}]" + }; } - public void RefreshUncrackedMomentRanges(MomentUnit momentUnit) { - UncrackedMomentRangesOutput.Description = $"The range of moments (in the direction of the applied moment, assuming constant axial force) over which the section remains uncracked. Moment values are in [{Moment.GetAbbreviation(momentUnit)}]"; + public static OutputAttributeInfo UncrackedMomentRangesDescription(MomentUnit momentUnit) { + return new OutputAttributeInfo() { + Id = 6, Description = $"The range of moments (in the direction of the applied moment, assuming constant axial force) over which the section remains uncracked. Moment values are in [{Moment.GetAbbreviation(momentUnit)}]" + }; } public override void Compute() { diff --git a/AdSecCoreTests/SlsResultFunctionTests.cs b/AdSecCoreTests/SlsResultFunctionTests.cs index 3eb6e381..40fc46a7 100644 --- a/AdSecCoreTests/SlsResultFunctionTests.cs +++ b/AdSecCoreTests/SlsResultFunctionTests.cs @@ -50,25 +50,25 @@ public void ShouldHaveCorrectOutputAttributes() { } [Fact] - public void ShouldRefreshDeformationDescription() { - _component.RefreshDeformation(StrainUnit.Ratio, CurvatureUnit.PerMeter); - Assert.Contains("[ε]", _component.DeformationOutput.Description); - Assert.Contains("[εm⁻¹]", _component.DeformationOutput.Description); - Assert.Contains("[εm⁻¹]", _component.DeformationOutput.Description); + public void ShoulHaveValidDeformationDescription() { + var description = SlsResultFunction.DeformationDescription(StrainUnit.Ratio, CurvatureUnit.PerMeter).Description; ; + Assert.Contains("[ε]", description); + Assert.Contains("[εm⁻¹]", description); + Assert.Contains("[εm⁻¹]", description); } [Fact] - public void ShouldRefreshSecantStiffnessDescription() { - _component.RefreshSecantStiffness(AxialStiffnessUnit.Newton, BendingStiffnessUnit.NewtonSquareMeter); - Assert.Contains("[N]", _component.SecantStiffnessOutput.Description); - Assert.Contains("[N·m²]", _component.SecantStiffnessOutput.Description); - Assert.Contains("[N·m²]", _component.SecantStiffnessOutput.Description); + public void ShouldHaveValidSecantStiffnessDescription() { + var description = SlsResultFunction.SecantStiffnessDescription(AxialStiffnessUnit.Newton, BendingStiffnessUnit.NewtonSquareMeter).Description; + Assert.Contains("[N]", description); + Assert.Contains("[N·m²]", description); + Assert.Contains("[N·m²]", description); } [Fact] - public void ShouldRefreshUncrackedMomentRangesDescription() { - _component.RefreshUncrackedMomentRanges(MomentUnit.NewtonMeter); - Assert.Contains("[N·m]", _component.UncrackedMomentRangesOutput.Description); + public void ShouldHaveValidUncrackedMomentRangesDescription() { + var description = SlsResultFunction.UncrackedMomentRangesDescription(MomentUnit.NewtonMeter).Description; ; + Assert.Contains("[N·m]", description); } [Fact] diff --git a/AdSecGH/Components/6_Results/ResultsSLS.cs b/AdSecGH/Components/6_Results/ResultsSLS.cs index c8189263..d7a81844 100644 --- a/AdSecGH/Components/6_Results/ResultsSLS.cs +++ b/AdSecGH/Components/6_Results/ResultsSLS.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Drawing; using System.Linq; @@ -9,6 +10,7 @@ using AdSecGHCore.Constants; using Grasshopper.Kernel; +using Grasshopper.Kernel.Geometry; using Oasys.GH.Helpers; @@ -24,10 +26,11 @@ public SlsResultGh() { public class SlsResult : ComponentAdapter { protected override void BeforeSolveInstance() { - BusinessComponent.RefreshDeformation(DefaultUnits.StrainUnitResult, DefaultUnits.CurvatureUnit); - BusinessComponent.RefreshSecantStiffness(DefaultUnits.AxialStiffnessUnit, DefaultUnits.BendingStiffnessUnit); - BusinessComponent.RefreshUncrackedMomentRanges(DefaultUnits.MomentUnit); - RefreshParameters(); + var outputAttributes = new List(); + outputAttributes.Add(SlsResultFunction.DeformationDescription(DefaultUnits.StrainUnitResult, DefaultUnits.CurvatureUnit)); + outputAttributes.Add(SlsResultFunction.SecantStiffnessDescription(DefaultUnits.AxialStiffnessUnit, DefaultUnits.BendingStiffnessUnit)); + outputAttributes.Add(SlsResultFunction.UncrackedMomentRangesDescription(DefaultUnits.MomentUnit)); + RefreshOutputParameter(outputAttributes); } public SlsResult() { Hidden = true; Category = CategoryName.Name(); SubCategory = SubCategoryName.Cat7(); } diff --git a/AdSecGH/Helpers/ComponentAdapter.cs b/AdSecGH/Helpers/ComponentAdapter.cs index 4e744f58..7ebf751f 100644 --- a/AdSecGH/Helpers/ComponentAdapter.cs +++ b/AdSecGH/Helpers/ComponentAdapter.cs @@ -1,5 +1,5 @@ using System; -using System.Linq; +using System.Collections.Generic; using AdSecCore.Functions; @@ -8,7 +8,6 @@ using OasysGH; using OasysGH.Components; -using Attribute = AdSecCore.Functions.Attribute; namespace Oasys.GH.Helpers { public abstract class ComponentAdapter : GH_OasysComponent, IDefaultValues where T : IFunction { @@ -39,6 +38,7 @@ protected override void SolveInstance(IGH_DataAccess DA) { foreach (var warning in function.WarningMessages) { AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, warning); } + foreach (var remark in function.RemarkMessages) { AddRuntimeMessage(GH_RuntimeMessageLevel.Remark, remark); } @@ -53,29 +53,10 @@ protected override void SolveInstance(IGH_DataAccess DA) { BusinessComponent.SetOutputValues(this, DA); } - public void RefreshParameters() { - BusinessComponent.GetAllInputAttributes().ToList().ForEach(UpdateInputFrom); - BusinessComponent.GetAllOutputAttributes().ToList().ForEach(UpdateOutputFrom); - } - - private void UpdateInputFrom(Attribute attribute) { - var list = Params.Input.Where(x => x.NickName == attribute.NickName); - if (!list.Any()) { - return; - } - var param = list.First(); - param.Name = attribute.Name; - param.Description = attribute.Description; - } - - private void UpdateOutputFrom(Attribute attribute) { - var list = Params.Output.Where(x => x.NickName == attribute.NickName); - if (!list.Any()) { - return; + public void RefreshOutputParameter(List attributes) { + foreach (var attribute in attributes) { + Params.Output[attribute.Id].Description = attribute.Description; } - var param = list.First(); - param.Name = attribute.Name; - param.Description = attribute.Description; } } From 1a7658fd56bc111aa34f0a0a16b697811aee35c0 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Thu, 13 Mar 2025 16:47:05 +0530 Subject: [PATCH 13/14] refactor(SlsResultTests): test modified and code refactored to update parameter based on unit. --- AdSecCore/Functions/SlsResultFunction.cs | 16 ++++----- AdSecCoreTests/SlsResultFunctionTests.cs | 11 +++--- AdSecGH/Components/6_Results/ResultsSLS.cs | 9 +++-- AdSecGH/Helpers/ComponentAdapter.cs | 7 ++-- .../Components/6_Results/SlsResultTests.cs | 35 ------------------- AdSecGHTests/Helpers/ComponentTestHelper.cs | 3 +- 6 files changed, 21 insertions(+), 60 deletions(-) diff --git a/AdSecCore/Functions/SlsResultFunction.cs b/AdSecCore/Functions/SlsResultFunction.cs index 9bbb7215..d48213ef 100644 --- a/AdSecCore/Functions/SlsResultFunction.cs +++ b/AdSecCore/Functions/SlsResultFunction.cs @@ -110,22 +110,18 @@ public override Attribute[] GetAllOutputAttributes() { }; } - public static OutputAttributeInfo DeformationDescription(StrainUnit strainUnit, CurvatureUnit curvatureUnit) { + public void DeformationDescription(StrainUnit strainUnit, CurvatureUnit curvatureUnit) { var strainAbbreviation = Strain.GetAbbreviation(strainUnit); var curvatureAbbreviation = $"{strainAbbreviation}{Curvature.GetAbbreviation(curvatureUnit)}"; - return new OutputAttributeInfo() { Id = 4, Description = $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{strainAbbreviation}]{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{curvatureAbbreviation}]{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{curvatureAbbreviation}]" }; + DeformationOutput.Description = $"The section deformation under the applied action. The output is a vector representing:{Environment.NewLine}X: Strain [{strainAbbreviation}]{Environment.NewLine}Y: Curvature around zz (so in local y-direction) [{curvatureAbbreviation}]{Environment.NewLine}Z: Curvature around yy (so in local z-direction) [{curvatureAbbreviation}]"; } - public static OutputAttributeInfo SecantStiffnessDescription(AxialStiffnessUnit axialUnit, BendingStiffnessUnit bendingUnit) { - return new OutputAttributeInfo() { - Id = 5, Description = $"The secant stiffness under the applied action. The output is a vector representing:{Environment.NewLine}X: Axial stiffness [{AxialStiffness.GetAbbreviation(axialUnit)}],{Environment.NewLine}Y: The bending stiffness about the y-axis in the local coordinate system [{BendingStiffness.GetAbbreviation(bendingUnit)}],{Environment.NewLine}Z: The bending stiffness about the z-axis in the local coordinate system [{BendingStiffness.GetAbbreviation(bendingUnit)}]" - }; + public void SecantStiffnessDescription(AxialStiffnessUnit axialUnit, BendingStiffnessUnit bendingUnit) { + SecantStiffnessOutput.Description = $"The secant stiffness under the applied action. The output is a vector representing:{Environment.NewLine}X: Axial stiffness [{AxialStiffness.GetAbbreviation(axialUnit)}],{Environment.NewLine}Y: The bending stiffness about the y-axis in the local coordinate system [{BendingStiffness.GetAbbreviation(bendingUnit)}],{Environment.NewLine}Z: The bending stiffness about the z-axis in the local coordinate system [{BendingStiffness.GetAbbreviation(bendingUnit)}]"; } - public static OutputAttributeInfo UncrackedMomentRangesDescription(MomentUnit momentUnit) { - return new OutputAttributeInfo() { - Id = 6, Description = $"The range of moments (in the direction of the applied moment, assuming constant axial force) over which the section remains uncracked. Moment values are in [{Moment.GetAbbreviation(momentUnit)}]" - }; + public void UncrackedMomentRangesDescription(MomentUnit momentUnit) { + UncrackedMomentRangesOutput.Description = $"The range of moments (in the direction of the applied moment, assuming constant axial force) over which the section remains uncracked. Moment values are in [{Moment.GetAbbreviation(momentUnit)}]"; } public override void Compute() { diff --git a/AdSecCoreTests/SlsResultFunctionTests.cs b/AdSecCoreTests/SlsResultFunctionTests.cs index 40fc46a7..c887a237 100644 --- a/AdSecCoreTests/SlsResultFunctionTests.cs +++ b/AdSecCoreTests/SlsResultFunctionTests.cs @@ -51,15 +51,16 @@ public void ShouldHaveCorrectOutputAttributes() { [Fact] public void ShoulHaveValidDeformationDescription() { - var description = SlsResultFunction.DeformationDescription(StrainUnit.Ratio, CurvatureUnit.PerMeter).Description; ; - Assert.Contains("[ε]", description); + _component.DeformationDescription(StrainUnit.Ratio, CurvatureUnit.PerMeter); + var description = _component.DeformationOutput.Description; Assert.Contains("[εm⁻¹]", description); Assert.Contains("[εm⁻¹]", description); } [Fact] public void ShouldHaveValidSecantStiffnessDescription() { - var description = SlsResultFunction.SecantStiffnessDescription(AxialStiffnessUnit.Newton, BendingStiffnessUnit.NewtonSquareMeter).Description; + _component.SecantStiffnessDescription(AxialStiffnessUnit.Newton, BendingStiffnessUnit.NewtonSquareMeter); + var description = _component.SecantStiffnessOutput.Description; Assert.Contains("[N]", description); Assert.Contains("[N·m²]", description); Assert.Contains("[N·m²]", description); @@ -67,8 +68,8 @@ public void ShouldHaveValidSecantStiffnessDescription() { [Fact] public void ShouldHaveValidUncrackedMomentRangesDescription() { - var description = SlsResultFunction.UncrackedMomentRangesDescription(MomentUnit.NewtonMeter).Description; ; - Assert.Contains("[N·m]", description); + _component.UncrackedMomentRangesDescription(MomentUnit.NewtonMeter); + Assert.Contains("[N·m]", _component.UncrackedMomentRangesOutput.Description); } [Fact] diff --git a/AdSecGH/Components/6_Results/ResultsSLS.cs b/AdSecGH/Components/6_Results/ResultsSLS.cs index d7a81844..bc90221c 100644 --- a/AdSecGH/Components/6_Results/ResultsSLS.cs +++ b/AdSecGH/Components/6_Results/ResultsSLS.cs @@ -26,11 +26,10 @@ public SlsResultGh() { public class SlsResult : ComponentAdapter { protected override void BeforeSolveInstance() { - var outputAttributes = new List(); - outputAttributes.Add(SlsResultFunction.DeformationDescription(DefaultUnits.StrainUnitResult, DefaultUnits.CurvatureUnit)); - outputAttributes.Add(SlsResultFunction.SecantStiffnessDescription(DefaultUnits.AxialStiffnessUnit, DefaultUnits.BendingStiffnessUnit)); - outputAttributes.Add(SlsResultFunction.UncrackedMomentRangesDescription(DefaultUnits.MomentUnit)); - RefreshOutputParameter(outputAttributes); + BusinessComponent.DeformationDescription(DefaultUnits.StrainUnitResult, DefaultUnits.CurvatureUnit); + BusinessComponent.SecantStiffnessDescription(DefaultUnits.AxialStiffnessUnit, DefaultUnits.BendingStiffnessUnit); + BusinessComponent.UncrackedMomentRangesDescription(DefaultUnits.MomentUnit); + RefreshOutputParameter(BusinessComponent.GetAllOutputAttributes()); } public SlsResult() { Hidden = true; Category = CategoryName.Name(); SubCategory = SubCategoryName.Cat7(); } diff --git a/AdSecGH/Helpers/ComponentAdapter.cs b/AdSecGH/Helpers/ComponentAdapter.cs index 7ebf751f..480791b3 100644 --- a/AdSecGH/Helpers/ComponentAdapter.cs +++ b/AdSecGH/Helpers/ComponentAdapter.cs @@ -8,6 +8,7 @@ using OasysGH; using OasysGH.Components; +using Attribute = AdSecCore.Functions.Attribute; namespace Oasys.GH.Helpers { public abstract class ComponentAdapter : GH_OasysComponent, IDefaultValues where T : IFunction { @@ -53,9 +54,9 @@ protected override void SolveInstance(IGH_DataAccess DA) { BusinessComponent.SetOutputValues(this, DA); } - public void RefreshOutputParameter(List attributes) { - foreach (var attribute in attributes) { - Params.Output[attribute.Id].Description = attribute.Description; + public void RefreshOutputParameter(Attribute[] attributes) { + for (int id = 0; id < attributes.Length; id++) { + Params.Output[id].Description = attributes[id].Description; } } } diff --git a/AdSecGHTests/Components/6_Results/SlsResultTests.cs b/AdSecGHTests/Components/6_Results/SlsResultTests.cs index d22fb721..d8db7363 100644 --- a/AdSecGHTests/Components/6_Results/SlsResultTests.cs +++ b/AdSecGHTests/Components/6_Results/SlsResultTests.cs @@ -55,41 +55,6 @@ private void SetLargeLoad() { ComponentTestHelper.GetOutput(_component); } - [Fact] - public void ComponentGuid_IsCorrect() { - Assert.Equal(new Guid("27ba3ec5-b94c-43ad-8623-087540413628"), _component.ComponentGuid); - } - - [Fact] - public void Exposure_IsPrimary() { - Assert.Equal(GH_Exposure.primary, _component.Exposure); - } - - [Fact] - public void PluginInfo_IsCorrect() { - Assert.Equal(AdSecGH.PluginInfo.Instance, _component.PluginInfo); - } - - [Fact] - public void Icon_IsCorrect() { - Assert.Equal(Resources.SLS.ToString(), _component.Icon_24x24.ToString()); - } - - [Fact] - public void Category_IsCorrect() { - Assert.Equal(CategoryName.Name(), _component.Category); - } - - [Fact] - public void SubCategory_IsCorrect() { - Assert.Equal(SubCategoryName.Cat7(), _component.SubCategory); - } - - [Fact] - public void Hidden_IsTrue() { - Assert.True(_component.Hidden); - } - [Fact] public void ShouldHaveRemarkWhenUtiliztionIsGreaterThanOne() { SetLoad(); diff --git a/AdSecGHTests/Helpers/ComponentTestHelper.cs b/AdSecGHTests/Helpers/ComponentTestHelper.cs index baf1cd55..87f61bbb 100644 --- a/AdSecGHTests/Helpers/ComponentTestHelper.cs +++ b/AdSecGHTests/Helpers/ComponentTestHelper.cs @@ -8,8 +8,7 @@ using Rhino.Geometry; namespace AdSecGHTests.Helpers { - public class ComponentTestHelper { - private ComponentTestHelper() { } + public static class ComponentTestHelper { public static object GetOutput(GH_Component component, int index = 0, int branch = 0, int item = 0, bool forceUpdate = false) { if (forceUpdate || component.Params.Output[index].VolatileDataCount == 0) { component.ExpireSolution(true); From 65a7d1f87b2215279b2e378131a2bd6c83b866b7 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Thu, 13 Mar 2025 18:43:40 +0530 Subject: [PATCH 14/14] refactor(IFunction): remove unused code --- AdSecCore/Functions/IFunction.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/AdSecCore/Functions/IFunction.cs b/AdSecCore/Functions/IFunction.cs index 060a7062..27516c97 100644 --- a/AdSecCore/Functions/IFunction.cs +++ b/AdSecCore/Functions/IFunction.cs @@ -3,11 +3,6 @@ namespace AdSecCore.Functions { - public struct OutputAttributeInfo { - public int Id { get; set; } - public string Description { get; set; } - } - public interface IFunction { FuncAttribute Metadata { get; set; }