Skip to content

Commit

Permalink
GsaGH-149 springprop for node (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlmnrnhrdt authored Dec 13, 2023
2 parents 2fd8cf4 + 99249ef commit 010a0fe
Show file tree
Hide file tree
Showing 31 changed files with 536 additions and 139 deletions.
Binary file modified ExampleFiles/Components/CreateSpringProperties.gh
Binary file not shown.
Binary file modified ExampleFiles/Parameters/2_Geometry/GetGeometry_TrGen_10.gh
Binary file not shown.
3 changes: 2 additions & 1 deletion GsaGH/Components/0_Model/GetModelGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,8 @@ private SolveResults Compute(GsaModel model, string nodeList, string elemList, s
_results.Nodes = Nodes.GetNodes(
nodeList.ToLower() == "all" ? model.ApiNodes : model.Model.Nodes(nodeList),
model.ModelUnit,
model.ApiAxis);
model.ApiAxis,
model.SpringProps);
_results.DisplaySupports
= new ConcurrentBag<GsaNodeGoo>(_results.Nodes.Where(n => n.Value.IsSupport));
break;
Expand Down
32 changes: 16 additions & 16 deletions GsaGH/Components/1_Properties/CreateSpringProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,23 @@ public override void VariableParameterMaintenance() {
return;

case SpringPropertyType.Torsional:
SetInputProperties(1, "Stiffness xx [" + rotationalStiffnessAbr + "]", "Sxx", "Stiffness xx", false);
SetInputProperties(1, "Stiffness xx [" + rotationalStiffnessAbr + "]", "Sxx", "Stiffness in xx direction", false);
SetDampingRatioInputAt(2);
return;

case SpringPropertyType.General:
SetInputProperties(1, "Spring Curve x", "SCx", "[Optional] Spring Curve x");
SetInputProperties(2, "Stiffness x [" + stiffnessAbr + "]", "Sx", "[Optional] Stiffness x");
SetInputProperties(3, "Spring Curve y", "SCy", "[Optional] Spring Curve y");
SetInputProperties(4, "Stiffness y [" + stiffnessAbr + "]", "Sy", "[Optional] Stiffness y");
SetInputProperties(5, "Spring Curve z", "SCz", "[Optional] Spring Curve z");
SetInputProperties(6, "Stiffness z [" + stiffnessAbr + "]", "Sz", "[Optional] Stiffness z");
SetInputProperties(7, "Spring Curve xx", "SCxx", "[Optional] Spring Curve xx");
SetInputProperties(8, "Stiffness xx [" + rotationalStiffnessAbr + "]", "Sxx", "[Optional] Stiffness xx");
SetInputProperties(9, "Spring Curve yy", "SCyy", "[Optional] Spring Curve yy");
SetInputProperties(10, "Stiffness yy [" + rotationalStiffnessAbr + "]", "Syy", "[Optional] Stiffness yy");
SetInputProperties(11, "Spring Curve zz", "SCzz", "[Optional] Spring Curve zz");
SetInputProperties(12, "Stiffness zz [" + rotationalStiffnessAbr + "]", "Szz", "[Optional] Stiffness zz");
SetInputProperties(1, "Spring Curve x", "SCx", "[Optional] Spring Curve in x direction");
SetInputProperties(2, "Stiffness x [" + stiffnessAbr + "]", "Sx", "[Optional] Stiffness in x direction");
SetInputProperties(3, "Spring Curve y", "SCy", "[Optional] Spring Curve in y direction");
SetInputProperties(4, "Stiffness y [" + stiffnessAbr + "]", "Sy", "[Optional] Stiffness in y direction");
SetInputProperties(5, "Spring Curve z", "SCz", "[Optional] Spring Curve in z direction");
SetInputProperties(6, "Stiffness z [" + stiffnessAbr + "]", "Sz", "[Optional] Stiffness in z direction");
SetInputProperties(7, "Spring Curve xx", "SCxx", "[Optional] Spring Curve in xx direction");
SetInputProperties(8, "Stiffness xx [" + rotationalStiffnessAbr + "]", "Sxx", "[Optional] Stiffness in xx direction");
SetInputProperties(9, "Spring Curve yy", "SCyy", "[Optional] Spring Curve in yy direction");
SetInputProperties(10, "Stiffness yy [" + rotationalStiffnessAbr + "]", "Syy", "[Optional] Stiffness in yy direction");
SetInputProperties(11, "Spring Curve zz", "SCzz", "[Optional] Spring Curve in zz direction");
SetInputProperties(12, "Stiffness zz [" + rotationalStiffnessAbr + "]", "Szz", "[Optional] Stiffness in zz direction");
SetDampingRatioInputAt(13);
return;

Expand All @@ -151,9 +151,9 @@ public override void VariableParameterMaintenance() {
return;

case SpringPropertyType.Friction:
SetInputProperties(1, "Stiffness x [" + stiffnessAbr + "]", "Sx", "Stiffness x", false);
SetInputProperties(2, "Stiffness y [" + stiffnessAbr + "]", "Sy", "Stiffness y", false);
SetInputProperties(3, "Stiffness z [" + stiffnessAbr + "]", "Sz", "Stiffness z", false);
SetInputProperties(1, "Stiffness x [" + stiffnessAbr + "]", "Sx", "Stiffness in x direction", false);
SetInputProperties(2, "Stiffness y [" + stiffnessAbr + "]", "Sy", "Stiffness in y direction", false);
SetInputProperties(3, "Stiffness z [" + stiffnessAbr + "]", "Sz", "Stiffness in z direction", false);
SetInputProperties(4, "Coeff. of Friction [" + stiffnessAbr + "]", "CF", "Coefficient of Friction", false);
SetDampingRatioInputAt(5);
return;
Expand Down
37 changes: 18 additions & 19 deletions GsaGH/Components/1_Properties/GetSpringProperty.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using GH_IO.Serialization;
Expand All @@ -25,7 +24,6 @@ public class GetSpringProperty : GH_OasysComponent, IGH_VariableParameterCompone
protected override Bitmap Icon => Resources.GetSpringProperty;
private RotationalStiffnessUnit _rotationalStiffnessUnit = RotationalStiffnessUnit.NewtonMeterPerRadian;
private LengthUnit _lengthUnit = DefaultUnits.LengthUnitSection;
private List<string> _rotationalStiffnessUnitAbbreviations = new List<string>();
private ForcePerLengthUnit _stiffnessUnit = DefaultUnits.ForcePerLengthUnit;

public GetSpringProperty() : base("Get Spring Property", "GetPS",
Expand Down Expand Up @@ -148,29 +146,29 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) {

pManager.AddTextParameter("Name", "Na", "Spring Property Name", GH_ParamAccess.item);

pManager.AddTextParameter("Spring Curve x", "SCx", "Spring Curve x", GH_ParamAccess.item);
pManager.AddIntegerParameter("Spring Curve x", "SCx", "Spring Curve in x direction", GH_ParamAccess.item);

pManager.AddGenericParameter("Stiffness x [" + stiffnessAbr + "]", "Sx", "Stiffness x", GH_ParamAccess.item);
pManager.AddGenericParameter("Stiffness x [" + stiffnessAbr + "]", "Sx", "Stiffness in x direction", GH_ParamAccess.item);

pManager.AddTextParameter("Spring Curve y", "SCy", "Spring Curve y", GH_ParamAccess.item);
pManager.AddIntegerParameter("Spring Curve y", "SCy", "Spring Curve y", GH_ParamAccess.item);

pManager.AddGenericParameter("Stiffness y [" + stiffnessAbr + "]", "Sy", "Stiffness y", GH_ParamAccess.item);
pManager.AddGenericParameter("Stiffness y [" + stiffnessAbr + "]", "Sy", "Stiffness in y direction", GH_ParamAccess.item);

pManager.AddTextParameter("Spring Curve z", "SCz", "Spring Curve z", GH_ParamAccess.item);
pManager.AddIntegerParameter("Spring Curve z", "SCz", "Spring Curve z", GH_ParamAccess.item);

pManager.AddGenericParameter("Stiffness z [" + stiffnessAbr + "]", "Sz", "Stiffness z", GH_ParamAccess.item);
pManager.AddGenericParameter("Stiffness z [" + stiffnessAbr + "]", "Sz", "Stiffness in z direction", GH_ParamAccess.item);

pManager.AddTextParameter("Spring Curve xx", "SCxx", "Spring Curve xx", GH_ParamAccess.item);
pManager.AddIntegerParameter("Spring Curve xx", "SCxx", "Spring Curve xx", GH_ParamAccess.item);

pManager.AddGenericParameter("Stiffness xx [" + rotationalStiffnessAbr + "]", "Sxx", "Stiffness xx", GH_ParamAccess.item);
pManager.AddGenericParameter("Stiffness xx [" + rotationalStiffnessAbr + "]", "Sxx", "Stiffness in xx direction", GH_ParamAccess.item);

pManager.AddTextParameter("Spring Curve yy", "SCyy", "Spring Curve yy", GH_ParamAccess.item);
pManager.AddIntegerParameter("Spring Curve yy", "SCyy", "Spring Curve yy", GH_ParamAccess.item);

pManager.AddGenericParameter("Stiffness yy [" + rotationalStiffnessAbr + "]", "Syy", "Stiffness yy", GH_ParamAccess.item);
pManager.AddGenericParameter("Stiffness yy [" + rotationalStiffnessAbr + "]", "Syy", "Stiffness in yy direction", GH_ParamAccess.item);

pManager.AddTextParameter("Spring Curve zz", "SCzz", "Spring Curve zz", GH_ParamAccess.item);
pManager.AddIntegerParameter("Spring Curve zz", "SCzz", "Spring Curve zz", GH_ParamAccess.item);

pManager.AddGenericParameter("Stiffness zz [" + rotationalStiffnessAbr + "]", "Szz", "Stiffness zz", GH_ParamAccess.item);
pManager.AddGenericParameter("Stiffness zz [" + rotationalStiffnessAbr + "]", "Szz", "Stiffness in zz direction", GH_ParamAccess.item);

pManager.AddGenericParameter("Spring Matrix", "SM", "Spring Matrix", GH_ParamAccess.item);

Expand All @@ -186,7 +184,7 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) {
protected override void SolveInstance(IGH_DataAccess da) {
GsaSpringPropertyGoo springPropertyGoo = null;
if (!da.GetData(0, ref springPropertyGoo)) {
this.AddRuntimeWarning("Input PB failed to collect data");
this.AddRuntimeWarning("Input PS failed to collect data");
return;
}
GsaSpringProperty springProperty = springPropertyGoo.Value;
Expand Down Expand Up @@ -249,19 +247,20 @@ protected override void SolveInstance(IGH_DataAccess da) {
case LockupSpringProperty lockup:
da.SetData(14, new GH_UnitNumber(new Length((double)lockup.NegativeLockup, LengthUnit.Meter).ToUnit(_lengthUnit)));
da.SetData(15, new GH_UnitNumber(new Length((double)lockup.PositiveLockup, LengthUnit.Meter).ToUnit(_lengthUnit)));
return;
break;

case FrictionSpringProperty friction:
da.SetData(2, new GH_UnitNumber(new ForcePerLength((double)friction.StiffnessX, ForcePerLengthUnit.NewtonPerMeter).ToUnit(_stiffnessUnit)));
da.SetData(4, new GH_UnitNumber(new ForcePerLength((double)friction.StiffnessY, ForcePerLengthUnit.NewtonPerMeter).ToUnit(_stiffnessUnit)));
da.SetData(6, new GH_UnitNumber(new ForcePerLength((double)friction.StiffnessZ, ForcePerLengthUnit.NewtonPerMeter).ToUnit(_stiffnessUnit)));
da.SetData(2, new GH_UnitNumber(new ForcePerLength((double)friction.StiffnessX, ForcePerLengthUnit.NewtonPerMeter).ToUnit(_stiffnessUnit)));
da.SetData(4, new GH_UnitNumber(new ForcePerLength((double)friction.StiffnessY, ForcePerLengthUnit.NewtonPerMeter).ToUnit(_stiffnessUnit)));
da.SetData(6, new GH_UnitNumber(new ForcePerLength((double)friction.StiffnessZ, ForcePerLengthUnit.NewtonPerMeter).ToUnit(_stiffnessUnit)));
da.SetData(16, friction.FrictionCoefficient);
break;

case ConnectorSpringProperty connector:
default:
break;
}

da.SetData(17, new GH_UnitNumber(new Ratio(springProperty.ApiProperty.DampingRatio, RatioUnit.DecimalFraction).ToUnit(RatioUnit.Percent)));
}

Expand Down
33 changes: 28 additions & 5 deletions GsaGH/Components/2_Geometry/Create1dElement.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using System.Drawing;
using GH_IO.Serialization;
using System.Linq;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Types;
using GsaAPI;
using GsaGH.Helpers.GH;
using GsaGH.Parameters;
using GsaGH.Properties;
Expand All @@ -22,9 +25,18 @@ public class Create1dElement : Section3dPreviewComponent {
public Create1dElement() : base("Create 1D Element", "Elem1D", "Create GSA 1D Element",
CategoryName.Name(), SubCategoryName.Cat2()) { }

public override bool Read(GH_IReader reader) {
bool flag = base.Read(reader);
if (Params.Input[1].Name == new GsaSectionParameter().Name) {
Params.ReplaceInputParameter(new GsaPropertyParameter(), 1, true);
}

return flag;
}

protected override void RegisterInputParams(GH_InputParamManager pManager) {
pManager.AddLineParameter("Line", "L", "Line to create GSA Element", GH_ParamAccess.item);
pManager.AddParameter(new GsaSectionParameter());
pManager.AddParameter(new GsaPropertyParameter());
pManager[1].Optional = true;
pManager.HideParameter(0);
}
Expand All @@ -38,11 +50,22 @@ protected override void SolveInstance(IGH_DataAccess da) {
da.GetData(0, ref ghln);
var elem = new GsaElement1d(new LineCurve(ghln.Value));

GsaSectionGoo sectionGoo = null;
GsaPropertyGoo sectionGoo = null;
if (da.GetData(1, ref sectionGoo)) {
elem.Section = sectionGoo.Value;
if (Preview3dSection) {
elem.CreateSection3dPreview();
switch (sectionGoo.Value) {
case GsaSection section:
elem.Section = section;
elem.SpringProperty = null;
if (Preview3dSection) {
elem.CreateSection3dPreview();
}
break;

case GsaSpringProperty springProperty:
elem.ApiElement.Type = ElementType.SPRING;
elem.Section = null;
elem.SpringProperty = springProperty;
break;
}
}

Expand Down
30 changes: 24 additions & 6 deletions GsaGH/Components/2_Geometry/Create1dMember.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using GH_IO.Serialization;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Types;
using GsaAPI;
using GsaGH.Helpers.GH;
using GsaGH.Parameters;
using GsaGH.Properties;
Expand Down Expand Up @@ -92,7 +94,12 @@ public override bool Read(GH_IReader reader) {
_xx2 = reader.GetBoolean("xx2");
_yy2 = reader.GetBoolean("yy2");
_zz2 = reader.GetBoolean("zz2");
return base.Read(reader);
bool flag = base.Read(reader);
if (Params.Input[1].Name == new GsaSectionParameter().Name) {
Params.ReplaceInputParameter(new GsaPropertyParameter(), 1, true);
}

return flag;
}

public void SetReleases(List<List<bool>> restraints) {
Expand Down Expand Up @@ -136,7 +143,7 @@ protected override void RegisterInputParams(GH_InputParamManager pManager) {
pManager.AddCurveParameter("Curve", "C",
"Curve (a NURBS curve will automatically be converted in to a Polyline of Arc and Line segments)",
GH_ParamAccess.item);
pManager.AddParameter(new GsaSectionParameter());
pManager.AddParameter(new GsaPropertyParameter());
pManager.AddNumberParameter("Mesh Size in model units", "Ms", "Target mesh size",
GH_ParamAccess.item);
pManager[1].Optional = true;
Expand Down Expand Up @@ -188,11 +195,22 @@ protected override void SolveInternal(IGH_DataAccess da) {
};
mem.ReleaseEnd = rel2;

GsaSectionGoo sectionGoo = null;
GsaPropertyGoo sectionGoo = null;
if (da.GetData(1, ref sectionGoo)) {
mem.Section = sectionGoo.Value;
if (Preview3dSection) {
mem.CreateSection3dPreview();
switch (sectionGoo.Value) {
case GsaSection section:
mem.Section = section;
mem.SpringProperty = null;
if (Preview3dSection) {
mem.CreateSection3dPreview();
}
break;

case GsaSpringProperty springProperty:
mem.ApiMember.Type1D = ElementType.SPRING;
mem.Section = null;
mem.SpringProperty = springProperty;
break;
}
}

Expand Down
39 changes: 25 additions & 14 deletions GsaGH/Components/2_Geometry/Edit1dElement.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Drawing;
using System.Linq;
using GH_IO.Serialization;
using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
Expand Down Expand Up @@ -37,6 +38,16 @@ protected override void BeforeSolveInstance() {
}
}

public override bool Read(GH_IReader reader) {
bool flag = base.Read(reader);
if (Params.Input[3].Name == new GsaSectionParameter().Name) {
Params.ReplaceInputParameter(new GsaPropertyParameter(), 3, true);
Params.ReplaceOutputParameter(new GsaPropertyParameter(), 3);
}

return flag;
}

protected override void RegisterInputParams(GH_InputParamManager pManager) {
pManager.AddParameter(new GsaElement1dParameter(), GsaElement1dGoo.Name,
GsaElement1dGoo.NickName,
Expand Down Expand Up @@ -92,8 +103,7 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) {
GH_ParamAccess.item);
pManager.AddLineParameter("Line", "L", "Element Line", GH_ParamAccess.item);
pManager.HideParameter(2);
pManager.AddGenericParameter("Section", "PB", "Get Section or Spring Property",
GH_ParamAccess.item);
pManager.AddParameter(new GsaPropertyParameter());
pManager.AddIntegerParameter("Group", "Gr", "Get Element Group", GH_ParamAccess.item);
pManager.AddTextParameter("Type", "eT", "Get Element Type", GH_ParamAccess.item);

Expand Down Expand Up @@ -142,26 +152,27 @@ protected override void SolveInstance(IGH_DataAccess da) {
if (da.GetData(3, ref sectionGoo)) {
switch (sectionGoo.Value) {
case GsaSection section:
if (elem.ApiElement.Type == ElementType.SPRING) {
this.AddRuntimeError("Input PB has to be a Spring Property");
return;
if (section.IsReferencedById && elem.ApiElement.Type == ElementType.SPRING) {
elem.Section = null;
elem.SpringProperty = new GsaSpringProperty(section.Id);
} else {
if (elem.ApiElement.Type == ElementType.SPRING) {
this.AddRuntimeError("PB input must be a SpringProperty");
return;
}
elem.Section = section;
elem.SpringProperty = null;
}
elem.Section = section;
elem.SpringProperty = null;

break;

case GsaSpringProperty springProperty:
if (elem.ApiElement.Type != ElementType.SPRING) {
this.AddRuntimeError("Element Type is not Spring");
return;
}
elem.ApiElement.Type = ElementType.SPRING;
this.AddRuntimeRemark("ElementType changed to Spring");
elem.Section = null;
elem.SpringProperty = springProperty;
break;
}
} else if (elem.ApiElement.Type == ElementType.SPRING) {
this.AddRuntimeError("Input PB has to be a Spring Property");
return;
}

int id = 0;
Expand Down
Loading

0 comments on commit 010a0fe

Please sign in to comment.