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-392 2d/3d stress result abbreviation #546

Merged
merged 7 commits into from
Oct 13, 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
2 changes: 1 addition & 1 deletion GsaGH/Components/5_Results/Element2dStresses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected override void InitialiseDropdowns() {
_selectedItems = new List<string>();

_dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Stress));
_selectedItems.Add(_stresshUnit.ToString());
_selectedItems.Add(Pressure.GetAbbreviation(_stresshUnit));

_isInitialised = true;
}
Expand Down
85 changes: 18 additions & 67 deletions GsaGH/Components/5_Results/Element3dDisplacements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ protected override void RegisterInputParams(GH_InputParamManager pManager) {

protected override void RegisterOutputParams(GH_OutputParamManager pManager) {
string unitAbbreviation = Length.GetAbbreviation(_lengthUnit);

string note = ResultNotes.Note2dResults;

pManager.AddGenericParameter("Translations X [" + unitAbbreviation + "]", "Ux",
"Translations in X-direction in Global Axis." + note, GH_ParamAccess.tree);
pManager.AddGenericParameter("Translations Y [" + unitAbbreviation + "]", "Uy",
Expand All @@ -86,14 +84,6 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) {
"Translations in Z-direction in Global Axis." + note, GH_ParamAccess.tree);
pManager.AddGenericParameter("Translations |XYZ| [" + unitAbbreviation + "]", "|U|",
"Combined |XYZ| Translations." + note, GH_ParamAccess.tree);
pManager.AddGenericParameter("Rotations XX [rad]", "Rxx",
"Rotations around X-axis in Global Axis." + note, GH_ParamAccess.tree);
pManager.AddGenericParameter("Rotations YY [rad]", "Ryy",
"Rotations around Y-axis in Global Axiss." + note, GH_ParamAccess.tree);
pManager.AddGenericParameter("Rotations ZZ [rad]", "Rzz",
"Rotations around Z-axis in Global Axis." + note, GH_ParamAccess.tree);
pManager.AddGenericParameter("Rotations |XYZ| [rad]", "|R|",
"Combined |XXYYZZ| Rotations." + note, GH_ParamAccess.tree);
}

protected override void SolveInternal(IGH_DataAccess da) {
Expand All @@ -105,10 +95,6 @@ protected override void SolveInternal(IGH_DataAccess da) {
var outTransY = new DataTree<GH_UnitNumber>();
var outTransZ = new DataTree<GH_UnitNumber>();
var outTransXyz = new DataTree<GH_UnitNumber>();
var outRotX = new DataTree<GH_UnitNumber>();
var outRotY = new DataTree<GH_UnitNumber>();
var outRotZ = new DataTree<GH_UnitNumber>();
var outRotXyz = new DataTree<GH_UnitNumber>();

var ghTypes = new List<GH_ObjectWrapper>();
if (!da.GetDataList(0, ghTypes)) {
Expand Down Expand Up @@ -147,68 +133,33 @@ protected override void SolveInternal(IGH_DataAccess da) {
continue;
}

Parallel.For(0, 2, thread => // split computation in two for xyz and xxyyzz
{
switch (thread) {
case 0: {
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in
vals[perm - 1].XyzResults) {
int elementId = kvp.Key;
ConcurrentDictionary<int, GsaResultQuantity> res = kvp.Value;
if (res.Count == 0) {
continue;
}

var path = new GH_Path(result.CaseId,
result.SelectedPermutationIds == null ? 0 : perm, elementId);

outTransX.AddRange(
res.Select(x => new GH_UnitNumber(x.Value.X.ToUnit(_lengthUnit))),
path); // use ToUnit to capture changes in dropdown
outTransY.AddRange(
res.Select(x => new GH_UnitNumber(x.Value.Y.ToUnit(_lengthUnit))), path);
outTransZ.AddRange(
res.Select(x => new GH_UnitNumber(x.Value.Z.ToUnit(_lengthUnit))), path);
outTransXyz.AddRange(
res.Select(x => new GH_UnitNumber(x.Value.Xyz.ToUnit(_lengthUnit))), path);
}

break;
}
case 1: {
foreach (KeyValuePair<int, ConcurrentDictionary<int, GsaResultQuantity>> kvp in
vals[perm - 1].XxyyzzResults) {
int elementId = kvp.Key;
ConcurrentDictionary<int, GsaResultQuantity> res = kvp.Value;
if (res.Count == 0) {
continue;
}

var path = new GH_Path(result.CaseId,
result.SelectedPermutationIds == null ? 0 : perm, elementId);

outRotX.AddRange(res.Select(x => new GH_UnitNumber(x.Value.X)),
path); // always use [rad] units
outRotY.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Y)), path);
outRotZ.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Z)), path);
outRotXyz.AddRange(res.Select(x => new GH_UnitNumber(x.Value.Xyz)), path);
}

break;
}
int elementId = kvp.Key;
ConcurrentDictionary<int, GsaResultQuantity> res = kvp.Value;
if (res.Count == 0) {
continue;
}
});

