Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GsaGH-389 remove tuples #543

Merged
merged 8 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions GsaGH/Components/5_Results/NodeDisplacements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ protected override void SolveInternal(IGH_DataAccess da) {
return;
}

(List<GsaResultsValues> vals, List<int> sortedIDs)
= result.NodeDisplacementValues(nodeList, _lengthUnit);
List<GsaResultsValues> vals = result.NodeDisplacementValues(nodeList, _lengthUnit);

List<int> permutations = result.SelectedPermutationIds ?? new List<int>() {
1,
Expand All @@ -155,37 +154,32 @@ protected override void SolveInternal(IGH_DataAccess da) {
var rotY = new List<GH_UnitNumber>();
var rotZ = new List<GH_UnitNumber>();
var rotXyz = new List<GH_UnitNumber>();
var ids = new List<int>();

Parallel.For(0, 2, item => // split into two tasks
{
switch (item) {
case 0: {
foreach (int id in sortedIDs) {
ids.Add(id);
ConcurrentDictionary<int, GsaResultQuantity> res = vals[perm - 1].XyzResults[id];
GsaResultQuantity values = res[0]; // there is only one result per node
transX.Add(
new GH_UnitNumber(
values.X.ToUnit(_lengthUnit))); // use ToUnit to capture changes in dropdown
case 0:
foreach (int id in vals[perm - 1].Ids) {
// there is only one result per node
GsaResultQuantity values = vals[perm - 1].XyzResults[id][0];
// use ToUnit to capture changes in dropdown
transX.Add(new GH_UnitNumber(values.X.ToUnit(_lengthUnit)));
transY.Add(new GH_UnitNumber(values.Y.ToUnit(_lengthUnit)));
transZ.Add(new GH_UnitNumber(values.Z.ToUnit(_lengthUnit)));
transXyz.Add(new GH_UnitNumber(values.Xyz.ToUnit(_lengthUnit)));
}

break;
}
case 1: {
foreach (GsaResultQuantity values in sortedIDs
.Select(id => vals[perm - 1].XxyyzzResults[id]).Select(res => res[0])) {

case 1:
foreach (int id in vals[perm - 1].Ids) {
// there is only one result per node
GsaResultQuantity values = vals[perm - 1].XxyyzzResults[id][0];
rotX.Add(new GH_UnitNumber(values.X));
rotY.Add(new GH_UnitNumber(values.Y));
rotZ.Add(new GH_UnitNumber(values.Z));
rotXyz.Add(new GH_UnitNumber(values.Xyz));
}

break;
}
}
});

Expand All @@ -197,7 +191,7 @@ protected override void SolveInternal(IGH_DataAccess da) {
outRotY.AddRange(rotY, path);
outRotZ.AddRange(rotZ, path);
outRotXyz.AddRange(rotXyz, path);
outIDs.AddRange(ids, path);
outIDs.AddRange(vals[perm - 1].Ids, path);
}
}

Expand Down
35 changes: 15 additions & 20 deletions GsaGH/Components/5_Results/ReactionForces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected override void SolveInternal(IGH_DataAccess da) {
return;
}

(List<GsaResultsValues> vals, List<int> sortedIDs)
List<GsaResultsValues> vals
= result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit);

List<int> permutations = result.SelectedPermutationIds ?? new List<int>() {
Expand All @@ -176,38 +176,33 @@ protected override void SolveInternal(IGH_DataAccess da) {
var rotY = new List<GH_UnitNumber>();
var rotZ = new List<GH_UnitNumber>();
var rotXyz = new List<GH_UnitNumber>();
var ids = new List<int>();

Parallel.For(0, 2, item => // split into two tasks
{
switch (item) {
case 0: {
foreach (int key in sortedIDs) {
ids.Add(key);
ConcurrentDictionary<int, GsaResultQuantity> res = vals[perm - 1].XyzResults[key];
GsaResultQuantity values = res[0]; // there is only one result per node
transX.Add(
new GH_UnitNumber(
values.X.ToUnit(_forceUnit))); // use ToUnit to capture changes in dropdown
case 0:
foreach (int key in vals[perm - 1].Ids) {
// there is only one result per node
GsaResultQuantity values = vals[perm - 1].XyzResults[key][0];
// use ToUnit to capture changes in dropdown
transX.Add(new GH_UnitNumber(values.X.ToUnit(_forceUnit)));
transY.Add(new GH_UnitNumber(values.Y.ToUnit(_forceUnit)));
transZ.Add(new GH_UnitNumber(values.Z.ToUnit(_forceUnit)));
transXyz.Add(new GH_UnitNumber(values.Xyz.ToUnit(_forceUnit)));
}

break;
}
case 1: {
foreach (GsaResultQuantity values in sortedIDs
.Select(id => vals[perm - 1].XxyyzzResults[id]).Select(res => res[0])) {
rotX.Add(new GH_UnitNumber(
values.X.ToUnit(_momentUnit))); // use ToUnit to capture changes in dropdown

case 1:
foreach (int key in vals[perm - 1].Ids) {
// there is only one result per node
GsaResultQuantity values = vals[perm - 1].XxyyzzResults[key][0];
// use ToUnit to capture changes in dropdown
rotX.Add(new GH_UnitNumber(values.X.ToUnit(_momentUnit)));
rotY.Add(new GH_UnitNumber(values.Y.ToUnit(_momentUnit)));
rotZ.Add(new GH_UnitNumber(values.Z.ToUnit(_momentUnit)));
rotXyz.Add(new GH_UnitNumber(values.Xyz.ToUnit(_momentUnit)));
}

break;
}
}
});

Expand All @@ -219,7 +214,7 @@ protected override void SolveInternal(IGH_DataAccess da) {
outRotY.AddRange(rotY, path);
outRotZ.AddRange(rotZ, path);
outRotXyz.AddRange(rotXyz, path);
outIDs.AddRange(ids, path);
outIDs.AddRange(vals[perm - 1].Ids, path);
}
}

Expand Down
37 changes: 15 additions & 22 deletions GsaGH/Components/5_Results/SpringReactionForces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,8 @@ protected override void SolveInternal(IGH_DataAccess da) {
return;
}

Tuple<List<GsaResultsValues>, List<int>> resultgetter
List<GsaResultsValues> vals
= result.SpringReactionForceValues(nodeList, _forceUnit, _momentUnit);
List<GsaResultsValues> vals = resultgetter.Item1;
List<int> sortedIDs = resultgetter.Item2;

List<int> permutations = result.SelectedPermutationIds ?? new List<int>() {
1,
Expand All @@ -178,38 +176,33 @@ Tuple<List<GsaResultsValues>, List<int>> resultgetter
var rotY = new List<GH_UnitNumber>();
var rotZ = new List<GH_UnitNumber>();
var rotXyz = new List<GH_UnitNumber>();
var ids = new List<int>();

Parallel.For(0, 2, item => // split into two tasks
{
switch (item) {
case 0: {
foreach (int id in sortedIDs) {
ids.Add(id);
ConcurrentDictionary<int, GsaResultQuantity> res = vals[perm - 1].XyzResults[id];
GsaResultQuantity values = res[0]; // there is only one result per node
transX.Add(
new GH_UnitNumber(
values.X.ToUnit(_forceUnit))); // use ToUnit to capture changes in dropdown
case 0:
foreach (int key in vals[perm - 1].Ids) {
// there is only one result per node
GsaResultQuantity values = vals[perm - 1].XyzResults[key][0];
// use ToUnit to capture changes in dropdown
transX.Add(new GH_UnitNumber(values.X.ToUnit(_forceUnit)));
transY.Add(new GH_UnitNumber(values.Y.ToUnit(_forceUnit)));
transZ.Add(new GH_UnitNumber(values.Z.ToUnit(_forceUnit)));
transXyz.Add(new GH_UnitNumber(values.Xyz.ToUnit(_forceUnit)));
}

break;
}
case 1: {
foreach (GsaResultQuantity values in sortedIDs
.Select(id => vals[perm - 1].XxyyzzResults[id]).Select(res => res[0])) {
rotX.Add(new GH_UnitNumber(
values.X.ToUnit(_momentUnit))); // use ToUnit to capture changes in dropdown

case 1:
foreach (int key in vals[perm - 1].Ids) {
// there is only one result per node
GsaResultQuantity values = vals[perm - 1].XxyyzzResults[key][0];
// use ToUnit to capture changes in dropdown
rotX.Add(new GH_UnitNumber(values.X.ToUnit(_momentUnit)));
rotY.Add(new GH_UnitNumber(values.Y.ToUnit(_momentUnit)));
rotZ.Add(new GH_UnitNumber(values.Z.ToUnit(_momentUnit)));
rotXyz.Add(new GH_UnitNumber(values.Xyz.ToUnit(_momentUnit)));
}

break;
}
}
});

Expand All @@ -221,7 +214,7 @@ Tuple<List<GsaResultsValues>, List<int>> resultgetter
outRotY.AddRange(rotY, path);
outRotZ.AddRange(rotZ, path);
outRotXyz.AddRange(rotXyz, path);
outIDs.AddRange(ids, path);
outIDs.AddRange(vals[perm - 1].Ids, path);
}
}

Expand Down
10 changes: 3 additions & 7 deletions GsaGH/Components/6_Display/ContourNodeResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,16 +482,12 @@ protected override void SolveInternal(IGH_DataAccess da) {
var res = new GsaResultsValues();
switch (_mode) {
case FoldMode.Displacement:
Tuple<List<GsaResultsValues>, List<int>> nodedisp
= result.NodeDisplacementValues(nodeList, _lengthResultUnit);
res = nodedisp.Item1[0];
res = result.NodeDisplacementValues(nodeList, _lengthResultUnit)[0];
break;

case FoldMode.Reaction:
Tuple<List<GsaResultsValues>, List<int>> resultgetter
= result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit);
res = resultgetter.Item1[0];
nodeList = string.Join(" ", resultgetter.Item2);
res = result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit)[0];
nodeList = string.Join(" ", res.Ids);
break;

case FoldMode.Footfall:
Expand Down
8 changes: 3 additions & 5 deletions GsaGH/Components/6_Display/ReactionForceDiagrams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,9 @@ protected override void SolveInternal(IGH_DataAccess da) {
result = (ghObject.Value as GsaResultGoo).Value;
string nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model);

Tuple<List<GsaResultsValues>, List<int>> reactionForceValues
= result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit);
GsaResultsValues forceValues = reactionForceValues.Item1[0];
nodeList = string.Join(" ", reactionForceValues.Item2);

GsaResultsValues forceValues
= result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit)[0];
nodeList = string.Join(" ", forceValues.Ids);
LengthUnit lengthUnit = GetLengthUnit(result);

ReadOnlyDictionary<int, Node> gsaFilteredNodes = result.Model.Model.Nodes(nodeList);
Expand Down
12 changes: 4 additions & 8 deletions GsaGH/Components/GraveyardComp/NodeContourResults_OBSOLETE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,13 @@ protected override void SolveInternal(IGH_DataAccess da) {
var res = new GsaResultsValues();
switch (_mode) {
case FoldMode.Displacement:
Tuple<List<GsaResultsValues>, List<int>> nodedisp
= result.NodeDisplacementValues(nodeList, _lengthUnit);
res = nodedisp.Item1[0];
res = result.NodeDisplacementValues(nodeList, _lengthUnit)[0];
break;

case FoldMode.Reaction:
Tuple<List<GsaResultsValues>, List<int>> resultgetter
= result.NodeReactionForceValues(nodeList, DefaultUnits.ForceUnit,
DefaultUnits.MomentUnit);
res = resultgetter.Item1[0];
nodeList = string.Join(" ", resultgetter.Item2);
res = result.NodeReactionForceValues(nodeList, DefaultUnits.ForceUnit,
DefaultUnits.MomentUnit)[0];
nodeList = string.Join(" ", res.Ids);
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,9 @@ protected override void SolveInternal(IGH_DataAccess da) {
result = (ghObject.Value as GsaResultGoo).Value;
string nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model);

Tuple<List<GsaResultsValues>, List<int>> reactionForceValues
= result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit);
GsaResultsValues forceValues = reactionForceValues.Item1[0];
nodeList = string.Join(" ", reactionForceValues.Item2);
GsaResultsValues forceValues
= result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit)[0];
nodeList = string.Join(" ", forceValues.Ids);

LengthUnit lengthUnit = GetLengthUnit(result);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ protected override void SolveInternal(IGH_DataAccess da) {
result = (ghObject.Value as GsaResultGoo).Value;
string nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model);

Tuple<List<GsaResultsValues>, List<int>> reactionForceValues
= result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit);
GsaResultsValues forceValues = reactionForceValues.Item1[0];
nodeList = string.Join(" ", reactionForceValues.Item2);
GsaResultsValues forceValues = result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit)[0];
nodeList = string.Join(" ", forceValues.Ids);

LengthUnit lengthUnit = GetLengthUnit(result);

Expand Down
35 changes: 15 additions & 20 deletions GsaGH/Components/GraveyardComp/ReactionForce_OBSOLETE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ protected override void SolveInternal(IGH_DataAccess da) {
return;
}

(List<GsaResultsValues> vals, List<int> sortedIDs)
List<GsaResultsValues> vals
= result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit);

List<int> permutations = result.SelectedPermutationIds ?? new List<int>() {
Expand All @@ -183,38 +183,33 @@ protected override void SolveInternal(IGH_DataAccess da) {
var rotY = new List<GH_UnitNumber>();
var rotZ = new List<GH_UnitNumber>();
var rotXyz = new List<GH_UnitNumber>();
var ids = new List<int>();

Parallel.For(0, 2, item => // split into two tasks
{
switch (item) {
case 0: {
foreach (int key in sortedIDs) {
ids.Add(key);
ConcurrentDictionary<int, GsaResultQuantity> res = vals[perm - 1].XyzResults[key];
GsaResultQuantity values = res[0]; // there is only one result per node
transX.Add(
new GH_UnitNumber(
values.X.ToUnit(_forceUnit))); // use ToUnit to capture changes in dropdown
case 0:
foreach (int key in vals[perm - 1].Ids) {
// there is only one result per node
GsaResultQuantity values = vals[perm - 1].XyzResults[key][0];
// use ToUnit to capture changes in dropdown
transX.Add(new GH_UnitNumber(values.X.ToUnit(_forceUnit)));
transY.Add(new GH_UnitNumber(values.Y.ToUnit(_forceUnit)));
transZ.Add(new GH_UnitNumber(values.Z.ToUnit(_forceUnit)));
transXyz.Add(new GH_UnitNumber(values.Xyz.ToUnit(_forceUnit)));
}

break;
}
case 1: {
foreach (GsaResultQuantity values in sortedIDs
.Select(id => vals[perm - 1].XxyyzzResults[id]).Select(res => res[0])) {
rotX.Add(new GH_UnitNumber(
values.X.ToUnit(_momentUnit))); // use ToUnit to capture changes in dropdown

case 1:
foreach (int key in vals[perm - 1].Ids) {
// there is only one result per node
GsaResultQuantity values = vals[perm - 1].XxyyzzResults[key][0];
// use ToUnit to capture changes in dropdown
rotX.Add(new GH_UnitNumber(values.X.ToUnit(_momentUnit)));
rotY.Add(new GH_UnitNumber(values.Y.ToUnit(_momentUnit)));
rotZ.Add(new GH_UnitNumber(values.Z.ToUnit(_momentUnit)));
rotXyz.Add(new GH_UnitNumber(values.Xyz.ToUnit(_momentUnit)));
}

break;
}
}
});

Expand All @@ -226,7 +221,7 @@ protected override void SolveInternal(IGH_DataAccess da) {
outRotY.AddRange(rotY, path);
outRotZ.AddRange(rotZ, path);
outRotXyz.AddRange(rotXyz, path);
outIDs.AddRange(ids, path);
outIDs.AddRange(vals[perm - 1].Ids, path);
}
}

Expand Down
Loading