Skip to content

Commit

Permalink
gsagh-391 first step
Browse files Browse the repository at this point in the history
  • Loading branch information
DominikaLos committed Oct 10, 2023
1 parent e132b25 commit 6cfab49
Show file tree
Hide file tree
Showing 14 changed files with 319 additions and 107 deletions.
38 changes: 14 additions & 24 deletions GsaGH/Components/5_Results/NodeDisplacements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected override void SolveInternal(IGH_DataAccess da) {
return;
}

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

List<int> permutations = result.SelectedPermutationIds ?? new List<int>() {
1,
Expand All @@ -157,29 +157,19 @@ protected override void SolveInternal(IGH_DataAccess da) {

Parallel.For(0, 2, item => // split into two tasks
{
switch (item) {
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 (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;
foreach (int id in vals[perm - 1].Ids) {
// there is only one result per node
Parameters._5_Results.Quantities.IDisplacementQuantity values = vals[perm - 1].Results[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)));
// there is only one result per node
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));
}
});

Expand Down
54 changes: 28 additions & 26 deletions GsaGH/Helpers/GsaAPI/Results/AnalysisCaseQuantities.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using GsaAPI;
using GsaGH.Parameters;
using GsaGH.Parameters._5_Results.Quantities;
using OasysUnits;
using OasysUnits.Units;
using System;
using System.Collections.Concurrent;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using GsaAPI;
using GsaGH.Parameters;
using OasysUnits;
using OasysUnits.Units;
using static GsaGH.Parameters.GsaResultsValues;
using AngleUnit = OasysUnits.Units.AngleUnit;
using EnergyUnit = OasysUnits.Units.EnergyUnit;
using ForceUnit = OasysUnits.Units.ForceUnit;
Expand All @@ -26,7 +28,7 @@ internal static GsaResultsValues GetElement1DResultValues(
ReadOnlyDictionary<int, Element1DResult> globalResults, ForceUnit forceUnit,
MomentUnit momentUnit) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.Force,
Type = ResultType.Force,
};

