Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristjan Nielsen committed Nov 15, 2023
1 parent bc9b0ea commit c2b9fcf
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 15 deletions.
20 changes: 19 additions & 1 deletion GsaGH/Components/2_Geometry/Edit1dMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace GsaGH.Components {
/// <summary>
/// Component to edit a 1D Member
/// </summary>
public class Edit1dMember : Section3dPreviewComponent {
public class Edit1dMember : Section3dPreviewComponent, IGH_VariableParameterComponent {
public override Guid ComponentGuid => new Guid("32e744e5-7352-4308-81d0-13bf06db5e82");
public override GH_Exposure Exposure => GH_Exposure.tertiary | GH_Exposure.obscure;
public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance;
Expand All @@ -40,6 +40,24 @@ protected override void BeforeSolveInstance() {
}
}

bool IGH_VariableParameterComponent.CanInsertParameter(GH_ParameterSide side, int index) {
return false;
}

bool IGH_VariableParameterComponent.CanRemoveParameter(GH_ParameterSide side, int index) {
return false;
}

IGH_Param IGH_VariableParameterComponent.CreateParameter(GH_ParameterSide side, int index) {
return null;
}

bool IGH_VariableParameterComponent.DestroyParameter(GH_ParameterSide side, int index) {
return false;
}

public void VariableParameterMaintenance() { }

protected override void RegisterInputParams(GH_InputParamManager pManager) {
pManager.AddParameter(new GsaMember1dParameter(), GsaMember1dGoo.Name,
GsaMember1dGoo.NickName,
Expand Down
44 changes: 38 additions & 6 deletions GsaGH/Parameters/5_Results/3_Caches/NodeSpringForceCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ public INodeResultSubset<IInternalForce, ResultVector6<NodeExtremaKey>> ResultSu
switch (ApiResult.Result) {
case AnalysisCaseResult analysisCase:
ReadOnlyDictionary<int, NodeResult> aCaseResults = analysisCase.NodeResults(nodelist);
Parallel.ForEach(aCaseResults.Keys, nodeId => {
var res = new ReactionForce(aCaseResults[nodeId].SpringForce);
Cache.TryAdd(nodeId, new Collection<IInternalForce>() {
Parallel.ForEach(aCaseResults, resultKvp => {
if (!HasValues(resultKvp)) {
return;
}

var res = new ReactionForce(resultKvp.Value.SpringForce);
Cache.TryAdd(resultKvp.Key, new Collection<IInternalForce>() {
res,
});
});
Expand All @@ -40,19 +44,47 @@ public INodeResultSubset<IInternalForce, ResultVector6<NodeExtremaKey>> ResultSu
case CombinationCaseResult combinationCase:
ReadOnlyDictionary<int, ReadOnlyCollection<NodeResult>> cCaseResults
= combinationCase.NodeResults(nodelist);
Parallel.ForEach(cCaseResults.Keys, nodeId => {
Parallel.ForEach(cCaseResults, resultKvp => {
if (!HasValues(resultKvp)) {
return;
}

var permutationResults = new Collection<IInternalForce>();
foreach (NodeResult permutationResult in cCaseResults[nodeId]) {
foreach (NodeResult permutationResult in resultKvp.Value) {
permutationResults.Add(new ReactionForce(permutationResult.SpringForce));
}

Cache.TryAdd(nodeId, permutationResults);
Cache.TryAdd(resultKvp.Key, permutationResults);
});
break;

}
}

return new NodeForceSubset(Cache.GetSubset(nodeIds));
}

private bool HasValues(KeyValuePair<int, NodeResult> kvp) {
return HasValues(kvp.Value.SpringForce);
}

private bool HasValues(KeyValuePair<int, ReadOnlyCollection<NodeResult>> kvp) {
foreach (NodeResult res in kvp.Value) {
if (HasValues(res.SpringForce)) {
return true;
}
}

return false;
}

private bool HasValues(Double6 values) {
return HasValue(values.X) || HasValue(values.Y) || HasValue(values.Z)
|| HasValue(values.XX) || HasValue(values.YY) || HasValue(values.ZZ);
}

private bool HasValue(double value) {
return !double.IsNaN(value) && value != 0;
}
}
}
6 changes: 4 additions & 2 deletions GsaGHTests/3_Components/GH_OasysComponentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class GH_OasysComponentTests {
[InlineData(typeof(SaveGsaModel))]
[InlineData(typeof(ModelTitles))]
[InlineData(typeof(CreateBool6))]
[InlineData(typeof(CreateBucklingFactors))]
[InlineData(typeof(CreateCustomMaterial))]
[InlineData(typeof(CreateMaterial))]
[InlineData(typeof(CreateOffset))]
Expand All @@ -37,7 +36,6 @@ public class GH_OasysComponentTests {
[InlineData(typeof(CreateSection))]
[InlineData(typeof(CreateSectionModifier))]
[InlineData(typeof(EditBool6))]
[InlineData(typeof(EditBucklingFactors))]
[InlineData(typeof(EditMaterial))]
[InlineData(typeof(EditOffset))]
[InlineData(typeof(EditProfile))]
Expand Down Expand Up @@ -66,6 +64,10 @@ public class GH_OasysComponentTests {
[InlineData(typeof(EditNode))]
[InlineData(typeof(Create2dElementsFromBrep))]
[InlineData(typeof(CreateElementsFromMembers))]
[InlineData(typeof(CreateEffectiveLength))]
[InlineData(typeof(EffectiveLengthInfo))]
[InlineData(typeof(CreateMemberEndRestraint))]
[InlineData(typeof(MemberEndRestraintInfo))]
[InlineData(typeof(LocalAxes))]
[InlineData(typeof(SectionAlignment))]
[InlineData(typeof(Annotate))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class AppendAdditionalMenuItemsTests {
[InlineData(typeof(SectionProperties), 2)]
[InlineData(typeof(Create2dElementsFromBrep), 2)]
[InlineData(typeof(CreateElementsFromMembers), 2)]
[InlineData(typeof(Edit1dMember), 3)]
[InlineData(typeof(GridPlaneSurfaceProperties), 2)]
[InlineData(typeof(AnalyseModel), 2)]
// AppendAdditionalComponentMenuItems
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ public class CreateEditBucklingFactorsTest {
private static GH_Document Document => document ?? (document = OpenDocument());
private static GH_Document document = null;

[Fact]
public void NoRuntimeErrorTest() {
Helper.TestNoRuntimeMessagesInDocument(Document, GH_RuntimeMessageLevel.Error);
}

[Fact]
public void NoRuntimeWarningTest() {
Helper.TestNoRuntimeMessagesInDocument(Document, GH_RuntimeMessageLevel.Warning);
Expand Down

0 comments on commit c2b9fcf

Please sign in to comment.