var path = new GH_Path(result.CaseId,
result.SelectedPermutationIds == null ? 0 : perm, elementId);
// use ToUnit to capture changes in dropdown
outTransX.AddRange(
res.Select(x => new GH_UnitNumber(x.Value.X.ToUnit(_lengthUnit))), path);
outTransY.AddRange(
res.Select(x => new GH_UnitNumber(x.Value.Y.ToUnit(_lengthUnit))), path);
outTransZ.AddRange(
res.Select(x => new GH_UnitNumber(x.Value.Z.ToUnit(_lengthUnit))), path);
outTransXyz.AddRange(
res.Select(x => new GH_UnitNumber(x.Value.Xyz.ToUnit(_lengthUnit))), path);
}
}
}

da.SetDataTree(0, outTransX);
da.SetDataTree(1, outTransY);
da.SetDataTree(2, outTransZ);
da.SetDataTree(3, outTransXyz);
da.SetDataTree(4, outRotX);
da.SetDataTree(5, outRotY);
da.SetDataTree(6, outRotZ);
da.SetDataTree(7, outRotXyz);

PostHog.Result(result.Type, 3, GsaResultsValues.ResultType.Displacement);
}
Expand Down
2 changes: 1 addition & 1 deletion GsaGH/Components/5_Results/Element3dStresses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected override void InitialiseDropdowns() {
_selectedItems = new List<string>();

_dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Stress));
_selectedItems.Add(_stresshUnit.ToString());
_selectedItems.Add(Pressure.GetAbbreviation(_stresshUnit));

_isInitialised = true;
}
Expand Down
4 changes: 4 additions & 0 deletions GsaGH/Components/6_Display/ResultDiagrams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ private List<GsaAnnotationGoo> GenerateAnnotations(
= $"{Math.Round(valResult * valueScaleFactor, significantDigits)} {Message}";
}

if (color == Color.Empty) {
color = (Color)annotation.Colour;
}

diagramAnnotations.Add(new GsaAnnotationGoo(
new GsaAnnotationDot(location, color, valueToAnnotate)));
}
Expand Down
4 changes: 2 additions & 2 deletions GsaGHTests/3_Components/ComponentsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ public void WhenInitialiseDropdowns_ThenDropDownItems_ShouldBeNull(Type t) {
[InlineData(typeof(Contour2dResults), "Displacement", "Footfall")]
[InlineData(typeof(Element2dDisplacements), "mm", "ft")]
[InlineData(typeof(Element2dForcesAndMoments), "kN/m", "kipf/ft")]
[InlineData(typeof(Element2dStresses), "Megapascal", "kipf/ft²")]
[InlineData(typeof(Element2dStresses), "MPa", "kipf/ft²")]
[InlineData(typeof(Contour3dResults), "Displacement", "Stress")]
[InlineData(typeof(Element3dDisplacements), "mm", "ft")]
[InlineData(typeof(Element3dStresses), "Megapascal", "kipf/ft²")]
[InlineData(typeof(Element3dStresses), "MPa", "kipf/ft²")]
[InlineData(typeof(GlobalPerformanceResults), "t", "slug")]
[InlineData(typeof(ContourNodeResults), "Displacement", "Footfall")]
[InlineData(typeof(NodeDisplacements), "mm", "ft")]
Expand Down
Loading