Skip to content

Commit

Permalink
GSAGH-149 component tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tilman Reinhardt committed Dec 1, 2023
1 parent 11a3a9f commit fbaad51
Show file tree
Hide file tree
Showing 4 changed files with 291 additions and 13 deletions.
40 changes: 28 additions & 12 deletions GsaGH/Components/1_Properties/CreateSpringProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using OasysGH.Units.Helpers;
using OasysUnits;
using OasysUnits.Units;
using Rhino.Runtime;
using LengthUnit = OasysUnits.Units.LengthUnit;

namespace GsaGH.Components {
Expand Down Expand Up @@ -89,11 +88,11 @@ public override void SetSelected(int i, int j) {
_selectedItems[i] = _dropDownItems[i][j];

SpringPropertyType mode = GetModeBy(_selectedItems[0]);
ParseSelectedItems(mode);
if (i == 0) {
UpdateParameters(mode);
UpdateDropDownItems(mode);
}
ParseSelectedItems(mode);

base.UpdateUI();
}
Expand All @@ -114,6 +113,7 @@ public override void VariableParameterMaintenance() {

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

case SpringPropertyType.General:
Expand All @@ -137,8 +137,8 @@ public override void VariableParameterMaintenance() {

case SpringPropertyType.Lockup:
SetStiffnessInputAt(1, true);
SetInputProperties(2, "Lockup +ve [" + lengthAbr + "]", "L+ve", "Lockup +ve", false);
SetInputProperties(3, "Lockup -ve [" + lengthAbr + "]", "L-ve", "Lockup -ve", false);
SetInputProperties(2, "Lockup -ve [" + lengthAbr + "]", "L-ve", "Lockup -ve", false);
SetInputProperties(3, "Lockup +ve [" + lengthAbr + "]", "L+ve", "Lockup +ve", false);
SetDampingRatioInputAt(4);
return;

Expand Down Expand Up @@ -177,7 +177,7 @@ protected override void RegisterInputParams(GH_InputParamManager pManager) {
pManager[0].Optional = true;
pManager[2].Optional = true;
}

protected override void RegisterOutputParams(GH_OutputParamManager pManager) {
pManager.AddParameter(new GsaSpringPropertyParameter());
}
Expand All @@ -188,18 +188,22 @@ protected override void SolveInternal(IGH_DataAccess da) {
double stiffness = 0;
switch (_mode) {
case SpringPropertyType.Axial:
case SpringPropertyType.Torsional:
case SpringPropertyType.TensionOnly:
case SpringPropertyType.CompressionOnly:
case SpringPropertyType.Lockup:
case SpringPropertyType.Gap:
stiffness = Input.UnitNumber(this, da, 1, _stiffnessUnit).As(ForcePerLengthUnit.NewtonPerMeter);
break;

case SpringPropertyType.Torsional:
stiffness = Input.UnitNumber(this, da, 1, _rotationalStiffnessUnit).As(RotationalStiffnessUnit.NewtonMeterPerRadian);
break;
}

double stiffnessX;
double stiffnessY;
double stiffnessZ;
int dampingRatioIndex = 2;

switch (_mode) {
case SpringPropertyType.Axial:
Expand All @@ -217,6 +221,7 @@ protected override void SolveInternal(IGH_DataAccess da) {
break;

case SpringPropertyType.General:
dampingRatioIndex = 7;

// do want to add spring curves??

Expand Down Expand Up @@ -267,17 +272,21 @@ protected override void SolveInternal(IGH_DataAccess da) {
break;

case SpringPropertyType.Connector:
dampingRatioIndex = 1;

var connectorProperty = new ConnectorSpringProperty();
spring = new GsaSpringProperty(connectorProperty);
break;

case SpringPropertyType.Lockup:
double positiveLockup = Input.UnitNumber(this, da, 2, _lengthUnit).As(LengthUnit.Meter);
double negativeLockup = Input.UnitNumber(this, da, 3, _lengthUnit).As(LengthUnit.Meter);
dampingRatioIndex = 4;

double negativeLockup = Input.UnitNumber(this, da, 2, _lengthUnit).As(LengthUnit.Meter);
double positiveLockup = Input.UnitNumber(this, da, 3, _lengthUnit).As(LengthUnit.Meter);
var lockupProperty = new LockupSpringProperty {
Stiffness = stiffness,
PositiveLockup = positiveLockup,
NegativeLockup = negativeLockup
NegativeLockup = negativeLockup,
PositiveLockup = positiveLockup
};
spring = new GsaSpringProperty(lockupProperty);
break;
Expand All @@ -290,11 +299,13 @@ protected override void SolveInternal(IGH_DataAccess da) {
break;

case SpringPropertyType.Friction:
dampingRatioIndex = 5;

stiffnessX = Input.UnitNumber(this, da, 1, _stiffnessUnit).As(ForcePerLengthUnit.NewtonPerMeter);
stiffnessY = Input.UnitNumber(this, da, 2, _stiffnessUnit).As(ForcePerLengthUnit.NewtonPerMeter);
stiffnessZ = Input.UnitNumber(this, da, 3, _stiffnessUnit).As(ForcePerLengthUnit.NewtonPerMeter);
double frictionCoefficient = 0;
if (da.GetData(0, ref frictionCoefficient)) {
if (da.GetData(4, ref frictionCoefficient)) {
var frictionProperty = new FrictionSpringProperty {
StiffnessX = stiffnessX,
StiffnessY = stiffnessY,
Expand All @@ -317,6 +328,11 @@ protected override void SolveInternal(IGH_DataAccess da) {
spring.ApiProperty.Name = name;
}

double dampingRatio = 0;
if (da.GetData(dampingRatioIndex, ref dampingRatio)) {
spring.ApiProperty.DampingRatio = dampingRatio;
}

da.SetData(0, new GsaSpringPropertyGoo(spring));
}

Expand Down Expand Up @@ -482,8 +498,8 @@ private void UpdateParameters(SpringPropertyType mode) {
break;

case SpringPropertyType.Matrix:
Params.RegisterInputParam(new Param_GenericObject());
Params.RegisterInputParam(new Param_Integer());
Params.RegisterInputParam(new Param_Number());
break;

case SpringPropertyType.Connector:
Expand Down
1 change: 1 addition & 0 deletions GsaGHTests/2_GooWrappers/GH_OasysGooTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class GhOasysGooTest {
[InlineData(typeof(GsaSectionGoo), typeof(GsaSection))]
[InlineData(typeof(GsaSectionModifierGoo), typeof(GsaSectionModifier))]
[InlineData(typeof(GsaProperty2dModifierGoo), typeof(GsaProperty2dModifier))]
[InlineData(typeof(GsaSpringPropertyGoo), typeof(GsaSpringProperty))]
// 2_Geometry
[InlineData(typeof(GsaElement1dGoo), typeof(GsaElement1d))]
[InlineData(typeof(GsaElement2dGoo), typeof(GsaElement2d))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public class GH_OasysPersistentParamTest {
[InlineData(typeof(GsaProperty3dParameter))]
[InlineData(typeof(GsaSectionModifierParameter))]
[InlineData(typeof(GsaSectionParameter))]
[InlineData(typeof(GsaSpringPropertyParameter))]
// 2_Geometry
[InlineData(typeof(GsaGH.Parameters.GsaElement1dParameter))]
[InlineData(typeof(GsaElement1dParameter))]
[InlineData(typeof(GsaElement2dParameter))]
[InlineData(typeof(GsaElement3dParameter))]
[InlineData(typeof(GsaMember1dParameter))]
Expand Down
Loading

0 comments on commit fbaad51

Please sign in to comment.