Parallel.ForEach(globalResults.Keys, key => {
Expand Down Expand Up @@ -66,7 +68,7 @@ internal static GsaResultsValues GetElement1DResultValues(
ReadOnlyDictionary<int, Element1DResult> globalResults, EnergyUnit energyUnit,
bool average = false) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.StrainEnergy,
Type = ResultType.StrainEnergy,
};

Parallel.ForEach(globalResults.Keys, key => {
Expand Down Expand Up @@ -97,7 +99,7 @@ internal static GsaResultsValues GetElement1DResultValues(
internal static GsaResultsValues GetElement1DResultValues(
ReadOnlyDictionary<int, Element1DResult> globalResults, LengthUnit resultLengthUnit) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.Displacement,
Type = ResultType.Displacement,
};

Parallel.ForEach(globalResults.Keys, key => {
Expand Down Expand Up @@ -135,7 +137,7 @@ internal static GsaResultsValues GetElement1DResultValues(
internal static GsaResultsValues GetElement2DResultValues(
ReadOnlyDictionary<int, Element2DResult> globalResults, PressureUnit stressUnit) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.Stress,
Type = ResultType.Stress,
};

Parallel.ForEach(globalResults.Keys, key => {
Expand Down Expand Up @@ -189,7 +191,7 @@ internal static GsaResultsValues GetElement2DResultValues(
internal static GsaResultsValues GetElement2DResultValues(
ReadOnlyDictionary<int, Element2DResult> globalResults, ForcePerLengthUnit forceUnit) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.Shear,
Type = ResultType.Shear,
};

Parallel.ForEach(globalResults.Keys, key => {
Expand Down Expand Up @@ -230,7 +232,7 @@ internal static GsaResultsValues GetElement2DResultValues(
ReadOnlyDictionary<int, Element2DResult> globalResults, ForcePerLengthUnit forceUnit,
ForceUnit momentUnit) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.Force,
Type = ResultType.Force,
};

Parallel.ForEach(globalResults.Keys, key => {
Expand Down Expand Up @@ -294,7 +296,7 @@ internal static GsaResultsValues GetElement2DResultValues(
internal static GsaResultsValues GetElement2DResultValues(
ReadOnlyDictionary<int, Element2DResult> globalResults, LengthUnit resultLengthUnit) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.Displacement,
Type = ResultType.Displacement,
};

Parallel.ForEach(globalResults.Keys, key => {
Expand Down Expand Up @@ -346,7 +348,7 @@ internal static GsaResultsValues GetElement2DResultValues(
internal static GsaResultsValues GetElement3DResultValues(
ReadOnlyDictionary<int, Element3DResult> globalResults, LengthUnit resultLengthUnit) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.Displacement,
Type = ResultType.Displacement,
};

Parallel.ForEach(globalResults.Keys, key => {
Expand Down Expand Up @@ -382,7 +384,7 @@ internal static GsaResultsValues GetElement3DResultValues(
internal static GsaResultsValues GetElement3DResultValues(
ReadOnlyDictionary<int, Element3DResult> globalResults, PressureUnit stressUnit) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.Stress,
Type = ResultType.Stress,
};

Parallel.ForEach(globalResults.Keys, key => {
Expand Down Expand Up @@ -440,7 +442,7 @@ internal static GsaResultsValues GetNodeReactionForceResultValues(
ReadOnlyDictionary<int, NodeResult> globalResults, ForceUnit forceUnit, MomentUnit momentUnit,
ConcurrentBag<int> supportnodeIDs = null) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.Force,
Type = ResultType.Force,
};

Parallel.ForEach(globalResults.Keys, nodeId => {
Expand Down Expand Up @@ -477,26 +479,26 @@ internal static GsaResultsValues GetNodeReactionForceResultValues(
/// <param name="globalResults"></param>
/// <param name="resultLengthUnit"></param>
/// <returns></returns>
internal static GsaResultsValues GetNodeResultValues(
internal static GsaDisplacementValues GetNodeResultValues(
ReadOnlyDictionary<int, NodeResult> globalResults, LengthUnit resultLengthUnit) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.Force,
var r = new GsaDisplacementValues {
Type = ResultType.Displacement,
};

Parallel.ForEach(globalResults.Keys, nodeId => {
NodeResult result = globalResults[nodeId];
Double6 values = result.Displacement;

var quantities = new GsaDisplacementQuantity(values, resultLengthUnit, AngleUnit.Radian);
if (!double.IsNaN(values.X) && !double.IsNaN(values.Y) && !double.IsNaN(values.Z)) {
var xyz = new ConcurrentDictionary<int, GsaResultQuantity>();
xyz.TryAdd(0, GetQuantityResult(values, resultLengthUnit));
r.XyzResults.TryAdd(nodeId, xyz);
var xyz = new ConcurrentDictionary<int, IDisplacementQuantity>();
xyz.TryAdd(0, quantities);
r.Results.TryAdd(nodeId, xyz);
}

if (!double.IsNaN(values.XX) && !double.IsNaN(values.YY) && !double.IsNaN(values.ZZ)) {
var xxyyzz = new ConcurrentDictionary<int, GsaResultQuantity>();
xxyyzz.TryAdd(0, GetQuantityResult(values, AngleUnit.Radian));
r.XxyyzzResults.TryAdd(nodeId, xxyyzz);
var xxyyzz = new ConcurrentDictionary<int, IDisplacementQuantity>();
xxyyzz.TryAdd(0, quantities);
r.Results.TryAdd(nodeId, xxyyzz);
}
});

Expand All @@ -517,7 +519,7 @@ internal static GsaResultsValues GetNodeSpringForceResultValues(
ReadOnlyDictionary<int, NodeResult> globalResults, ForceUnit forceUnit, MomentUnit momentUnit,
ConcurrentBag<int> supportnodeIDs = null) {
var r = new GsaResultsValues {
Type = GsaResultsValues.ResultType.Force,
Type = ResultType.Force,
};

Parallel.ForEach(globalResults.Keys, nodeId => {
Expand Down
20 changes: 11 additions & 9 deletions GsaGH/Helpers/GsaAPI/Results/CombinationCaseQuantities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using GsaAPI;
using GsaGH.Parameters;
using GsaGH.Parameters._5_Results.Quantities;
using OasysUnits;
using OasysUnits.Units;
using AngleUnit = OasysUnits.Units.AngleUnit;
Expand Down Expand Up @@ -650,10 +651,10 @@ internal static ConcurrentDictionary<int, GsaResultsValues> GetNodeReactionForce
/// <param name="resultLengthUnit"></param>
/// <param name="permutations">list of permutations, input an empty list to get all permutations</param>
/// <returns></returns>
internal static ConcurrentDictionary<int, GsaResultsValues> GetNodeResultValues(
internal static ConcurrentDictionary<int, GsaDisplacementValues> GetNodeResultValues(
ReadOnlyDictionary<int, ReadOnlyCollection<NodeResult>> globalResults,
LengthUnit resultLengthUnit, List<int> permutations) {
var rs = new ConcurrentDictionary<int, GsaResultsValues>();
var rs = new ConcurrentDictionary<int, GsaDisplacementValues>();

if (permutations.Count == 0) {
permutations = Enumerable.Range(1, globalResults[globalResults.Keys.First()].Count)
Expand All @@ -664,25 +665,26 @@ internal static ConcurrentDictionary<int, GsaResultsValues> GetNodeResultValues(

Parallel.For(0, permutationCount, index => {
int permutationId = permutations[index];
var r = new GsaResultsValues {
var r = new GsaDisplacementValues {
Type = GsaResultsValues.ResultType.Displacement,
};

Parallel.ForEach(globalResults.Keys, nodeId => {
ReadOnlyCollection<NodeResult> results = globalResults[nodeId];
NodeResult result = results[permutationId - 1];
Double6 values = result.Displacement;
var quantities = new GsaDisplacementQuantity(values, resultLengthUnit, AngleUnit.Radian);

if (!double.IsNaN(values.X) && !double.IsNaN(values.Y) && !double.IsNaN(values.Z)) {
var xyz = new ConcurrentDictionary<int, GsaResultQuantity>();
xyz.TryAdd(0, GetQuantityResult(values, resultLengthUnit));
r.XyzResults.TryAdd(nodeId, xyz);
var xyz = new ConcurrentDictionary<int, IDisplacementQuantity>();
xyz.TryAdd(0, quantities);
r.Results.TryAdd(nodeId, xyz);
}

if (!double.IsNaN(values.XX) && !double.IsNaN(values.YY) && !double.IsNaN(values.ZZ)) {
var xxyyzz = new ConcurrentDictionary<int, GsaResultQuantity>();
xxyyzz.TryAdd(0, GetQuantityResult(values, AngleUnit.Radian));
r.XxyyzzResults.TryAdd(nodeId, xxyyzz);
var xxyyzz = new ConcurrentDictionary<int, IDisplacementQuantity>();
xxyyzz.TryAdd(0, quantities);
r.Results.TryAdd(nodeId, xxyyzz);
}
});

Expand Down
12 changes: 6 additions & 6 deletions GsaGH/Parameters/5_Results/GsaResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ internal Dictionary<string, ReadOnlyDictionary<int, Element3DResult>>
/// Append to this dictionary to chache results
/// key = elementList
/// </summary>
internal Dictionary<string, GsaResultsValues> ACaseNodeDisplacementValues { get; set; }
= new Dictionary<string, GsaResultsValues>();
internal Dictionary<string, GsaDisplacementValues> ACaseNodeDisplacementValues { get; set; }
= new Dictionary<string, GsaDisplacementValues>();
/// <summary>
/// Analysis Case Node Footfall Result VALUES Dictionary
/// Append to this dictionary to chache results
Expand Down Expand Up @@ -302,9 +302,9 @@ internal Dictionary<string, ConcurrentDictionary<int, GsaResultsValues>>
/// key = elementList
/// value = Dictionary(permutationID, permutationsResults)
/// </summary>
internal Dictionary<string, ConcurrentDictionary<int, GsaResultsValues>>
internal Dictionary<string, ConcurrentDictionary<int, GsaDisplacementValues>>
ComboNodeDisplacementValues { get; set; }
= new Dictionary<string, ConcurrentDictionary<int, GsaResultsValues>>();
= new Dictionary<string, ConcurrentDictionary<int, GsaDisplacementValues>>();
/// <summary>
/// Combination Case Node Reaction Force Result VALUES Dictionary
/// Append to this dictionary to chache results
Expand Down Expand Up @@ -924,7 +924,7 @@ internal List<GsaResultsValues> Element3DStressValues(
/// <param name="nodelist"></param>
/// <param name="lengthUnit"></param>
/// <returns></returns>
internal List<GsaResultsValues> NodeDisplacementValues(
internal List<GsaDisplacementValues> NodeDisplacementValues(
string nodelist, LengthUnit lengthUnit) {
if (nodelist.ToLower() == "all" || nodelist == string.Empty) {
nodelist = "All";
Expand All @@ -940,7 +940,7 @@ internal List<GsaResultsValues> NodeDisplacementValues(
ResultHelper.GetNodeResultValues(ACaseNodeResults[nodelist], lengthUnit));
}

return new List<GsaResultsValues> {
return new List<GsaDisplacementValues> {
ACaseNodeDisplacementValues[nodelist],
};
}
Expand Down
2 changes: 1 addition & 1 deletion GsaGH/Parameters/5_Results/GsaResultQuantity.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using OasysUnits;

namespace GsaGH.Parameters {
internal class GsaResultQuantity {
public class GsaResultQuantity {
internal IQuantity X { get; set; }
internal IQuantity Xyz { get; set; }
internal IQuantity Y { get; set; }
Expand Down
56 changes: 30 additions & 26 deletions GsaGH/Parameters/5_Results/GsaResultsValues.cs
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
using System;
using GsaAPI;
using GsaGH.Parameters._5_Results.Quantities;
using GsaGH.Parameters._5_Results.Values;
using OasysUnits;
using Rhino.Geometry;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using GsaAPI;
using OasysUnits;
using Rhino.Geometry;
using AngleUnit = OasysUnits.Units.AngleUnit;
using LengthUnit = OasysUnits.Units.LengthUnit;

namespace GsaGH.Parameters {
internal class GsaResultsValues {
internal enum ResultType {


public class GsaResultsValues : IResultValues<IQuantity, IQuantity, IDisplacementQuantity> {
public enum ResultType {
Displacement,
Force,
Stress,
Shear,
StrainEnergy,
Footfall,
}

internal IQuantity DmaxX { get; set; }
internal IQuantity DmaxXx { get; set; }
internal IQuantity DmaxXxyyzz { get; set; }
internal IQuantity DmaxXyz { get; set; }
internal IQuantity DmaxY { get; set; }
internal IQuantity DmaxYy { get; set; }
internal IQuantity DmaxZ { get; set; }
internal IQuantity DmaxZz { get; set; }
internal IQuantity DminX { get; set; }
internal IQuantity DminXx { get; set; }
internal IQuantity DminXxyyzz { get; set; }
internal IQuantity DminXyz { get; set; }
internal IQuantity DminY { get; set; }
internal IQuantity DminYy { get; set; }
internal IQuantity DminZ { get; set; }
internal IQuantity DminZz { get; set; }
internal ResultType Type { get; set; }
internal List<int> Ids => XyzResults.Keys.OrderBy(x => x).ToList();
public IQuantity DmaxX { get; set; }
public IQuantity DmaxXx { get; set; }
public IQuantity DmaxXxyyzz { get; set; }
public IQuantity DmaxXyz { get; set; }
public IQuantity DmaxY { get; set; }
public IQuantity DmaxYy { get; set; }
public IQuantity DmaxZ { get; set; }
public IQuantity DmaxZz { get; set; }
public IQuantity DminX { get; set; }
public IQuantity DminXx { get; set; }
public IQuantity DminXxyyzz { get; set; }
public IQuantity DminXyz { get; set; }
public IQuantity DminY { get; set; }
public IQuantity DminYy { get; set; }
public IQuantity DminZ { get; set; }
public IQuantity DminZz { get; set; }
public ResultType Type { get; set; }
public List<int> Ids => XyzResults.Keys.OrderBy(x => x).ToList();

internal ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>>
XxyyzzResults { get; set; }
Expand All @@ -49,6 +52,7 @@ internal ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>>
internal ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>>
XyzResults { get; set; }
= new ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>>();
public ConcurrentDictionary<int, ConcurrentDictionary<int, IDisplacementQuantity>> Results { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

internal GsaResultsValues() { }

Expand Down Expand Up @@ -170,4 +174,4 @@ internal void UpdateMinMax() {
}
}
}
}
}
Loading

0 comments on commit 6cfab49

Please sign in to comment.