diff --git a/GsaGH/Components/1_Properties/Create2dProperty.cs b/GsaGH/Components/1_Properties/Create2dProperty.cs index c0df28d21..cbad2b1bc 100644 --- a/GsaGH/Components/1_Properties/Create2dProperty.cs +++ b/GsaGH/Components/1_Properties/Create2dProperty.cs @@ -14,7 +14,6 @@ using OasysGH; using OasysGH.Components; using OasysGH.Helpers; -using OasysGH.Parameters; using OasysGH.Units; using OasysGH.Units.Helpers; using OasysUnits; diff --git a/GsaGH/Components/5_Results/BeamDisplacements.cs b/GsaGH/Components/5_Results/BeamDisplacements.cs index 89193adab..03be03fc7 100644 --- a/GsaGH/Components/5_Results/BeamDisplacements.cs +++ b/GsaGH/Components/5_Results/BeamDisplacements.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using System.Linq; using System.Threading.Tasks; @@ -12,6 +13,7 @@ using GsaGH.Helpers; using GsaGH.Helpers.GH; using GsaGH.Parameters; +using GsaGH.Parameters.Results; using GsaGH.Properties; using OasysGH; using OasysGH.Components; @@ -40,7 +42,7 @@ public BeamDisplacements() : base("Beam Displacements", "BeamDisp", public override void SetSelected(int i, int j) { _selectedItems[i] = _dropDownItems[i][j]; - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); + _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[1]); base.UpdateUI(); } @@ -55,12 +57,16 @@ public override void VariableParameterMaintenance() { protected override void InitialiseDropdowns() { _spacerDescriptions = new List(new[] { + "Envelope", "Unit", }); _dropDownItems = new List>(); _selectedItems = new List(); + _dropDownItems.Add(ExtremaHelper.Vector6Displacements.ToList()); + _selectedItems.Add(_dropDownItems[0][0]); + _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); @@ -78,7 +84,6 @@ protected override void RegisterInputParams(GH_InputParamManager pManager) { protected override void RegisterOutputParams(GH_OutputParamManager pManager) { string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - string note = ResultNotes.Note1dResults; pManager.AddGenericParameter("Translations X [" + unitAbbreviation + "]", "Ux", @@ -100,15 +105,16 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) { } protected override void SolveInternal(IGH_DataAccess da) { - var result = new GsaResult(); - + GsaResult2 result; string elementlist = "All"; - var ghDivisions = new GH_Integer(); da.GetData(2, ref ghDivisions); GH_Convert.ToInt32(ghDivisions, out int positionsCount, GH_Conversion.Both); positionsCount = Math.Abs(positionsCount) + 2; // taken absolute value and add 2 end points. + var ghTypes = new List(); + da.GetDataList(0, ghTypes); + var outTransX = new DataTree(); var outTransY = new DataTree(); var outTransZ = new DataTree(); @@ -118,95 +124,71 @@ protected override void SolveInternal(IGH_DataAccess da) { var outRotZ = new DataTree(); var outRotXyz = new DataTree(); - var ghTypes = new List(); - if (!da.GetDataList(0, ghTypes)) { - return; - } - foreach (GH_ObjectWrapper ghTyp in ghTypes) { - if (ghTyp?.Value == null) { - this.AddRuntimeWarning("Input is null"); - return; - } - - if (ghTyp.Value is GsaResultGoo goo) { - result = goo.Value; - elementlist = Inputs.GetElementListDefinition(this, da, 1, result.Model); - } else { - this.AddRuntimeError("Error converting input to GSA Result"); - return; + switch (ghTyp?.Value) { + case GsaResultGoo goo: + result = new GsaResult2((GsaResult)goo.Value); + elementlist = Inputs.GetElementListDefinition(this, da, 1, result.Model); + break; + + case null: + this.AddRuntimeWarning("Input is null"); + return; + + default: + this.AddRuntimeError("Error converting input to GSA Result"); + return; } - List vals - = result.Element1DDisplacementValues(elementlist, positionsCount, -1, _lengthUnit); + ReadOnlyCollection elementIds = result.ElementIds(elementlist); + IElement1dResultSubset> resultSet = + result.Element1dDisplacements.ResultSubset(elementIds, positionsCount); - List permutations = result.SelectedPermutationIds is null ? new List() { + List permutations = result.SelectedPermutationIds ?? new List() { 1, - } : result.SelectedPermutationIds; + }; if (permutations.Count == 1 && permutations[0] == -1) { - permutations = Enumerable.Range(1, vals.Count).ToList(); + permutations = Enumerable.Range(1, resultSet.Subset.Values.First().Count).ToList(); } - // loop through all permutations (analysis case will just have one) - foreach (int perm in permutations) { - if (vals[perm - 1].XyzResults.Count == 0 & vals[perm - 1].XxyyzzResults.Count == 0) { - string acase = result.ToString().Replace('}', ' ').Replace('{', ' '); - this.AddRuntimeWarning("Case " + acase + " contains no Element1D results."); - continue; - } - - Parallel.For(0, 2, thread => // split computation in two for xyz and xxyyzz - { - switch (thread) { - case 0: { - foreach (KeyValuePair> kvp in - vals[perm - 1].XyzResults) { - int elementId = kvp.Key; - ConcurrentDictionary 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> kvp in - vals[perm - 1].XxyyzzResults) { - int elementId = kvp.Key; - ConcurrentDictionary 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; - } + if (_selectedItems[0] == ExtremaHelper.Vector6Displacements[0]) { + foreach (KeyValuePair> kvp in resultSet.Subset) { + foreach (int p in permutations) { + var path = new GH_Path(result.CaseId, result.SelectedPermutationIds == null ? 0 : p, kvp.Key); + outTransX.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.X.ToUnit(_lengthUnit))), path); + outTransY.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Y.ToUnit(_lengthUnit))), path); + outTransZ.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Z.ToUnit(_lengthUnit))), path); + outTransXyz.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Xyz.ToUnit(_lengthUnit))), path); + outRotX.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Xx)), path); + outRotY.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Yy)), path); + outRotZ.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Zz)), path); + outRotXyz.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Xxyyzz)), path); } - }); + } + } else { + Element1dExtremaKey key = ExtremaHelper.DisplacementExtremaKey(resultSet, _selectedItems[0]); + IDisplacement extrema = resultSet.GetExtrema(key); + int perm = result.CaseType == CaseType.AnalysisCase ? 0 : 1; + var path = new GH_Path(result.CaseId, key.Permutation + perm, key.Id); + outTransX.Add(new GH_UnitNumber(extrema.X.ToUnit(_lengthUnit)), path); + outTransY.Add(new GH_UnitNumber(extrema.Y.ToUnit(_lengthUnit)), path); + outTransZ.Add(new GH_UnitNumber(extrema.Z.ToUnit(_lengthUnit)), path); + outTransXyz.Add(new GH_UnitNumber(extrema.Xyz.ToUnit(_lengthUnit)), path); + outRotX.Add(new GH_UnitNumber(extrema.Xx), path); + outRotY.Add(new GH_UnitNumber(extrema.Yy), path); + outRotZ.Add(new GH_UnitNumber(extrema.Zz), path); + outRotXyz.Add(new GH_UnitNumber(extrema.Xxyyzz), path); } + + PostHog.Result(result.CaseType, 1, GsaResultsValues.ResultType.Displacement); } da.SetDataTree(0, outTransX); @@ -217,12 +199,16 @@ List vals da.SetDataTree(5, outRotY); da.SetDataTree(6, outRotZ); da.SetDataTree(7, outRotXyz); - - PostHog.Result(result.Type, 1, GsaResultsValues.ResultType.Displacement); } protected override void UpdateUIFromSelectedItems() { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[0]); + if (_selectedItems.Count == 1) { + _spacerDescriptions.Insert(0, "Envelope"); + _dropDownItems.Insert(0, ExtremaHelper.Vector6Displacements.ToList()); + _selectedItems.Insert(0, _dropDownItems[0][0]); + } + + _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[1]); base.UpdateUIFromSelectedItems(); } } diff --git a/GsaGH/Components/5_Results/BeamForcesAndMoments.cs b/GsaGH/Components/5_Results/BeamForcesAndMoments.cs index 224d70d3c..c622628f8 100644 --- a/GsaGH/Components/5_Results/BeamForcesAndMoments.cs +++ b/GsaGH/Components/5_Results/BeamForcesAndMoments.cs @@ -1,9 +1,8 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using System.Linq; -using System.Threading.Tasks; using Grasshopper; using Grasshopper.Kernel; using Grasshopper.Kernel.Data; @@ -12,6 +11,7 @@ using GsaGH.Helpers; using GsaGH.Helpers.GH; using GsaGH.Parameters; +using GsaGH.Parameters.Results; using GsaGH.Properties; using OasysGH; using OasysGH.Components; @@ -41,11 +41,11 @@ public BeamForcesAndMoments() : base("Beam Forces and Moments", "BeamForces", public override void SetSelected(int i, int j) { _selectedItems[i] = _dropDownItems[i][j]; switch (i) { - case 0: + case 1: _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[i]); break; - case 1: + case 2: _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), _selectedItems[i]); break; } @@ -69,6 +69,7 @@ public override void VariableParameterMaintenance() { protected override void InitialiseDropdowns() { _spacerDescriptions = new List(new[] { + "Envelope", "Force Unit", "Moment Unit", }); @@ -76,6 +77,9 @@ protected override void InitialiseDropdowns() { _dropDownItems = new List>(); _selectedItems = new List(); + _dropDownItems.Add(ExtremaHelper.Vector6InternalForces.ToList()); + _selectedItems.Add(_dropDownItems[0][0]); + _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Force)); _selectedItems.Add(Force.GetAbbreviation(_forceUnit)); @@ -127,14 +131,16 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) { } protected override void SolveInternal(IGH_DataAccess da) { - var result = new GsaResult(); + GsaResult2 result; string elementlist = "All"; - var ghDivisions = new GH_Integer(); da.GetData(2, ref ghDivisions); GH_Convert.ToInt32(ghDivisions, out int positionsCount, GH_Conversion.Both); positionsCount = Math.Abs(positionsCount) + 2; // taken absolute value and add 2 end points. + var ghTypes = new List(); + da.GetDataList(0, ghTypes); + var outTransX = new DataTree(); var outTransY = new DataTree(); var outTransZ = new DataTree(); @@ -144,100 +150,71 @@ protected override void SolveInternal(IGH_DataAccess da) { var outRotZ = new DataTree(); var outRotXyz = new DataTree(); - var ghTypes = new List(); - if (!da.GetDataList(0, ghTypes)) { - return; - } - foreach (GH_ObjectWrapper ghTyp in ghTypes) { switch (ghTyp?.Value) { - case null: - this.AddRuntimeWarning("Input is null"); - return; - case GsaResultGoo goo: - result = goo.Value; + result = new GsaResult2((GsaResult)goo.Value); elementlist = Inputs.GetElementListDefinition(this, da, 1, result.Model); break; + case null: + this.AddRuntimeWarning("Input is null"); + return; + default: this.AddRuntimeError("Error converting input to GSA Result"); return; } - List vals - = result.Element1DForceValues(elementlist, positionsCount, 0, _forceUnit, _momentUnit); + ReadOnlyCollection elementIds = result.ElementIds(elementlist); + IElement1dResultSubset> resultSet = + result.Element1dInternalForces.ResultSubset(elementIds, positionsCount); List permutations = result.SelectedPermutationIds ?? new List() { 1, }; if (permutations.Count == 1 && permutations[0] == -1) { - permutations = Enumerable.Range(1, vals.Count).ToList(); + permutations = Enumerable.Range(1, resultSet.Subset.Values.First().Count).ToList(); } - foreach (int perm in permutations) { - if (vals[perm - 1].XyzResults.Count == 0 & vals[perm - 1].XxyyzzResults.Count == 0) { - string acase = result.ToString().Replace('}', ' ').Replace('{', ' '); - this.AddRuntimeWarning("Case " + acase + " contains no Element1D results."); - continue; - } - - Parallel.For(0, 2, thread => // split computation in two for xyz and xxyyzz - { - switch (thread) { - case 0: { - foreach (KeyValuePair> kvp in - vals[perm - 1].XyzResults) { - int elementId = kvp.Key; - ConcurrentDictionary 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(_forceUnit))), - path); // use ToUnit to capture changes in dropdown - outTransY.AddRange( - res.Select(x => new GH_UnitNumber(x.Value.Y.ToUnit(_forceUnit))), path); - outTransZ.AddRange( - res.Select(x => new GH_UnitNumber(x.Value.Z.ToUnit(_forceUnit))), path); - outTransXyz.AddRange( - res.Select(x => new GH_UnitNumber(x.Value.Xyz.ToUnit(_forceUnit))), path); - } - - break; - } - case 1: { - foreach (KeyValuePair> kvp in - vals[perm - 1].XxyyzzResults) { - int elementId = kvp.Key; - ConcurrentDictionary 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.ToUnit(_momentUnit))), - path); // always use [rad] units - outRotY.AddRange( - res.Select(x => new GH_UnitNumber(x.Value.Y.ToUnit(_momentUnit))), path); - outRotZ.AddRange( - res.Select(x => new GH_UnitNumber(x.Value.Z.ToUnit(_momentUnit))), path); - outRotXyz.AddRange( - res.Select(x => new GH_UnitNumber(x.Value.Xyz.ToUnit(_momentUnit))), path); - } - - break; - } + if (_selectedItems[0] == ExtremaHelper.Vector6Displacements[0]) { + foreach (KeyValuePair> kvp in resultSet.Subset) { + foreach (int p in permutations) { + var path = new GH_Path(result.CaseId, result.SelectedPermutationIds == null ? 0 : p, kvp.Key); + outTransX.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.X.ToUnit(_forceUnit))), path); + outTransY.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Y.ToUnit(_forceUnit))), path); + outTransZ.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Z.ToUnit(_forceUnit))), path); + outTransXyz.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Xyz.ToUnit(_forceUnit))), path); + outRotX.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Xx.ToUnit(_momentUnit))), path); + outRotY.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Yy.ToUnit(_momentUnit))), path); + outRotZ.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Zz.ToUnit(_momentUnit))), path); + outRotXyz.AddRange(kvp.Value[p - 1].Results.Values.Select( + r => new GH_UnitNumber(r.Xxyyzz.ToUnit(_momentUnit))), path); } - }); + } + } else { + Element1dExtremaKey key = ExtremaHelper.InternalForceExtremaKey(resultSet, _selectedItems[0]); + IInternalForce extrema = resultSet.GetExtrema(key); + int perm = result.CaseType == CaseType.AnalysisCase ? 0 : 1; + var path = new GH_Path(result.CaseId, key.Permutation + perm, key.Id); + outTransX.Add(new GH_UnitNumber(extrema.X.ToUnit(_forceUnit)), path); + outTransY.Add(new GH_UnitNumber(extrema.Y.ToUnit(_forceUnit)), path); + outTransZ.Add(new GH_UnitNumber(extrema.Z.ToUnit(_forceUnit)), path); + outTransXyz.Add(new GH_UnitNumber(extrema.Xyz.ToUnit(_forceUnit)), path); + outRotX.Add(new GH_UnitNumber(extrema.Xx.ToUnit(_momentUnit)), path); + outRotY.Add(new GH_UnitNumber(extrema.Yy.ToUnit(_momentUnit)), path); + outRotZ.Add(new GH_UnitNumber(extrema.Zz.ToUnit(_momentUnit)), path); + outRotXyz.Add(new GH_UnitNumber(extrema.Xxyyzz.ToUnit(_momentUnit)), path); } + + PostHog.Result(result.CaseType, 1, GsaResultsValues.ResultType.Force); } da.SetDataTree(0, outTransX); @@ -248,13 +225,17 @@ List vals da.SetDataTree(5, outRotY); da.SetDataTree(6, outRotZ); da.SetDataTree(7, outRotXyz); - - PostHog.Result(result.Type, 1, GsaResultsValues.ResultType.Force); } protected override void UpdateUIFromSelectedItems() { - _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[0]); - _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), _selectedItems[1]); + if (_selectedItems.Count == 2) { + _spacerDescriptions.Insert(0, "Envelope"); + _dropDownItems.Insert(0, ExtremaHelper.Vector6InternalForces.ToList()); + _selectedItems.Insert(0, _dropDownItems[0][0]); + } + + _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[1]); + _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), _selectedItems[2]); base.UpdateUIFromSelectedItems(); } } diff --git a/GsaGH/Components/5_Results/BeamStrainEnergyDensity.cs b/GsaGH/Components/5_Results/BeamStrainEnergyDensity.cs index 97f9405de..896b876eb 100644 --- a/GsaGH/Components/5_Results/BeamStrainEnergyDensity.cs +++ b/GsaGH/Components/5_Results/BeamStrainEnergyDensity.cs @@ -161,7 +161,7 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: - result = goo.Value; + result = (GsaResult)goo.Value; elementlist = Inputs.GetElementListDefinition(this, da, 1, result.Model); break; @@ -207,7 +207,7 @@ protected override void SolveInternal(IGH_DataAccess da) { da.SetDataTree(0, outTransX); - PostHog.Result(result.Type, 1, GsaResultsValues.ResultType.StrainEnergy); + PostHog.Result(result.CaseType, 1, GsaResultsValues.ResultType.StrainEnergy); } protected override void UpdateUIFromSelectedItems() { diff --git a/GsaGH/Components/5_Results/Element2dDisplacements.cs b/GsaGH/Components/5_Results/Element2dDisplacements.cs index de7ed8721..86a955106 100644 --- a/GsaGH/Components/5_Results/Element2dDisplacements.cs +++ b/GsaGH/Components/5_Results/Element2dDisplacements.cs @@ -121,7 +121,7 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: - result = goo.Value; + result = (GsaResult)goo.Value; elementlist = Inputs.GetElementListDefinition(this, da, 1, result.Model); break; @@ -209,7 +209,7 @@ protected override void SolveInternal(IGH_DataAccess da) { da.SetDataTree(6, outRotZ); da.SetDataTree(7, outRotXyz); - PostHog.Result(result.Type, 2, GsaResultsValues.ResultType.Displacement); + PostHog.Result(result.CaseType, 2, GsaResultsValues.ResultType.Displacement); } protected override void UpdateUIFromSelectedItems() { diff --git a/GsaGH/Components/5_Results/Element2dForcesAndMoments.cs b/GsaGH/Components/5_Results/Element2dForcesAndMoments.cs index 95705e169..45b802948 100644 --- a/GsaGH/Components/5_Results/Element2dForcesAndMoments.cs +++ b/GsaGH/Components/5_Results/Element2dForcesAndMoments.cs @@ -184,7 +184,7 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: - result = goo.Value; + result = (GsaResult)goo.Value; elementlist = Inputs.GetElementListDefinition(this, da, 1, result.Model); break; @@ -295,7 +295,7 @@ List vals da.SetDataTree(6, outYy); da.SetDataTree(7, outXxyy); - PostHog.Result(result.Type, 2, GsaResultsValues.ResultType.Force); + PostHog.Result(result.CaseType, 2, GsaResultsValues.ResultType.Force); da.SetDataTree(8, outWaxx); da.SetDataTree(9, outWayy); } diff --git a/GsaGH/Components/5_Results/Element2dStresses.cs b/GsaGH/Components/5_Results/Element2dStresses.cs index 34f536721..016362424 100644 --- a/GsaGH/Components/5_Results/Element2dStresses.cs +++ b/GsaGH/Components/5_Results/Element2dStresses.cs @@ -128,7 +128,7 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: - result = goo.Value; + result = (GsaResult)goo.Value; elementlist = Inputs.GetElementListDefinition(this, da, 1, result.Model); break; @@ -213,7 +213,7 @@ List vals da.SetDataTree(4, outYz); da.SetDataTree(5, outZx); - PostHog.Result(result.Type, 2, GsaResultsValues.ResultType.Stress); + PostHog.Result(result.CaseType, 2, GsaResultsValues.ResultType.Stress); } protected override void UpdateUIFromSelectedItems() { diff --git a/GsaGH/Components/5_Results/Element3dDisplacements.cs b/GsaGH/Components/5_Results/Element3dDisplacements.cs index 6c2f02006..37fa8fa3c 100644 --- a/GsaGH/Components/5_Results/Element3dDisplacements.cs +++ b/GsaGH/Components/5_Results/Element3dDisplacements.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; -using System.Threading.Tasks; using Grasshopper; using Grasshopper.Kernel; using Grasshopper.Kernel.Data; @@ -108,7 +107,7 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: - result = goo.Value; + result = (GsaResult)goo.Value; elementlist = Inputs.GetElementListDefinition(this, da, 1, result.Model); break; @@ -161,7 +160,7 @@ protected override void SolveInternal(IGH_DataAccess da) { da.SetDataTree(2, outTransZ); da.SetDataTree(3, outTransXyz); - PostHog.Result(result.Type, 3, GsaResultsValues.ResultType.Displacement); + PostHog.Result(result.CaseType, 3, GsaResultsValues.ResultType.Displacement); } protected override void UpdateUIFromSelectedItems() { diff --git a/GsaGH/Components/5_Results/Element3dStresses.cs b/GsaGH/Components/5_Results/Element3dStresses.cs index 1a60c5225..97011f4e3 100644 --- a/GsaGH/Components/5_Results/Element3dStresses.cs +++ b/GsaGH/Components/5_Results/Element3dStresses.cs @@ -118,7 +118,7 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: - result = goo.Value; + result = (GsaResult)goo.Value; elementlist = Inputs.GetElementListDefinition(this, da, 1, result.Model); break; @@ -202,7 +202,7 @@ protected override void SolveInternal(IGH_DataAccess da) { da.SetDataTree(4, outYz); da.SetDataTree(5, outZx); - PostHog.Result(result.Type, 3, GsaResultsValues.ResultType.Stress); + PostHog.Result(result.CaseType, 3, GsaResultsValues.ResultType.Stress); } protected override void UpdateUIFromSelectedItems() { diff --git a/GsaGH/Components/5_Results/FootfallResults.cs b/GsaGH/Components/5_Results/FootfallResults.cs index d094281bf..b4b62f278 100644 --- a/GsaGH/Components/5_Results/FootfallResults.cs +++ b/GsaGH/Components/5_Results/FootfallResults.cs @@ -1,80 +1,186 @@ using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; +using System.Linq; +using Grasshopper; using Grasshopper.Kernel; +using Grasshopper.Kernel.Data; using Grasshopper.Kernel.Types; +using GsaGH.Components.Helpers; using GsaGH.Helpers; using GsaGH.Helpers.GH; -using GsaGH.Helpers.GsaApi; using GsaGH.Parameters; +using GsaGH.Parameters.Results; using GsaGH.Properties; using OasysGH; using OasysGH.Components; +using OasysGH.Parameters; +using OasysUnits; +using OasysUnits.Units; namespace GsaGH.Components { - /// - /// Component to select results from a GSA Model - /// - public class FootfallResults : GH_OasysComponent { - public override Guid ComponentGuid => new Guid("c5194fe3-8c20-43f0-a8cb-3207ed867221"); + public class FootfallResults : GH_OasysDropDownComponent { + public override Guid ComponentGuid => new Guid("224074e5-2fdc-48fa-a042-89a2c62f0c88"); public override GH_Exposure Exposure => GH_Exposure.senary | GH_Exposure.obscure; public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; protected override Bitmap Icon => Resources.FootfallResults; public FootfallResults() : base("Footfall Results", "Footfall", - "Get the maximum response factor for a footfall analysis case", CategoryName.Name(), - SubCategoryName.Cat5()) { + "Node Resonant or Transient Footfall result values", CategoryName.Name(), SubCategoryName.Cat5()) { Hidden = true; } + public override void SetSelected(int i, int j) { + _selectedItems[i] = _dropDownItems[i][j]; + base.UpdateUI(); + } + + protected override void InitialiseDropdowns() { + _spacerDescriptions = new List(new[] { + "Type", + "Envelope", + }); + + _dropDownItems = new List>(); + _selectedItems = new List(); + + _dropDownItems.Add(new List(new[] { + "Resonant", + "Transient", + })); + _selectedItems.Add(_dropDownItems[0][0]); + + _dropDownItems.Add(ExtremaHelper.Vector6Displacements.ToList()); + _selectedItems.Add(_dropDownItems[1][0]); + + _isInitialised = true; + } + protected override void RegisterInputParams(GH_InputParamManager pManager) { pManager.AddParameter(new GsaResultParameter(), "Result", "Res", "GSA Result", - GH_ParamAccess.item); + GH_ParamAccess.list); pManager.AddParameter(new GsaNodeListParameter()); pManager[1].Optional = true; } protected override void RegisterOutputParams(GH_OutputParamManager pManager) { - pManager.AddNumberParameter("Resonant Response Factor", "RRF", - "Maximum resonant response factor", GH_ParamAccess.item); - pManager.AddNumberParameter("Transient Response Factor", "TRF", - "Maximum transient response factor", GH_ParamAccess.item); + string hz = Frequency.GetAbbreviation(FrequencyUnit.Hertz); + string mps2 = Acceleration.GetAbbreviation(AccelerationUnit.MeterPerSecondSquared); + string mps = Speed.GetAbbreviation(SpeedUnit.MeterPerSecond); + string note = ResultNotes.NoteNodeResults; + + pManager.AddNumberParameter("Maximum Response Factor", "RF", + "The maximum response factor." + note, GH_ParamAccess.tree); + pManager.AddGenericParameter("Peak Velocity [" + mps + "]", "PkV", + "The peak velocity." + note, GH_ParamAccess.tree); + pManager.AddGenericParameter("RMS Velocity [" + mps + "]", "RmV", + "The root mean square (rms) veloocity." + note, GH_ParamAccess.tree); + pManager.AddGenericParameter("Peak Acceleration [" + mps + "]", "PkA", + "The peak velocity." + note, GH_ParamAccess.tree); + pManager.AddGenericParameter("RMS Acceleration [" + mps + "]", "RmA", + "The root mean square (rms) acceleration." + note, GH_ParamAccess.tree); + pManager.AddIntegerParameter("Critical Node", "CN", + "The node ID of the critical frequency" + note, GH_ParamAccess.tree); + pManager.AddGenericParameter("Critical Frequency [" + hz + "]", "Cf", + "The critical frequency" + note, GH_ParamAccess.tree); + pManager.AddTextParameter("Nodes IDs", "ID", "Node IDs for each result value", + GH_ParamAccess.tree); } - protected override void SolveInstance(IGH_DataAccess da) { - GsaResult result; - var ghTyp = new GH_ObjectWrapper(); - if (!da.GetData(0, ref ghTyp)) { + protected override void SolveInternal(IGH_DataAccess da) { + GsaResult2 result; + string nodeList = "All"; + + var ghTypes = new List(); + if (!da.GetDataList(0, ghTypes)) { return; } - switch (ghTyp?.Value) { - case null: - this.AddRuntimeWarning("Input is null"); - return; + var rf = new DataTree(); + var peakVelo = new DataTree(); + var rmsVelo = new DataTree(); + var peakAcc = new DataTree(); + var rmsAcc = new DataTree(); + var critId = new DataTree(); + var critfreq = new DataTree(); + var outIDs = new DataTree(); - case GsaResultGoo goo: { - result = goo.Value; - if (result.Type == CaseType.CombinationCase) { - this.AddRuntimeError("Footfall Result only available for Analysis Cases"); + foreach (GH_ObjectWrapper ghTyp in ghTypes) { + switch (ghTyp?.Value) { + case GsaResultGoo goo: + result = new GsaResult2((GsaResult)goo.Value); + nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model); + break; + + case null: + this.AddRuntimeWarning("Input is null"); return; - } - break; + default: + this.AddRuntimeError("Error converting input to GSA Result"); + return; } - default: - this.AddRuntimeError("Error converting input to GSA Result"); + + ReadOnlyCollection nodeIds = result.NodeIds(nodeList); + INodeResultSubset> resultSet + = _selectedItems[0] == _dropDownItems[0][0] + ? result.NodeResonantFootfalls.ResultSubset(nodeIds) + : result.NodeTransientFootfalls.ResultSubset(nodeIds); + + if (resultSet.Ids.Count == 0) { + this.AddRuntimeWarning($"{result.CaseType} {result.CaseId} contains no Footfall results."); return; - } + } - string nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model); + List permutations = result.SelectedPermutationIds ?? new List() { + 1, + }; + if (permutations.Count == 1 && permutations[0] == -1) { + permutations = Enumerable.Range(1, resultSet.Subset.Values.First().Count).ToList(); + } - GsaResultsValues res = result.NodeFootfallValues(nodeList, FootfallResultType.Resonant); - GsaResultsValues tra = result.NodeFootfallValues(nodeList, FootfallResultType.Transient); + if (_selectedItems[1] == ExtremaHelper.Footfall[0]) { + foreach (int id in resultSet.Ids) { + foreach (int p in permutations) { + var path = new GH_Path(result.CaseId, result.SelectedPermutationIds == null ? 0 : p); + IFootfall res = resultSet.Subset[id][p - 1]; + rf.Add(res.MaximumResponseFactor, path); + peakVelo.Add(new GH_UnitNumber(res.PeakVelocity), path); + rmsVelo.Add(new GH_UnitNumber(res.RmsVelocity), path); + peakAcc.Add(new GH_UnitNumber(res.PeakAcceleration), path); + rmsAcc.Add(new GH_UnitNumber(res.RmsAcceleration), path); + critId.Add(res.CriticalNode, path); + critfreq.Add(new GH_UnitNumber(res.CriticalFrequency), path); + outIDs.Add(id, path); + } + } + } else { + NodeExtremaKey key = ExtremaHelper.FootfallExtremaKey(resultSet, _selectedItems[0]); + IFootfall extrema = resultSet.GetExtrema(key); + int perm = result.CaseType == CaseType.AnalysisCase ? 0 : 1; + var path = new GH_Path(result.CaseId, key.Permutation + perm); + rf.Add(extrema.MaximumResponseFactor, path); + peakVelo.Add(new GH_UnitNumber(extrema.PeakVelocity), path); + rmsVelo.Add(new GH_UnitNumber(extrema.RmsVelocity), path); + peakAcc.Add(new GH_UnitNumber(extrema.PeakAcceleration), path); + rmsAcc.Add(new GH_UnitNumber(extrema.RmsAcceleration), path); + critId.Add(extrema.CriticalNode, path); + critfreq.Add(new GH_UnitNumber(extrema.CriticalFrequency), path); + outIDs.Add(key.Id, path); + } - da.SetData(0, res.DmaxX.Value); - da.SetData(1, tra.DmaxX.Value); + PostHog.Result(result.CaseType, 0, GsaResultsValues.ResultType.Displacement); + } - PostHog.Result(result.Type, 0, GsaResultsValues.ResultType.Footfall, "Max"); + da.SetDataTree(0, rf); + da.SetDataTree(1, peakVelo); + da.SetDataTree(2, rmsVelo); + da.SetDataTree(3, peakAcc); + da.SetDataTree(4, rmsAcc); + da.SetDataTree(5, critId); + da.SetDataTree(6, critfreq); + da.SetDataTree(7, outIDs); } } } diff --git a/GsaGH/Components/5_Results/GlobalPerformanceResults.cs b/GsaGH/Components/5_Results/GlobalPerformanceResults.cs index 7a3ef67e4..2526d64dc 100644 --- a/GsaGH/Components/5_Results/GlobalPerformanceResults.cs +++ b/GsaGH/Components/5_Results/GlobalPerformanceResults.cs @@ -167,8 +167,8 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: { - result = goo.Value; - if (result.Type == CaseType.CombinationCase) { + result = (GsaResult)goo.Value; + if (result.CaseType == CaseType.CombinationCase) { this.AddRuntimeError("Global Result only available for Analysis Cases"); return; } @@ -260,7 +260,7 @@ GsaResultQuantity stiff da.SetData(i, null); } - PostHog.Result(result.Type, -1, "Global", "Performance"); + PostHog.Result(result.CaseType, -1, "Global", "Performance"); } protected override void UpdateUIFromSelectedItems() { diff --git a/GsaGH/Components/5_Results/Helpers/ExtremaHelper.cs b/GsaGH/Components/5_Results/Helpers/ExtremaHelper.cs new file mode 100644 index 000000000..a6a161fd7 --- /dev/null +++ b/GsaGH/Components/5_Results/Helpers/ExtremaHelper.cs @@ -0,0 +1,223 @@ +using System; +using System.Collections.ObjectModel; +using GsaGH.Parameters.Results; + +namespace GsaGH.Components.Helpers { + internal class ExtremaHelper { + internal static readonly ReadOnlyCollection Footfall + = new ReadOnlyCollection(new[] { + "All", + "Max Response Factor", + "Max Peak Velocity", + "Max RMS Velocity", + "Max Peak Acceleration", + "Max RMS Acceleration", + "Max Critical Frequency", + "Min Response Factor", + "Min Peak Velocity", + "Min RMS Velocity", + "Min Peak Acceleration", + "Min RMS Acceleration", + "Min Critical Frequency", + }); + + internal static readonly ReadOnlyCollection Vector6Displacements + = new ReadOnlyCollection(new[] { + "All", + "Max Ux", + "Max Uy", + "Max Uz", + "Max |U|", + "Max Rxx", + "Max Ryy", + "Max Rzz", + "Max |R|", + "Min Ux", + "Min Uy", + "Min Uz", + "Min |U|", + "Min Rxx", + "Min Ryy", + "Min Rzz", + "Min |R|", + }); + + internal static readonly ReadOnlyCollection Vector6InternalForces + = new ReadOnlyCollection(new[] { + "All", + "Max Fx", + "Max Fy", + "Max Fz", + "Max |Fyz|", + "Max Mxx", + "Max Myy", + "Max Mzz", + "Max |Myz|", + "Min Fx", + "Min Fy", + "Min Fz", + "Min |Fyz|", + "Min Mxx", + "Min Myy", + "Min Mzz", + "Min |Myz|", + }); + + internal static readonly ReadOnlyCollection Vector6ReactionForces + = new ReadOnlyCollection(new[] { + "All", + "Max Fx", + "Max Fy", + "Max Fz", + "Max |F|", + "Max Mxx", + "Max Myy", + "Max Mzz", + "Max |M|", + "Min Fx", + "Min Fy", + "Min Fz", + "Min |F|", + "Min Mxx", + "Min Myy", + "Min Mzz", + "Min |M|", + }); + + internal static U FootfallExtremaKey( + INodeResultSubset> resultSet, string key) { + return key switch { + "Max Response Factor" => resultSet.Max.MaximumResponseFactor, + "Max Peak Velocity" => resultSet.Max.PeakVelocity, + "Max RMS Velocity" => resultSet.Max.RmsVelocity, + "Max Peak Acceleration" => resultSet.Max.PeakAcceleration, + "Max RMS Acceleration" => resultSet.Max.RmsAcceleration, + "Max Critical Frequency" => resultSet.Max.CriticalFrequency, + "Min Response Factor" => resultSet.Min.MaximumResponseFactor, + "Min Peak Velocity" => resultSet.Min.PeakVelocity, + "Min RMS Velocity" => resultSet.Min.RmsVelocity, + "Min Peak Acceleration" => resultSet.Min.PeakAcceleration, + "Min RMS Acceleration" => resultSet.Min.RmsAcceleration, + "Min Critical Frequency" => resultSet.Min.CriticalFrequency, + _ => throw new ArgumentException("Extrema case not found"), + }; + } + + internal static U DisplacementExtremaKey( + INodeResultSubset> resultSet, string key) where T : IResultItem { + return key switch { + "Max Ux" => resultSet.Max.X, + "Max Uy" => resultSet.Max.Y, + "Max Uz" => resultSet.Max.Z, + "Max |U|" => resultSet.Max.Xyz, + "Max Rxx" => resultSet.Max.Xx, + "Max Ryy" => resultSet.Max.Yy, + "Max Rzz" => resultSet.Max.Zz, + "Max |R|" => resultSet.Max.Xxyyzz, + "Min Ux" => resultSet.Min.X, + "Min Uy" => resultSet.Min.Y, + "Min Uz" => resultSet.Min.Z, + "Min |U|" => resultSet.Min.Xyz, + "Min Rxx" => resultSet.Min.Xx, + "Min Ryy" => resultSet.Min.Yy, + "Min Rzz" => resultSet.Min.Zz, + "Min |R|" => resultSet.Min.Xxyyzz, + _ => throw new ArgumentException("Extrema case not found"), + }; + } + + internal static U DisplacementExtremaKey( + IElement1dResultSubset> resultSet, string key) + where T1 : IElement1dQuantity where T2 : IResultItem { + return key switch { + "Max Ux" => resultSet.Max.X, + "Max Uy" => resultSet.Max.Y, + "Max Uz" => resultSet.Max.Z, + "Max |U|" => resultSet.Max.Xyz, + "Max Rxx" => resultSet.Max.Xx, + "Max Ryy" => resultSet.Max.Yy, + "Max Rzz" => resultSet.Max.Zz, + "Max |R|" => resultSet.Max.Xxyyzz, + "Min Ux" => resultSet.Min.X, + "Min Uy" => resultSet.Min.Y, + "Min Uz" => resultSet.Min.Z, + "Min |U|" => resultSet.Min.Xyz, + "Min Rxx" => resultSet.Min.Xx, + "Min Ryy" => resultSet.Min.Yy, + "Min Rzz" => resultSet.Min.Zz, + "Min |R|" => resultSet.Min.Xxyyzz, + _ => throw new ArgumentException("Extrema case not found"), + }; + } + + internal static U InternalForceExtremaKey( + INodeResultSubset> resultSet, string key) where T : IResultItem { + return key switch { + "Max Fx" => resultSet.Max.X, + "Max Fy" => resultSet.Max.Y, + "Max Fz" => resultSet.Max.Z, + "Max |Fyz|" => resultSet.Max.Xyz, + "Max Mxx" => resultSet.Max.Xx, + "Max Myy" => resultSet.Max.Yy, + "Max Mzz" => resultSet.Max.Zz, + "Max |Myz|" => resultSet.Max.Xxyyzz, + "Min Fx" => resultSet.Min.X, + "Min Fy" => resultSet.Min.Y, + "Min Fz" => resultSet.Min.Z, + "Min |Fyz|" => resultSet.Min.Xyz, + "Min Mxx" => resultSet.Min.Xx, + "Min Myy" => resultSet.Min.Yy, + "Min Mzz" => resultSet.Min.Zz, + "Min |Myz|" => resultSet.Min.Xxyyzz, + _ => throw new ArgumentException("Extrema case not found"), + }; + } + + internal static U ReactionForceExtremaKey( + INodeResultSubset> resultSet, string key) where T : IResultItem { + return key switch { + "Max Fx" => resultSet.Max.X, + "Max Fy" => resultSet.Max.Y, + "Max Fz" => resultSet.Max.Z, + "Max |F|" => resultSet.Max.Xyz, + "Max Mxx" => resultSet.Max.Xx, + "Max Myy" => resultSet.Max.Yy, + "Max Mzz" => resultSet.Max.Zz, + "Max |M|" => resultSet.Max.Xxyyzz, + "Min Fx" => resultSet.Min.X, + "Min Fy" => resultSet.Min.Y, + "Min Fz" => resultSet.Min.Z, + "Min |F|" => resultSet.Min.Xyz, + "Min Mxx" => resultSet.Min.Xx, + "Min Myy" => resultSet.Min.Yy, + "Min Mzz" => resultSet.Min.Zz, + "Min |M|" => resultSet.Min.Xxyyzz, + _ => throw new ArgumentException("Extrema case not found"), + }; + } + + internal static U InternalForceExtremaKey( + IElement1dResultSubset> resultSet, string key) + where T1 : IElement1dQuantity where T2 : IResultItem { + return key switch { + "Max Fx" => resultSet.Max.X, + "Max Fy" => resultSet.Max.Y, + "Max Fz" => resultSet.Max.Z, + "Max |Fyz|" => resultSet.Max.Xyz, + "Max Mxx" => resultSet.Max.Xx, + "Max Myy" => resultSet.Max.Yy, + "Max Mzz" => resultSet.Max.Zz, + "Max |Myz|" => resultSet.Max.Xxyyzz, + "Min Fx" => resultSet.Min.X, + "Min Fy" => resultSet.Min.Y, + "Min Fz" => resultSet.Min.Z, + "Min |Fyz|" => resultSet.Min.Xyz, + "Min Mxx" => resultSet.Min.Xx, + "Min Myy" => resultSet.Min.Yy, + "Min Mzz" => resultSet.Min.Zz, + "Min |Myz|" => resultSet.Min.Xxyyzz, + _ => throw new ArgumentException("Extrema case not found"), + }; + } + } +} diff --git a/GsaGH/Components/5_Results/NodeDisplacements.cs b/GsaGH/Components/5_Results/NodeDisplacements.cs index 3dd7dec85..716b35a54 100644 --- a/GsaGH/Components/5_Results/NodeDisplacements.cs +++ b/GsaGH/Components/5_Results/NodeDisplacements.cs @@ -1,9 +1,8 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using System.Linq; -using System.Threading.Tasks; using Grasshopper; using Grasshopper.Kernel; using Grasshopper.Kernel.Data; @@ -12,6 +11,7 @@ using GsaGH.Helpers; using GsaGH.Helpers.GH; using GsaGH.Parameters; +using GsaGH.Parameters.Results; using GsaGH.Properties; using OasysGH; using OasysGH.Components; @@ -39,7 +39,7 @@ public NodeDisplacements() : base("Node Displacements", "NodeDisp", public override void SetSelected(int i, int j) { _selectedItems[i] = _dropDownItems[i][j]; - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[i]); + _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[1]); base.UpdateUI(); } @@ -54,12 +54,16 @@ public override void VariableParameterMaintenance() { protected override void InitialiseDropdowns() { _spacerDescriptions = new List(new[] { + "Envelope", "Unit", }); _dropDownItems = new List>(); _selectedItems = new List(); + _dropDownItems.Add(ExtremaHelper.Vector6Displacements.ToList()); + _selectedItems.Add(_dropDownItems[0][0]); + _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Length)); _selectedItems.Add(Length.GetAbbreviation(_lengthUnit)); @@ -75,7 +79,6 @@ protected override void RegisterInputParams(GH_InputParamManager pManager) { protected override void RegisterOutputParams(GH_OutputParamManager pManager) { string unitAbbreviation = Length.GetAbbreviation(_lengthUnit); - string note = ResultNotes.NoteNodeResults; pManager.AddGenericParameter("Translations X [" + unitAbbreviation + "]", "Ux", @@ -99,10 +102,14 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) { } protected override void SolveInternal(IGH_DataAccess da) { - var result = new GsaResult(); - + GsaResult2 result; string nodeList = "All"; + var ghTypes = new List(); + if (!da.GetDataList(0, ghTypes)) { + return; + } + var outTransX = new DataTree(); var outTransY = new DataTree(); var outTransZ = new DataTree(); @@ -113,86 +120,66 @@ protected override void SolveInternal(IGH_DataAccess da) { var outRotXyz = new DataTree(); var outIDs = new DataTree(); - var ghTypes = new List(); - if (!da.GetDataList(0, ghTypes)) { - return; - } - foreach (GH_ObjectWrapper ghTyp in ghTypes) { switch (ghTyp?.Value) { - case null: - this.AddRuntimeWarning("Input is null"); - return; - case GsaResultGoo goo: - result = goo.Value; + result = new GsaResult2((GsaResult)goo.Value); nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model); break; + case null: + this.AddRuntimeWarning("Input is null"); + return; + default: this.AddRuntimeError("Error converting input to GSA Result"); return; } - List vals = result.NodeDisplacementValues(nodeList, _lengthUnit); + ReadOnlyCollection nodeIds = result.NodeIds(nodeList); + INodeResultSubset> resultSet + = result.NodeDisplacements.ResultSubset(nodeIds); List permutations = result.SelectedPermutationIds ?? new List() { 1, }; if (permutations.Count == 1 && permutations[0] == -1) { - permutations = Enumerable.Range(1, vals.Count).ToList(); + permutations = Enumerable.Range(1, resultSet.Subset.Values.First().Count).ToList(); } - foreach (int perm in permutations) { - var path = new GH_Path(result.CaseId, result.SelectedPermutationIds == null ? 0 : perm); - - var transX = new List(); - var transY = new List(); - var transZ = new List(); - var transXyz = new List(); - var rotX = new List(); - var rotY = new List(); - var rotZ = new List(); - var rotXyz = new List(); - - 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; + if (_selectedItems[0] == ExtremaHelper.Vector6Displacements[0]) { + foreach (int id in resultSet.Ids) { + foreach (int p in permutations) { + var path = new GH_Path(result.CaseId, result.SelectedPermutationIds == null ? 0 : p); + IDisplacement res = resultSet.Subset[id][p - 1]; + outTransX.Add(new GH_UnitNumber(res.X.ToUnit(_lengthUnit)), path); + outTransY.Add(new GH_UnitNumber(res.Y.ToUnit(_lengthUnit)), path); + outTransZ.Add(new GH_UnitNumber(res.Z.ToUnit(_lengthUnit)), path); + outTransXyz.Add(new GH_UnitNumber(res.Xyz.ToUnit(_lengthUnit)), path); + outRotX.Add(new GH_UnitNumber(res.Xx), path); + outRotY.Add(new GH_UnitNumber(res.Yy), path); + outRotZ.Add(new GH_UnitNumber(res.Zz), path); + outRotXyz.Add(new GH_UnitNumber(res.Xxyyzz), path); + outIDs.Add(id, path); } - }); - - outTransX.AddRange(transX, path); - outTransY.AddRange(transY, path); - outTransZ.AddRange(transZ, path); - outTransXyz.AddRange(transXyz, path); - outRotX.AddRange(rotX, path); - outRotY.AddRange(rotY, path); - outRotZ.AddRange(rotZ, path); - outRotXyz.AddRange(rotXyz, path); - outIDs.AddRange(vals[perm - 1].Ids, path); + } + } else { + NodeExtremaKey key = ExtremaHelper.DisplacementExtremaKey(resultSet, _selectedItems[0]); + IDisplacement extrema = resultSet.GetExtrema(key); + int perm = result.CaseType == CaseType.AnalysisCase ? 0 : 1; + var path = new GH_Path(result.CaseId, key.Permutation + perm); + outTransX.Add(new GH_UnitNumber(extrema.X.ToUnit(_lengthUnit)), path); + outTransY.Add(new GH_UnitNumber(extrema.Y.ToUnit(_lengthUnit)), path); + outTransZ.Add(new GH_UnitNumber(extrema.Z.ToUnit(_lengthUnit)), path); + outTransXyz.Add(new GH_UnitNumber(extrema.Xyz.ToUnit(_lengthUnit)), path); + outRotX.Add(new GH_UnitNumber(extrema.Xx), path); + outRotY.Add(new GH_UnitNumber(extrema.Yy), path); + outRotZ.Add(new GH_UnitNumber(extrema.Zz), path); + outRotXyz.Add(new GH_UnitNumber(extrema.Xxyyzz), path); + outIDs.Add(key.Id, path); } + + PostHog.Result(result.CaseType, 0, GsaResultsValues.ResultType.Displacement); } da.SetDataTree(0, outTransX); @@ -204,12 +191,16 @@ protected override void SolveInternal(IGH_DataAccess da) { da.SetDataTree(6, outRotZ); da.SetDataTree(7, outRotXyz); da.SetDataTree(8, outIDs); - - PostHog.Result(result.Type, 0, GsaResultsValues.ResultType.Displacement); } protected override void UpdateUIFromSelectedItems() { - _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[0]); + if (_selectedItems.Count == 1) { + _spacerDescriptions.Insert(0, "Envelope"); + _dropDownItems.Insert(0, ExtremaHelper.Vector6Displacements.ToList()); + _selectedItems.Insert(0, _dropDownItems[0][0]); + } + + _lengthUnit = (LengthUnit)UnitsHelper.Parse(typeof(LengthUnit), _selectedItems[1]); base.UpdateUIFromSelectedItems(); } } diff --git a/GsaGH/Components/5_Results/ReactionForces.cs b/GsaGH/Components/5_Results/ReactionForces.cs index 5990d77db..bd1ca7457 100644 --- a/GsaGH/Components/5_Results/ReactionForces.cs +++ b/GsaGH/Components/5_Results/ReactionForces.cs @@ -1,9 +1,8 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using System.Linq; -using System.Threading.Tasks; using Grasshopper; using Grasshopper.Kernel; using Grasshopper.Kernel.Data; @@ -12,6 +11,7 @@ using GsaGH.Helpers; using GsaGH.Helpers.GH; using GsaGH.Parameters; +using GsaGH.Parameters.Results; using GsaGH.Properties; using OasysGH; using OasysGH.Components; @@ -41,11 +41,11 @@ public ReactionForces() : base("Reaction Forces", "ReactForce", "Reaction Force public override void SetSelected(int i, int j) { _selectedItems[i] = _dropDownItems[i][j]; switch (i) { - case 0: + case 1: _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[i]); break; - case 1: + case 2: _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), _selectedItems[i]); break; } @@ -69,6 +69,7 @@ public override void VariableParameterMaintenance() { protected override void InitialiseDropdowns() { _spacerDescriptions = new List(new[] { + "Envelope", "Force Unit", "Moment Unit", }); @@ -76,6 +77,9 @@ protected override void InitialiseDropdowns() { _dropDownItems = new List>(); _selectedItems = new List(); + _dropDownItems.Add(ExtremaHelper.Vector6ReactionForces.ToList()); + _selectedItems.Add(_dropDownItems[0][0]); + _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Force)); _selectedItems.Add(Force.GetAbbreviation(_forceUnit)); @@ -120,7 +124,7 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) { } protected override void SolveInternal(IGH_DataAccess da) { - var result = new GsaResult(); + GsaResult2 result; string nodeList = "All"; @@ -146,7 +150,7 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: - result = goo.Value; + result = new GsaResult2((GsaResult)goo.Value); nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model); break; @@ -155,67 +159,50 @@ protected override void SolveInternal(IGH_DataAccess da) { return; } - List vals - = result.NodeReactionForceValues(nodeList, _forceUnit, _momentUnit); + ReadOnlyCollection nodeIds = result.NodeIds(nodeList); + INodeResultSubset> resultSet + = result.NodeReactionForces.ResultSubset(nodeIds); List permutations = result.SelectedPermutationIds ?? new List() { 1, }; + if (permutations.Count == 1 && permutations[0] == -1) { - permutations = Enumerable.Range(1, vals.Count).ToList(); + permutations = Enumerable.Range(1, resultSet.Subset.Values.First().Count).ToList(); } - foreach (int perm in permutations) { - var path = new GH_Path(result.CaseId, result.SelectedPermutationIds == null ? 0 : perm); - - var transX = new List(); - var transY = new List(); - var transZ = new List(); - var transXyz = new List(); - var rotX = new List(); - var rotY = new List(); - var rotZ = new List(); - var rotXyz = new List(); - - Parallel.For(0, 2, item => // split into two tasks - { - switch (item) { - 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 (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; + if (_selectedItems[0] == ExtremaHelper.Vector6ReactionForces[0]) { + foreach (int id in resultSet.Ids) { + foreach (int p in permutations) { + var path = new GH_Path(result.CaseId, result.SelectedPermutationIds == null ? 0 : p); + IInternalForce res = resultSet.Subset[id][p - 1]; + outTransX.Add(new GH_UnitNumber(res.X.ToUnit(_forceUnit)), path); + outTransY.Add(new GH_UnitNumber(res.Y.ToUnit(_forceUnit)), path); + outTransZ.Add(new GH_UnitNumber(res.Z.ToUnit(_forceUnit)), path); + outTransXyz.Add(new GH_UnitNumber(res.Xyz.ToUnit(_forceUnit)), path); + outRotX.Add(new GH_UnitNumber(res.Xx.ToUnit(_momentUnit)), path); + outRotY.Add(new GH_UnitNumber(res.Yy.ToUnit(_momentUnit)), path); + outRotZ.Add(new GH_UnitNumber(res.Zz.ToUnit(_momentUnit)), path); + outRotXyz.Add(new GH_UnitNumber(res.Xxyyzz.ToUnit(_momentUnit)), path); + outIDs.Add(id, path); } - }); - - outTransX.AddRange(transX, path); - outTransY.AddRange(transY, path); - outTransZ.AddRange(transZ, path); - outTransXyz.AddRange(transXyz, path); - outRotX.AddRange(rotX, path); - outRotY.AddRange(rotY, path); - outRotZ.AddRange(rotZ, path); - outRotXyz.AddRange(rotXyz, path); - outIDs.AddRange(vals[perm - 1].Ids, path); + } + } else { + NodeExtremaKey key = ExtremaHelper.ReactionForceExtremaKey(resultSet, _selectedItems[0]); + IInternalForce extrema = resultSet.GetExtrema(key); + var path = new GH_Path(result.CaseId, key.Permutation); + outTransX.Add(new GH_UnitNumber(extrema.X.ToUnit(_forceUnit)), path); + outTransY.Add(new GH_UnitNumber(extrema.Y.ToUnit(_forceUnit)), path); + outTransZ.Add(new GH_UnitNumber(extrema.Z.ToUnit(_forceUnit)), path); + outTransXyz.Add(new GH_UnitNumber(extrema.Xyz.ToUnit(_forceUnit)), path); + outRotX.Add(new GH_UnitNumber(extrema.Xx.ToUnit(_momentUnit)), path); + outRotY.Add(new GH_UnitNumber(extrema.Yy.ToUnit(_momentUnit)), path); + outRotZ.Add(new GH_UnitNumber(extrema.Zz.ToUnit(_momentUnit)), path); + outRotXyz.Add(new GH_UnitNumber(extrema.Xxyyzz.ToUnit(_momentUnit)), path); + outIDs.Add(key.Id, path); } + + PostHog.Result(result.CaseType, 0, GsaResultsValues.ResultType.Force); } da.SetDataTree(0, outTransX); @@ -227,13 +214,18 @@ List vals da.SetDataTree(6, outRotZ); da.SetDataTree(7, outRotXyz); da.SetDataTree(8, outIDs); - - PostHog.Result(result.Type, 0, GsaResultsValues.ResultType.Force); } protected override void UpdateUIFromSelectedItems() { - _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[0]); - _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), _selectedItems[1]); + if (_selectedItems.Count == 2) { + _spacerDescriptions.Insert(0, "Envelope"); + _dropDownItems.Insert(0, ExtremaHelper.Vector6ReactionForces.ToList()); + _selectedItems.Insert(0, _dropDownItems[0][0]); + } + + _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[1]); + _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), _selectedItems[2]); + base.UpdateUIFromSelectedItems(); } } diff --git a/GsaGH/Components/5_Results/SpringReactionForces.cs b/GsaGH/Components/5_Results/SpringReactionForces.cs index 58107eb55..40370e7dc 100644 --- a/GsaGH/Components/5_Results/SpringReactionForces.cs +++ b/GsaGH/Components/5_Results/SpringReactionForces.cs @@ -1,9 +1,8 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using System.Linq; -using System.Threading.Tasks; using Grasshopper; using Grasshopper.Kernel; using Grasshopper.Kernel.Data; @@ -12,6 +11,7 @@ using GsaGH.Helpers; using GsaGH.Helpers.GH; using GsaGH.Parameters; +using GsaGH.Parameters.Results; using GsaGH.Properties; using OasysGH; using OasysGH.Components; @@ -41,11 +41,11 @@ public SpringReactionForces() : base("Spring Reaction Forces", "SpringForce", public override void SetSelected(int i, int j) { _selectedItems[i] = _dropDownItems[i][j]; switch (i) { - case 0: + case 1: _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[i]); break; - case 1: + case 2: _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), _selectedItems[i]); break; } @@ -69,6 +69,7 @@ public override void VariableParameterMaintenance() { protected override void InitialiseDropdowns() { _spacerDescriptions = new List(new[] { + "Envelope", "Force Unit", "Moment Unit", }); @@ -76,6 +77,9 @@ protected override void InitialiseDropdowns() { _dropDownItems = new List>(); _selectedItems = new List(); + _dropDownItems.Add(ExtremaHelper.Vector6ReactionForces.ToList()); + _selectedItems.Add(_dropDownItems[0][0]); + _dropDownItems.Add(UnitsHelper.GetFilteredAbbreviations(EngineeringUnits.Force)); _selectedItems.Add(Force.GetAbbreviation(_forceUnit)); @@ -120,10 +124,15 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) { } protected override void SolveInternal(IGH_DataAccess da) { - var result = new GsaResult(); + GsaResult2 result; string nodeList = "All"; + var ghTypes = new List(); + if (!da.GetDataList(0, ghTypes)) { + return; + } + var outTransX = new DataTree(); var outTransY = new DataTree(); var outTransZ = new DataTree(); @@ -134,11 +143,6 @@ protected override void SolveInternal(IGH_DataAccess da) { var outRotXyz = new DataTree(); var outIDs = new DataTree(); - var ghTypes = new List(); - if (!da.GetDataList(0, ghTypes)) { - return; - } - foreach (GH_ObjectWrapper ghTyp in ghTypes) { switch (ghTyp?.Value) { case null: @@ -146,7 +150,7 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: - result = goo.Value; + result = new GsaResult2((GsaResult)goo.Value); nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model); break; @@ -155,67 +159,50 @@ protected override void SolveInternal(IGH_DataAccess da) { return; } - List vals - = result.SpringReactionForceValues(nodeList, _forceUnit, _momentUnit); + ReadOnlyCollection nodeIds = result.NodeIds(nodeList); + INodeResultSubset> resultSet + = result.NodeSpringForces.ResultSubset(nodeIds); List permutations = result.SelectedPermutationIds ?? new List() { 1, }; + if (permutations.Count == 1 && permutations[0] == -1) { - permutations = Enumerable.Range(1, vals.Count).ToList(); + permutations = Enumerable.Range(1, resultSet.Subset.Values.First().Count).ToList(); } - foreach (int perm in permutations) { - var path = new GH_Path(result.CaseId, result.SelectedPermutationIds == null ? 0 : perm); - - var transX = new List(); - var transY = new List(); - var transZ = new List(); - var transXyz = new List(); - var rotX = new List(); - var rotY = new List(); - var rotZ = new List(); - var rotXyz = new List(); - - Parallel.For(0, 2, item => // split into two tasks - { - switch (item) { - 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 (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; + if (_selectedItems[0] == ExtremaHelper.Vector6ReactionForces[0]) { + foreach (KeyValuePair> kvp in resultSet.Subset) { + foreach (int p in permutations) { + var path = new GH_Path(result.CaseId, result.SelectedPermutationIds == null ? 0 : p); + outTransX.Add(new GH_UnitNumber(kvp.Value[p - 1].X.ToUnit(_forceUnit)), path); + outTransY.Add(new GH_UnitNumber(kvp.Value[p - 1].Y.ToUnit(_forceUnit)), path); + outTransZ.Add(new GH_UnitNumber(kvp.Value[p - 1].Z.ToUnit(_forceUnit)), path); + outTransXyz.Add(new GH_UnitNumber(kvp.Value[p - 1].Xyz.ToUnit(_forceUnit)), path); + outRotX.Add(new GH_UnitNumber(kvp.Value[p - 1].Xx), path); + outRotY.Add(new GH_UnitNumber(kvp.Value[p - 1].Yy), path); + outRotZ.Add(new GH_UnitNumber(kvp.Value[p - 1].Zz), path); + outRotXyz.Add(new GH_UnitNumber(kvp.Value[p - 1].Xxyyzz), path); + outIDs.Add(kvp.Key, path); } - }); - - outTransX.AddRange(transX, path); - outTransY.AddRange(transY, path); - outTransZ.AddRange(transZ, path); - outTransXyz.AddRange(transXyz, path); - outRotX.AddRange(rotX, path); - outRotY.AddRange(rotY, path); - outRotZ.AddRange(rotZ, path); - outRotXyz.AddRange(rotXyz, path); - outIDs.AddRange(vals[perm - 1].Ids, path); + } + } else { + NodeExtremaKey key = ExtremaHelper.ReactionForceExtremaKey(resultSet, _selectedItems[0]); + IInternalForce extrema = resultSet.GetExtrema(key); + int perm = result.CaseType == CaseType.AnalysisCase ? 0 : 1; + var path = new GH_Path(result.CaseId, key.Permutation + perm); + outTransX.Add(new GH_UnitNumber(extrema.X.ToUnit(_forceUnit)), path); + outTransY.Add(new GH_UnitNumber(extrema.Y.ToUnit(_forceUnit)), path); + outTransZ.Add(new GH_UnitNumber(extrema.Z.ToUnit(_forceUnit)), path); + outTransXyz.Add(new GH_UnitNumber(extrema.Xyz.ToUnit(_forceUnit)), path); + outRotX.Add(new GH_UnitNumber(extrema.Xx), path); + outRotY.Add(new GH_UnitNumber(extrema.Yy), path); + outRotZ.Add(new GH_UnitNumber(extrema.Zz), path); + outRotXyz.Add(new GH_UnitNumber(extrema.Xxyyzz), path); + outIDs.Add(key.Id, path); } + + PostHog.Result(result.CaseType, 0, GsaResultsValues.ResultType.Force, "Spring"); } da.SetDataTree(0, outTransX); @@ -227,13 +214,18 @@ List vals da.SetDataTree(6, outRotZ); da.SetDataTree(7, outRotXyz); da.SetDataTree(8, outIDs); - - PostHog.Result(result.Type, 0, GsaResultsValues.ResultType.Force, "Spring"); } protected override void UpdateUIFromSelectedItems() { - _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[0]); - _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), _selectedItems[1]); + if (_selectedItems.Count == 2) { + _spacerDescriptions.Insert(0, "Envelope"); + _dropDownItems.Insert(0, ExtremaHelper.Vector6ReactionForces.ToList()); + _selectedItems.Insert(0, _dropDownItems[0][0]); + } + + _forceUnit = (ForceUnit)UnitsHelper.Parse(typeof(ForceUnit), _selectedItems[1]); + _momentUnit = (MomentUnit)UnitsHelper.Parse(typeof(MomentUnit), _selectedItems[2]); + base.UpdateUIFromSelectedItems(); } } diff --git a/GsaGH/Components/5_Results/TotalLoadsAndReactions.cs b/GsaGH/Components/5_Results/TotalLoadsAndReactions.cs index 9413f6514..5f862bb7d 100644 --- a/GsaGH/Components/5_Results/TotalLoadsAndReactions.cs +++ b/GsaGH/Components/5_Results/TotalLoadsAndReactions.cs @@ -141,8 +141,8 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: { - result = goo.Value; - if (result.Type == CaseType.CombinationCase) { + result = (GsaResult)goo.Value; + if (result.CaseType == CaseType.CombinationCase) { this.AddRuntimeError("Global Result only available for Analysis Cases"); return; } @@ -191,7 +191,7 @@ GsaResultQuantity rm da.SetData(i++, new GH_UnitNumber(rm.Z)); da.SetData(i, new GH_UnitNumber(rm.Xyz)); - PostHog.Result(result.Type, -1, "Global", "TotalLoadsAndReactions"); + PostHog.Result(result.CaseType, -1, "Global", "TotalLoadsAndReactions"); } protected override void UpdateUIFromSelectedItems() { diff --git a/GsaGH/Components/6_Display/Annotate.cs b/GsaGH/Components/6_Display/Annotate.cs index 9c26ac3bc..5c699f38b 100644 --- a/GsaGH/Components/6_Display/Annotate.cs +++ b/GsaGH/Components/6_Display/Annotate.cs @@ -3,7 +3,6 @@ using Grasshopper.Kernel; using Grasshopper.Kernel.Data; using Grasshopper.Kernel.Types; -using GsaAPI; using GsaGH.Helpers.GH; using GsaGH.Parameters; using GsaGH.Properties; diff --git a/GsaGH/Components/6_Display/Contour1dResults.cs b/GsaGH/Components/6_Display/Contour1dResults.cs index a6d0d74b4..e52bb167e 100644 --- a/GsaGH/Components/6_Display/Contour1dResults.cs +++ b/GsaGH/Components/6_Display/Contour1dResults.cs @@ -501,8 +501,8 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: { - result = goo.Value; - switch (result.Type) { + result = (GsaResult)goo.Value; + switch (result.CaseType) { case CaseType.CombinationCase when result.SelectedPermutationIds.Count > 1: this.AddRuntimeWarning("Combination Case " + result.CaseId + " contains " + result.SelectedPermutationIds.Count @@ -1024,7 +1024,7 @@ Color gradientcolour var resultType = (GsaResultsValues.ResultType)Enum.Parse(typeof(GsaResultsValues.ResultType), _mode.ToString()); - PostHog.Result(result.Type, 1, resultType, _disp.ToString()); + PostHog.Result(result.CaseType, 1, resultType, _disp.ToString()); } internal GH_GradientControl CreateGradient(GH_Document doc = null) { diff --git a/GsaGH/Components/6_Display/Contour2dResults.cs b/GsaGH/Components/6_Display/Contour2dResults.cs index 2e79eddbc..0c33761ad 100644 --- a/GsaGH/Components/6_Display/Contour2dResults.cs +++ b/GsaGH/Components/6_Display/Contour2dResults.cs @@ -564,8 +564,8 @@ protected override void SolveInternal(IGH_DataAccess da) { return; } - result = goo.Value; - switch (result.Type) { + result = (GsaResult)goo.Value; + switch (result.CaseType) { case CaseType.CombinationCase when result.SelectedPermutationIds.Count > 1: this.AddRuntimeWarning("Combination Case " + result.CaseId + " contains " + result.SelectedPermutationIds.Count @@ -1086,7 +1086,7 @@ Color gradientcolour var resultType = (GsaResultsValues.ResultType)Enum.Parse(typeof(GsaResultsValues.ResultType), _mode.ToString()); - PostHog.Result(result.Type, 2, resultType, _disp.ToString()); + PostHog.Result(result.CaseType, 2, resultType, _disp.ToString()); } internal GH_GradientControl CreateGradient(GH_Document doc = null) { diff --git a/GsaGH/Components/6_Display/Contour3dResults.cs b/GsaGH/Components/6_Display/Contour3dResults.cs index f18324d3b..eccce9ce2 100644 --- a/GsaGH/Components/6_Display/Contour3dResults.cs +++ b/GsaGH/Components/6_Display/Contour3dResults.cs @@ -397,8 +397,8 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: { - result = goo.Value; - switch (result.Type) { + result = (GsaResult)goo.Value; + switch (result.CaseType) { case CaseType.CombinationCase when result.SelectedPermutationIds.Count > 1: this.AddRuntimeWarning("Combination Case " + result.CaseId + " contains " + result.SelectedPermutationIds.Count @@ -795,7 +795,7 @@ Color gradientcolour var resultType = (GsaResultsValues.ResultType)Enum.Parse(typeof(GsaResultsValues.ResultType), _mode.ToString()); - PostHog.Result(result.Type, 3, resultType, _disp.ToString()); + PostHog.Result(result.CaseType, 3, resultType, _disp.ToString()); } internal GH_GradientControl CreateGradient(GH_Document doc = null) { diff --git a/GsaGH/Components/6_Display/ContourNodeResults.cs b/GsaGH/Components/6_Display/ContourNodeResults.cs index 7e86664ad..9cae39fe8 100644 --- a/GsaGH/Components/6_Display/ContourNodeResults.cs +++ b/GsaGH/Components/6_Display/ContourNodeResults.cs @@ -428,8 +428,8 @@ protected override void SolveInternal(IGH_DataAccess da) { return; case GsaResultGoo goo: { - result = goo.Value; - if (result.Type == CaseType.CombinationCase + result = (GsaResult)goo.Value; + if (result.CaseType == CaseType.CombinationCase && result.SelectedPermutationIds.Count > 1) { this.AddRuntimeWarning("Combination Case " + result.CaseId + " contains " + result.SelectedPermutationIds.Count @@ -439,11 +439,11 @@ protected override void SolveInternal(IGH_DataAccess da) { _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; } - if (result.Type == CaseType.CombinationCase) { + if (result.CaseType == CaseType.CombinationCase) { _case = "Case C" + result.CaseId + " P" + result.SelectedPermutationIds[0]; } - if (result.Type == CaseType.AnalysisCase) { + if (result.CaseType == CaseType.AnalysisCase) { _case = "Case A" + result.CaseId + Environment.NewLine + result.CaseName; } @@ -822,7 +822,7 @@ Color gradientcolour GsaResultsValues.ResultType.Force : (GsaResultsValues.ResultType)Enum.Parse(typeof(GsaResultsValues.ResultType), _mode.ToString()); - PostHog.Result(result.Type, 0, resultType, _disp.ToString()); + PostHog.Result(result.CaseType, 0, resultType, _disp.ToString()); } internal GH_GradientControl CreateGradient(GH_Document doc = null) { diff --git a/GsaGH/Components/6_Display/LoadDiagrams.cs b/GsaGH/Components/6_Display/LoadDiagrams.cs index 700ebfec1..22a7caffa 100644 --- a/GsaGH/Components/6_Display/LoadDiagrams.cs +++ b/GsaGH/Components/6_Display/LoadDiagrams.cs @@ -22,7 +22,6 @@ using OasysGH.Units; using OasysGH.Units.Helpers; using OasysUnits; -using Rhino.Commands; using Rhino.Geometry; using DiagramType = GsaAPI.DiagramType; using ForceUnit = OasysUnits.Units.ForceUnit; diff --git a/GsaGH/Components/6_Display/PreviewDeformed3dSections.cs b/GsaGH/Components/6_Display/PreviewDeformed3dSections.cs index 7e992c7ba..217146567 100644 --- a/GsaGH/Components/6_Display/PreviewDeformed3dSections.cs +++ b/GsaGH/Components/6_Display/PreviewDeformed3dSections.cs @@ -80,7 +80,7 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager) { protected override void SolveInternal(IGH_DataAccess da) { GsaResultGoo resultGoo = null; da.GetData(0, ref resultGoo); - GsaResult result = resultGoo.Value; + var result = (GsaResult)resultGoo.Value; string elementlist = Inputs.GetElementListDefinition(this, da, 1, resultGoo.Value.Model); _section3dPreview = new Section3dPreview(result, elementlist, _defScale); @@ -88,7 +88,7 @@ protected override void SolveInternal(IGH_DataAccess da) { da.SetData(0, _section3dPreview.Mesh); da.SetDataList(1, _section3dPreview.Outlines); - PostHog.Result(result.Type, 1, "Displacement", "DeformedSection3d"); + PostHog.Result(result.CaseType, 1, "Displacement", "DeformedSection3d"); } public override void DrawViewportMeshes(IGH_PreviewArgs args) { diff --git a/GsaGH/Components/6_Display/ReactionForceDiagrams.cs b/GsaGH/Components/6_Display/ReactionForceDiagrams.cs index da55b3663..029d4d8f4 100644 --- a/GsaGH/Components/6_Display/ReactionForceDiagrams.cs +++ b/GsaGH/Components/6_Display/ReactionForceDiagrams.cs @@ -184,7 +184,7 @@ protected override void SolveInternal(IGH_DataAccess da) { return; } - result = (ghObject.Value as GsaResultGoo).Value; + result = (GsaResult)(ghObject.Value as GsaResultGoo).Value; string nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model); GsaResultsValues forceValues @@ -227,7 +227,7 @@ GsaResultsValues forceValues }); SetOutputs(da, reactionForceVectors, annotations); - PostHog.Diagram("Result", result.Type, "ReactionForce", _selectedDisplayValue.ToString(), Parameters.EntityType.Node); + PostHog.Diagram("Result", result.CaseType, "ReactionForce", _selectedDisplayValue.ToString(), Parameters.EntityType.Node); } private double ComputeAutoScale(GsaResultsValues forceValues, BoundingBox bbox) { diff --git a/GsaGH/Components/6_Display/ResultDiagrams.cs b/GsaGH/Components/6_Display/ResultDiagrams.cs index cdd232c09..75f79d4eb 100644 --- a/GsaGH/Components/6_Display/ResultDiagrams.cs +++ b/GsaGH/Components/6_Display/ResultDiagrams.cs @@ -200,8 +200,8 @@ protected override void SolveInternal(IGH_DataAccess da) { } if (ghTyp?.Value is GsaResultGoo goo) { - result = goo.Value; - switch (result.Type) { + result = (GsaResult)goo.Value; + switch (result.CaseType) { case CaseType.CombinationCase when result.SelectedPermutationIds.Count > 1: string warningText = $"Combination Case {result.CaseId} contains {result.SelectedPermutationIds.Count} permutations - only one permutation can be displayed at a time.{Environment.NewLine}Displaying first permutation; please use the 'Select Results' to select other single permutations"; @@ -284,7 +284,7 @@ double computedScale da.SetDataList(0, diagramLines); da.SetDataList(1, diagramAnnotations); - PostHog.Diagram("Result", result.Type, _selectedItems[0], type.ToString(), Parameters.EntityType.Element); + PostHog.Diagram("Result", result.CaseType, _selectedItems[0], type.ToString(), Parameters.EntityType.Element); } private List GenerateAnnotations( diff --git a/GsaGH/Components/99_Obsolete/FootfallResults_OBSOLETE.cs b/GsaGH/Components/99_Obsolete/FootfallResults_OBSOLETE.cs new file mode 100644 index 000000000..d73c86574 --- /dev/null +++ b/GsaGH/Components/99_Obsolete/FootfallResults_OBSOLETE.cs @@ -0,0 +1,82 @@ +using System; +using System.Drawing; +using Grasshopper.Kernel; +using Grasshopper.Kernel.Types; +using GsaGH.Helpers; +using GsaGH.Helpers.GH; +using GsaGH.Helpers.GsaApi; +using GsaGH.Parameters; +using GsaGH.Properties; +using OasysGH; +using OasysGH.Components; + +namespace GsaGH.Components { + /// + /// Component to select results from a GSA Model + /// + public class FootfallResults_OBSOLETE : GH_OasysComponent { + public override Guid ComponentGuid => new Guid("c5194fe3-8c20-43f0-a8cb-3207ed867221"); + public override GH_Exposure Exposure => GH_Exposure.hidden; + public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; + protected override Bitmap Icon => Resources.FootfallResults; + + public FootfallResults_OBSOLETE() : base("Footfall Results", "Footfall", + "Get the maximum response factor for a footfall analysis case", CategoryName.Name(), + SubCategoryName.Cat5()) { + Hidden = true; + } + + protected override void RegisterInputParams(GH_InputParamManager pManager) { + pManager.AddParameter(new GsaResultParameter(), "Result", "Res", "GSA Result", + GH_ParamAccess.item); + pManager.AddParameter(new GsaNodeListParameter()); + pManager[1].Optional = true; + } + + protected override void RegisterOutputParams(GH_OutputParamManager pManager) { + pManager.AddNumberParameter("Resonant Response Factor", "RRF", + "Maximum resonant response factor", GH_ParamAccess.item); + pManager.AddNumberParameter("Transient Response Factor", "TRF", + "Maximum transient response factor", GH_ParamAccess.item); + } + + protected override void SolveInstance(IGH_DataAccess da) { + GsaResult result; + var ghTyp = new GH_ObjectWrapper(); + if (!da.GetData(0, ref ghTyp)) { + return; + } + + this.AddRuntimeError("This component is obsolete and will be removed in the next version of the plugin. Please update to use the newest version of Footfall results which is faster and better all together."); + + switch (ghTyp?.Value) { + case null: + this.AddRuntimeWarning("Input is null"); + return; + + case GsaResultGoo goo: { + result = (GsaResult)goo.Value; + if (result.CaseType == CaseType.CombinationCase) { + this.AddRuntimeError("Footfall Result only available for Analysis Cases"); + return; + } + + break; + } + default: + this.AddRuntimeError("Error converting input to GSA Result"); + return; + } + + string nodeList = Inputs.GetNodeListDefinition(this, da, 1, result.Model); + + GsaResultsValues res = result.NodeFootfallValues(nodeList, FootfallResultType.Resonant); + GsaResultsValues tra = result.NodeFootfallValues(nodeList, FootfallResultType.Transient); + + da.SetData(0, res.DmaxX.Value); + da.SetData(1, tra.DmaxX.Value); + + PostHog.Result(result.CaseType, 0, GsaResultsValues.ResultType.Footfall, "Max"); + } + } +} diff --git a/GsaGH/Helpers/GsaAPI/Results/AnalysisCaseQuantities.cs b/GsaGH/Helpers/GsaAPI/Results/AnalysisCaseQuantities.cs index 39f2291a4..ecb099fbf 100644 --- a/GsaGH/Helpers/GsaAPI/Results/AnalysisCaseQuantities.cs +++ b/GsaGH/Helpers/GsaAPI/Results/AnalysisCaseQuantities.cs @@ -154,7 +154,7 @@ internal static GsaResultsValues GetElement2DResultValues( if (i < stresses.Count && !double.IsNaN(stresses[i].XX) && !double.IsNaN(stresses[i].YY) && !double.IsNaN(stresses[i].ZZ)) { xyzRes[i] = GetQuantityResult(stresses[i], stressUnit); - } else if (!double.IsNaN(stresses[i - stresses.Count].XY) + } else if (!double.IsNaN(stresses[i - stresses.Count].XY) && !double.IsNaN(stresses[i - stresses.Count].YZ) && !double.IsNaN(stresses[i - stresses.Count].ZX)) { xxyyzzRes[i - stresses.Count] @@ -480,7 +480,7 @@ internal static GsaResultsValues GetNodeReactionForceResultValues( internal static GsaResultsValues GetNodeResultValues( ReadOnlyDictionary globalResults, LengthUnit resultLengthUnit) { var r = new GsaResultsValues { - Type = GsaResultsValues.ResultType.Force, + Type = GsaResultsValues.ResultType.Displacement, }; Parallel.ForEach(globalResults.Keys, nodeId => { @@ -548,4 +548,4 @@ internal static GsaResultsValues GetNodeSpringForceResultValues( return r; } } -} +} \ No newline at end of file diff --git a/GsaGH/Helpers/GsaAPI/Results/CombinationCaseQuantities.cs b/GsaGH/Helpers/GsaAPI/Results/CombinationCaseQuantities.cs index e6f4dc135..deccf0823 100644 --- a/GsaGH/Helpers/GsaAPI/Results/CombinationCaseQuantities.cs +++ b/GsaGH/Helpers/GsaAPI/Results/CombinationCaseQuantities.cs @@ -56,12 +56,12 @@ internal static ConcurrentDictionary GetElement1DResultVa xxyyzzRes.AsParallel().AsOrdered(); Parallel.For(0, values.Count, i => { - if (!double.IsNaN(values[i].X) && !double.IsNaN(values[i].Y) + if (!double.IsNaN(values[i].X) && !double.IsNaN(values[i].Y) && !double.IsNaN(values[i].Z)) { xyzRes.TryAdd(i, GetQuantityResult(values[i], forceUnit, true)); } - if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) + if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) && !double.IsNaN(values[i].ZZ)) { xxyyzzRes.TryAdd(i, GetQuantityResult(values[i], momentUnit, true)); } @@ -168,12 +168,12 @@ internal static ConcurrentDictionary GetElement1DResultVa xxyyzzRes.AsParallel().AsOrdered(); Parallel.For(0, values.Count, i => { - if (!double.IsNaN(values[i].X) && !double.IsNaN(values[i].Y) + if (!double.IsNaN(values[i].X) && !double.IsNaN(values[i].Y) && !double.IsNaN(values[i].Z)) { xyzRes.TryAdd(i, GetQuantityResult(values[i], resultLengthUnit)); } - if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) + if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) && !double.IsNaN(values[i].ZZ)) { xxyyzzRes.TryAdd(i, GetQuantityResult(values[i], AngleUnit.Radian)); } @@ -227,22 +227,22 @@ internal static ConcurrentDictionary GetElement2DResultVa xxyyzzRes.AsParallel().AsOrdered(); Parallel.For(1, values.Count, i => { - if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) + if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) && !double.IsNaN(values[i].ZZ)) { xyzRes.TryAdd(i, GetQuantityResult(values[i], stressUnit)); } - if (!double.IsNaN(values[i].XY) && !double.IsNaN(values[i].YZ) + if (!double.IsNaN(values[i].XY) && !double.IsNaN(values[i].YZ) && !double.IsNaN(values[i].ZX)) { xxyyzzRes.TryAdd(i, GetQuantityResult(values[i], stressUnit, true)); } }); - if (!double.IsNaN(values[0].XX) && !double.IsNaN(values[0].YY) + if (!double.IsNaN(values[0].XX) && !double.IsNaN(values[0].YY) && !double.IsNaN(values[0].ZZ)) { xyzRes.TryAdd(values.Count, GetQuantityResult(values[0], stressUnit)); // add centre point last } - if (!double.IsNaN(values[0].XY) && !double.IsNaN(values[0].YZ) + if (!double.IsNaN(values[0].XY) && !double.IsNaN(values[0].YZ) && !double.IsNaN(values[0].ZX)) { xxyyzzRes.TryAdd(values.Count, GetQuantityResult(values[0], stressUnit, true)); } @@ -301,7 +301,7 @@ internal static ConcurrentDictionary GetElement2DResultVa if (!double.IsNaN(values[0].X) && !double.IsNaN(values[0].Y)) { // add centre point last - xyzRes.TryAdd(values.Count, GetQuantityResult(values[0], forceUnit)); + xyzRes.TryAdd(values.Count, GetQuantityResult(values[0], forceUnit)); } r.XyzResults.TryAdd(key, xyzRes); @@ -354,24 +354,24 @@ internal static ConcurrentDictionary GetElement2DResultVa xxyyzzRes.AsParallel().AsOrdered(); Parallel.For(1, forceValues.Count, i => { - if (!double.IsNaN(forceValues[i].XX) && !double.IsNaN(forceValues[i].YY) + if (!double.IsNaN(forceValues[i].XX) && !double.IsNaN(forceValues[i].YY) && !double.IsNaN(forceValues[i].XY)) { xyzRes.TryAdd(i, GetQuantityResult(forceValues[i], forceUnit)); } - if (!double.IsNaN(momentValues[i].XX) && !double.IsNaN(momentValues[i].YY) + if (!double.IsNaN(momentValues[i].XX) && !double.IsNaN(momentValues[i].YY) && !double.IsNaN(momentValues[i].XY)) { xxyyzzRes.TryAdd(i, GetQuantityResult(momentValues[i], momentUnit)); } }); - if (!double.IsNaN(forceValues[0].XX) && !double.IsNaN(forceValues[0].YY) + if (!double.IsNaN(forceValues[0].XX) && !double.IsNaN(forceValues[0].YY) && !double.IsNaN(forceValues[0].XY)) { xyzRes.TryAdd(forceValues.Count, GetQuantityResult(forceValues[0], forceUnit)); // add centre point last } - if (!double.IsNaN(momentValues[0].XX) && !double.IsNaN(momentValues[0].YY) + if (!double.IsNaN(momentValues[0].XX) && !double.IsNaN(momentValues[0].YY) && !double.IsNaN(momentValues[0].XY)) { xxyyzzRes.TryAdd(forceValues.Count, GetQuantityResult(momentValues[0], momentUnit)); } @@ -437,7 +437,7 @@ internal static ConcurrentDictionary GetElement2DResultVa xyzRes.TryAdd(i, GetQuantityResult(values[i], resultLengthUnit)); } - if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) + if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) && !double.IsNaN(values[i].ZZ)) { xxyyzzRes.TryAdd(i, GetQuantityResult(values[i], AngleUnit.Radian)); } @@ -492,12 +492,12 @@ internal static ConcurrentDictionary GetElement3DResultVa xyzRes.AsParallel().AsOrdered(); Parallel.For(1, values.Count, i => { - if (!double.IsNaN(values[i].X) && !double.IsNaN(values[i].Y) + if (!double.IsNaN(values[i].X) && !double.IsNaN(values[i].Y) && !double.IsNaN(values[i].Z)) { xyzRes.TryAdd(i, GetQuantityResult(values[i], lengthUnit)); } }); - if (!double.IsNaN(values[0].X) && !double.IsNaN(values[0].Y) + if (!double.IsNaN(values[0].X) && !double.IsNaN(values[0].Y) && !double.IsNaN(values[0].Z)) { xyzRes[values.Count] = GetQuantityResult(values[0], lengthUnit); // add centre point at the end } @@ -550,23 +550,23 @@ internal static ConcurrentDictionary GetElement3DResultVa xxyyzzRes.AsParallel().AsOrdered(); Parallel.For(1, values.Count, i => { - if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) + if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) && !double.IsNaN(values[i].ZZ)) { xyzRes.TryAdd(i, GetQuantityResult(values[i], stressUnit)); } - if (!double.IsNaN(values[i].XY) && !double.IsNaN(values[i].YZ) + if (!double.IsNaN(values[i].XY) && !double.IsNaN(values[i].YZ) && !double.IsNaN(values[i].ZX)) { xxyyzzRes.TryAdd(i, GetQuantityResult(values[i], stressUnit, true)); } }); - if (!double.IsNaN(values[0].XX) && !double.IsNaN(values[0].YY) + if (!double.IsNaN(values[0].XX) && !double.IsNaN(values[0].YY) && !double.IsNaN(values[0].ZZ)) { // add centre point at the end - xyzRes[values.Count] = GetQuantityResult(values[0], stressUnit); + xyzRes[values.Count] = GetQuantityResult(values[0], stressUnit); } - if (!double.IsNaN(values[0].XY) && !double.IsNaN(values[0].YZ) + if (!double.IsNaN(values[0].XY) && !double.IsNaN(values[0].YZ) && !double.IsNaN(values[0].ZX)) { xxyyzzRes[values.Count] = GetQuantityResult(values[0], stressUnit, true); } @@ -755,4 +755,4 @@ internal static ConcurrentDictionary GetNodeSpringForceRe return rs; } } -} +} \ No newline at end of file diff --git a/GsaGH/Helpers/GsaCOM/ComResultsHelper.cs b/GsaGH/Helpers/GsaCOM/ComResultsHelper.cs index 54a16276d..23fa06154 100644 --- a/GsaGH/Helpers/GsaCOM/ComResultsHelper.cs +++ b/GsaGH/Helpers/GsaCOM/ComResultsHelper.cs @@ -1,6 +1,5 @@ using System.Collections.Concurrent; using System.Collections.ObjectModel; -using System.Windows.Forms; using GsaAPI; using GsaGH.Parameters; using Interop.Gsa_10_2; diff --git a/GsaGH/Helpers/PostHog.cs b/GsaGH/Helpers/PostHog.cs index 305d8ee0e..1dcf39906 100644 --- a/GsaGH/Helpers/PostHog.cs +++ b/GsaGH/Helpers/PostHog.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Data; using GsaGH.Parameters; using GsaGH.Parameters.Enums; diff --git a/GsaGH/Parameters/2_Geometry/Section3dPreview.cs b/GsaGH/Parameters/2_Geometry/Section3dPreview.cs index 499bdab9b..a1e85789a 100644 --- a/GsaGH/Parameters/2_Geometry/Section3dPreview.cs +++ b/GsaGH/Parameters/2_Geometry/Section3dPreview.cs @@ -355,7 +355,7 @@ private static GraphicSpecification AnalysisLayerSpec() { private static GraphicSpecification ResultSpec( GsaResult res, string elementList = "all", double scaleFactor = 1.0) { - string caseType = res.Type == CaseType.AnalysisCase ? "A" : "C"; + string caseType = res.CaseType == CaseType.AnalysisCase ? "A" : "C"; string caseDefinition = $"{caseType}{res.CaseId}"; return new GraphicSpecification() { Entities = new EntityList() { diff --git a/GsaGH/Parameters/5_Results/1_ApiResults/ApiResult.cs b/GsaGH/Parameters/5_Results/1_ApiResults/ApiResult.cs new file mode 100644 index 000000000..ba5afc849 --- /dev/null +++ b/GsaGH/Parameters/5_Results/1_ApiResults/ApiResult.cs @@ -0,0 +1,14 @@ +using GsaAPI; + +namespace GsaGH.Parameters.Results { + public class ApiResult : IApiResult { + public object Result { get; } + internal ApiResult(AnalysisCaseResult result) { + Result = result; + } + + internal ApiResult(CombinationCaseResult result) { + Result = result; + } + } +} diff --git a/GsaGH/Parameters/5_Results/1_ApiResults/IApiResult.cs b/GsaGH/Parameters/5_Results/1_ApiResults/IApiResult.cs new file mode 100644 index 000000000..57ed1e157 --- /dev/null +++ b/GsaGH/Parameters/5_Results/1_ApiResults/IApiResult.cs @@ -0,0 +1,5 @@ +namespace GsaGH.Parameters.Results { + public interface IApiResult { + public object Result { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/2_Results/GsaResult2.cs b/GsaGH/Parameters/5_Results/2_Results/GsaResult2.cs new file mode 100644 index 000000000..cd5d84fab --- /dev/null +++ b/GsaGH/Parameters/5_Results/2_Results/GsaResult2.cs @@ -0,0 +1,151 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using GsaAPI; +using GsaGH.Helpers; + +namespace GsaGH.Parameters.Results { + + public class GsaResult2 : IGsaResult { + // Caches + public IElement1dResultCache> Element1dDisplacements { + get; + private set; + } + public IElement1dResultCache> Element1dInternalForces { + get; + private set; + } + + public INodeResultCache> NodeDisplacements { + get; + private set; + } + public INodeResultCache> NodeResonantFootfalls { + get; + private set; + } + public INodeResultCache> NodeReactionForces { + get; + private set; + } + public INodeResultCache> NodeSpringForces { + get; + private set; + } + public INodeResultCache> NodeTransientFootfalls { + get; + private set; + } + + // temp conversion from old class + internal GsaResult2(GsaResult result) { + switch (result.CaseType) { + case CaseType.AnalysisCase: + InitialiseAnalysisCaseResults(result.Model, result.AnalysisCaseResult, result.CaseId); + break; + + case CaseType.CombinationCase: + InitialiseCombinationsCaseResults(result.Model, result.CombinationCaseResult, + result.CaseId, result.SelectedPermutationIds); + break; + } + } + + internal GsaResult2(GsaModel model, AnalysisCaseResult result, int caseId) { + InitialiseAnalysisCaseResults(model, result, caseId); + } + + internal GsaResult2( + GsaModel model, CombinationCaseResult result, int caseId, IEnumerable permutations) { + InitialiseCombinationsCaseResults(model, result, caseId, permutations.OrderBy(x => x)); + } + + // Other members + public int CaseId { get; set; } + public string CaseName { get; set; } + public GsaModel Model { get; set; } + public List SelectedPermutationIds { get; set; } + public CaseType CaseType { get; set; } + + public override string ToString() { + string txt = string.Empty; + switch (CaseType) { + case CaseType.AnalysisCase: + txt = "A" + CaseId; + break; + + case CaseType.CombinationCase: + txt = "C" + CaseId; + if (SelectedPermutationIds.Count > 0) { + txt = SelectedPermutationIds.Count > 1 ? txt + " P:" + SelectedPermutationIds.Count : + txt + " p" + SelectedPermutationIds[0]; + } + + break; + } + + return txt.TrimSpaces(); + } + + internal ReadOnlyCollection NodeIds(string nodeList) { + var entityList = new EntityList() { + Definition = nodeList, + Type = GsaAPI.EntityType.Node, + Name = "node", + }; + return Model.Model.ExpandList(entityList); + } + + internal ReadOnlyCollection ElementIds(string elementList) { + var entityList = new EntityList() { + Definition = elementList, + Type = GsaAPI.EntityType.Element, + Name = "elem", + }; + return Model.Model.ExpandList(entityList); + } + + internal ReadOnlyCollection MemberIds(string memberList) { + var entityList = new EntityList() { + Definition = memberList, + Type = GsaAPI.EntityType.Member, + Name = "mem", + }; + return Model.Model.ExpandList(entityList); + } + + private void InitialiseAnalysisCaseResults( + GsaModel model, AnalysisCaseResult result, int caseId) { + Model = model; + CaseType = CaseType.AnalysisCase; + CaseId = caseId; + CaseName = model.Model.AnalysisCaseName(CaseId); + + Element1dDisplacements = new Element1dDisplacementCache(result); + Element1dInternalForces = new Element1dInternalForceCache(result); + NodeDisplacements = new NodeDisplacementCache(result); + NodeReactionForces = new NodeReactionForceCache(result, model.Model); + NodeSpringForces = new NodeSpringForceCache(result); + NodeResonantFootfalls = new NodeResonantFootfallCache(result); + NodeTransientFootfalls = new NodeTransientFootfallCache(result); + } + + private void InitialiseCombinationsCaseResults( + GsaModel model, CombinationCaseResult result, int caseId, IEnumerable permutations) { + Model = model; + CaseType = CaseType.CombinationCase; + CaseId = caseId; + CaseName = model.Model.CombinationCases()[caseId].Name; + SelectedPermutationIds = permutations.ToList(); + + Element1dDisplacements = new Element1dDisplacementCache(result); + Element1dInternalForces = new Element1dInternalForceCache(result); + NodeDisplacements = new NodeDisplacementCache(result); + NodeReactionForces = new NodeReactionForceCache(result, model.Model); + NodeSpringForces = new NodeSpringForceCache(result); + NodeResonantFootfalls = new NodeResonantFootfallCache(result); + NodeTransientFootfalls = new NodeTransientFootfallCache(result); + } + } +} diff --git a/GsaGH/Parameters/5_Results/2_Results/IGsaResult.cs b/GsaGH/Parameters/5_Results/2_Results/IGsaResult.cs new file mode 100644 index 000000000..9c34f27d9 --- /dev/null +++ b/GsaGH/Parameters/5_Results/2_Results/IGsaResult.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace GsaGH.Parameters.Results { + public interface IGsaResult { + public int CaseId { get; } + public string CaseName { get; } + public GsaModel Model { get; } + public List SelectedPermutationIds { get; } + public CaseType CaseType { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/3_Caches/CacheUtility.cs b/GsaGH/Parameters/5_Results/3_Caches/CacheUtility.cs new file mode 100644 index 000000000..8e26b0980 --- /dev/null +++ b/GsaGH/Parameters/5_Results/3_Caches/CacheUtility.cs @@ -0,0 +1,50 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Threading.Tasks; + +namespace GsaGH.Parameters.Results { + public static class CacheUtility { + public static ConcurrentBag GetMissingKeys( + this IDictionary existing, ICollection newKeys) { + var missingIds = new ConcurrentBag(); + Parallel.ForEach(newKeys, key => { + if (!existing.ContainsKey(key)) { + missingIds.Add(key); + } + }); + + return missingIds; + } + + public static ConcurrentBag GetMissingKeysAndPositions( + this IDictionary> existing, ICollection newKeys, ReadOnlyCollection positions) + where T1 : IElement1dQuantity where T2 : IResultItem { + var missingIds = new ConcurrentBag(); + Parallel.ForEach(newKeys, key => { + if (!existing.ContainsKey(key)) { + missingIds.Add(key); + } else { + foreach (double position in positions) { + if (!existing[key][0].Results.ContainsKey(position)) { + missingIds.Add(key); + } + } + } + }); + + return missingIds; + } + + public static ConcurrentDictionary GetSubset(this IDictionary dictionary, + ICollection keys) { + var subset = new ConcurrentDictionary(); + Parallel.ForEach(keys, key => { + if (dictionary.ContainsKey(key)) { + subset.TryAdd(key, dictionary[key]); + } + }); + return subset; + } + } +} diff --git a/GsaGH/Parameters/5_Results/3_Caches/Element1dDisplacementCache.cs b/GsaGH/Parameters/5_Results/3_Caches/Element1dDisplacementCache.cs new file mode 100644 index 000000000..c23bfa353 --- /dev/null +++ b/GsaGH/Parameters/5_Results/3_Caches/Element1dDisplacementCache.cs @@ -0,0 +1,60 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Eto.Forms; +using GsaAPI; + +namespace GsaGH.Parameters.Results { + public class Element1dDisplacementCache + : IElement1dResultCache> { + public IApiResult ApiResult { get; set; } + + public ConcurrentDictionary> Cache { get; } + = new ConcurrentDictionary>(); + + internal Element1dDisplacementCache(AnalysisCaseResult result) { + ApiResult = new ApiResult(result); + } + + internal Element1dDisplacementCache(CombinationCaseResult result) { + ApiResult = new ApiResult(result); + } + + public IElement1dResultSubset> + ResultSubset(ICollection elementIds, int positionCount) { + var positions = Enumerable.Range(0, positionCount).Select( + i => (double)i / (positionCount - 1)).ToList(); + return ResultSubset(elementIds, new ReadOnlyCollection(positions)); + } + + public IElement1dResultSubset> + ResultSubset(ICollection elementIds, ReadOnlyCollection positions) { + ConcurrentBag missingIds + = Cache.GetMissingKeysAndPositions(elementIds, positions); + if (missingIds.Count > 0) { + string elementList = string.Join(" ", missingIds); + switch (ApiResult.Result) { + case AnalysisCaseResult analysisCase: + ReadOnlyDictionary> aCaseResults + = analysisCase.Element1dDisplacement(elementList, positions); + Parallel.ForEach(aCaseResults.Keys, elementId => Cache.AddOrUpdate( + elementId, Element1dResultsFactory.CreateBeamDisplacements(aCaseResults[elementId], positions), + (key, oldValue) => oldValue.AddMissingPositions(aCaseResults[elementId], positions))); + break; + + case CombinationCaseResult combinationCase: + ReadOnlyDictionary>> cCaseResults + = combinationCase.Element1dDisplacement(elementList, positions); + Parallel.ForEach(cCaseResults.Keys, elementId => Cache.AddOrUpdate( + elementId, Element1dResultsFactory.CreateBeamDisplacements(cCaseResults[elementId], positions), + (key, oldValue) => oldValue.AddMissingPositions(cCaseResults[elementId], positions))); + break; + } + } + + return new Element1dDisplacements(Cache.GetSubset(elementIds)); + } + } +} diff --git a/GsaGH/Parameters/5_Results/3_Caches/Element1dInternalForceCache.cs b/GsaGH/Parameters/5_Results/3_Caches/Element1dInternalForceCache.cs new file mode 100644 index 000000000..ce4d7ee01 --- /dev/null +++ b/GsaGH/Parameters/5_Results/3_Caches/Element1dInternalForceCache.cs @@ -0,0 +1,60 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using Eto.Forms; +using GsaAPI; + +namespace GsaGH.Parameters.Results { + public class Element1dInternalForceCache + : IElement1dResultCache> { + public IApiResult ApiResult { get; set; } + + public ConcurrentDictionary> Cache { get; } + = new ConcurrentDictionary>(); + + internal Element1dInternalForceCache(AnalysisCaseResult result) { + ApiResult = new ApiResult(result); + } + + internal Element1dInternalForceCache(CombinationCaseResult result) { + ApiResult = new ApiResult(result); + } + + public IElement1dResultSubset> + ResultSubset(ICollection elementIds, int positionCount) { + var positions = Enumerable.Range(0, positionCount).Select( + i => (double)i / (positionCount - 1)).ToList(); + return ResultSubset(elementIds, new ReadOnlyCollection(positions)); + } + + public IElement1dResultSubset> + ResultSubset(ICollection elementIds, ReadOnlyCollection positions) { + ConcurrentBag missingIds + = Cache.GetMissingKeysAndPositions(elementIds, positions); + if (missingIds.Count > 0) { + string elementList = string.Join(" ", missingIds); + switch (ApiResult.Result) { + case AnalysisCaseResult analysisCase: + ReadOnlyDictionary> aCaseResults + = analysisCase.Element1dForce(elementList, positions); + Parallel.ForEach(aCaseResults.Keys, elementId => Cache.AddOrUpdate( + elementId, Element1dResultsFactory.CreateBeamForces(aCaseResults[elementId], positions), + (key, oldValue) => oldValue.AddMissingPositions(aCaseResults[elementId], positions))); + break; + + case CombinationCaseResult combinationCase: + ReadOnlyDictionary>> cCaseResults + = combinationCase.Element1dForce(elementList, positions); + Parallel.ForEach(cCaseResults.Keys, elementId => Cache.AddOrUpdate( + elementId, Element1dResultsFactory.CreateBeamForces(cCaseResults[elementId], positions), + (key, oldValue) => oldValue.AddMissingPositions(cCaseResults[elementId], positions))); + break; + } + } + + return new Element1dInternalForces(Cache.GetSubset(elementIds)); + } + } +} diff --git a/GsaGH/Parameters/5_Results/3_Caches/IElement1dResultCache.cs b/GsaGH/Parameters/5_Results/3_Caches/IElement1dResultCache.cs new file mode 100644 index 000000000..f9a126509 --- /dev/null +++ b/GsaGH/Parameters/5_Results/3_Caches/IElement1dResultCache.cs @@ -0,0 +1,13 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace GsaGH.Parameters.Results { + public interface IElement1dResultCache + where T1 : IElement1dQuantity where T2 : IResultItem { + IApiResult ApiResult { get; } + ConcurrentDictionary> Cache { get; } + IElement1dResultSubset ResultSubset(ICollection elementIds, int positionCount); + IElement1dResultSubset ResultSubset(ICollection elementIds, ReadOnlyCollection positions); + } +} diff --git a/GsaGH/Parameters/5_Results/3_Caches/INodeResultCache.cs b/GsaGH/Parameters/5_Results/3_Caches/INodeResultCache.cs new file mode 100644 index 000000000..f8ed121a5 --- /dev/null +++ b/GsaGH/Parameters/5_Results/3_Caches/INodeResultCache.cs @@ -0,0 +1,11 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace GsaGH.Parameters.Results { + public interface INodeResultCache where T1 : IResultItem { + IApiResult ApiResult { get; } + ConcurrentDictionary> Cache { get; } + INodeResultSubset ResultSubset(ICollection list); + } +} \ No newline at end of file diff --git a/GsaGH/Parameters/5_Results/3_Caches/NodeDisplacementCache.cs b/GsaGH/Parameters/5_Results/3_Caches/NodeDisplacementCache.cs new file mode 100644 index 000000000..c75d3a782 --- /dev/null +++ b/GsaGH/Parameters/5_Results/3_Caches/NodeDisplacementCache.cs @@ -0,0 +1,52 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using GsaAPI; + +namespace GsaGH.Parameters.Results { + public class NodeDisplacementCache : INodeResultCache> { + public IApiResult ApiResult { get; set; } + + public ConcurrentDictionary> Cache { get; } + = new ConcurrentDictionary>(); + + internal NodeDisplacementCache(AnalysisCaseResult result) { + ApiResult = new ApiResult(result); + } + + internal NodeDisplacementCache(CombinationCaseResult result) { + ApiResult = new ApiResult(result); + } + + public INodeResultSubset> ResultSubset(ICollection nodeIds) { + ConcurrentBag missingIds = Cache.GetMissingKeys(nodeIds); + if (missingIds.Count > 0) { + string nodelist = string.Join(" ", missingIds); + switch (ApiResult.Result) { + case AnalysisCaseResult analysisCase: + ReadOnlyDictionary aCaseResults = analysisCase.NodeResults(nodelist); + Parallel.ForEach(aCaseResults.Keys, nodeId => { + var res = new Displacement(aCaseResults[nodeId].Displacement); + Cache.TryAdd(nodeId, new Collection() { res }); + }); + break; + + case CombinationCaseResult combinationCase: + ReadOnlyDictionary> cCaseResults = combinationCase.NodeResults(nodelist); + Parallel.ForEach(cCaseResults.Keys, nodeId => { + var permutationResults = new Collection(); + foreach (NodeResult permutationResult in cCaseResults[nodeId]) { + permutationResults.Add(new Displacement(permutationResult.Displacement)); + } + + Cache.TryAdd(nodeId, permutationResults); + }); + break; + } + } + + return new NodeDisplacements(Cache.GetSubset(nodeIds)); + } + } +} diff --git a/GsaGH/Parameters/5_Results/3_Caches/NodeReactionForceCache.cs b/GsaGH/Parameters/5_Results/3_Caches/NodeReactionForceCache.cs new file mode 100644 index 000000000..5845bdb67 --- /dev/null +++ b/GsaGH/Parameters/5_Results/3_Caches/NodeReactionForceCache.cs @@ -0,0 +1,114 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using GsaAPI; + +namespace GsaGH.Parameters.Results { + public class + NodeReactionForceCache : INodeResultCache> { + internal ConcurrentBag SupportNodeIds { get; private set; } + public IApiResult ApiResult { get; set; } + public ConcurrentDictionary> Cache { get; } + = new ConcurrentDictionary>(); + + internal ReadOnlyDictionary Nodes { get; private set; } + + internal NodeReactionForceCache(AnalysisCaseResult result, Model model) { + ApiResult = new ApiResult(result); + SetSupportNodeIds(model); + } + + internal NodeReactionForceCache(CombinationCaseResult result, Model model) { + ApiResult = new ApiResult(result); + SetSupportNodeIds(model); + } + + public INodeResultSubset> ResultSubset( + ICollection nodeIds) { + ConcurrentBag missingIds = Cache.GetMissingKeys(nodeIds); + + if (missingIds.Count > 0) { + string nodelist = string.Join(" ", missingIds); + switch (ApiResult.Result) { + case AnalysisCaseResult analysisCase: + ReadOnlyDictionary aCaseResults = analysisCase.NodeResults(nodelist); + Parallel.ForEach(aCaseResults, resultKvp => { + if (!IsSupport(resultKvp)) { + return; + } + + var res = new ReactionForce(resultKvp.Value.Reaction); + Cache.TryAdd(resultKvp.Key, new Collection() { + res, + }); + }); + break; + + case CombinationCaseResult combinationCase: + ReadOnlyDictionary> cCaseResults + = combinationCase.NodeResults(nodelist); + Parallel.ForEach(cCaseResults, resultKvp => { + if (!IsSupport(resultKvp)) { + return; + } + + var permutationResults = new Collection(); + foreach (NodeResult permutationResult in resultKvp.Value) { + permutationResults.Add(new ReactionForce(permutationResult.Reaction)); + } + + Cache.TryAdd(resultKvp.Key, permutationResults); + }); + break; + } + } + + return new NodeForceSubset(Cache.GetSubset(nodeIds)); + } + + private bool IsSupport(KeyValuePair kvp) { + return SupportNodeIds.Contains(kvp.Key) || HasValues(kvp.Value.Reaction); + } + + private bool IsSupport(KeyValuePair> kvp) { + if (SupportNodeIds.Contains(kvp.Key)) { + return true; + } + + foreach (NodeResult res in kvp.Value) { + if (HasValues(res.Reaction)) { + return true; + } + } + + return false; + } + + private bool IsRestrained(NodalRestraint rest) { + return rest.X || rest.Y || rest.Z || rest.XX || rest.YY || rest.ZZ; + } + + 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; + } + + private void SetSupportNodeIds(Model model) { + ConcurrentBag supportnodeIDs = null; + supportnodeIDs = new ConcurrentBag(); + ReadOnlyDictionary nodes = model.Nodes(); + Parallel.ForEach(nodes, node => { + if (IsRestrained(node.Value.Restraint)) { + supportnodeIDs.Add(node.Key); + } + }); + SupportNodeIds = supportnodeIDs; + } + } +} diff --git a/GsaGH/Parameters/5_Results/3_Caches/NodeResonantFootfallCache.cs b/GsaGH/Parameters/5_Results/3_Caches/NodeResonantFootfallCache.cs new file mode 100644 index 000000000..fccf5b96b --- /dev/null +++ b/GsaGH/Parameters/5_Results/3_Caches/NodeResonantFootfallCache.cs @@ -0,0 +1,60 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using GsaAPI; + +namespace GsaGH.Parameters.Results { + public class NodeResonantFootfallCache : INodeResultCache> { + public IApiResult ApiResult { get; set; } + public ConcurrentDictionary> Cache { get; } + = new ConcurrentDictionary>(); + + internal NodeResonantFootfallCache(AnalysisCaseResult result) { + ApiResult = new ApiResult(result); + } + internal NodeResonantFootfallCache(CombinationCaseResult result) { + ApiResult = new ApiResult(result); + } + + public INodeResultSubset> ResultSubset(ICollection nodeIds) { + ConcurrentBag missingIds = Cache.GetMissingKeys(nodeIds); + if (missingIds.Count > 0) { + string nodelist = string.Join(" ", missingIds); + switch (ApiResult.Result) { + case AnalysisCaseResult analysisCase: + ReadOnlyDictionary aCaseResults = analysisCase.NodeResonantFootfall(nodelist); + Parallel.ForEach(aCaseResults.Keys, nodeId => { + if (double.IsNaN(aCaseResults[nodeId].MaximumResponseFactor)) { + return; + } + + var res = new Footfall(aCaseResults[nodeId]); + Cache.TryAdd(nodeId, new Collection() { res }); + }); + break; + + case CombinationCaseResult combinationCase: + ReadOnlyDictionary> cCaseResults = combinationCase.NodeResonantFootfall(nodelist); + Parallel.ForEach(cCaseResults.Keys, nodeId => { + var permutationResults = new Collection(); + foreach (NodeFootfallResult permutationResult in cCaseResults[nodeId]) { + if (double.IsNaN(permutationResult.MaximumResponseFactor)) { + continue; + } + + permutationResults.Add(new Footfall(permutationResult)); + } + + if (permutationResults.Count > 0) { + Cache.TryAdd(nodeId, permutationResults); + } + }); + break; + } + } + + return new NodeFootfalls(Cache.GetSubset(nodeIds)); + } + } +} diff --git a/GsaGH/Parameters/5_Results/3_Caches/NodeSpringForceCache.cs b/GsaGH/Parameters/5_Results/3_Caches/NodeSpringForceCache.cs new file mode 100644 index 000000000..876d1d775 --- /dev/null +++ b/GsaGH/Parameters/5_Results/3_Caches/NodeSpringForceCache.cs @@ -0,0 +1,58 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using GsaAPI; + +namespace GsaGH.Parameters.Results { + public class + NodeSpringForceCache : INodeResultCache> { + + internal NodeSpringForceCache(AnalysisCaseResult result) { + ApiResult = new ApiResult(result); + } + + internal NodeSpringForceCache(CombinationCaseResult result) { + ApiResult = new ApiResult(result); + } + + public IApiResult ApiResult { get; set; } + public ConcurrentDictionary> Cache { get; } + = new ConcurrentDictionary>(); + + public INodeResultSubset> ResultSubset( + ICollection nodeIds) { + ConcurrentBag missingIds = Cache.GetMissingKeys(nodeIds); + + if (missingIds.Count > 0) { + string nodelist = string.Join(" ", missingIds); + switch (ApiResult.Result) { + case AnalysisCaseResult analysisCase: + ReadOnlyDictionary aCaseResults = analysisCase.NodeResults(nodelist); + Parallel.ForEach(aCaseResults.Keys, nodeId => { + var res = new ReactionForce(aCaseResults[nodeId].SpringForce); + Cache.TryAdd(nodeId, new Collection() { + res, + }); + }); + break; + + case CombinationCaseResult combinationCase: + ReadOnlyDictionary> cCaseResults + = combinationCase.NodeResults(nodelist); + Parallel.ForEach(cCaseResults.Keys, nodeId => { + var permutationResults = new Collection(); + foreach (NodeResult permutationResult in cCaseResults[nodeId]) { + permutationResults.Add(new ReactionForce(permutationResult.SpringForce)); + } + + Cache.TryAdd(nodeId, permutationResults); + }); + break; + } + } + + return new NodeForceSubset(Cache.GetSubset(nodeIds)); + } + } +} diff --git a/GsaGH/Parameters/5_Results/3_Caches/NodeTransientFootfallCache.cs b/GsaGH/Parameters/5_Results/3_Caches/NodeTransientFootfallCache.cs new file mode 100644 index 000000000..ec7a221bd --- /dev/null +++ b/GsaGH/Parameters/5_Results/3_Caches/NodeTransientFootfallCache.cs @@ -0,0 +1,50 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using GsaAPI; + +namespace GsaGH.Parameters.Results { + public class NodeTransientFootfallCache : INodeResultCache> { + public IApiResult ApiResult { get; set; } + public ConcurrentDictionary> Cache { get; } + = new ConcurrentDictionary>(); + + internal NodeTransientFootfallCache(AnalysisCaseResult result) { + ApiResult = new ApiResult(result); + } + internal NodeTransientFootfallCache(CombinationCaseResult result) { + ApiResult = new ApiResult(result); + } + + public INodeResultSubset> ResultSubset(ICollection nodeIds) { + ConcurrentBag missingIds = Cache.GetMissingKeys(nodeIds); + if (missingIds.Count > 0) { + string nodelist = string.Join(" ", missingIds); + switch (ApiResult.Result) { + case AnalysisCaseResult analysisCase: + ReadOnlyDictionary aCaseResults = analysisCase.NodeTransientFootfall(nodelist); + Parallel.ForEach(aCaseResults.Keys, nodeId => { + var res = new Footfall(aCaseResults[nodeId]); + Cache.TryAdd(nodeId, new Collection() { res }); + }); + break; + + case CombinationCaseResult combinationCase: + ReadOnlyDictionary> cCaseResults = combinationCase.NodeTransientFootfall(nodelist); + Parallel.ForEach(cCaseResults.Keys, nodeId => { + var permutationResults = new Collection(); + foreach (NodeFootfallResult permutationResult in cCaseResults[nodeId]) { + permutationResults.Add(new Footfall(permutationResult)); + } + + Cache.TryAdd(nodeId, permutationResults); + }); + break; + } + } + + return new NodeFootfalls(Cache.GetSubset(nodeIds)); + } + } +} diff --git a/GsaGH/Parameters/5_Results/4_Subsets/Element1dDisplacements.cs b/GsaGH/Parameters/5_Results/4_Subsets/Element1dDisplacements.cs new file mode 100644 index 000000000..05b50d282 --- /dev/null +++ b/GsaGH/Parameters/5_Results/4_Subsets/Element1dDisplacements.cs @@ -0,0 +1,26 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public class Element1dDisplacements : IElement1dResultSubset> { + public ResultVector6 Max { get; private set; } + public ResultVector6 Min { get; private set; } + public IList Ids { get; private set; } + + public ConcurrentDictionary> Subset { get; } + = new ConcurrentDictionary>(); + + public Element1dDisplacements(ConcurrentDictionary> results) { + Subset = results; + Ids = results.Keys.OrderBy(x => x).ToList(); + (Max, Min) = results.Extrema(); + } + + public IDisplacement GetExtrema(Element1dExtremaKey key) { + return Subset[key.Id][key.Permutation].Results[key.Position]; + } + } +} diff --git a/GsaGH/Parameters/5_Results/4_Subsets/Element1dInternalForces.cs b/GsaGH/Parameters/5_Results/4_Subsets/Element1dInternalForces.cs new file mode 100644 index 000000000..888aaf672 --- /dev/null +++ b/GsaGH/Parameters/5_Results/4_Subsets/Element1dInternalForces.cs @@ -0,0 +1,26 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public class Element1dInternalForces : IElement1dResultSubset> { + public ResultVector6 Max { get; private set; } + public ResultVector6 Min { get; private set; } + public IList Ids { get; private set; } + + public ConcurrentDictionary> Subset { get; } + = new ConcurrentDictionary>(); + + public Element1dInternalForces(ConcurrentDictionary> results) { + Subset = results; + Ids = results.Keys.OrderBy(x => x).ToList(); + (Max, Min) = results.Extrema(); + } + + public IInternalForce GetExtrema(Element1dExtremaKey key) { + return Subset[key.Id][key.Permutation].Results[key.Position]; + } + } +} diff --git a/GsaGH/Parameters/5_Results/4_Subsets/Element1dResultsFactory.cs b/GsaGH/Parameters/5_Results/4_Subsets/Element1dResultsFactory.cs new file mode 100644 index 000000000..090dc8040 --- /dev/null +++ b/GsaGH/Parameters/5_Results/4_Subsets/Element1dResultsFactory.cs @@ -0,0 +1,90 @@ +using GsaAPI; +using System.Collections.ObjectModel; + +namespace GsaGH.Parameters.Results { + public static class Element1dResultsFactory { + public static Collection CreateBeamDisplacements( + ReadOnlyCollection results, ReadOnlyCollection positions) { + return new Collection { + new Element1dDisplacement(results, positions) + }; + } + + public static Collection CreateBeamDisplacements( + ReadOnlyCollection> results, ReadOnlyCollection positions) { + var permutations = new Collection(); + foreach (ReadOnlyCollection permutation in results) { + permutations.Add(new Element1dDisplacement(permutation, positions)); + } + return permutations; + } + + public static Collection CreateBeamForces( + ReadOnlyCollection results, ReadOnlyCollection positions) { + return new Collection { + new Element1dInternalForce(results, positions) + }; + } + + public static Collection CreateBeamForces( + ReadOnlyCollection> results, ReadOnlyCollection positions) { + var permutations = new Collection(); + foreach (ReadOnlyCollection permutation in results) { + permutations.Add(new Element1dInternalForce(permutation, positions)); + } + return permutations; + } + + public static Collection AddMissingPositions( + this Collection existing, + ReadOnlyCollection results, ReadOnlyCollection positions) { + for (int i = 0; i < results.Count; i++) { + if (!existing[0].Results.ContainsKey(positions[i])) { + existing[0].Results.Add(positions[i], new ReactionForce(results[i])); + } + } + + return existing; + } + + public static Collection AddMissingPositions( + this Collection existing, + ReadOnlyCollection> results, ReadOnlyCollection positions) { + for (int i = 0; i < existing.Count; i++) { + for (int j = 0; j < results.Count; j++) { + if (!existing[i].Results.ContainsKey(positions[j])) { + existing[i].Results.Add(positions[j], new ReactionForce(results[i][j])); + } + } + } + + return existing; + } + + public static Collection AddMissingPositions( + this Collection existing, + ReadOnlyCollection results, ReadOnlyCollection positions) { + for (int i = 0; i < results.Count; i++) { + if (!existing[0].Results.ContainsKey(positions[i])) { + existing[0].Results.Add(positions[i], new Displacement(results[i])); + } + } + + return existing; + } + + public static Collection AddMissingPositions( + this Collection existing, + ReadOnlyCollection> results, ReadOnlyCollection positions) { + for (int i = 0; i < existing.Count; i++) { + for (int j = 0; j < results.Count; j++) { + if (!existing[i].Results.ContainsKey(positions[j])) { + existing[i].Results.Add(positions[j], new Displacement(results[i][j])); + } + } + } + + return existing; + } + } +} diff --git a/GsaGH/Parameters/5_Results/4_Subsets/IElement1dResultSubset.cs b/GsaGH/Parameters/5_Results/4_Subsets/IElement1dResultSubset.cs new file mode 100644 index 000000000..e6d9ee352 --- /dev/null +++ b/GsaGH/Parameters/5_Results/4_Subsets/IElement1dResultSubset.cs @@ -0,0 +1,20 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace GsaGH.Parameters.Results { + public interface IElement1dResultSubset + where T1 : IElement1dQuantity + where T2 : IResultItem { + T3 Max { get; } + T3 Min { get; } + IList Ids { get; } + /// + /// Key = Node Id + /// + /// Value = Collection of results, one for each permutation. Collection will have 1 item in case of AnalysisCase + /// + ConcurrentDictionary> Subset { get; } + T2 GetExtrema(Element1dExtremaKey key); + } +} diff --git a/GsaGH/Parameters/5_Results/4_Subsets/INodeResultSubset.cs b/GsaGH/Parameters/5_Results/4_Subsets/INodeResultSubset.cs new file mode 100644 index 000000000..2095a32d7 --- /dev/null +++ b/GsaGH/Parameters/5_Results/4_Subsets/INodeResultSubset.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace GsaGH.Parameters.Results { + public interface INodeResultSubset where T1 : IResultItem { + T2 Max { get; } + T2 Min { get; } + IList Ids { get; } + /// + /// Key = Node Id + /// + /// Value = Collection of results, one for each permutation. Collection will have 1 item in case of AnalysisCase + /// + IDictionary> Subset { get; } + T1 GetExtrema(NodeExtremaKey key); + } +} diff --git a/GsaGH/Parameters/5_Results/4_Subsets/NodeDisplacements.cs b/GsaGH/Parameters/5_Results/4_Subsets/NodeDisplacements.cs new file mode 100644 index 000000000..32f5a180d --- /dev/null +++ b/GsaGH/Parameters/5_Results/4_Subsets/NodeDisplacements.cs @@ -0,0 +1,26 @@ +using OasysUnits; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +namespace GsaGH.Parameters.Results { + public class NodeDisplacements : INodeResultSubset> { + public ResultVector6 Max { get; private set; } + public ResultVector6 Min { get; private set; } + public IList Ids { get; private set; } + + public IDictionary> Subset { get; } + = new ConcurrentDictionary>(); + + public NodeDisplacements(IDictionary> results) { + Subset = results; + Ids = results.Keys.OrderBy(x => x).ToList(); + (Max, Min) = results.Extrema(); + } + + public IDisplacement GetExtrema(NodeExtremaKey key) { + return Subset[key.Id][key.Permutation]; + } + } +} \ No newline at end of file diff --git a/GsaGH/Parameters/5_Results/4_Subsets/NodeFootfalls.cs b/GsaGH/Parameters/5_Results/4_Subsets/NodeFootfalls.cs new file mode 100644 index 000000000..37ede9796 --- /dev/null +++ b/GsaGH/Parameters/5_Results/4_Subsets/NodeFootfalls.cs @@ -0,0 +1,25 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +namespace GsaGH.Parameters.Results { + public class NodeFootfalls : INodeResultSubset> { + public ResultFootfall Max { get; private set; } + public ResultFootfall Min { get; private set; } + public IList Ids { get; private set; } + + public IDictionary> Subset { get; } + = new ConcurrentDictionary>(); + + public NodeFootfalls(IDictionary> results) { + Subset = results; + Ids = results.Keys.OrderBy(x => x).ToList(); + (Max, Min) = results.Extrema(); + } + + public IFootfall GetExtrema(NodeExtremaKey key) { + return Subset[key.Id][key.Permutation]; + } + } +} \ No newline at end of file diff --git a/GsaGH/Parameters/5_Results/4_Subsets/NodeForceSubset.cs b/GsaGH/Parameters/5_Results/4_Subsets/NodeForceSubset.cs new file mode 100644 index 000000000..4b36dcac7 --- /dev/null +++ b/GsaGH/Parameters/5_Results/4_Subsets/NodeForceSubset.cs @@ -0,0 +1,26 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +namespace GsaGH.Parameters.Results { + public class NodeForceSubset : INodeResultSubset> { + + public NodeForceSubset(IDictionary> results) { + Subset = results; + Ids = results.Keys.OrderBy(x => x).ToList(); + (Max, Min) = results.Extrema(); + } + + public ResultVector6 Max { get; private set; } + public ResultVector6 Min { get; private set; } + public IList Ids { get; private set; } + + public IDictionary> Subset { get; } + = new ConcurrentDictionary>(); + + public IInternalForce GetExtrema(NodeExtremaKey key) { + return Subset[key.Id][key.Permutation]; + } + } +} diff --git a/GsaGH/Parameters/5_Results/5_Extrema/Element1dExtremaKey.cs b/GsaGH/Parameters/5_Results/5_Extrema/Element1dExtremaKey.cs new file mode 100644 index 000000000..8eba4c28f --- /dev/null +++ b/GsaGH/Parameters/5_Results/5_Extrema/Element1dExtremaKey.cs @@ -0,0 +1,12 @@ +namespace GsaGH.Parameters.Results { + public class Element1dExtremaKey { + public int Id { get; internal set; } + public int Permutation { get; internal set; } + public double Position { get; internal set; } + public Element1dExtremaKey(int id, double position, int permutation = 0) { + Id = id; + Position = position; + Permutation = permutation; + } + } +} diff --git a/GsaGH/Parameters/5_Results/5_Extrema/ExtremaKeyUtility.cs b/GsaGH/Parameters/5_Results/5_Extrema/ExtremaKeyUtility.cs new file mode 100644 index 000000000..daa15cc7f --- /dev/null +++ b/GsaGH/Parameters/5_Results/5_Extrema/ExtremaKeyUtility.cs @@ -0,0 +1,330 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Newtonsoft.Json.Linq; +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public static class ExtremaKeyUtility { + public static (ResultVector6 Max, ResultVector6 Min) Extrema( + this IDictionary> subset) + where T : IElement1dQuantity where U : IResultItem { + + var maxValue = new ResultVector6(double.MinValue); + var minValue = new ResultVector6(double.MaxValue); + + var maxKey = new ResultVector6(); + var minKey = new ResultVector6(); + + foreach (int elementId in subset.Keys) { + Collection values = subset[elementId]; + for (int permutation = 0; permutation < values.Count; permutation++) { + foreach (double position in values[permutation].Results.Keys) { + switch (values[permutation]) { + case IElement1dDisplacement displacement: + UpdateExtrema(displacement.Results[position], + elementId, permutation, position, + ref maxValue, ref minValue, ref maxKey, ref minKey); + break; + + case IElement1dInternalForce displacement: + UpdateExtrema(displacement.Results[position], + elementId, permutation, position, + ref maxValue, ref minValue, ref maxKey, ref minKey); + break; + + } + } + } + } + + return (maxKey, minKey); + } + + public static (ResultFootfall Max, ResultFootfall Min) Extrema( + this IDictionary> subset) { + + var maxValue = new ResultFootfall(double.MinValue); + var minValue = new ResultFootfall(double.MaxValue); + + var maxKey = new ResultFootfall(); + var minKey = new ResultFootfall(); + + foreach (int nodeId in subset.Keys) { + Collection values = subset[nodeId]; + for (int permutation = 0; permutation < values.Count; permutation++) { + UpdateExtrema(values[permutation], nodeId, permutation, + ref maxValue, ref minValue, ref maxKey, ref minKey); + } + } + + return (maxKey, minKey); + } + + public static (ResultVector6 Max, ResultVector6 Min) Extrema( + this IDictionary> subset) { + + var maxValue = new ResultVector6(double.MinValue); + var minValue = new ResultVector6(double.MaxValue); + + var maxKey = new ResultVector6(); + var minKey = new ResultVector6(); + + foreach (int nodeId in subset.Keys) { + Collection values = subset[nodeId]; + for (int permutation = 0; permutation < values.Count; permutation++) { + switch (values[permutation]) { + case IDisplacement displacement: + UpdateExtrema(displacement, nodeId, permutation, + ref maxValue, ref minValue, ref maxKey, ref minKey); + break; + + case IInternalForce internalForce: + UpdateExtrema(internalForce, nodeId, permutation, + ref maxValue, ref minValue, ref maxKey, ref minKey); + break; + } + } + } + + return (maxKey, minKey); + } + + private static void UpdateExtrema(IFootfall item, int nodeId, int permutation, + ref ResultFootfall maxValue, ref ResultFootfall minValue, + ref ResultFootfall maxKey, ref ResultFootfall minKey) { + + if (item.CriticalFrequency.Value > maxValue.CriticalFrequency) { + maxValue.CriticalFrequency = item.CriticalFrequency.Value; + maxKey.CriticalFrequency = new NodeExtremaKey(nodeId, permutation); + } + + if (item.MaximumResponseFactor > maxValue.MaximumResponseFactor) { + maxValue.MaximumResponseFactor = item.MaximumResponseFactor; + maxKey.MaximumResponseFactor = new NodeExtremaKey(nodeId, permutation); + } + + if (item.PeakAcceleration.Value > maxValue.PeakAcceleration) { + maxValue.PeakAcceleration = item.PeakAcceleration.Value; + maxKey.PeakAcceleration = new NodeExtremaKey(nodeId, permutation); + } + + if (item.PeakVelocity.Value > maxValue.PeakVelocity) { + maxValue.PeakVelocity = item.PeakVelocity.Value; + maxKey.PeakVelocity = new NodeExtremaKey(nodeId, permutation); + } + + if (item.RmsAcceleration.Value > maxValue.RmsAcceleration) { + maxValue.RmsAcceleration = item.RmsAcceleration.Value; + maxKey.RmsAcceleration = new NodeExtremaKey(nodeId, permutation); + } + + if (item.RmsVelocity.Value > maxValue.RmsVelocity) { + maxValue.RmsVelocity = item.RmsVelocity.Value; + maxKey.RmsVelocity = new NodeExtremaKey(nodeId, permutation); + } + + if (item.CriticalFrequency.Value < minValue.CriticalFrequency) { + minValue.CriticalFrequency = item.CriticalFrequency.Value; + minKey.CriticalFrequency = new NodeExtremaKey(nodeId, permutation); + } + + if (item.MaximumResponseFactor < minValue.MaximumResponseFactor) { + minValue.MaximumResponseFactor = item.MaximumResponseFactor; + minKey.MaximumResponseFactor = new NodeExtremaKey(nodeId, permutation); + } + + if (item.PeakAcceleration.Value < minValue.PeakAcceleration) { + minValue.PeakAcceleration = item.PeakAcceleration.Value; + minKey.PeakAcceleration = new NodeExtremaKey(nodeId, permutation); + } + + if (item.PeakVelocity.Value < minValue.PeakVelocity) { + minValue.PeakVelocity = item.PeakVelocity.Value; + minKey.PeakVelocity = new NodeExtremaKey(nodeId, permutation); + } + + if (item.RmsAcceleration.Value < minValue.RmsAcceleration) { + minValue.RmsAcceleration = item.RmsAcceleration.Value; + minKey.RmsAcceleration = new NodeExtremaKey(nodeId, permutation); + } + + if (item.RmsVelocity.Value < minValue.RmsVelocity) { + minValue.RmsVelocity = item.RmsVelocity.Value; + minKey.RmsVelocity = new NodeExtremaKey(nodeId, permutation); + } + } + + private static void UpdateExtrema(T item, int nodeId, int permutation, + ref ResultVector6 maxValue, ref ResultVector6 minValue, + ref ResultVector6 maxKey, ref ResultVector6 minKey) + where T : IResultVector6 where Q1 : IQuantity where Q2 : IQuantity { + + if (item.X.Value > maxValue.X) { + maxValue.X = item.X.Value; + maxKey.X = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Y.Value > maxValue.Y) { + maxValue.Y = item.Y.Value; + maxKey.Y = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Z.Value > maxValue.Z) { + maxValue.Z = item.Z.Value; + maxKey.Z = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Xyz.Value > maxValue.Xyz) { + maxValue.Xyz = item.Xyz.Value; + maxKey.Xyz = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Xx.Value > maxValue.Xx) { + maxValue.Xx = item.Xx.Value; + maxKey.Xx = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Yy.Value > maxValue.Yy) { + maxValue.Yy = item.Yy.Value; + maxKey.Yy = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Zz.Value > maxValue.Zz) { + maxValue.Zz = item.Zz.Value; + maxKey.Zz = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Xxyyzz.Value > maxValue.Xxyyzz) { + maxValue.Xxyyzz = item.Xxyyzz.Value; + maxKey.Xxyyzz = new NodeExtremaKey(nodeId, permutation); + } + + if (item.X.Value < minValue.X) { + minValue.X = item.X.Value; + minKey.X = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Y.Value < minValue.Y) { + minValue.Y = item.Y.Value; + minKey.Y = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Z.Value < minValue.Z) { + minValue.Z = item.Z.Value; + minKey.Z = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Xyz.Value < minValue.Xyz) { + minValue.Xyz = item.Xyz.Value; + minKey.Xyz = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Xx.Value < minValue.Xx) { + minValue.Xx = item.Xx.Value; + minKey.Xx = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Yy.Value < minValue.Yy) { + minValue.Yy = item.Yy.Value; + minKey.Yy = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Zz.Value < minValue.Zz) { + minValue.Zz = item.Zz.Value; + minKey.Zz = new NodeExtremaKey(nodeId, permutation); + } + + if (item.Xxyyzz.Value < minValue.Xxyyzz) { + minValue.Xxyyzz = item.Xxyyzz.Value; + minKey.Xxyyzz = new NodeExtremaKey(nodeId, permutation); + } + } + + private static void UpdateExtrema(T item, int elementId, int permutation, double position, + ref ResultVector6 maxValue, ref ResultVector6 minValue, + ref ResultVector6 maxKey, ref ResultVector6 minKey) + where T : IResultVector6 where Q1 : IQuantity where Q2 : IQuantity { + + if (item.X.Value > maxValue.X) { + maxValue.X = item.X.Value; + maxKey.X = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Y.Value > maxValue.Y) { + maxValue.Y = item.Y.Value; + maxKey.Y = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Z.Value > maxValue.Z) { + maxValue.Z = item.Z.Value; + maxKey.Z = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Xyz.Value > maxValue.Xyz) { + maxValue.Xyz = item.Xyz.Value; + maxKey.Xyz = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Xx.Value > maxValue.Xx) { + maxValue.Xx = item.Xx.Value; + maxKey.Xx = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Yy.Value > maxValue.Yy) { + maxValue.Yy = item.Yy.Value; + maxKey.Yy = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Zz.Value > maxValue.Zz) { + maxValue.Zz = item.Zz.Value; + maxKey.Zz = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Xxyyzz.Value > maxValue.Xxyyzz) { + maxValue.Xxyyzz = item.Xxyyzz.Value; + maxKey.Xxyyzz = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.X.Value < minValue.X) { + minValue.X = item.X.Value; + minKey.X = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Y.Value < minValue.Y) { + minValue.Y = item.Y.Value; + minKey.Y = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Z.Value < minValue.Z) { + minValue.Z = item.Z.Value; + minKey.Z = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Xyz.Value < minValue.Xyz) { + minValue.Xyz = item.Xyz.Value; + minKey.Xyz = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Xx.Value < minValue.Xx) { + minValue.Xx = item.Xx.Value; + minKey.Xx = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Yy.Value < minValue.Yy) { + minValue.Yy = item.Yy.Value; + minKey.Yy = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Zz.Value < minValue.Zz) { + minValue.Zz = item.Zz.Value; + minKey.Zz = new Element1dExtremaKey(elementId, position, permutation); + } + + if (item.Xxyyzz.Value < minValue.Xxyyzz) { + minValue.Xxyyzz = item.Xxyyzz.Value; + minKey.Xxyyzz = new Element1dExtremaKey(elementId, position, permutation); + } + } + } +} diff --git a/GsaGH/Parameters/5_Results/5_Extrema/NodeExtremaKey.cs b/GsaGH/Parameters/5_Results/5_Extrema/NodeExtremaKey.cs new file mode 100644 index 000000000..60adc847f --- /dev/null +++ b/GsaGH/Parameters/5_Results/5_Extrema/NodeExtremaKey.cs @@ -0,0 +1,10 @@ +namespace GsaGH.Parameters.Results { + public class NodeExtremaKey { + public int Id { get; internal set; } + public int Permutation { get; internal set; } + public NodeExtremaKey(int id, int permutation = 0) { + Id = id; + Permutation = permutation; + } + } +} diff --git a/GsaGH/Parameters/5_Results/5_Extrema/ResultFootfall.cs b/GsaGH/Parameters/5_Results/5_Extrema/ResultFootfall.cs new file mode 100644 index 000000000..edf21dc0c --- /dev/null +++ b/GsaGH/Parameters/5_Results/5_Extrema/ResultFootfall.cs @@ -0,0 +1,28 @@ +namespace GsaGH.Parameters.Results { + public class ResultFootfall { + public T CriticalFrequency { get; set; } + + public T MaximumResponseFactor { get; set; } + + public T PeakAcceleration { get; set; } + + public T PeakVelocity { get; set; } + + public T RmsAcceleration { get; set; } + + public T RmsVelocity { get; set; } + + + public ResultFootfall() { + } + + public ResultFootfall(T initialValue) { + CriticalFrequency = initialValue; + MaximumResponseFactor = initialValue; + PeakAcceleration = initialValue; + PeakVelocity = initialValue; + RmsAcceleration = initialValue; + RmsVelocity = initialValue; + } + } +} diff --git a/GsaGH/Parameters/5_Results/5_Extrema/ResultVector6.cs b/GsaGH/Parameters/5_Results/5_Extrema/ResultVector6.cs new file mode 100644 index 000000000..6fd9a7b89 --- /dev/null +++ b/GsaGH/Parameters/5_Results/5_Extrema/ResultVector6.cs @@ -0,0 +1,33 @@ +namespace GsaGH.Parameters.Results { + public class ResultVector6 : IResultVector6 { + public T X { get; set; } + + public T Y { get; set; } + + public T Z { get; set; } + + public T Xyz { get; set; } + + public T Xx { get; set; } + + public T Yy { get; set; } + + public T Zz { get; set; } + + public T Xxyyzz { get; set; } + + public ResultVector6() { + } + + public ResultVector6(T initialValue) { + X = initialValue; + Y = initialValue; + Z = initialValue; + Xyz = initialValue; + Xx = initialValue; + Yy = initialValue; + Zz = initialValue; + Xxyyzz = initialValue; + } + } +} diff --git a/GsaGH/Parameters/5_Results/6_Quantities/Displacement.cs b/GsaGH/Parameters/5_Results/6_Quantities/Displacement.cs new file mode 100644 index 000000000..fdb07d99f --- /dev/null +++ b/GsaGH/Parameters/5_Results/6_Quantities/Displacement.cs @@ -0,0 +1,41 @@ +using GsaAPI; +using OasysUnits; +using AngleUnit = OasysUnits.Units.AngleUnit; +using LengthUnit = OasysUnits.Units.LengthUnit; + +namespace GsaGH.Parameters.Results { + public class Displacement : IDisplacement { + public Length X { get; internal set; } + public Length Y { get; internal set; } + public Length Z { get; internal set; } + public Length Xyz { get; internal set; } + public Angle Xx { get; internal set; } + public Angle Yy { get; internal set; } + public Angle Zz { get; internal set; } + public Angle Xxyyzz { get; internal set; } + + internal Displacement(Double6 result) { + X = new Length(result.X, LengthUnit.Meter); + Y = new Length(result.Y, LengthUnit.Meter); + Z = new Length(result.Z, LengthUnit.Meter); + Xyz = QuantityUtility.PythagoreanQuadruple(X, Y, Z); + Xx = CreateAngle(result.XX); + Yy = CreateAngle(result.YY); + Zz = CreateAngle(result.ZZ); + Xxyyzz = QuantityUtility.PythagoreanQuadruple(Xx, Yy, Zz); + } + + private Angle CreateAngle(double val) { + // TO-DO: GSA-5351 remove NaN and Infinity values from GsaAPI results + if (!double.IsNaN(val)) { + return !double.IsInfinity(val) + ? new Angle(val, AngleUnit.Radian) + : (double.IsPositiveInfinity(val) + ? new Angle(360, AngleUnit.Degree) + : new Angle(-360, AngleUnit.Degree)); + } else { + return Angle.Zero; + } + } + } +} diff --git a/GsaGH/Parameters/5_Results/6_Quantities/Element1dDisplacement.cs b/GsaGH/Parameters/5_Results/6_Quantities/Element1dDisplacement.cs new file mode 100644 index 000000000..2e7ba67b8 --- /dev/null +++ b/GsaGH/Parameters/5_Results/6_Quantities/Element1dDisplacement.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using GsaAPI; + +namespace GsaGH.Parameters.Results { + public class Element1dDisplacement : IElement1dDisplacement { + public IDictionary Results { get; private set; } + + internal Element1dDisplacement(ReadOnlyCollection result, ReadOnlyCollection positions) { + Results = new Dictionary(); + for (int i = 0; i < result.Count; i++) { + Results.Add(positions[i], new Displacement(result[i])); + } + } + } +} diff --git a/GsaGH/Parameters/5_Results/6_Quantities/Element1dInternalForce.cs b/GsaGH/Parameters/5_Results/6_Quantities/Element1dInternalForce.cs new file mode 100644 index 000000000..8ffb0e27a --- /dev/null +++ b/GsaGH/Parameters/5_Results/6_Quantities/Element1dInternalForce.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using GsaAPI; + +namespace GsaGH.Parameters.Results { + public class Element1dInternalForce : IElement1dInternalForce { + public IDictionary Results { get; private set; } + + internal Element1dInternalForce(ReadOnlyCollection result, ReadOnlyCollection positions) { + Results = new Dictionary(); + for (int i = 0; i < result.Count; i++) { + Results.Add(positions[i], new InternalForce(result[i])); + } + } + } +} diff --git a/GsaGH/Parameters/5_Results/6_Quantities/Footfall.cs b/GsaGH/Parameters/5_Results/6_Quantities/Footfall.cs new file mode 100644 index 000000000..04772f04b --- /dev/null +++ b/GsaGH/Parameters/5_Results/6_Quantities/Footfall.cs @@ -0,0 +1,28 @@ +using GsaAPI; +using OasysUnits; +using OasysUnits.Units; +using AccelerationUnit = OasysUnits.Units.AccelerationUnit; + +namespace GsaGH.Parameters.Results { + public class Footfall : IFootfall { + public Frequency CriticalFrequency { get; internal set; } + public int CriticalNode { get; internal set; } + public double MaximumResponseFactor { get; internal set; } + public Acceleration PeakAcceleration { get; internal set; } + public Speed PeakVelocity { get; internal set; } + public Acceleration RmsAcceleration { get; internal set; } + public Speed RmsVelocity { get; internal set; } + + internal Footfall(NodeFootfallResult result) { + CriticalFrequency = new Frequency(result.CriticalFrequency, FrequencyUnit.Hertz); + CriticalNode = result.CriticalNode; + MaximumResponseFactor = result.MaximumResponseFactor; + AccelerationUnit acceleration = AccelerationUnit.MeterPerSecondSquared; + PeakAcceleration = new Acceleration(result.PeakAcceleration, acceleration); + SpeedUnit speed = SpeedUnit.MeterPerSecond; + PeakVelocity = new Speed(result.PeakVelocity, speed); + RmsAcceleration = new Acceleration(result.RmsAcceleration, acceleration); + RmsVelocity = new Speed(result.RmsVelocity, speed); + } + } +} diff --git a/GsaGH/Parameters/5_Results/6_Quantities/IElement1dQuantity.cs b/GsaGH/Parameters/5_Results/6_Quantities/IElement1dQuantity.cs new file mode 100644 index 000000000..b3dfa57a0 --- /dev/null +++ b/GsaGH/Parameters/5_Results/6_Quantities/IElement1dQuantity.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using GsaAPI; + +namespace GsaGH.Parameters.Results { + public interface IElement1dQuantity where T : IResultItem { + IDictionary Results { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/6_Quantities/InternalForce.cs b/GsaGH/Parameters/5_Results/6_Quantities/InternalForce.cs new file mode 100644 index 000000000..90b62c942 --- /dev/null +++ b/GsaGH/Parameters/5_Results/6_Quantities/InternalForce.cs @@ -0,0 +1,28 @@ +using GsaAPI; +using OasysUnits; +using OasysUnits.Units; +using ForceUnit = OasysUnits.Units.ForceUnit; + +namespace GsaGH.Parameters.Results { + public class InternalForce : IInternalForce { + internal InternalForce(Double6 result) { + X = new Force(result.X, ForceUnit.Newton); + Y = new Force(result.Y, ForceUnit.Newton); + Z = new Force(result.Z, ForceUnit.Newton); + Xyz = QuantityUtility.PythagoreanTriple(Y, Z); + Xx = new Moment(result.XX, MomentUnit.NewtonMeter); + Yy = new Moment(result.YY, MomentUnit.NewtonMeter); + Zz = new Moment(result.ZZ, MomentUnit.NewtonMeter); + Xxyyzz = QuantityUtility.PythagoreanTriple(Yy, Zz); + } + + public Force X { get; internal set; } + public Force Y { get; internal set; } + public Force Z { get; internal set; } + public Force Xyz { get; internal set; } + public Moment Xx { get; internal set; } + public Moment Yy { get; internal set; } + public Moment Zz { get; internal set; } + public Moment Xxyyzz { get; internal set; } + } +} diff --git a/GsaGH/Parameters/5_Results/6_Quantities/QuantityUtility.cs b/GsaGH/Parameters/5_Results/6_Quantities/QuantityUtility.cs new file mode 100644 index 000000000..849cecc04 --- /dev/null +++ b/GsaGH/Parameters/5_Results/6_Quantities/QuantityUtility.cs @@ -0,0 +1,33 @@ +using OasysUnits; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +namespace GsaGH.Parameters.Results { + public static class QuantityUtility { + internal static T PythagoreanQuadruple(T x, T y, T z) where T : IQuantity { + double a = x.Value; + double b = y.Value; + double c = z.Value; + double pythagoras = Pythagoras(new List { a, b, c }); + return (T)Quantity.From(pythagoras, x.Unit); + } + + internal static T PythagoreanTriple(T x, T y) where T : IQuantity { + double a = x.Value; + double b = y.Value; + double pythagoras = Pythagoras(new List { a, b }); + return (T)Quantity.From(pythagoras, x.Unit); + } + + private static double Pythagoras(List doubles) { + double sum = 0; + foreach (double val in doubles) { + sum += val * val; + } + + return Math.Sqrt(sum); + } + } +} diff --git a/GsaGH/Parameters/5_Results/6_Quantities/ReactionForce.cs b/GsaGH/Parameters/5_Results/6_Quantities/ReactionForce.cs new file mode 100644 index 000000000..09bc89dd4 --- /dev/null +++ b/GsaGH/Parameters/5_Results/6_Quantities/ReactionForce.cs @@ -0,0 +1,28 @@ +using GsaAPI; +using OasysUnits; +using OasysUnits.Units; +using ForceUnit = OasysUnits.Units.ForceUnit; + +namespace GsaGH.Parameters.Results { + public class ReactionForce : IInternalForce { + internal ReactionForce(Double6 result) { + X = new Force(result.X, ForceUnit.Newton); + Y = new Force(result.Y, ForceUnit.Newton); + Z = new Force(result.Z, ForceUnit.Newton); + Xyz = QuantityUtility.PythagoreanQuadruple(X, Y, Z); + Xx = new Moment(result.XX, MomentUnit.NewtonMeter); + Yy = new Moment(result.YY, MomentUnit.NewtonMeter); + Zz = new Moment(result.ZZ, MomentUnit.NewtonMeter); + Xxyyzz = QuantityUtility.PythagoreanQuadruple(Xx, Yy, Zz); + } + + public Force X { get; internal set; } + public Force Y { get; internal set; } + public Force Z { get; internal set; } + public Force Xyz { get; internal set; } + public Moment Xx { get; internal set; } + public Moment Yy { get; internal set; } + public Moment Zz { get; internal set; } + public Moment Xxyyzz { get; internal set; } + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IDisplacement.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IDisplacement.cs new file mode 100644 index 000000000..7d5e47737 --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IDisplacement.cs @@ -0,0 +1,6 @@ +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public interface IDisplacement : IResultVector6, IResultItem { + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IElement1dDisplacement.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IElement1dDisplacement.cs new file mode 100644 index 000000000..c1e15edd3 --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IElement1dDisplacement.cs @@ -0,0 +1,4 @@ +namespace GsaGH.Parameters.Results { + public interface IElement1dInternalForce : IElement1dQuantity { + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IElement1dInternalForce.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IElement1dInternalForce.cs new file mode 100644 index 000000000..81707f598 --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IElement1dInternalForce.cs @@ -0,0 +1,4 @@ +namespace GsaGH.Parameters.Results { + public interface IElement1dDisplacement : IElement1dQuantity { + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IFootfall.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IFootfall.cs new file mode 100644 index 000000000..766e22067 --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IFootfall.cs @@ -0,0 +1,13 @@ +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public interface IFootfall : IResultItem { + Frequency CriticalFrequency { get; } + int CriticalNode { get; } + double MaximumResponseFactor { get; } + Acceleration PeakAcceleration { get; } + Speed PeakVelocity { get; } + Acceleration RmsAcceleration { get; } + Speed RmsVelocity { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IForce2d.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IForce2d.cs new file mode 100644 index 000000000..8a23eea5f --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IForce2d.cs @@ -0,0 +1,6 @@ +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public interface IForce2d : IResultTensor3InAxis, IResultItem { + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IGlobalMass.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IGlobalMass.cs new file mode 100644 index 000000000..675a466fd --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IGlobalMass.cs @@ -0,0 +1,6 @@ +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public interface IGlobalMass : IResultVector3InAxis, IResultItem { + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IInternalForce.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IInternalForce.cs new file mode 100644 index 000000000..9361a4360 --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IInternalForce.cs @@ -0,0 +1,6 @@ +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public interface IInternalForce : IResultVector6, IResultItem { + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IMoment2d.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IMoment2d.cs new file mode 100644 index 000000000..aef730588 --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IMoment2d.cs @@ -0,0 +1,6 @@ +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public interface IMoment2d : IResultTensor3AboutAxis, IResultItem { + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IResultItem.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IResultItem.cs new file mode 100644 index 000000000..949704af5 --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IResultItem.cs @@ -0,0 +1,4 @@ +namespace GsaGH.Parameters.Results { + public interface IResultItem { + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IShear2d.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IShear2d.cs new file mode 100644 index 000000000..3b453c9b5 --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IShear2d.cs @@ -0,0 +1,6 @@ +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public interface IShear2d : IResultVector2, IResultItem { + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IStress2d.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IStress2d.cs new file mode 100644 index 000000000..49dcbd141 --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/IStress2d.cs @@ -0,0 +1,6 @@ +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public interface IStress2d : IResultTensor3, IResultItem { + } +} diff --git a/GsaGH/Parameters/5_Results/7_QuantityInterfaces/ITranslation.cs b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/ITranslation.cs new file mode 100644 index 000000000..748276bb2 --- /dev/null +++ b/GsaGH/Parameters/5_Results/7_QuantityInterfaces/ITranslation.cs @@ -0,0 +1,6 @@ +using OasysUnits; + +namespace GsaGH.Parameters.Results { + public interface ITranslation : IResultVector3InAxis, IResultItem { + } +} diff --git a/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultSingle.cs b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultSingle.cs new file mode 100644 index 000000000..6fdd6a25c --- /dev/null +++ b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultSingle.cs @@ -0,0 +1,5 @@ +namespace GsaGH.Parameters.Results { + public interface IResultSingle { + T Item { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor2AroundAxis.cs b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor2AroundAxis.cs new file mode 100644 index 000000000..82c6db8e8 --- /dev/null +++ b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor2AroundAxis.cs @@ -0,0 +1,9 @@ +namespace GsaGH.Parameters.Results { + public interface IResultTensor2AroundAxis { + T Mx { get; } + T My { get; } + T Mxy { get; } + T WoodArmerX { get; } + T WoodArmerY { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor2InAxis.cs b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor2InAxis.cs new file mode 100644 index 000000000..9628fb46d --- /dev/null +++ b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor2InAxis.cs @@ -0,0 +1,7 @@ +namespace GsaGH.Parameters.Results { + public interface IResultTensor2InAxis { + T Nx { get; } + T Ny { get; } + T Nxy { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor3.cs b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor3.cs new file mode 100644 index 000000000..67d5fb9ac --- /dev/null +++ b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor3.cs @@ -0,0 +1,10 @@ +namespace GsaGH.Parameters.Results { + public interface IResultTensor3 { + T Xx { get; } + T Yy { get; } + T Zz { get; } + T Xy { get; } + T Yz { get; } + T Zx { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor3AboutAxis.cs b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor3AboutAxis.cs new file mode 100644 index 000000000..a1dbbd0d6 --- /dev/null +++ b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor3AboutAxis.cs @@ -0,0 +1,7 @@ +namespace GsaGH.Parameters.Results { + public interface IResultTensor3AboutAxis { + T Xx { get; } + T Yy { get; } + T Zz { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor3InAxis.cs b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor3InAxis.cs new file mode 100644 index 000000000..e5f0fb1b5 --- /dev/null +++ b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultTensor3InAxis.cs @@ -0,0 +1,7 @@ +namespace GsaGH.Parameters.Results { + public interface IResultTensor3InAxis { + T Xy { get; } + T Yz { get; } + T Zx { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector2.cs b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector2.cs new file mode 100644 index 000000000..d5883e8ba --- /dev/null +++ b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector2.cs @@ -0,0 +1,6 @@ +namespace GsaGH.Parameters.Results { + public interface IResultVector2 { + T Vx { get; } + T Vy { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector3AboutAxis.cs b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector3AboutAxis.cs new file mode 100644 index 000000000..133a17717 --- /dev/null +++ b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector3AboutAxis.cs @@ -0,0 +1,8 @@ +namespace GsaGH.Parameters.Results { + public interface IResultVector3AboutAxis { + T Xx { get; } + T Yy { get; } + T Zz { get; } + T Xxyyzz { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector3InAxis.cs b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector3InAxis.cs new file mode 100644 index 000000000..8058b7151 --- /dev/null +++ b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector3InAxis.cs @@ -0,0 +1,8 @@ +namespace GsaGH.Parameters.Results { + public interface IResultVector3InAxis { + T X { get; } + T Y { get; } + T Z { get; } + T Xyz { get; } + } +} diff --git a/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector6.cs b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector6.cs new file mode 100644 index 000000000..5017e1442 --- /dev/null +++ b/GsaGH/Parameters/5_Results/8_ResultInterfaces/IResultVector6.cs @@ -0,0 +1,4 @@ +namespace GsaGH.Parameters.Results { + public interface IResultVector6 : IResultVector3InAxis, IResultVector3AboutAxis { + } +} diff --git a/GsaGH/Parameters/5_Results/GsaResult.cs b/GsaGH/Parameters/5_Results/GsaResult.cs index bb4582c22..e863f949e 100644 --- a/GsaGH/Parameters/5_Results/GsaResult.cs +++ b/GsaGH/Parameters/5_Results/GsaResult.cs @@ -7,6 +7,7 @@ using GsaAPI; using GsaGH.Helpers; using GsaGH.Helpers.GsaApi; +using GsaGH.Parameters.Results; using OasysUnits.Units; using Rhino.Geometry; using EnergyUnit = OasysUnits.Units.EnergyUnit; @@ -26,7 +27,7 @@ namespace GsaGH.Parameters { /// /// All result values from the .NET API has been wrapped in Unit Number and can be converted into different measures on the fly. The Result parameter caches the result values /// - public class GsaResult { + public class GsaResult : IGsaResult { /// /// Analysis Case 1DElement Displacement Result VALUES Dictionary /// Append to this dictionary to chache results @@ -167,8 +168,8 @@ internal Dictionary, GsaResultsValues> /// Analysis Case API Result /// internal AnalysisCaseResult AnalysisCaseResult { get; set; } - internal int CaseId { get; set; } - internal string CaseName { get; set; } + public int CaseId { get; set; } + public string CaseName { get; set; } /// /// Combination Case API Result /// @@ -323,19 +324,19 @@ internal Dictionary> internal Dictionary>> ComboNodeResults { get; set; } = new Dictionary>>(); - internal GsaModel Model { get; set; } + public GsaModel Model { get; set; } /// /// User set permutation ID. If -1 => return all. /// - internal List SelectedPermutationIds { get; set; } - internal CaseType Type { get; set; } + public List SelectedPermutationIds { get; set; } + public CaseType CaseType { get; set; } public GsaResult() { } internal GsaResult(GsaModel model, AnalysisCaseResult result, int caseId) { Model = model; AnalysisCaseResult = result; - Type = CaseType.AnalysisCase; + CaseType = CaseType.AnalysisCase; CaseId = caseId; CaseName = model.Model.AnalysisCaseName(CaseId); } @@ -344,7 +345,7 @@ internal GsaResult( GsaModel model, CombinationCaseResult result, int caseId, IEnumerable permutations) { Model = model; CombinationCaseResult = result; - Type = CaseType.CombinationCase; + CaseType = CaseType.CombinationCase; CaseId = caseId; SelectedPermutationIds = permutations.OrderBy(x => x).ToList(); } @@ -355,7 +356,7 @@ public GsaResult Duplicate() { public override string ToString() { string txt = string.Empty; - switch (Type) { + switch (CaseType) { case CaseType.AnalysisCase: txt = "A" + CaseId; break; @@ -390,7 +391,7 @@ internal List Element1DAverageStrainEnergyDensityValues( } var key = new Tuple(elementlist, 1, axisId); - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseElement1DStrainEnergyDensityValues.ContainsKey(key)) { if (!ACaseElement1DResults.ContainsKey(key)) { ACaseElement1DResults.Add(key, AnalysisCaseResult.Element1DResults(elementlist, 1)); @@ -439,7 +440,7 @@ internal List Element1DDisplacementValues( Plane global = Plane.WorldXY; var key = new Tuple(elementlist, positionsCount, axisId); - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseElement1DDisplacementValues.ContainsKey(key)) { if (!ACaseElement1DResults.ContainsKey(key)) { ACaseElement1DResults.Add(key, @@ -488,7 +489,7 @@ internal List Element1DFootfallValues( } var key = new Tuple(elementlist, type); - if (Type != CaseType.AnalysisCase) { + if (CaseType != CaseType.AnalysisCase) { throw new Exception("Cannot get Footfall results for a Combination Case."); } @@ -522,7 +523,7 @@ internal List Element1DForceValues( } var key = new Tuple(elementlist, positionsCount, axisId); - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseElement1DForceValues.ContainsKey(key)) { if (!ACaseElement1DResults.ContainsKey(key)) { ACaseElement1DResults.Add(key, @@ -570,7 +571,7 @@ internal List Element1DStrainEnergyDensityValues( } var key = new Tuple(elementlist, positionsCount, axisId); - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseElement1DStrainEnergyDensityValues.ContainsKey(key)) { if (!ACaseElement1DResults.ContainsKey(key)) { ACaseElement1DResults.Add(key, @@ -616,7 +617,7 @@ internal List Element2DDisplacementValues( elementlist = "All"; } - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseElement2DDisplacementValues.ContainsKey(elementlist)) { if (!ACaseElement2DResults.ContainsKey(new Tuple(elementlist, 0))) { ACaseElement2DResults.Add(new Tuple(elementlist, 0), @@ -665,7 +666,7 @@ internal List Element2DFootfallValues( } var key = new Tuple(elementlist, type); - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseElement2DFootfallValues.ContainsKey(key)) { GsaResultsValues nodeFootfallResultValues = NodeFootfallValues("All", type); ACaseElement2DFootfallValues.Add(key, @@ -696,7 +697,7 @@ internal List Element2DForceValues( elementlist = "All"; } - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseElement2DForceValues.ContainsKey(elementlist)) { if (!ACaseElement2DResults.ContainsKey(new Tuple(elementlist, 0))) { ACaseElement2DResults.Add(new Tuple(elementlist, 0), @@ -746,7 +747,7 @@ internal List Element2DShearValues( elementlist = "All"; } - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseElement2DShearValues.ContainsKey(elementlist)) { if (!ACaseElement2DResults.ContainsKey(new Tuple(elementlist, 0))) { ACaseElement2DResults.Add(new Tuple(elementlist, 0), @@ -796,7 +797,7 @@ internal List Element2DStressValues( } var key = new Tuple(elementlist, layer); - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseElement2DStressValues.ContainsKey(key)) { if (!ACaseElement2DResults.ContainsKey(key)) { ACaseElement2DResults.Add(key, AnalysisCaseResult.Element2DResults(elementlist, layer)); @@ -840,7 +841,7 @@ internal List Element3DDisplacementValues( elementlist = "All"; } - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseElement3DDisplacementValues.ContainsKey(elementlist)) { if (!ACaseElement3DResults.ContainsKey(elementlist)) { ACaseElement3DResults.Add(elementlist, @@ -885,7 +886,7 @@ internal List Element3DStressValues( elementlist = "All"; } - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseElement3DStressValues.ContainsKey(elementlist)) { if (!ACaseElement3DResults.ContainsKey(elementlist)) { ACaseElement3DResults.Add(elementlist, @@ -930,7 +931,7 @@ internal List NodeDisplacementValues( nodelist = "All"; } - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseNodeDisplacementValues.ContainsKey(nodelist)) { if (!ACaseNodeResults.ContainsKey(nodelist)) { ACaseNodeResults.Add(nodelist, AnalysisCaseResult.NodeResults(nodelist)); @@ -971,7 +972,7 @@ internal GsaResultsValues NodeFootfallValues(string nodelist, FootfallResultType nodelist = "All"; } - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { var key = new Tuple(nodelist, type); if (!ACaseNodeFootfallValues.ContainsKey(key)) { ACaseNodeFootfallValues.Add(key, @@ -1012,7 +1013,7 @@ internal List NodeReactionForceValues( nodelist = "All"; } - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseNodeReactionForceValues.ContainsKey(nodelist)) { if (!ACaseNodeResults.ContainsKey(nodelist)) { ACaseNodeResults.Add(nodelist, AnalysisCaseResult.NodeResults(nodelist)); @@ -1069,7 +1070,7 @@ internal List SpringReactionForceValues( nodelist = "All"; } - if (Type == CaseType.AnalysisCase) { + if (CaseType == CaseType.AnalysisCase) { if (!ACaseNodeReactionForceValues.ContainsKey(nodelist)) { if (!ACaseNodeResults.ContainsKey(nodelist)) { ACaseNodeResults.Add(nodelist, AnalysisCaseResult.NodeResults(nodelist)); @@ -1098,4 +1099,4 @@ internal List SpringReactionForceValues( return ComboNodeReactionForceValues[nodelist].Values.ToList(); } } -} +} \ No newline at end of file diff --git a/GsaGH/Parameters/5_Results/GsaResultGoo.cs b/GsaGH/Parameters/5_Results/GsaResultGoo.cs index 18af62690..7b644aa0d 100644 --- a/GsaGH/Parameters/5_Results/GsaResultGoo.cs +++ b/GsaGH/Parameters/5_Results/GsaResultGoo.cs @@ -1,4 +1,5 @@ using Grasshopper.Kernel.Types; +using GsaGH.Parameters.Results; using OasysGH; using OasysGH.Parameters; @@ -6,13 +7,13 @@ namespace GsaGH.Parameters { /// /// Goo wrapper class, makes sure can be used in Grasshopper. /// - public class GsaResultGoo : GH_OasysGoo { + public class GsaResultGoo : GH_OasysGoo { public static string Description => "GSA Result"; public static string Name => "Result"; public static string NickName => "Res"; public override OasysPluginInfo PluginInfo => GsaGH.PluginInfo.Instance; - public GsaResultGoo(GsaResult item) : base(item) { } + public GsaResultGoo(IGsaResult item) : base(item) { } public override bool CastTo(ref TQ target) { if (typeof(TQ).IsAssignableFrom(typeof(GH_Integer))) { diff --git a/GsaGH/Parameters/5_Results/GsaResultQuantity.cs b/GsaGH/Parameters/5_Results/GsaResultQuantity.cs index b9e62f508..e444125cc 100644 --- a/GsaGH/Parameters/5_Results/GsaResultQuantity.cs +++ b/GsaGH/Parameters/5_Results/GsaResultQuantity.cs @@ -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; } diff --git a/GsaGH/Parameters/5_Results/GsaResultsValues.cs b/GsaGH/Parameters/5_Results/GsaResultsValues.cs index a4a9c4454..40bed91f5 100644 --- a/GsaGH/Parameters/5_Results/GsaResultsValues.cs +++ b/GsaGH/Parameters/5_Results/GsaResultsValues.cs @@ -1,17 +1,19 @@ -using System; +using GsaAPI; +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{ + public enum ResultType { Displacement, Force, Stress, @@ -19,25 +21,24 @@ internal enum ResultType { 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 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 Ids => XyzResults.Keys.OrderBy(x => x).ToList(); internal ConcurrentDictionary> XxyyzzResults { get; set; } @@ -49,6 +50,9 @@ internal ConcurrentDictionary> internal ConcurrentDictionary> XyzResults { get; set; } = new ConcurrentDictionary>(); + internal ConcurrentDictionary> + XyyyzzResults { get; set; } + = new ConcurrentDictionary>(); internal GsaResultsValues() { } @@ -170,4 +174,4 @@ internal void UpdateMinMax() { } } } -} +} \ No newline at end of file diff --git a/GsaGH/Parameters/Enums/CaseType.cs b/GsaGH/Parameters/Enums/CaseType.cs index 389b09719..2ed3a56e1 100644 --- a/GsaGH/Parameters/Enums/CaseType.cs +++ b/GsaGH/Parameters/Enums/CaseType.cs @@ -4,4 +4,4 @@ public enum CaseType { AnalysisCase, CombinationCase } -} +} \ No newline at end of file diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/Element1dDisplacementsTests.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/Element1dDisplacementsTests.cs new file mode 100644 index 000000000..2d3c638da --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/Element1dDisplacementsTests.cs @@ -0,0 +1,286 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using GsaGH.Helpers.Import; +using GsaGH.Parameters.Results; +using GsaGHTests.Helper; +using Xunit; + +namespace GsaGHTests.Parameters.Results { + [Collection("GrasshopperFixture collection")] + public class Element1dDisplacementsTests { + + private static readonly string ElementList = "24 to 30"; + + [Fact] + public void Element1dDisplacementsElement1dIdsFromAnalysisCaseTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dDisplacements.ResultSubset(elementIds, 1); + + // Assert element IDs + var expectedIds = result.Model.Model.Elements(ElementList).Keys.OrderBy(x => x).ToList(); + Assert.Equal(expectedIds, resultSet.Ids); + } + + [Fact] + public void Element1dDisplacementsElement1dIdsFromCombinationCaseTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dDisplacements.ResultSubset(elementIds, 1); + + // Assert element IDs + var expectedIds = result.Model.Model.Elements(ElementList).Keys.OrderBy(x => x).ToList(); + Assert.Equal(expectedIds, resultSet.Ids); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dDisplacementsMaxFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + double expected = ExpectedAnalysisCaseValues(component).Max(); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dDisplacements.ResultSubset(elementIds, 4); + + // Assert Max in set + double max = TestsResultHelper.ResultsHelper(resultSet, component, true); + Assert.Equal(expected, max); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dDisplacementsMaxFromCombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + double expected = Math.Max(ExpectedCombinationCaseC4p1Values(component).Max(), + ExpectedCombinationCaseC4p2Values(component).Max()); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dDisplacements.ResultSubset(elementIds, 4); + + // Assert Max in set + double max = TestsResultHelper.ResultsHelper(resultSet, component, true); + Assert.Equal(expected, max); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dDisplacementsMinFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + double expected = ExpectedAnalysisCaseValues(component).Min(); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dDisplacements.ResultSubset(elementIds, 4); + + // Assert Max in set + double min = TestsResultHelper.ResultsHelper(resultSet, component, false); + Assert.Equal(expected, min); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dDisplacementsMinFromcombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + double expected = Math.Min(ExpectedCombinationCaseC4p1Values(component).Min(), + ExpectedCombinationCaseC4p2Values(component).Min()); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dDisplacements.ResultSubset(elementIds, 4); + + // Assert Max in set + double min = TestsResultHelper.ResultsHelper(resultSet, component, false); + Assert.Equal(expected, min); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dDisplacementsValuesFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + List expected = ExpectedAnalysisCaseValues(component); + int positionsCount = 4; + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dDisplacements.ResultSubset(elementIds, positionsCount); + + // Assert result values + int i = 0; + foreach (int id in resultSet.Ids) { + Collection displacementQuantity = resultSet.Subset[id]; + + // for analysis case results we expect 4 positions + Assert.Single(displacementQuantity); + var positions = Enumerable.Range(0, positionsCount).Select( + k => (double)k / (positionsCount - 1)).ToList(); + foreach (double position in positions) { + double x = TestsResultHelper.ResultsHelper(displacementQuantity[0].Results[position], component); + Assert.Equal(expected[i++], x); + } + } + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dDisplacementsValuesFromCombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + List expectedP1 = ExpectedCombinationCaseC4p1Values(component); + List expectedP2 = ExpectedCombinationCaseC4p2Values(component); + int positionsCount = 4; + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dDisplacements.ResultSubset(elementIds, positionsCount); + + // Assert result values + int i = 0; + foreach (int id in resultSet.Ids) { + Collection displacementQuantity = resultSet.Subset[id]; + + // for C4 case results we expect two permutations in the collection + Assert.Equal(2, displacementQuantity.Count); + + var positions = Enumerable.Range(0, positionsCount).Select( + k => (double)k / (positionsCount - 1)).ToList(); + foreach (double position in positions) { + double perm1 = TestsResultHelper.ResultsHelper(displacementQuantity[0].Results[position], component); + Assert.Equal(expectedP1[i], perm1); + double perm2 = TestsResultHelper.ResultsHelper(displacementQuantity[1].Results[position], component); + Assert.Equal(expectedP2[i++], perm2); + } + } + } + + private List ExpectedAnalysisCaseValues(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return Element1dDisplacementsA1.XInMillimeter(); + + case ResultVector6HelperEnum.Y: return Element1dDisplacementsA1.YInMillimeter(); + + case ResultVector6HelperEnum.Z: return Element1dDisplacementsA1.ZInMillimeter(); + + case ResultVector6HelperEnum.Xyz: return Element1dDisplacementsA1.XyzInMillimeter(); + + case ResultVector6HelperEnum.Xx: return Element1dDisplacementsA1.XxInRadian(); + + case ResultVector6HelperEnum.Yy: return Element1dDisplacementsA1.YyInRadian(); + + case ResultVector6HelperEnum.Zz: return Element1dDisplacementsA1.ZzInRadian(); + + case ResultVector6HelperEnum.Xxyyzz: return Element1dDisplacementsA1.XxyyzzInRadian(); + } + + throw new NotImplementedException(); + } + + private List ExpectedCombinationCaseC4p1Values(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return Element1dDisplacementsC4p1.XInMillimeter(); + + case ResultVector6HelperEnum.Y: return Element1dDisplacementsC4p1.YInMillimeter(); + + case ResultVector6HelperEnum.Z: return Element1dDisplacementsC4p1.ZInMillimeter(); + + case ResultVector6HelperEnum.Xyz: return Element1dDisplacementsC4p1.XyzInMillimeter(); + + case ResultVector6HelperEnum.Xx: return Element1dDisplacementsC4p1.XxInRadian(); + + case ResultVector6HelperEnum.Yy: return Element1dDisplacementsC4p1.YyInRadian(); + + case ResultVector6HelperEnum.Zz: return Element1dDisplacementsC4p1.ZzInRadian(); + + case ResultVector6HelperEnum.Xxyyzz: return Element1dDisplacementsC4p1.XxyyzzInRadian(); + } + + throw new NotImplementedException(); + } + + private List ExpectedCombinationCaseC4p2Values(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return Element1dDisplacementsC4p2.XInMillimeter(); + + case ResultVector6HelperEnum.Y: return Element1dDisplacementsC4p2.YInMillimeter(); + + case ResultVector6HelperEnum.Z: return Element1dDisplacementsC4p2.ZInMillimeter(); + + case ResultVector6HelperEnum.Xyz: return Element1dDisplacementsC4p2.XyzInMillimeter(); + + case ResultVector6HelperEnum.Xx: return Element1dDisplacementsC4p2.XxInRadian(); + + case ResultVector6HelperEnum.Yy: return Element1dDisplacementsC4p2.YyInRadian(); + + case ResultVector6HelperEnum.Zz: return Element1dDisplacementsC4p2.ZzInRadian(); + + case ResultVector6HelperEnum.Xxyyzz: return Element1dDisplacementsC4p2.XxyyzzInRadian(); + } + + throw new NotImplementedException(); + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/Element1dInternalForcesTests.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/Element1dInternalForcesTests.cs new file mode 100644 index 000000000..5ee10a0a9 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/Element1dInternalForcesTests.cs @@ -0,0 +1,286 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using GsaGH.Helpers.Import; +using GsaGH.Parameters.Results; +using GsaGHTests.Helper; +using Xunit; + +namespace GsaGHTests.Parameters.Results { + [Collection("GrasshopperFixture collection")] + public class Element1dInternalForcesTests { + + private static readonly string ElementList = "2 to 6"; + + [Fact] + public void Element1dInternalForcesElement1dIdsFromAnalysisCaseTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dInternalForces.ResultSubset(elementIds, 1); + + // Assert element IDs + var expectedIds = result.Model.Model.Elements(ElementList).Keys.OrderBy(x => x).ToList(); + Assert.Equal(expectedIds, resultSet.Ids); + } + + [Fact] + public void Element1dInternalForcesElement1dIdsFromCombinationCaseTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dInternalForces.ResultSubset(elementIds, 1); + + // Assert element IDs + var expectedIds = result.Model.Model.Elements(ElementList).Keys.OrderBy(x => x).ToList(); + Assert.Equal(expectedIds, resultSet.Ids); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dInternalForcesMaxFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + double expected = ExpectedAnalysisCaseValues(component).Max(); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dInternalForces.ResultSubset(elementIds, 5); + + // Assert Max in set + double max = TestsResultHelper.ResultsHelper(resultSet, component, true); + Assert.Equal(expected, max); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dInternalForcesMaxFromCombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + double expected = Math.Max(ExpectedCombinationCaseC4p1Values(component).Max(), + ExpectedCombinationCaseC4p2Values(component).Max()); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dInternalForces.ResultSubset(elementIds, 5); + + // Assert Max in set + double max = TestsResultHelper.ResultsHelper(resultSet, component, true); + Assert.Equal(expected, max); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dInternalForcesMinFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + double expected = ExpectedAnalysisCaseValues(component).Min(); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dInternalForces.ResultSubset(elementIds, 5); + + // Assert Max in set + double min = TestsResultHelper.ResultsHelper(resultSet, component, false); + Assert.Equal(expected, min); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dInternalForcesMinFromcombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + double expected = Math.Min(ExpectedCombinationCaseC4p1Values(component).Min(), + ExpectedCombinationCaseC4p2Values(component).Min()); + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dInternalForces.ResultSubset(elementIds, 5); + + // Assert Max in set + double min = TestsResultHelper.ResultsHelper(resultSet, component, false); + Assert.Equal(expected, min); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dInternalForcesValuesFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + List expected = ExpectedAnalysisCaseValues(component); + int positionsCount = 5; + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dInternalForces.ResultSubset(elementIds, positionsCount); + + // Assert result values + int i = 0; + foreach (int id in resultSet.Ids) { + Collection displacementQuantity = resultSet.Subset[id]; + + // for analysis case results we expect 4 positions + Assert.Single(displacementQuantity); + var positions = Enumerable.Range(0, positionsCount).Select( + k => (double)k / (positionsCount - 1)).ToList(); + foreach (double position in positions) { + double x = TestsResultHelper.ResultsHelper(displacementQuantity[0].Results[position], component); + Assert.Equal(expected[i++], x); + } + } + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void Element1dInternalForcesValuesFromCombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + List expectedP1 = ExpectedCombinationCaseC4p1Values(component); + List expectedP2 = ExpectedCombinationCaseC4p2Values(component); + int positionsCount = 5; + + // Act + ReadOnlyCollection elementIds = result.ElementIds(ElementList); + IElement1dResultSubset> resultSet + = result.Element1dInternalForces.ResultSubset(elementIds, positionsCount); + + // Assert result values + int i = 0; + foreach (int id in resultSet.Ids) { + Collection displacementQuantity = resultSet.Subset[id]; + + // for C4 case results we expect two permutations in the collection + Assert.Equal(2, displacementQuantity.Count); + + var positions = Enumerable.Range(0, positionsCount).Select( + k => (double)k / (positionsCount - 1)).ToList(); + foreach (double position in positions) { + double perm1 = TestsResultHelper.ResultsHelper(displacementQuantity[0].Results[position], component); + Assert.Equal(expectedP1[i], perm1); + double perm2 = TestsResultHelper.ResultsHelper(displacementQuantity[1].Results[position], component); + Assert.Equal(expectedP2[i++], perm2); + } + } + } + + private List ExpectedAnalysisCaseValues(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return Element1dForcesAndMomentsA1.XInKiloNewton(); + + case ResultVector6HelperEnum.Y: return Element1dForcesAndMomentsA1.YInKiloNewton(); + + case ResultVector6HelperEnum.Z: return Element1dForcesAndMomentsA1.ZInKiloNewton(); + + case ResultVector6HelperEnum.Xyz: return Element1dForcesAndMomentsA1.XyzInKiloNewton(); + + case ResultVector6HelperEnum.Xx: return Element1dForcesAndMomentsA1.XxInKiloNewtonMeter(); + + case ResultVector6HelperEnum.Yy: return Element1dForcesAndMomentsA1.YyInKiloNewtonMeter(); + + case ResultVector6HelperEnum.Zz: return Element1dForcesAndMomentsA1.ZzInKiloNewtonMeter(); + + case ResultVector6HelperEnum.Xxyyzz: return Element1dForcesAndMomentsA1.XxyyzzInKiloNewtonMeter(); + } + + throw new NotImplementedException(); + } + + private List ExpectedCombinationCaseC4p1Values(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return Element1dForcesAndMomentsC4p1.XInKiloNewton(); + + case ResultVector6HelperEnum.Y: return Element1dForcesAndMomentsC4p1.YInKiloNewton(); + + case ResultVector6HelperEnum.Z: return Element1dForcesAndMomentsC4p1.ZInKiloNewton(); + + case ResultVector6HelperEnum.Xyz: return Element1dForcesAndMomentsC4p1.XyzInKiloNewton(); + + case ResultVector6HelperEnum.Xx: return Element1dForcesAndMomentsC4p1.XxInKiloNewtonMeter(); + + case ResultVector6HelperEnum.Yy: return Element1dForcesAndMomentsC4p1.YyInKiloNewtonMeter(); + + case ResultVector6HelperEnum.Zz: return Element1dForcesAndMomentsC4p1.ZzInKiloNewtonMeter(); + + case ResultVector6HelperEnum.Xxyyzz: return Element1dForcesAndMomentsC4p1.XxyyzzInKiloNewtonMeter(); + } + + throw new NotImplementedException(); + } + + private List ExpectedCombinationCaseC4p2Values(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return Element1dForcesAndMomentsC4p2.XInKiloNewton(); + + case ResultVector6HelperEnum.Y: return Element1dForcesAndMomentsC4p2.YInKiloNewton(); + + case ResultVector6HelperEnum.Z: return Element1dForcesAndMomentsC4p2.ZInKiloNewton(); + + case ResultVector6HelperEnum.Xyz: return Element1dForcesAndMomentsC4p2.XyzInKiloNewton(); + + case ResultVector6HelperEnum.Xx: return Element1dForcesAndMomentsC4p2.XxInKiloNewtonMeter(); + + case ResultVector6HelperEnum.Yy: return Element1dForcesAndMomentsC4p2.YyInKiloNewtonMeter(); + + case ResultVector6HelperEnum.Zz: return Element1dForcesAndMomentsC4p2.ZzInKiloNewtonMeter(); + + case ResultVector6HelperEnum.Xxyyzz: return Element1dForcesAndMomentsC4p2.XxyyzzInKiloNewtonMeter(); + } + + throw new NotImplementedException(); + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/Element1dResultSubsetTests.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/Element1dResultSubsetTests.cs new file mode 100644 index 000000000..ad070917d --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/Element1dResultSubsetTests.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using GsaGH.Helpers.Import; +using GsaGH.Parameters.Results; +using GsaGHTests.Helper; +using Xunit; + +namespace GsaGHTests.Parameters.Results { + [Collection("GrasshopperFixture collection")] + public class Element1dResultSubsetTests { + + [Fact] + public void GetMissingKeysTests() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + + // Act + ReadOnlyCollection elementIds = result.ElementIds("1"); + IElement1dResultSubset> resultSet + = result.Element1dDisplacements.ResultSubset(elementIds, 1); + + // Assert + var positions = new ReadOnlyCollection(new Collection() { 0.0, 1.0 }); + var newKeys = new Collection() { 2 }; + ConcurrentBag missingIds = result.Element1dDisplacements.Cache. + GetMissingKeysAndPositions(newKeys, positions); + Assert.Single(missingIds); + Assert.Equal(newKeys[0], missingIds.First()); + } + + [Fact] + public void GetMissingKeysAndPositionsTests() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + + // Act + ReadOnlyCollection elementIds = result.ElementIds("1"); + IElement1dResultSubset> resultSet + = result.Element1dDisplacements.ResultSubset(elementIds, 1); + + // Assert + var positions = new ReadOnlyCollection(new Collection() { 0.0, 1.0 }); + var newKeys = new Collection() { 1 }; + ConcurrentBag missingIds = result.Element1dDisplacements.Cache. + GetMissingKeysAndPositions(newKeys, positions); + Assert.Single(missingIds); + Assert.Equal(newKeys[0], missingIds.First()); + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/GsaResult2Tests.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/GsaResult2Tests.cs new file mode 100644 index 000000000..a370f7698 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/GsaResult2Tests.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using GsaAPI; +using GsaGH.Parameters; +using GsaGH.Parameters.Results; +using Xunit; + +namespace GsaGHTests.Parameters.Results { + [Collection("GrasshopperFixture collection")] + public partial class GsaResult2Tests { + public static IGsaResult AnalysisCaseResult(string file, int caseId) { + var apiModel = new GsaAPI.Model(file); + var model = new GsaModel(apiModel); + ReadOnlyDictionary analysisCaseResults = model.Model.Results(); + return new GsaResult2(model, analysisCaseResults[caseId], caseId); + } + + public static IGsaResult CombinationCaseResult(string file, int caseId, IEnumerable permutations = null) { + var apiModel = new GsaAPI.Model(file); + var model = new GsaModel(apiModel); + ReadOnlyDictionary combinationCaseResults = model.Model.CombinationCaseResults(); + if (permutations == null) { + permutations = new List() { 1, 2 }; + } + + return new GsaResult2(model, combinationCaseResults[caseId], caseId, permutations); + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeDisplacementsTests.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeDisplacementsTests.cs new file mode 100644 index 000000000..5ba9b2b81 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeDisplacementsTests.cs @@ -0,0 +1,276 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using GsaGH.Parameters.Results; +using GsaGHTests.Helper; +using Xunit; + +namespace GsaGHTests.Parameters.Results { + [Collection("GrasshopperFixture collection")] + public class NodeDisplacementsTests { + + private static readonly string NodeList = "442 to 468"; + + [Fact] + public void NodeDisplacementsNodeIdsFromAnalysisCaseTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeDisplacements.ResultSubset(nodeIds); + + // Assert node IDs + var expectedIds = result.Model.Model.Nodes(NodeList).Keys.OrderBy(x => x).ToList(); + Assert.Equal(expectedIds, resultSet.Ids); + } + + [Fact] + public void NodeDisplacementsNodeIdsFromcombinationCaseTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeDisplacements.ResultSubset(nodeIds); + + // Assert node IDs + var expectedIds = result.Model.Model.Nodes(NodeList).Keys.ToList(); + Assert.Equal(expectedIds, resultSet.Ids); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeDisplacementsMaxFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + double expected = ExpectedAnalysisCaseValues(component).Max(); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeDisplacements.ResultSubset(nodeIds); + + // Assert Max in set + double max = TestsResultHelper.ResultsHelper(resultSet, component, true); + Assert.Equal(expected, max); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeDisplacementsMaxFromCombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + double expected = Math.Max(ExpectedCombinationCaseC4p1Values(component).Max(), + ExpectedCombinationCaseC4p2Values(component).Max()); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeDisplacements.ResultSubset(nodeIds); + + // Assert Max in set + double max = TestsResultHelper.ResultsHelper(resultSet, component, true); + Assert.Equal(expected, max); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeDisplacementsMinFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + double expected = ExpectedAnalysisCaseValues(component).Min(); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeDisplacements.ResultSubset(nodeIds); + + // Assert Max in set + double min = TestsResultHelper.ResultsHelper(resultSet, component, false); + Assert.Equal(expected, min); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeDisplacementsMinFromcombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + double expected = Math.Min(ExpectedCombinationCaseC4p1Values(component).Min(), + ExpectedCombinationCaseC4p2Values(component).Min()); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeDisplacements.ResultSubset(nodeIds); + + // Assert Max in set + double min = TestsResultHelper.ResultsHelper(resultSet, component, false); + Assert.Equal(expected, min); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeDisplacementsValuesFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + List expected = ExpectedAnalysisCaseValues(component); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeDisplacements.ResultSubset(nodeIds); + + // Assert result values + int i = 0; + foreach (int id in resultSet.Ids) { + Collection displacementQuantity = resultSet.Subset[id]; + + // for analysis case results we expect only one value in the collection + Assert.Single(displacementQuantity); + + double x = TestsResultHelper.ResultsHelper(displacementQuantity[0], component); + Assert.Equal(expected[i++], x); + } + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeDisplacementsValuesFromCombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + List expectedP1 = ExpectedCombinationCaseC4p1Values(component); + List expectedP2 = ExpectedCombinationCaseC4p2Values(component); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeDisplacements.ResultSubset(nodeIds); + + // Assert result values + int i = 0; + foreach (int id in resultSet.Ids) { + var displacementQuantity = (Collection)resultSet.Subset[id]; + + // for C4 case results we expect two permutations in the collection + Assert.Equal(2, displacementQuantity.Count); + + double perm1 = TestsResultHelper.ResultsHelper(displacementQuantity[0], component); + Assert.Equal(expectedP1[i], perm1); + double perm2 = TestsResultHelper.ResultsHelper(displacementQuantity[1], component); + Assert.Equal(expectedP2[i++], perm2); + } + } + + private List ExpectedAnalysisCaseValues(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return NodeDisplacementsA1.XInMillimeter(); + + case ResultVector6HelperEnum.Y: return NodeDisplacementsA1.YInMillimeter(); + + case ResultVector6HelperEnum.Z: return NodeDisplacementsA1.ZInMillimeter(); + + case ResultVector6HelperEnum.Xyz: return NodeDisplacementsA1.XyzInMillimeter(); + + case ResultVector6HelperEnum.Xx: return NodeDisplacementsA1.XxInRadian(); + + case ResultVector6HelperEnum.Yy: return NodeDisplacementsA1.YyInRadian(); + + case ResultVector6HelperEnum.Zz: return NodeDisplacementsA1.ZzInRadian(); + + case ResultVector6HelperEnum.Xxyyzz: return NodeDisplacementsA1.XxyyzzInRadian(); + } + + throw new NotImplementedException(); + } + + private List ExpectedCombinationCaseC4p1Values(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return NodeDisplacementsC4p1.XInMillimeter(); + + case ResultVector6HelperEnum.Y: return NodeDisplacementsC4p1.YInMillimeter(); + + case ResultVector6HelperEnum.Z: return NodeDisplacementsC4p1.ZInMillimeter(); + + case ResultVector6HelperEnum.Xyz: return NodeDisplacementsC4p1.XyzInMillimeter(); + + case ResultVector6HelperEnum.Xx: return NodeDisplacementsC4p1.XxInRadian(); + + case ResultVector6HelperEnum.Yy: return NodeDisplacementsC4p1.YyInRadian(); + + case ResultVector6HelperEnum.Zz: return NodeDisplacementsC4p1.ZzInRadian(); + + case ResultVector6HelperEnum.Xxyyzz: return NodeDisplacementsC4p1.XxyyzzInRadian(); + } + + throw new NotImplementedException(); + } + + private List ExpectedCombinationCaseC4p2Values(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return NodeDisplacementsC4p2.XInMillimeter(); + + case ResultVector6HelperEnum.Y: return NodeDisplacementsC4p2.YInMillimeter(); + + case ResultVector6HelperEnum.Z: return NodeDisplacementsC4p2.ZInMillimeter(); + + case ResultVector6HelperEnum.Xyz: return NodeDisplacementsC4p2.XyzInMillimeter(); + + case ResultVector6HelperEnum.Xx: return NodeDisplacementsC4p2.XxInRadian(); + + case ResultVector6HelperEnum.Yy: return NodeDisplacementsC4p2.YyInRadian(); + + case ResultVector6HelperEnum.Zz: return NodeDisplacementsC4p2.ZzInRadian(); + + case ResultVector6HelperEnum.Xxyyzz: return NodeDisplacementsC4p2.XxyyzzInRadian(); + } + + throw new NotImplementedException(); + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeFootfallTests.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeFootfallTests.cs new file mode 100644 index 000000000..fd9d37421 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeFootfallTests.cs @@ -0,0 +1,272 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using GsaGH.Components.Helpers; +using GsaGH.Helpers.GsaApi; +using GsaGH.Parameters.Results; +using GsaGHTests.Helper; +using Xunit; + +namespace GsaGHTests.Parameters.Results { + [Collection("GrasshopperFixture collection")] + public class NodeFootfallTests { + + private static readonly string NodeList = "200 to 206"; + + [Fact] + public void NodeFootfallNodeIdsFromAnalysisCaseTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelFootfall, 16); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeResonantFootfalls.ResultSubset(nodeIds); + + // Assert node IDs + var expectedIds = result.Model.Model.Nodes(NodeList).Keys.OrderBy(x => x).ToList(); + Assert.Equal(expectedIds, resultSet.Ids); + + result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelFootfall, 17); + resultSet = result.NodeTransientFootfalls.ResultSubset(nodeIds); + Assert.Equal(expectedIds, resultSet.Ids); + } + + [Fact] + public void NodeFootfallResonantResponseFactorTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelFootfall, 16); + List expected = NodeFootfallResonantA16.MaximumResponseFactor(); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeResonantFootfalls.ResultSubset(nodeIds); + + // Assert values + for (int i = 0; i < nodeIds.Count; i++) { + double value = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].MaximumResponseFactor, 4); + Assert.Equal(expected[i], value); + } + + // Assert Max in set + NodeExtremaKey key = resultSet.Max.MaximumResponseFactor; + IFootfall extrema = resultSet.GetExtrema(key); + double max = ResultHelper.RoundToSignificantDigits(extrema.MaximumResponseFactor, 4); + Assert.Equal(expected.Max(), max); + } + + [Fact] + public void NodeFootfallTransientResponseFactorTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelFootfall, 17); + List expected = NodeFootfallTransientA17.MaximumResponseFactor(); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeTransientFootfalls.ResultSubset(nodeIds); + + // Assert values + for (int i = 0; i < nodeIds.Count; i++) { + double value = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].MaximumResponseFactor, 4); + Assert.Equal(expected[i], value); + } + + // Assert Max in set + NodeExtremaKey key = resultSet.Max.MaximumResponseFactor; + IFootfall extrema = resultSet.GetExtrema(key); + double max = ResultHelper.RoundToSignificantDigits(extrema.MaximumResponseFactor, 4); + Assert.Equal(expected.Max(), max); + } + + [Fact] + public void NodeFootfallResonantVelocitiesTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelFootfall, 16); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeResonantFootfalls.ResultSubset(nodeIds); + + List expectedPeak = NodeFootfallResonantA16.PeakVelocity(); + List expectedRMS = NodeFootfallResonantA16.RMSVelocity(); + for (int i = 0; i < nodeIds.Count; i++) { + double peak = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].PeakVelocity.Value, 4); + Assert.Equal(expectedPeak[i], peak); + double rms = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].RmsVelocity.Value, 4); + Assert.Equal(expectedRMS[i], rms); + } + + // Assert Max in set + NodeExtremaKey key = resultSet.Max.PeakVelocity; + IFootfall extrema = resultSet.GetExtrema(key); + double max = ResultHelper.RoundToSignificantDigits(extrema.PeakVelocity.Value, 4); + Assert.Equal(expectedPeak.Max(), max); + + key = resultSet.Max.RmsVelocity; + extrema = resultSet.GetExtrema(key); + max = ResultHelper.RoundToSignificantDigits(extrema.RmsVelocity.Value, 4); + Assert.Equal(expectedRMS.Max(), max); + } + + [Fact] + public void NodeFootfallTransientVelocitiesTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelFootfall, 17); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeTransientFootfalls.ResultSubset(nodeIds); + + List expectedPeak = NodeFootfallTransientA17.PeakVelocity(); + List expectedRMS = NodeFootfallTransientA17.RMSVelocity(); + for (int i = 0; i < nodeIds.Count; i++) { + double peak = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].PeakVelocity.Value, 4); + Assert.Equal(expectedPeak[i], peak); + double rms = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].RmsVelocity.Value, 4); + Assert.Equal(expectedRMS[i], rms); + } + + // Assert Max in set + NodeExtremaKey key = resultSet.Max.PeakVelocity; + IFootfall extrema = resultSet.GetExtrema(key); + double max = ResultHelper.RoundToSignificantDigits(extrema.PeakVelocity.Value, 4); + Assert.Equal(expectedPeak.Max(), max); + + key = resultSet.Max.RmsVelocity; + extrema = resultSet.GetExtrema(key); + max = ResultHelper.RoundToSignificantDigits(extrema.RmsVelocity.Value, 4); + Assert.Equal(expectedRMS.Max(), max); + } + + [Fact] + public void NodeFootfallResonantAccelerationsTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelFootfall, 16); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeResonantFootfalls.ResultSubset(nodeIds); + + List expectedPeak = NodeFootfallResonantA16.PeakAcceleration(); + List expectedRMS = NodeFootfallResonantA16.RMSAcceleration(); + for (int i = 0; i < nodeIds.Count; i++) { + double peak = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].PeakAcceleration.Value, 4); + Assert.Equal(expectedPeak[i], peak); + double rms = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].RmsAcceleration.Value, 4); + Assert.Equal(expectedRMS[i], rms); + } + + // Assert Max in set + NodeExtremaKey key = resultSet.Max.PeakVelocity; + IFootfall extrema = resultSet.GetExtrema(key); + double max = ResultHelper.RoundToSignificantDigits(extrema.PeakAcceleration.Value, 4); + Assert.Equal(expectedPeak.Max(), max); + + key = resultSet.Max.RmsVelocity; + extrema = resultSet.GetExtrema(key); + max = ResultHelper.RoundToSignificantDigits(extrema.RmsAcceleration.Value, 4); + Assert.Equal(expectedRMS.Max(), max); + } + + [Fact] + public void NodeFootfallTransientAccelerationsTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelFootfall, 17); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeTransientFootfalls.ResultSubset(nodeIds); + + List expectedPeak = NodeFootfallTransientA17.PeakAcceleration(); + List expectedRMS = NodeFootfallTransientA17.RMSAcceleration(); + for (int i = 0; i < nodeIds.Count; i++) { + double peak = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].PeakAcceleration.Value, 4); + Assert.Equal(expectedPeak[i], peak); + double rms = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].RmsAcceleration.Value, 4); + Assert.Equal(expectedRMS[i], rms); + } + + // Assert Max in set + NodeExtremaKey key = resultSet.Max.PeakAcceleration; + IFootfall extrema = resultSet.GetExtrema(key); + double max = ResultHelper.RoundToSignificantDigits(extrema.PeakAcceleration.Value, 4); + Assert.Equal(expectedPeak.Max(), max); + + key = resultSet.Max.RmsAcceleration; + extrema = resultSet.GetExtrema(key); + max = ResultHelper.RoundToSignificantDigits(extrema.RmsAcceleration.Value, 4); + Assert.Equal(expectedRMS.Max(), max); + } + + [Fact] + public void NodeFootfallResonantFrequencyTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelFootfall, 16); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeResonantFootfalls.ResultSubset(nodeIds); + + List expectedFrequency = NodeFootfallResonantA16.CriticalFrequency(); + List expectedNode = NodeFootfallResonantA16.CriticalNode(); + for (int i = 0; i < nodeIds.Count; i++) { + double frequency = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].CriticalFrequency.Value, 4); + Assert.Equal(expectedFrequency[i], frequency); + int node = resultSet.Subset[nodeIds[i]][0].CriticalNode; + Assert.Equal(expectedNode[i], node); + } + + // Assert Max in set + NodeExtremaKey key = resultSet.Max.CriticalFrequency; + IFootfall extrema = resultSet.GetExtrema(key); + double max = ResultHelper.RoundToSignificantDigits(extrema.CriticalFrequency.Value, 4); + Assert.Equal(expectedFrequency.Max(), max); + } + + [Fact] + public void NodeFootfallTransientFrequencyTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelFootfall, 17); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeTransientFootfalls.ResultSubset(nodeIds); + + List expectedFrequency = NodeFootfallTransientA17.CriticalFrequency(); + List expectedNode = NodeFootfallTransientA17.CriticalNode(); + for (int i = 0; i < nodeIds.Count; i++) { + double frequency = ResultHelper.RoundToSignificantDigits( + resultSet.Subset[nodeIds[i]][0].CriticalFrequency.Value, 4); + Assert.Equal(expectedFrequency[i], frequency); + int node = resultSet.Subset[nodeIds[i]][0].CriticalNode; + Assert.Equal(expectedNode[i], node); + } + + // Assert Max in set + NodeExtremaKey key = resultSet.Max.CriticalFrequency; + IFootfall extrema = resultSet.GetExtrema(key); + double max = ResultHelper.RoundToSignificantDigits(extrema.CriticalFrequency.Value, 4); + Assert.Equal(expectedFrequency.Max(), max); + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeReactionForcesTests.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeReactionForcesTests.cs new file mode 100644 index 000000000..e1530c355 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeReactionForcesTests.cs @@ -0,0 +1,276 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using GsaGH.Parameters.Results; +using GsaGHTests.Helper; +using Xunit; + +namespace GsaGHTests.Parameters.Results { + [Collection("GrasshopperFixture collection")] + public class GsaNodeReactionForcesTests { + private static readonly string NodeList = "1324 to 1327"; + + [Fact] + public void NodeReactionForceNodeIdsFromAnalysisCaseTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeReactionForces.ResultSubset(nodeIds); + + // Assert node IDs + var expectedIds = result.Model.Model.Nodes(NodeList).Keys.OrderBy(x => x).ToList(); + Assert.Equal(expectedIds, resultSet.Ids); + } + + [Fact] + public void NodeReactionForceNodeIdsFromcombinationCaseTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeReactionForces.ResultSubset(nodeIds); + + // Assert node IDs + var expectedIds = result.Model.Model.Nodes(NodeList).Keys.ToList(); + Assert.Equal(expectedIds, resultSet.Ids); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceMaxFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + double expected = ExpectedAnalysisCaseValues(component).Max(); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeReactionForces.ResultSubset(nodeIds); + + // Assert Max in set + double max = TestsResultHelper.ResultsHelper(resultSet, component, true); + Assert.Equal(expected, max); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceMaxFromCombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + double expected = Math.Max(ExpectedCombinationCaseC4p1Values(component).Max(), + ExpectedCombinationCaseC4p2Values(component).Max()); + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeReactionForces.ResultSubset(nodeIds); + + // Assert Max in set + double max = TestsResultHelper.ResultsHelper(resultSet, component, true); + Assert.Equal(expected, max); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceMinFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + double expected = ExpectedAnalysisCaseValues(component).Min(); + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeReactionForces.ResultSubset(nodeIds); + + // Assert Max in set + double min = TestsResultHelper.ResultsHelper(resultSet, component, false); + Assert.Equal(expected, min); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceMinFromcombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + double expected = Math.Min(ExpectedCombinationCaseC4p1Values(component).Min(), + ExpectedCombinationCaseC4p2Values(component).Min()); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeReactionForces.ResultSubset(nodeIds); + + // Assert Max in set + double min = TestsResultHelper.ResultsHelper(resultSet, component, false); + Assert.Equal(expected, min); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceValuesFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + List expected = ExpectedAnalysisCaseValues(component); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeReactionForces.ResultSubset(nodeIds); + + // Assert result values + int i = 0; + foreach (int id in resultSet.Ids) { + Collection reactionForceQuantity = resultSet.Subset[id]; + + // for analysis case results we expect only one value in the collection + Assert.Single(reactionForceQuantity); + + double x = TestsResultHelper.ResultsHelper(reactionForceQuantity[0], component); + Assert.Equal(expected[i++], x); + } + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceValuesFromCombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SteelDesignComplex, 4); + List expectedP1 = ExpectedCombinationCaseC4p1Values(component); + List expectedP2 = ExpectedCombinationCaseC4p2Values(component); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeReactionForces.ResultSubset(nodeIds); + + // Assert result values + int i = 0; + foreach (int id in resultSet.Ids) { + Collection reactionForceQuantity = resultSet.Subset[id]; + + // for C4 case results we expect two permutations in the collection + Assert.Equal(2, reactionForceQuantity.Count); + + double perm1 = TestsResultHelper.ResultsHelper(reactionForceQuantity[0], component); + Assert.Equal(expectedP1[i], perm1); + double perm2 = TestsResultHelper.ResultsHelper(reactionForceQuantity[1], component); + Assert.Equal(expectedP2[i++], perm2); + } + } + + private List ExpectedAnalysisCaseValues(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return NodeReactionForcesA1.XInKiloNewtons(); + + case ResultVector6HelperEnum.Y: return NodeReactionForcesA1.YInKiloNewtons(); + + case ResultVector6HelperEnum.Z: return NodeReactionForcesA1.ZInKiloNewtons(); + + case ResultVector6HelperEnum.Xyz: return NodeReactionForcesA1.XyzInKiloNewtons(); + + case ResultVector6HelperEnum.Xx: return NodeReactionForcesA1.XxInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Yy: return NodeReactionForcesA1.YyInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Zz: return NodeReactionForcesA1.ZzInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Xxyyzz: + return NodeReactionForcesA1.XxyyzzInKiloNewtonsPerMeter(); + } + + throw new NotImplementedException(); + } + + private List ExpectedCombinationCaseC4p1Values(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return NodeReactionForcesC4p1.XInKiloNewtons(); + + case ResultVector6HelperEnum.Y: return NodeReactionForcesC4p1.YInKiloNewtons(); + + case ResultVector6HelperEnum.Z: return NodeReactionForcesC4p1.ZInKiloNewtons(); + + case ResultVector6HelperEnum.Xyz: return NodeReactionForcesC4p1.XyzInKiloNewtons(); + + case ResultVector6HelperEnum.Xx: return NodeReactionForcesC4p1.XxInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Yy: return NodeReactionForcesC4p1.YyInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Zz: return NodeReactionForcesC4p1.ZzInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Xxyyzz: + return NodeReactionForcesC4p1.XxyyzzInKiloNewtonsPerMeter(); + } + + throw new NotImplementedException(); + } + + private List ExpectedCombinationCaseC4p2Values(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return NodeReactionForcesC4p2.XInKiloNewtons(); + + case ResultVector6HelperEnum.Y: return NodeReactionForcesC4p2.YInKiloNewtons(); + + case ResultVector6HelperEnum.Z: return NodeReactionForcesC4p2.ZInKiloNewtons(); + + case ResultVector6HelperEnum.Xyz: return NodeReactionForcesC4p2.XyzInKiloNewtons(); + + case ResultVector6HelperEnum.Xx: return NodeReactionForcesC4p2.XxInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Yy: return NodeReactionForcesC4p2.YyInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Zz: return NodeReactionForcesC4p2.ZzInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Xxyyzz: + return NodeReactionForcesC4p2.XxyyzzInKiloNewtonsPerMeter(); + } + + throw new NotImplementedException(); + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeResultsCacheTests.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeResultsCacheTests.cs new file mode 100644 index 000000000..e8f1664ab --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeResultsCacheTests.cs @@ -0,0 +1,42 @@ +using System.Collections.Concurrent; +using System.Collections.ObjectModel; +using System.Linq; +using GsaGH.Parameters.Results; +using GsaGHTests.Helper; +using Xunit; + +namespace GsaGHTests.Parameters.Results { + [Collection("GrasshopperFixture collection")] + public class NodeResultsCacheTests { + + [Fact] + public void GetMissingKeysEmptyTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds("442"); + ConcurrentBag missingIds + = result.NodeDisplacements.Cache.GetMissingKeys(nodeIds); + Assert.Single(missingIds); + Assert.Equal(442, missingIds.First()); + } + + [Fact] + public void GetMissingKeysUpdateTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SteelDesignComplex, 1); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds("442"); + INodeResultSubset> resultSet + = result.NodeDisplacements.ResultSubset(nodeIds); + nodeIds = result.NodeIds("444"); + ConcurrentBag missingIds + = result.NodeDisplacements.Cache.GetMissingKeys(nodeIds); + + Assert.Single(missingIds); + Assert.Equal(444, missingIds.First()); + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeSpringForcesTests.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeSpringForcesTests.cs new file mode 100644 index 000000000..253b284ef --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/NodeSpringForcesTests.cs @@ -0,0 +1,277 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using GsaGH.Parameters.Results; +using GsaGHTests.Helper; +using Xunit; + +namespace GsaGHTests.Parameters.Results { + [Collection("GrasshopperFixture collection")] + public class GsaNodeSpringForcesTests { + + private static readonly string NodeList = "1 to 4"; + + [Fact] + public void NodeReactionForceNodeIdsFromAnalysisCaseTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SpringForces, 1); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeSpringForces.ResultSubset(nodeIds); + + // Assert node IDs + var expectedIds = result.Model.Model.Nodes(NodeList).Keys.OrderBy(x => x).ToList(); + Assert.Equal(expectedIds, resultSet.Ids); + } + + [Fact] + public void NodeReactionForceNodeIdsFromcombinationCaseTest() { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SpringForces, 2); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeSpringForces.ResultSubset(nodeIds); + + // Assert node IDs + var expectedIds = result.Model.Model.Nodes(NodeList).Keys.ToList(); + Assert.Equal(expectedIds, resultSet.Ids); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceMaxFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SpringForces, 1); + double expected = ExpectedAnalysisCaseValues(component).Max(); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeSpringForces.ResultSubset(nodeIds); + + // Assert Max in set + double max = TestsResultHelper.ResultsHelper(resultSet, component, true); + Assert.Equal(expected, max); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceMaxFromCombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SpringForces, 2); + double expected = Math.Max(ExpectedCombinationCaseC2p1Values(component).Max(), + ExpectedCombinationCaseC2p2Values(component).Max()); + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeSpringForces.ResultSubset(nodeIds); + + // Assert Max in set + double max = TestsResultHelper.ResultsHelper(resultSet, component, true); + Assert.Equal(expected, max); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceMinFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SpringForces, 1); + double expected = ExpectedAnalysisCaseValues(component).Min(); + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeSpringForces.ResultSubset(nodeIds); + + // Assert Max in set + double min = TestsResultHelper.ResultsHelper(resultSet, component, false); + Assert.Equal(expected, min); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceMinFromcombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SpringForces, 2); + double expected = Math.Min(ExpectedCombinationCaseC2p1Values(component).Min(), + ExpectedCombinationCaseC2p2Values(component).Min()); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeSpringForces.ResultSubset(nodeIds); + + // Assert Max in set + double min = TestsResultHelper.ResultsHelper(resultSet, component, false); + Assert.Equal(expected, min); + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceValuesFromAnalysisCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.AnalysisCaseResult(GsaFile.SpringForces, 1); + List expected = ExpectedAnalysisCaseValues(component); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeSpringForces.ResultSubset(nodeIds); + + // Assert result values + int i = 0; + foreach (int id in resultSet.Ids) { + Collection reactionForceQuantity = resultSet.Subset[id]; + + // for analysis case results we expect only one value in the collection + Assert.Single(reactionForceQuantity); + + double x = TestsResultHelper.ResultsHelper(reactionForceQuantity[0], component); + Assert.Equal(expected[i++], x); + } + } + + [Theory] + [InlineData(ResultVector6HelperEnum.X)] + [InlineData(ResultVector6HelperEnum.Y)] + [InlineData(ResultVector6HelperEnum.Z)] + [InlineData(ResultVector6HelperEnum.Xyz)] + [InlineData(ResultVector6HelperEnum.Xx)] + [InlineData(ResultVector6HelperEnum.Yy)] + [InlineData(ResultVector6HelperEnum.Zz)] + [InlineData(ResultVector6HelperEnum.Xxyyzz)] + public void NodeReactionForceValuesFromCombinationCaseTest(ResultVector6HelperEnum component) { + // Assemble + var result = (GsaResult2)GsaResult2Tests.CombinationCaseResult(GsaFile.SpringForces, 2); + List expectedP1 = ExpectedCombinationCaseC2p1Values(component); + List expectedP2 = ExpectedCombinationCaseC2p2Values(component); + + // Act + ReadOnlyCollection nodeIds = result.NodeIds(NodeList); + INodeResultSubset> resultSet + = result.NodeSpringForces.ResultSubset(nodeIds); + + // Assert result values + int i = 0; + foreach (int id in resultSet.Ids) { + Collection reactionForceQuantity = resultSet.Subset[id]; + + // for C4 case results we expect two permutations in the collection + Assert.Equal(2, reactionForceQuantity.Count); + + double perm1 = TestsResultHelper.ResultsHelper(reactionForceQuantity[0], component); + Assert.Equal(expectedP1[i], perm1); + double perm2 = TestsResultHelper.ResultsHelper(reactionForceQuantity[1], component); + Assert.Equal(expectedP2[i++], perm2); + } + } + + private List ExpectedAnalysisCaseValues(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return NodeSpringForcesA1.XInKiloNewtons(); + + case ResultVector6HelperEnum.Y: return NodeSpringForcesA1.YInKiloNewtons(); + + case ResultVector6HelperEnum.Z: return NodeSpringForcesA1.ZInKiloNewtons(); + + case ResultVector6HelperEnum.Xyz: return NodeSpringForcesA1.XyzInKiloNewtons(); + + case ResultVector6HelperEnum.Xx: return NodeSpringForcesA1.XxInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Yy: return NodeSpringForcesA1.YyInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Zz: return NodeSpringForcesA1.ZzInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Xxyyzz: + return NodeSpringForcesA1.XxyyzzInKiloNewtonsPerMeter(); + } + + throw new NotImplementedException(); + } + + private List ExpectedCombinationCaseC2p1Values(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return NodeSpringForcesC2p1.XInKiloNewtons(); + + case ResultVector6HelperEnum.Y: return NodeSpringForcesC2p1.YInKiloNewtons(); + + case ResultVector6HelperEnum.Z: return NodeSpringForcesC2p1.ZInKiloNewtons(); + + case ResultVector6HelperEnum.Xyz: return NodeSpringForcesC2p1.XyzInKiloNewtons(); + + case ResultVector6HelperEnum.Xx: return NodeSpringForcesC2p1.XxInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Yy: return NodeSpringForcesC2p1.YyInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Zz: return NodeSpringForcesC2p1.ZzInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Xxyyzz: + return NodeSpringForcesC2p1.XxyyzzInKiloNewtonsPerMeter(); + } + + throw new NotImplementedException(); + } + + private List ExpectedCombinationCaseC2p2Values(ResultVector6HelperEnum component) { + switch (component) { + case ResultVector6HelperEnum.X: return NodeSpringForcesC2p2.XInKiloNewtons(); + + case ResultVector6HelperEnum.Y: return NodeSpringForcesC2p2.YInKiloNewtons(); + + case ResultVector6HelperEnum.Z: return NodeSpringForcesC2p2.ZInKiloNewtons(); + + case ResultVector6HelperEnum.Xyz: return NodeSpringForcesC2p2.XyzInKiloNewtons(); + + case ResultVector6HelperEnum.Xx: return NodeSpringForcesC2p2.XxInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Yy: return NodeSpringForcesC2p2.YyInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Zz: return NodeSpringForcesC2p2.ZzInKiloNewtonsPerMeter(); + + case ResultVector6HelperEnum.Xxyyzz: + return NodeSpringForcesC2p2.XxyyzzInKiloNewtonsPerMeter(); + } + + throw new NotImplementedException(); + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dDisplacementsA1.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dDisplacementsA1.cs new file mode 100644 index 000000000..0cf5ca25a --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dDisplacementsA1.cs @@ -0,0 +1,207 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class Element1dDisplacementsA1 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for elements 24 to 30 for analysis case A1 + internal static List XInMillimeter() { + return new List() { + 1.923, +2.210, +2.498, +2.786, +9.883, +9.890, +9.897, +9.904, +2.786, +3.073, +3.359, +3.646, +9.990, +9.996, +10.00, +10.01, +3.646, +3.907, +4.168, +4.429 + }; + } + + internal static List YInMillimeter() { + return new List() { + 9.635, +9.722, +9.817, +9.883, +-2.786, +-2.794, +-2.826, +-2.843, +9.883, +9.924, +9.967, +9.990, +-3.646, +-3.660, +-3.682, +-3.695, +9.990, +9.992, +9.992, +9.983 + }; + } + + internal static List ZInMillimeter() { + return new List() { + -74.35, +-75.71, +-76.72, +-77.21, +-77.21, +-77.90, +-78.69, +-79.47, +-77.21, +-76.99, +-76.29, +-75.25, +-75.25, +-75.67, +-76.17, +-76.65, +-75.25, +-73.58, +-71.36, +-69.05 + }; + } + + internal static List XyzInMillimeter() { + return new List() { + 74.99, +76.36, +77.39, +77.89, +77.89, +78.58, +79.36, +80.13, +77.89, +77.69, +77.01, +76.00, +76.00, +76.42, +76.91, +77.38, +76.00, +74.36, +72.17, +69.90 + }; + } + + internal static List XxInRadian() { + return new List() { + -0.001404, +-0.001227, +-0.001050, +-872.6E-6, +169.9E-6, +41.20E-6, +-87.46E-6, +-216.1E-6, +-872.6E-6, +-748.7E-6, +-624.7E-6, +-500.7E-6, +-0.001669, +-0.001760, +-0.001852, +-0.001943, +-500.7E-6, +-420.1E-6, +-339.4E-6, +-258.7E-6 + }; + } + + internal static List YyInRadian() { + return new List() { + 0.002203, +0.001829, +0.001176, +243.1E-6, +915.4E-6, +0.001139, +0.001200, +0.001098, +109.8E-6, +-731.8E-6, +-0.001345, +-0.001729, +536.4E-6, +712.2E-6, +752.2E-6, +656.4E-6, +-0.001853, +-0.003037, +-0.003518, +-0.003296 + }; + } + + internal static List ZzInRadian() { + return new List() { + 102.4E-6, +146.2E-6, +131.0E-6, +56.79E-6, +25.64E-6, +-40.36E-6, +-46.60E-6, +6.929E-6, +49.65E-6, +68.06E-6, +54.74E-6, +9.694E-6, +-5.593E-6, +-31.28E-6, +-30.45E-6, +-3.080E-6, +3.376E-6, +2.495E-6, +-6.037E-6, +-22.22E-6 + }; + } + + internal static List XxyyzzInRadian() { + return new List() { + 0.002614, +0.002207, +0.001582, +907.6E-6, +931.4E-6, +0.001141, +0.001205, +0.001120, +880.9E-6, +0.001049, +0.001484, +0.001800, +0.001753, +0.001899, +0.001999, +0.002051, +0.001920, +0.003066, +0.003534, +0.003306 + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dDisplacementsC4p1.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dDisplacementsC4p1.cs new file mode 100644 index 000000000..0249a257f --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dDisplacementsC4p1.cs @@ -0,0 +1,207 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class Element1dDisplacementsC4p1 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for nodes 442 to 468 for combination case C4p1 + internal static List XInMillimeter() { + return new List() { + 2.674, +2.985, +3.296, +3.607, +-0.9809, +-0.9736, +-0.9663, +-0.9590, +3.607, +3.928, +4.248, +4.569, +-1.299, +-1.294, +-1.290, +-1.286, +4.569, +4.873, +5.176, +5.480 + }; + } + + internal static List YInMillimeter() { + return new List() { + -0.7855, +-0.8397, +-0.9050, +-0.9809, +-3.607, +-3.673, +-3.726, +-3.783, +-0.9809, +-1.077, +-1.187, +-1.299, +-4.569, +-4.648, +-4.707, +-4.772, +-1.299, +-1.423, +-1.561, +-1.692 + }; + } + + internal static List ZInMillimeter() { + return new List() { + -95.37, +-97.84, +-99.99, +-101.5, +-101.5, +-103.0, +-104.7, +-106.3, +-101.5, +-102.3, +-102.6, +-102.5, +-102.5, +-103.8, +-105.2, +-106.6, +-102.5, +-101.7, +-100.4, +-98.78 + }; + } + + internal static List XyzInMillimeter() { + return new List() { + 95.41, +97.89, +100.0, +101.6, +101.6, +103.1, +104.7, +106.4, +101.6, +102.4, +102.7, +102.6, +102.6, +104.0, +105.4, +106.8, +102.6, +101.9, +100.5, +98.94 + }; + } + + internal static List XxInRadian() { + return new List() { + -0.002413, +-0.002306, +-0.002199, +-0.002093, +0.001596, +0.001505, +0.001413, +0.001322, +-0.002093, +-0.002024, +-0.001955, +-0.001886, +-412.4E-6, +-492.2E-6, +-572.1E-6, +-651.9E-6, +-0.001886, +-0.001834, +-0.001783, +-0.001732 + }; + } + + internal static List YyInRadian() { + return new List() { + 0.003813, +0.003534, +0.002832, +0.001707, +0.002139, +0.002387, +0.002459, +0.002356, +0.001571, +804.4E-6, +135.0E-6, +-437.8E-6, +0.001914, +0.002069, +0.002117, +0.002057, +-556.3E-6, +-0.001705, +-0.002306, +-0.002358 + }; + } + + internal static List ZzInRadian() { + return new List() { + -72.83E-6, +-89.75E-6, +-106.0E-6, +-121.5E-6, +-115.1E-6, +-85.03E-6, +-78.59E-6, +-95.77E-6, +-126.4E-6, +-157.9E-6, +-169.9E-6, +-162.4E-6, +-147.1E-6, +-97.01E-6, +-86.06E-6, +-114.2E-6, +-165.4E-6, +-201.6E-6, +-206.9E-6, +-181.4E-6 + }; + } + + internal static List XxyyzzInRadian() { + return new List() { + 0.004513, +0.004221, +0.003587, +0.002703, +0.002671, +0.002823, +0.002837, +0.002703, +0.002620, +0.002183, +0.001967, +0.001942, +0.001963, +0.002129, +0.002195, +0.002161, +0.001973, +0.002513, +0.002922, +0.002931 + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dDisplacementsC4p2.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dDisplacementsC4p2.cs new file mode 100644 index 000000000..5f93bc191 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dDisplacementsC4p2.cs @@ -0,0 +1,207 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class Element1dDisplacementsC4p2 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for elements 24 to 30 for combination case C4p2 + internal static List XInMillimeter() { + return new List() { + 2.298, +2.598, +2.897, +3.197, +4.451, +4.458, +4.466, +4.473, +3.197, +3.500, +3.804, +4.108, +4.345, +4.351, +4.356, +4.361, +4.108, +4.390, +4.672, +4.955 + }; + } + + internal static List YInMillimeter() { + return new List() { + 4.425, +4.441, +4.456, +4.451, +-3.197, +-3.233, +-3.276, +-3.313, +4.451, +4.424, +4.390, +4.345, +-4.108, +-4.154, +-4.194, +-4.233, +4.345, +4.285, +4.215, +4.145 + }; + } + + internal static List ZInMillimeter() { + return new List() { + -84.86, +-86.77, +-88.36, +-89.37, +-89.37, +-90.47, +-91.68, +-92.88, +-89.37, +-89.65, +-89.45, +-88.88, +-88.88, +-89.76, +-90.71, +-91.65, +-88.88, +-87.65, +-85.86, +-83.91 + }; + } + + internal static List XyzInMillimeter() { + return new List() { + 85.00, +86.93, +88.52, +89.54, +89.54, +90.64, +91.85, +93.04, +89.54, +89.83, +89.64, +89.08, +89.08, +89.96, +90.91, +91.85, +89.08, +87.87, +86.09, +84.16 + }; + } + + internal static List XxInRadian() { + return new List() { + -0.001909, +-0.001767, +-0.001625, +-0.001483, +882.9E-6, +772.9E-6, +662.9E-6, +552.9E-6, +-0.001483, +-0.001386, +-0.001290, +-0.001193, +-0.001040, +-0.001126, +-0.001212, +-0.001298, +-0.001193, +-0.001127, +-0.001061, +-995.3E-6 + }; + } + + internal static List YyInRadian() { + return new List() { + 0.003008, +0.002681, +0.002004, +975.1E-6, +0.001527, +0.001763, +0.001830, +0.001727, +840.2E-6, +36.31E-6, +-604.8E-6, +-0.001083, +0.001225, +0.001391, +0.001435, +0.001357, +-0.001205, +-0.002371, +-0.002912, +-0.002827 + }; + } + + internal static List ZzInRadian() { + return new List() { + 14.79E-6, +28.21E-6, +12.50E-6, +-32.35E-6, +-44.74E-6, +-62.70E-6, +-62.59E-6, +-44.42E-6, +-38.39E-6, +-44.93E-6, +-57.59E-6, +-76.38E-6, +-76.33E-6, +-64.15E-6, +-58.26E-6, +-58.66E-6, +-81.02E-6, +-99.53E-6, +-106.5E-6, +-101.8E-6 + }; + } + + internal static List XxyyzzInRadian() { + return new List() { + 0.003562, +0.003211, +0.002580, +0.001775, +0.001765, +0.001926, +0.001947, +0.001814, +0.001705, +0.001387, +0.001426, +0.001613, +0.001609, +0.001791, +0.001879, +0.001878, +0.001697, +0.002627, +0.003101, +0.002999 + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dForcesAndMomentsA1.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dForcesAndMomentsA1.cs new file mode 100644 index 000000000..d2167610a --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dForcesAndMomentsA1.cs @@ -0,0 +1,207 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class Element1dForcesAndMomentsA1 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for elements 2 to 6 for analysis case A1 with 5 positions + internal static List XInKiloNewton() { + return new List() { + -343.6, +-343.6, +-343.6, +-343.6, +-343.6, +-337.2, +-337.2, +-337.2, +-337.2, +-337.2, +-187.9, +-187.9, +-187.9, +-187.9, +-187.9, +-482.2, +-482.2, +-482.2, +-482.2, +-482.2 + }; + } + + internal static List YInKiloNewton() { + return new List() { + 60.91, +60.91, +60.91, +60.91, +60.91, +-53.07, +-53.07, +-53.07, +-53.07, +-53.07, +47.15, +47.15, +47.15, +47.15, +47.15, +20.25, +20.25, +20.25, +20.25, +20.25, + }; + } + + internal static List ZInKiloNewton() { + return new List() { + 189.1, +189.1, +189.1, +189.1, +189.1, +167.9, +167.9, +167.9, +167.9, +167.9, +93.54, +93.54, +93.54, +93.54, +93.54, +110.5, +110.5, +110.5, +110.5, +110.5 + }; + } + + internal static List XyzInKiloNewton() { + return new List() { + 198.7, +198.7, +198.7, +198.7, +198.7, +176.0, +176.0, +176.0, +176.0, +176.0, +104.8, +104.8, +104.8, +104.8, +104.8, +112.3, +112.3, +112.3, +112.3, +112.3 + }; + } + + internal static List XxInKiloNewtonMeter() { + return new List() { + 23.01, +23.01, +23.01, +23.01, +23.01, +-21.16, +-21.16, +-21.16, +-21.16, +-21.16, +17.18, +17.18, +17.18, +17.18, +17.18, +-1.283, +-1.283, +-1.283, +-1.283, +-1.283, + }; + } + + internal static List YyInKiloNewtonMeter() { + return new List() { + -188.3, +-93.71, +0.8640, +95.44, +190.0, +-159.8, +-75.90, +8.025, +91.95, +175.9, +-97.00, +-50.23, +-3.458, +43.31, +90.08, +-32.27, +22.98, +78.23, +133.5, +188.7 + }; + } + + internal static List ZzInKiloNewtonMeter() { + return new List() { + 63.40, +32.94, +2.483, +-27.97, +-58.43, +-50.02, +-23.48, +3.056, +29.59, +56.13, +46.59, +23.02, +-0.5521, +-24.13, +-47.70, +11.60, +1.471, +-8.655, +-18.78, +-28.91 + }; + } + + internal static List XxyyzzInKiloNewtonMeter() { + return new List() { + 198.7, +99.33, +2.629, +99.45, +198.8, +167.5, +79.45, +8.587, +96.60, +184.6, +107.6, +55.25, +3.502, +49.58, +101.9, +34.29, +23.03, +78.71, +134.8, +190.9 + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dForcesAndMomentsC4p1.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dForcesAndMomentsC4p1.cs new file mode 100644 index 000000000..aba868d30 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dForcesAndMomentsC4p1.cs @@ -0,0 +1,207 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class Element1dForcesAndMomentsC4p1 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for elements 2 to 6 for analysis case C4p1 with 5 positions + internal static List XInKiloNewton() { + return new List() { + -466.1, +-466.1, +-466.1, +-466.1, +-466.1, +-466.1, +-466.1, +-466.1, +-466.1, +-466.1, +-243.6, +-243.6, +-243.6, +-243.6, +-243.6, +-680.2, +-680.2, +-680.2, +-680.2, +-680.2 + }; + } + + internal static List YInKiloNewton() { + return new List() { + 68.07, +68.07, +68.07, +68.07, +68.07, +-68.07, +-68.07, +-68.07, +-68.07, +-68.07, +54.32, +54.32, +54.32, +54.32, +54.32, +31.28, +31.28, +31.28, +31.28, +31.28, + }; + } + + internal static List ZInKiloNewton() { + return new List() { + 225.6, +225.6, +225.6, +225.6, +225.6, +225.6, +225.6, +225.6, +225.6, +225.6, +116.2, +116.2, +116.2, +116.2, +116.2, +143.1, +143.1, +143.1, +143.1, +143.1 + }; + } + + internal static List XyzInKiloNewton() { + return new List() { + 235.7, +235.7, +235.7, +235.7, +235.7, +235.7, +235.7, +235.7, +235.7, +235.7, +128.3, +128.3, +128.3, +128.3, +128.3, +146.5, +146.5, +146.5, +146.5, +146.5 + }; + } + + internal static List XxInKiloNewtonMeter() { + return new List() { + 29.82, +29.82, +29.82, +29.82, +29.82, +-29.82, +-29.82, +-29.82, +-29.82, +-29.82, +21.67, +21.67, +21.67, +21.67, +21.67, +-1.555, +-1.555, +-1.555, +-1.555, +-1.555 + }; + } + + internal static List YyInKiloNewtonMeter() { + return new List() { + -215.9, +-103.1, +9.669, +122.5, +235.3, +-215.9, +-103.1, +9.669, +122.5, +235.3, +-120.2, +-62.09, +-3.984, +54.12, +112.2, +-53.15, +18.40, +89.94, +161.5, +233.0 + }; + } + + internal static List ZzInKiloNewtonMeter() { + return new List() { + 67.08, +33.04, +-0.9938, +-35.03, +-69.07, +-67.08, +-33.04, +0.9938, +35.03, +69.07, +53.32, +26.17, +-0.9938, +-28.15, +-55.31, +16.32, +0.6808, +-14.96, +-30.60, +-46.24 + }; + } + + internal static List XxyyzzInKiloNewtonMeter() { + return new List() { + 226.1, +108.3, +9.720, +127.4, +245.2, +226.1, +108.3, +9.720, +127.4, +245.2, +131.5, +67.37, +4.106, +61.00, +125.1, +55.60, +18.41, +91.18, +164.4, +237.6 + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dForcesAndMomentsC4p2.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dForcesAndMomentsC4p2.cs new file mode 100644 index 000000000..01df22c7f --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Element1d/Element1dForcesAndMomentsC4p2.cs @@ -0,0 +1,207 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class Element1dForcesAndMomentsC4p2 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for elements 2 to 6 for analysis case C4p2 with 5 positions + internal static List XInKiloNewton() { + return new List() { + -404.8, +-404.8, +-404.8, +-404.8, +-404.8, +-401.6, +-401.6, +-401.6, +-401.6, +-401.6, +-215.7, +-215.7, +-215.7, +-215.7, +-215.7, +-581.2, +-581.2, +-581.2, +-581.2, +-581.2 + }; + } + + internal static List YInKiloNewton() { + return new List() { + 64.49, +64.49, +64.49, +64.49, +64.49, +-60.57, +-60.57, +-60.57, +-60.57, +-60.57, +50.73, +50.73, +50.73, +50.73, +50.73, +25.77, +25.77, +25.77, +25.77, +25.77 + }; + } + + internal static List ZInKiloNewton() { + return new List() { + 207.4, +207.4, +207.4, +207.4, +207.4, +196.7, +196.7, +196.7, +196.7, +196.7, +104.9, +104.9, +104.9, +104.9, +104.9, +126.8, +126.8, +126.8, +126.8, +126.8 + }; + } + + internal static List XyzInKiloNewton() { + return new List() { + 217.2, +217.2, +217.2, +217.2, +217.2, +205.8, +205.8, +205.8, +205.8, +205.8, +116.5, +116.5, +116.5, +116.5, +116.5, +129.4, +129.4, +129.4, +129.4, +129.4, + }; + } + + internal static List XxInKiloNewtonMeter() { + return new List() { + 26.42, +26.42, +26.42, +26.42, +26.42, +-25.49, +-25.49, +-25.49, +-25.49, +-25.49, +19.43, +19.43, +19.43, +19.43, +19.43, +-1.419, +-1.419, +-1.419, +-1.419, +-1.419, + }; + } + + internal static List YyInKiloNewtonMeter() { + return new List() { + -202.1, +-98.42, +5.266, +109.0, +212.6, +-187.9, +-89.52, +8.847, +107.2, +205.6, +-108.6, +-56.16, +-3.721, +48.72, +101.2, +-42.71, +20.69, +84.09, +147.5, +210.9 + }; + } + + internal static List ZzInKiloNewtonMeter() { + return new List() { + 65.24, +32.99, +0.7445, +-31.50, +-63.75, +-58.55, +-28.26, +2.025, +32.31, +62.60, +49.96, +24.59, +-0.7730, +-26.14, +-51.51, +13.96, +1.076, +-11.81, +-24.69, +-37.57, + }; + } + + internal static List XxyyzzInKiloNewtonMeter() { + return new List() { + 212.4, +103.8, +5.319, +113.4, +222.0, +196.8, +93.87, +9.076, +112.0, +214.9, +119.5, +61.31, +3.800, +55.29, +113.5, +44.93, +20.72, +84.91, +149.5, +214.2 + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeDisplacementsA1.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeDisplacementsA1.cs new file mode 100644 index 000000000..31c6dea53 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeDisplacementsA1.cs @@ -0,0 +1,263 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class NodeDisplacementsA1 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for nodes 442 to 468 for analysis case A1 + internal static List XInMillimeter() { + return new List() { + 1.108, +0.9107, +0.6290, +0.2078, +0.1886, +0.5299, +1.140, +1.923, +2.786, +3.646, +4.429, +5.087, +5.601, +5.973, +6.214, +6.349, +6.409, +6.426, +6.423, +6.419, +6.417, +0.3396, +0.2390, +0.01895, +-0.1426, +0.01656, +0.4770 + }; + } + + internal static List YInMillimeter() { + return new List() { + 10.27, +9.467, +9.513, +8.731, +8.510, +8.808, +9.253, +9.635, +9.883, +9.990, +9.983, +9.913, +9.797, +9.663, +9.507, +9.229, +8.746, +8.559, +8.498, +8.570, +8.800, +10.07, +9.357, +9.772, +8.715, +8.513, +8.833 + }; + } + + internal static List ZInMillimeter() { + return new List() { + 4.700, +4.609, +1.052, +-16.58, +-36.44, +-53.62, +-66.46, +-74.35, +-77.21, +-75.25, +-69.05, +-60.16, +-49.70, +-38.47, +-27.14, +-16.26, +-6.207, +2.840, +11.03, +18.72, +26.23, +1.362, +-2.120, +-7.704, +-24.96, +-44.39, +-60.25, + }; + } + + internal static List XyzInMillimeter() { + return new List() { + 11.35, +10.57, +9.592, +18.74, +37.42, +54.35, +67.11, +74.99, +77.89, +76.00, +69.90, +61.18, +50.97, +40.11, +29.42, +19.75, +12.49, +11.07, +15.33, +21.56, +28.40, +10.16, +9.597, +12.44, +26.44, +45.20, +60.90 + }; + } + + internal static List XxInRadian() { + return new List() { + -0.002972, +-0.004069, +-0.004135, +-0.004172, +-0.003659, +-0.002896, +-0.002095, +-0.001404, +-872.6E-6, +-500.7E-6, +-258.7E-6, +-12.80E-6, +182.4E-6, +353.0E-6, +489.5E-6, +499.1E-6, +284.1E-6, +-14.73E-6, +-278.4E-6, +-439.8E-6, +-516.8E-6, +-0.002999, +-0.003962, +-0.003166, +-0.004169, +-0.004045, +-0.003267 + }; + } + + internal static List YyInRadian() { + return new List() { + 0.001090, +0.001338, +0.003758, +0.007726, +0.007265, +0.005896, +0.004087, +0.002129, +169.9E-6, +-0.001669, +-0.003111, +-0.004044, +-0.004612, +-0.004887, +-0.004910, +-0.004734, +-0.004432, +-0.004114, +-0.003888, +-0.003780, +-0.003758, +0.002283, +0.002228, +0.004772, +0.007613, +0.007004, +0.005378 + }; + } + + internal static List ZzInRadian() { + return new List() { + -78.27E-6, +16.27E-6, +-251.5E-6, +-122.1E-6, +25.22E-6, +123.7E-6, +124.5E-6, +86.95E-6, +41.32E-6, +1.368E-6, +-24.23E-6, +-37.86E-6, +-43.57E-6, +-42.59E-6, +-56.57E-6, +-110.8E-6, +-80.44E-6, +7.425E-6, +48.68E-6, +102.6E-6, +136.0E-6, +-1.473E-6, +-806.3E-9, +-115.1E-6, +-208.4E-6, +-20.80E-6, +53.26E-6 + }; + } + + internal static List XxyyzzInRadian() { + return new List() { + 0.003166, +0.004283, +0.005593, +0.008781, +0.008135, +0.006570, +0.004594, +0.002552, +890.0E-6, +0.001742, +0.003122, +0.004044, +0.004616, +0.004900, +0.004934, +0.004762, +0.004442, +0.004114, +0.003898, +0.003807, +0.003796, +0.003769, +0.004546, +0.005728, +0.008682, +0.008089, +0.006293 + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeDisplacementsC4p1.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeDisplacementsC4p1.cs new file mode 100644 index 000000000..d449852a8 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeDisplacementsC4p1.cs @@ -0,0 +1,263 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class NodeDisplacementsC4p1 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for nodes 442 to 468 for combination case C4p1 + internal static List XInMillimeter() { + return new List() { + 2.318, +2.046, +1.648, +1.088, +0.9682, +1.256, +1.858, +2.674, +3.607, +4.569, +5.480, +6.274, +6.897, +7.318, +7.528, +7.551, +7.443, +7.285, +7.147, +7.064, +7.034, +1.401, +1.259, +0.9478, +0.6810, +0.7739, +1.216 + }; + } + + internal static List YInMillimeter() { + return new List() { + 2.318, +1.401, +1.435, +0.05658, +-0.6355, +-0.7498, +-0.7276, +-0.7855, +-0.9809, +-1.299, +-1.692, +-2.090, +-2.404, +-2.534, +-2.428, +-2.268, +-2.739, +-4.070, +-5.634, +-6.684, +-7.034, +2.046, +1.259, +1.693, +0.02701, +-0.6363, +-0.7238 + }; + } + + internal static List ZInMillimeter() { + return new List() { + 2.754, +2.436, +-2.111, +-22.48, +-46.02, +-67.15, +-83.86, +-95.37, +-101.5, +-102.5, +-98.78, +-91.01, +-80.20, +-67.63, +-54.77, +-42.95, +-33.05, +-25.37, +-19.63, +-15.03, +-10.58, +2.436, +-2.074, +-9.180, +-30.26, +-54.38, +-74.91, + }; + } + + internal static List XyzInMillimeter() { + return new List() { + 4.281, +3.476, +3.039, +22.51, +46.03, +67.17, +83.89, +95.41, +101.6, +102.6, +98.94, +91.25, +80.53, +68.07, +55.34, +43.67, +33.99, +26.71, +21.64, +17.90, +14.52, +3.476, +2.733, +9.383, +30.26, +54.39, +74.92 + }; + } + + internal static List XxInRadian() { + return new List() { + -0.001579, +-0.003125, +-0.003206, +-0.003965, +-0.003874, +-0.003417, +-0.002870, +-0.002413, +-0.002093, +-0.001886, +-0.001732, +-0.001547, +-0.001231, +-704.5E-6, +-848.0E-9, +618.2E-6, +674.2E-6, +13.79E-6, +-999.4E-6, +-0.001896, +-0.002444, +-0.001878, +-0.003002, +-0.002294, +-0.003935, +-0.004294, +-0.003837 + }; + } + + internal static List YyInRadian() { + return new List() { + 0.001579, +0.001878, +0.004661, +0.009273, +0.009004, +0.007665, +0.005784, +0.003703, +0.001596, +-412.4E-6, +-0.002214, +-0.003698, +-0.004746, +-0.005260, +-0.005214, +-0.004710, +-0.003946, +-0.003163, +-0.002590, +-0.002359, +-0.002444, +0.003125, +0.003002, +0.006072, +0.009561, +0.009063, +0.007377 + }; + } + + internal static List ZzInRadian() { + return new List() { + 0.0, +30.74E-6, +-432.0E-6, +-285.6E-6, +-113.9E-6, +-15.04E-6, +-25.93E-6, +-72.65E-6, +-121.3E-6, +-157.3E-6, +-173.3E-6, +-162.8E-6, +-120.1E-6, +-46.84E-6, +19.41E-6, +-57.91E-6, +-302.9E-6, +-477.8E-6, +-408.1E-6, +-180.2E-6, +0.0, +-30.74E-6, +0.0, +-181.0E-6, +-339.7E-6, +-118.5E-6, +-44.34E-6 + }; + } + + internal static List XxyyzzInRadian() { + return new List() { + 0.002233, +0.003646, +0.005673, +0.01009, +0.009803, +0.008392, +0.006457, +0.004420, +0.002635, +0.001936, +0.002816, +0.004012, +0.004905, +0.005307, +0.005214, +0.004751, +0.004015, +0.003199, +0.002806, +0.003032, +0.003456, +0.003646, +0.004245, +0.006493, +0.01035, +0.01003, +0.008315 + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeDisplacementsC4p2.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeDisplacementsC4p2.cs new file mode 100644 index 000000000..a7c908a37 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeDisplacementsC4p2.cs @@ -0,0 +1,263 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class NodeDisplacementsC4p2 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for nodes 442 to 468 for combination case C4p2 + internal static List XInMillimeter() { + return new List() { + 1.713, +1.478, +1.139, +0.6478, +0.5784, +0.8928, +1.499, +2.298, +3.197, +4.108, +4.955, +5.680, +6.249, +6.645, +6.871, +6.950, +6.926, +6.855, +6.785, +6.741, +6.726, +0.8704, +0.7490, +0.4834, +0.2692, +0.3952, +0.8465 + }; + } + + internal static List YInMillimeter() { + return new List() { + 6.293, +5.434, +5.474, +4.394, +3.937, +4.029, +4.263, +4.425, +4.451, +4.345, +4.145, +3.911, +3.697, +3.564, +3.540, +3.480, +3.004, +2.244, +1.432, +0.9428, +0.8830, +6.056, +5.308, +5.733, +4.371, +3.938, +4.054 + }; + } + + internal static List ZInMillimeter() { + return new List() { + 3.727, +3.523, +-0.5298, +-19.53, +-41.23, +-60.39, +-75.16, +-84.86, +-89.37, +-88.88, +-83.91, +-75.59, +-64.95, +-53.05, +-40.95, +-29.60, +-19.63, +-11.27, +-4.302, +1.843, +7.826, +1.899, +-2.097, +-8.442, +-27.61, +-49.38, +-67.58 + }; + } + + internal static List XyzInMillimeter() { + return new List() { + 7.511, +6.642, +5.617, +20.03, +41.42, +60.53, +75.29, +85.00, +89.54, +89.08, +84.16, +75.90, +65.36, +53.58, +41.68, +30.61, +21.03, +13.38, +8.161, +7.052, +10.36, +6.406, +5.756, +10.22, +27.95, +49.54, +67.71 + }; + } + + internal static List XxInRadian() { + return new List() { + -0.002276, +-0.003597, +-0.003671, +-0.004068, +-0.003766, +-0.003157, +-0.002482, +-0.001909, +-0.001483, +-0.001193, +-995.3E-6, +-779.9E-6, +-524.1E-6, +-175.8E-6, +244.3E-6, +558.7E-6, +479.1E-6, +-471.1E-9, +-638.9E-6, +-0.001168, +-0.001480, +-0.002439, +-0.003482, +-0.002730, +-0.004052, +-0.004170, +-0.003552 + }; + } + + internal static List YyInRadian() { + return new List() { + 0.001334, +0.001608, +0.004209, +0.008500, +0.008135, +0.006780, +0.004936, +0.002916, +882.9E-6, +-0.001040, +-0.002663, +-0.003871, +-0.004679, +-0.005074, +-0.005062, +-0.004722, +-0.004189, +-0.003639, +-0.003239, +-0.003069, +-0.003101, +0.002704, +0.002615, +0.005422, +0.008587, +0.008034, +0.006377 + }; + } + + internal static List ZzInRadian() { + return new List() { + -39.14E-6, +23.51E-6, +-341.7E-6, +-203.9E-6, +-44.32E-6, +54.34E-6, +49.30E-6, +7.147E-6, +-40.00E-6, +-77.98E-6, +-98.76E-6, +-100.3E-6, +-81.83E-6, +-44.71E-6, +-18.58E-6, +-84.38E-6, +-191.7E-6, +-235.2E-6, +-179.7E-6, +-38.78E-6, +67.98E-6, +-16.11E-6, +-403.2E-9, +-148.0E-6, +-274.1E-6, +-69.67E-6, +4.462E-6 + }; + } + + internal static List XxyyzzInRadian() { + return new List() { + 0.002638, +0.003940, +0.005595, +0.009425, +0.008964, +0.007479, +0.005525, +0.003485, +0.001726, +0.001585, +0.002844, +0.003950, +0.004709, +0.005077, +0.005068, +0.004756, +0.004221, +0.003646, +0.003306, +0.003284, +0.003437, +0.003641, +0.004355, +0.006072, +0.009499, +0.009052, +0.007300 + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeFootfallResonantA16.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeFootfallResonantA16.cs new file mode 100644 index 000000000..c191a4667 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeFootfallResonantA16.cs @@ -0,0 +1,91 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class NodeFootfallResonantA16 { + // these are regression tests, the values are taken directly from GSA results + // "footfall_steel.gwb" for nodes 200 to 206 for Resonant analysis case A16 + internal static List MaximumResponseFactor() { + return new List() { + 5.928, +7.416, +8.262, +8.207, +7.192, +5.322, +2.821 + }; + } + + internal static List PeakVelocity() { + return new List() { + 0.001104, +0.001383, +0.001541, +0.001531, +0.001342, +992.7E-6, +526.1E-6 + }; + } + + internal static List RMSVelocity() { + return new List() { + 928.3E-6, +0.001163, +0.001296, +0.001288, +0.001128, +834.7E-6, +442.4E-6 + }; + } + + internal static List PeakAcceleration() { + return new List() { + 0.04193, +0.05245, +0.05844, +0.05805, +0.05087, +0.03764, +0.01995 + }; + } + + internal static List RMSAcceleration() { + return new List() { + 0.03526, +0.04411, +0.04915, +0.04882, +0.04278, +0.03165, +0.01678 + }; + } + + internal static List CriticalNode() { + return new List() { + 202, +202, +202, +202, +202, +202, +202 + }; + } + + internal static List CriticalFrequency() { + return new List() { + 2.025, +2.025, +2.025, +2.025, +2.025, +2.025, +2.025 + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeFootfallTransientA17.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeFootfallTransientA17.cs new file mode 100644 index 000000000..1ab98fe20 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeFootfallTransientA17.cs @@ -0,0 +1,91 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class NodeFootfallTransientA17 { + // these are regression tests, the values are taken directly from GSA results + // "footfall_steel.gwb" for nodes 200 to 206 for Transient analysis case A17 + internal static List MaximumResponseFactor() { + return new List() { + 3.034, +3.768, +4.189, +4.194, +3.762, +2.848, +1.571 + }; + } + + internal static List PeakVelocity() { + return new List() { + 813.3E-6, +992.5E-6, +0.001130, +0.001222, +0.001148, +931.6E-6, +521.5E-6 + }; + } + + internal static List RMSVelocity() { + return new List() { + 374.0E-6, +464.3E-6, +515.4E-6, +510.8E-6, +451.5E-6, +336.8E-6, +179.6E-6 + }; + } + + internal static List PeakAcceleration() { + return new List() { + 0.03449, +0.03927, +0.04096, +0.04920, +0.05647, +0.04957, +0.02894 + }; + } + + internal static List RMSAcceleration() { + return new List() { + 0.01482, +0.01849, +0.02050, +0.02060, +0.01868, +0.01504, +0.008587 + }; + } + + internal static List CriticalNode() { + return new List() { + 203, +202, +202, +203, +203, +203, +204 + }; + } + + internal static List CriticalFrequency() { + return new List() { + 2.200, +2.200, +2.200, +2.200, +2.200, +2.200, +2.200 + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeReactionForcesA1.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeReactionForcesA1.cs new file mode 100644 index 000000000..37a3a74d6 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeReactionForcesA1.cs @@ -0,0 +1,79 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class NodeReactionForcesA1 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for nodes 1324 to 1327 for analysis case A1 + internal static List XInKiloNewtons() { + return new List() { + 1894, + -1245, + -204.1, + -444.8, + }; + } + + internal static List YInKiloNewtons() { + return new List() { + 1964, + -260.8, + -1317, + -385.5, + }; + } + + internal static List ZInKiloNewtons() { + return new List() { + 7019, + 2398, + 11990, + 593.4, + }; + } + + internal static List XyzInKiloNewtons() { + return new List() { + 7530, + 2714, + 12060, + 835.8, + }; + } + + internal static List XxInKiloNewtonsPerMeter() { + return new List() { + 129.9, + 0, + 0, + 422.9, + }; + } + + internal static List YyInKiloNewtonsPerMeter() { + return new List() { + 262.8, + 0, + 0, + -30.15, + }; + } + + internal static List ZzInKiloNewtonsPerMeter() { + return new List() { + -2.481, + 0, + 0, + 2.498, + }; + } + + internal static List XxyyzzInKiloNewtonsPerMeter() { + return new List() { + 293.2, + 0, + 0, + 424.0, + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeReactionForcesC4p1.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeReactionForcesC4p1.cs new file mode 100644 index 000000000..01cf2d907 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeReactionForcesC4p1.cs @@ -0,0 +1,79 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class NodeReactionForcesC4p1 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for nodes 1324 to 1327 for combination case C4p1 + internal static List XInKiloNewtons() { + return new List() { + 2351, + -1051, + 1051, + -2351, + }; + } + + internal static List YInKiloNewtons() { + return new List() { + 2351, + 1051, + -1051, + -2351, + }; + } + + internal static List ZInKiloNewtons() { + return new List() { + 7631, + 14420, + 14420, + 7631, + }; + } + + internal static List XyzInKiloNewtons() { + return new List() { + 8324, + 14500, + 14500, + 8324, + }; + } + + internal static List XxInKiloNewtonsPerMeter() { + return new List() { + -294.1, + 0, + 0, + 294.1, + }; + } + + internal static List YyInKiloNewtonsPerMeter() { + return new List() { + 294.1, + 0, + 0, + -294.1, + }; + } + + internal static List ZzInKiloNewtonsPerMeter() { + return new List() { + 2.930E-6, + 0, + 0, + -2.441E-6, + }; + } + + internal static List XxyyzzInKiloNewtonsPerMeter() { + return new List() { + 415.9, + 0, + 0, + 415.9, + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeReactionForcesC4p2.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeReactionForcesC4p2.cs new file mode 100644 index 000000000..30b5c99d2 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeReactionForcesC4p2.cs @@ -0,0 +1,79 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class NodeReactionForcesC4p2 { + // these are regression tests, the values are taken directly from GSA results + // "Steel_Design_Complex.gwb" for nodes 1324 to 1327 for combination case C4p2 + internal static List XInKiloNewtons() { + return new List() { + 2123, + -1148, + 423.3, + -1398, + }; + } + + internal static List YInKiloNewtons() { + return new List() { + 2158, + 394.9, + -1184, + -1368, + }; + } + + internal static List ZInKiloNewtons() { + return new List() { + 7325, + 8408, + 13200, + 4112, + }; + } + + internal static List XyzInKiloNewtons() { + return new List() { + 7926, + 8496, + 13260, + 4554, + }; + } + + internal static List XxInKiloNewtonsPerMeter() { + return new List() { + -82.10, + 0, + 0, + 358.5, + }; + } + + internal static List YyInKiloNewtonsPerMeter() { + return new List() { + 278.5, + 0, + 0, + -162.1, + }; + } + + internal static List ZzInKiloNewtonsPerMeter() { + return new List() { + -1.240, + 0, + 0, + 1.249, + }; + } + + internal static List XxyyzzInKiloNewtonsPerMeter() { + return new List() { + 290.3, + 0, + 0, + 393.5, + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeSpringForcesA1.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeSpringForcesA1.cs new file mode 100644 index 000000000..94c7b9411 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeSpringForcesA1.cs @@ -0,0 +1,79 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class NodeSpringForcesA1 { + // these are regression tests, the values are taken directly from GSA results + // "Spring Forces and Moments Output.gwb" for nodes 1 to 4 for analysis case A1 + internal static List XInKiloNewtons() { + return new List() { + 0, + 0, + 0, + 0, + }; + } + + internal static List YInKiloNewtons() { + return new List() { + 0, + 0, + 0, + 0, + }; + } + + internal static List ZInKiloNewtons() { + return new List() { + -99290, + -99290, + -99290, + -99290, + }; + } + + internal static List XyzInKiloNewtons() { + return new List() { + 99290, + 99290, + 99290, + 99290, + }; + } + + internal static List XxInKiloNewtonsPerMeter() { + return new List() { + -0.5710, + -0.5710, + 0.5710, + 0.5710, + }; + } + + internal static List YyInKiloNewtonsPerMeter() { + return new List() { + 0.5710, + -0.5710, + -0.5710, + 0.5710, + }; + } + + internal static List ZzInKiloNewtonsPerMeter() { + return new List() { + 0, + 0, + 0, + 0, + }; + } + + internal static List XxyyzzInKiloNewtonsPerMeter() { + return new List() { + 0.8075, + 0.8075, + 0.8075, + 0.8075, + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeSpringForcesC2p1.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeSpringForcesC2p1.cs new file mode 100644 index 000000000..19271fe55 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeSpringForcesC2p1.cs @@ -0,0 +1,79 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class NodeSpringForcesC2p1 { + // these are regression tests, the values are taken directly from GSA results + // "Spring Forces and Moments Output.gwb" for nodes 1 to 4 for combination case C2p1 + internal static List XInKiloNewtons() { + return new List() { + 0, + 0, + 0, + 0, + }; + } + + internal static List YInKiloNewtons() { + return new List() { + 0, + 0, + 0, + 0, + }; + } + + internal static List ZInKiloNewtons() { + return new List() { + -99290, + -99290, + -99290, + -99290, + }; + } + + internal static List XyzInKiloNewtons() { + return new List() { + 99290, + 99290, + 99290, + 99290, + }; + } + + internal static List XxInKiloNewtonsPerMeter() { + return new List() { + -0.5710, + -0.5710, + 0.5710, + 0.5710, + }; + } + + internal static List YyInKiloNewtonsPerMeter() { + return new List() { + 0.5710, + -0.5710, + -0.5710, + 0.5710, + }; + } + + internal static List ZzInKiloNewtonsPerMeter() { + return new List() { + 0, + 0, + 0, + 0, + }; + } + + internal static List XxyyzzInKiloNewtonsPerMeter() { + return new List() { + 0.8075, + 0.8075, + 0.8075, + 0.8075, + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeSpringForcesC2p2.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeSpringForcesC2p2.cs new file mode 100644 index 000000000..bbf769b69 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/RegressionValues/Node/NodeSpringForcesC2p2.cs @@ -0,0 +1,79 @@ +using System.Collections.Generic; + +namespace GsaGHTests.Parameters.Results { + public class NodeSpringForcesC2p2 { + // these are regression tests, the values are taken directly from GSA results + // "Spring Forces and Moments Output.gwb" for nodes 1 to 4 for combination case C2p2 + internal static List XInKiloNewtons() { + return new List() { + 0, + 0, + 0, + 0, + }; + } + + internal static List YInKiloNewtons() { + return new List() { + 0, + 0, + 0, + 0, + }; + } + + internal static List ZInKiloNewtons() { + return new List() { + -148900, + -148900, + -148900, + -148900, + }; + } + + internal static List XyzInKiloNewtons() { + return new List() { + 148900, + 148900, + 148900, + 148900, + }; + } + + internal static List XxInKiloNewtonsPerMeter() { + return new List() { + -0.8565, + -0.8565, + 0.8565, + 0.8565, + }; + } + + internal static List YyInKiloNewtonsPerMeter() { + return new List() { + 0.8565, + -0.8565, + -0.8565, + 0.8565, + }; + } + + internal static List ZzInKiloNewtonsPerMeter() { + return new List() { + 0, + 0, + 0, + 0, + }; + } + + internal static List XxyyzzInKiloNewtonsPerMeter() { + return new List() { + 1.211, + 1.211, + 1.211, + 1.211, + }; + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/ResultVector6HelperEnum.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/ResultVector6HelperEnum.cs new file mode 100644 index 000000000..85367e88a --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/ResultVector6HelperEnum.cs @@ -0,0 +1,12 @@ +namespace GsaGHTests.Parameters.Results { + public enum ResultVector6HelperEnum { + X, + Y, + Z, + Xyz, + Xx, + Yy, + Zz, + Xxyyzz, + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Collections/TestsResultHelper.cs.cs b/GsaGHTests/1_BaseParameters/5_Results/Collections/TestsResultHelper.cs.cs new file mode 100644 index 000000000..44800b636 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Collections/TestsResultHelper.cs.cs @@ -0,0 +1,252 @@ +using GsaGH.Helpers.GsaApi; +using GsaGH.Parameters.Results; + +namespace GsaGHTests.Parameters.Results { + public static class TestsResultHelper { + public static double ResultsHelper( + INodeResultSubset> result, + ResultVector6HelperEnum component, bool max) { + double d = 0; + ResultVector6 extrema = max ? result.Max : result.Min; + switch (component) { + case ResultVector6HelperEnum.X: + d = result.GetExtrema(extrema.X).X.Kilonewtons; + break; + + case ResultVector6HelperEnum.Y: + d = result.GetExtrema(extrema.Y).Y.Kilonewtons; + break; + + case ResultVector6HelperEnum.Z: + d = result.GetExtrema(extrema.Z).Z.Kilonewtons; + break; + + case ResultVector6HelperEnum.Xyz: + d = result.GetExtrema(extrema.Xyz).Xyz.Kilonewtons; + break; + + case ResultVector6HelperEnum.Xx: + d = result.GetExtrema(extrema.Xx).Xx.KilonewtonMeters; + break; + + case ResultVector6HelperEnum.Yy: + d = result.GetExtrema(extrema.Yy).Yy.KilonewtonMeters; + break; + + case ResultVector6HelperEnum.Zz: + d = result.GetExtrema(extrema.Zz).Zz.KilonewtonMeters; + break; + + case ResultVector6HelperEnum.Xxyyzz: + d = result.GetExtrema(extrema.Xxyyzz).Xxyyzz.KilonewtonMeters; + break; + } + + return ResultHelper.RoundToSignificantDigits(d, 4); + } + + public static double ResultsHelper(IInternalForce result, ResultVector6HelperEnum component) { + double d = 0; + switch (component) { + case ResultVector6HelperEnum.X: + d = result.X.Kilonewtons; + break; + + case ResultVector6HelperEnum.Y: + d = result.Y.Kilonewtons; + break; + + case ResultVector6HelperEnum.Z: + d = result.Z.Kilonewtons; + break; + + case ResultVector6HelperEnum.Xyz: + d = result.Xyz.Kilonewtons; + break; + + case ResultVector6HelperEnum.Xx: + d = result.Xx.KilonewtonMeters; + break; + + case ResultVector6HelperEnum.Yy: + d = result.Yy.KilonewtonMeters; + break; + + case ResultVector6HelperEnum.Zz: + d = result.Zz.KilonewtonMeters; + break; + + case ResultVector6HelperEnum.Xxyyzz: + d = result.Xxyyzz.KilonewtonMeters; + break; + } + + return ResultHelper.RoundToSignificantDigits(d, 4); + } + + public static double ResultsHelper( + INodeResultSubset> result, + ResultVector6HelperEnum component, bool max) { + double d = 0; + ResultVector6 extrema = max ? result.Max : result.Min; + switch (component) { + case ResultVector6HelperEnum.X: + d = result.GetExtrema(extrema.X).X.Millimeters; + break; + + case ResultVector6HelperEnum.Y: + d = result.GetExtrema(extrema.Y).Y.Millimeters; + break; + + case ResultVector6HelperEnum.Z: + d = result.GetExtrema(extrema.Z).Z.Millimeters; + break; + + case ResultVector6HelperEnum.Xyz: + d = result.GetExtrema(extrema.Xyz).Xyz.Millimeters; + break; + + case ResultVector6HelperEnum.Xx: + d = result.GetExtrema(extrema.Xx).Xx.Radians; + break; + + case ResultVector6HelperEnum.Yy: + d = result.GetExtrema(extrema.Yy).Yy.Radians; + break; + + case ResultVector6HelperEnum.Zz: + d = result.GetExtrema(extrema.Zz).Zz.Radians; + break; + + case ResultVector6HelperEnum.Xxyyzz: + d = result.GetExtrema(extrema.Xxyyzz).Xxyyzz.Radians; + break; + } + + return ResultHelper.RoundToSignificantDigits(d, 4); + } + + public static double ResultsHelper(IDisplacement result, ResultVector6HelperEnum component) { + double d = 0; + switch (component) { + case ResultVector6HelperEnum.X: + d = result.X.Millimeters; + break; + + case ResultVector6HelperEnum.Y: + d = result.Y.Millimeters; + break; + + case ResultVector6HelperEnum.Z: + d = result.Z.Millimeters; + break; + + case ResultVector6HelperEnum.Xyz: + d = result.Xyz.Millimeters; + break; + + case ResultVector6HelperEnum.Xx: + d = result.Xx.Radians; + break; + + case ResultVector6HelperEnum.Yy: + d = result.Yy.Radians; + break; + + case ResultVector6HelperEnum.Zz: + d = result.Zz.Radians; + break; + + case ResultVector6HelperEnum.Xxyyzz: + d = result.Xxyyzz.Radians; + break; + } + + return ResultHelper.RoundToSignificantDigits(d, 4); + } + + public static double ResultsHelper( + IElement1dResultSubset> result, + ResultVector6HelperEnum component, bool max) { + double d = 0; + ResultVector6 extrema = max ? result.Max : result.Min; + switch (component) { + case ResultVector6HelperEnum.X: + d = result.GetExtrema(extrema.X).X.Millimeters; + break; + + case ResultVector6HelperEnum.Y: + d = result.GetExtrema(extrema.Y).Y.Millimeters; + break; + + case ResultVector6HelperEnum.Z: + d = result.GetExtrema(extrema.Z).Z.Millimeters; + break; + + case ResultVector6HelperEnum.Xyz: + d = result.GetExtrema(extrema.Xyz).Xyz.Millimeters; + break; + + case ResultVector6HelperEnum.Xx: + d = result.GetExtrema(extrema.Xx).Xx.Radians; + break; + + case ResultVector6HelperEnum.Yy: + d = result.GetExtrema(extrema.Yy).Yy.Radians; + break; + + case ResultVector6HelperEnum.Zz: + d = result.GetExtrema(extrema.Zz).Zz.Radians; + break; + + case ResultVector6HelperEnum.Xxyyzz: + d = result.GetExtrema(extrema.Xxyyzz).Xxyyzz.Radians; + break; + } + + return ResultHelper.RoundToSignificantDigits(d, 4); + } + + public static double ResultsHelper( + IElement1dResultSubset> result, + ResultVector6HelperEnum component, bool max) { + double d = 0; + ResultVector6 extrema = max ? result.Max : result.Min; + switch (component) { + case ResultVector6HelperEnum.X: + d = result.GetExtrema(extrema.X).X.Kilonewtons; + break; + + case ResultVector6HelperEnum.Y: + d = result.GetExtrema(extrema.Y).Y.Kilonewtons; + break; + + case ResultVector6HelperEnum.Z: + d = result.GetExtrema(extrema.Z).Z.Kilonewtons; + break; + + case ResultVector6HelperEnum.Xyz: + d = result.GetExtrema(extrema.Xyz).Xyz.Kilonewtons; + break; + + case ResultVector6HelperEnum.Xx: + d = result.GetExtrema(extrema.Xx).Xx.KilonewtonMeters; + break; + + case ResultVector6HelperEnum.Yy: + d = result.GetExtrema(extrema.Yy).Yy.KilonewtonMeters; + break; + + case ResultVector6HelperEnum.Zz: + d = result.GetExtrema(extrema.Zz).Zz.KilonewtonMeters; + break; + + case ResultVector6HelperEnum.Xxyyzz: + d = result.GetExtrema(extrema.Xxyyzz).Xxyyzz.KilonewtonMeters; + break; + } + + return ResultHelper.RoundToSignificantDigits(d, 4); + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/GsaResultAnalysisCaseTests.cs b/GsaGHTests/1_BaseParameters/5_Results/GsaResultAnalysisCaseTests.cs index 4d5f0a59d..a860e5f0f 100644 --- a/GsaGHTests/1_BaseParameters/5_Results/GsaResultAnalysisCaseTests.cs +++ b/GsaGHTests/1_BaseParameters/5_Results/GsaResultAnalysisCaseTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using GsaAPI; @@ -38,7 +37,7 @@ public void GsaResultAnalysisCaseDisplacementXTest() { Assert.NotNull(result); Assert.Equal(1, result.CaseId); - Assert.Equal(CaseType.AnalysisCase, result.Type); + Assert.Equal(CaseType.AnalysisCase, result.CaseType); string nodeList = "442 to 468"; List resultValues = diff --git a/GsaGHTests/1_BaseParameters/5_Results/Quantities/DisplacementQuantityTests.cs b/GsaGHTests/1_BaseParameters/5_Results/Quantities/DisplacementQuantityTests.cs new file mode 100644 index 000000000..f2342c7e2 --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Quantities/DisplacementQuantityTests.cs @@ -0,0 +1,50 @@ +using System; +using GsaAPI; +using GsaGH.Parameters.Results; +using OasysUnits; +using Xunit; + +namespace GsaGHTests.Parameters.Results { + [Collection("GrasshopperFixture collection")] + public partial class DisplacementQuantityTests { + [Fact] + public void DisplacementQuantityConstructorTest() { + var apiResult = new Double6(1.1, 2.2, 3.3, 4.4, 5.5, 6.6); + var displacementQuantity = new Displacement(apiResult); + Assert.Equal(apiResult.X, displacementQuantity.X.Meters); + Assert.Equal(apiResult.Y, displacementQuantity.Y.Meters); + Assert.Equal(apiResult.Z, displacementQuantity.Z.Meters); + + double lPyth = Math.Sqrt((1.1 * 1.1) + (2.2 * 2.2) + (3.3 * 3.3)); + Assert.Equal(lPyth, displacementQuantity.Xyz.Meters); + + Assert.Equal(apiResult.XX, displacementQuantity.Xx.Radians); + Assert.Equal(apiResult.YY, displacementQuantity.Yy.Radians); + Assert.Equal(apiResult.ZZ, displacementQuantity.Zz.Radians); + + double aPyth = Math.Sqrt((4.4 * 4.4) + (5.5 * 5.5) + (6.6 * 6.6)); + Assert.Equal(aPyth, displacementQuantity.Xxyyzz.Radians); + } + + [Fact] + public void DisplacementQuantityAngleNanTest() { + var apiResult = new Double6(1.1, 2.2, 3.3, double.NaN, double.NaN, double.NaN); + var displacementQuantity = new Displacement(apiResult); + + Assert.Equal(Angle.Zero, displacementQuantity.Xx); + Assert.Equal(Angle.Zero, displacementQuantity.Yy); + Assert.Equal(Angle.Zero, displacementQuantity.Zz); + Assert.Equal(Angle.Zero, displacementQuantity.Xxyyzz); + } + + [Fact] + public void DisplacementQuantityAngleInfinityTest() { + var apiResult = new Double6(1.1, 2.2, 3.3, double.PositiveInfinity, double.NegativeInfinity, double.NaN); + var displacementQuantity = new Displacement(apiResult); + + Assert.Equal(360, displacementQuantity.Xx.Degrees); + Assert.Equal(-360, displacementQuantity.Yy.Degrees); + Assert.Equal(Angle.Zero, displacementQuantity.Zz); + } + } +} diff --git a/GsaGHTests/1_BaseParameters/5_Results/Quantities/ResultUtilityTests.cs b/GsaGHTests/1_BaseParameters/5_Results/Quantities/ResultUtilityTests.cs new file mode 100644 index 000000000..5a058d8ec --- /dev/null +++ b/GsaGHTests/1_BaseParameters/5_Results/Quantities/ResultUtilityTests.cs @@ -0,0 +1,25 @@ +using System; +using GsaGH.Parameters.Results; +using OasysUnits; +using Xunit; +using LengthUnit = OasysUnits.Units.LengthUnit; + +namespace GsaGHTests.Parameters.Results { + public partial class ResultUtilityTests { + [Theory] + [InlineData(2.0, 3.0, 4.0, LengthUnit.Meter)] + public void PythagoreanQuadrupleTest(double a, double b, double c, Enum unit) { + IQuantity x = Quantity.From(a, unit); + IQuantity y = Quantity.From(b, unit); + IQuantity z = Quantity.From(c, unit); + IQuantity quantity = QuantityUtility.PythagoreanQuadruple(x, y, z); + + double pyth = Math.Sqrt((a * a) + (b * b) + (c * c)); + IQuantity expected = Quantity.From(pyth, unit); + + Assert.Equal(expected.Value, quantity.Value); + Assert.Equal(expected.Unit, quantity.Unit); + Assert.Equal(expected, quantity); + } + } +} diff --git a/GsaGHTests/3_Components/3_Loads/CreateGridAreaLoadTests.cs b/GsaGHTests/3_Components/3_Loads/CreateGridAreaLoadTests.cs index 8dfbd0bb7..c0d7e86d1 100644 --- a/GsaGHTests/3_Components/3_Loads/CreateGridAreaLoadTests.cs +++ b/GsaGHTests/3_Components/3_Loads/CreateGridAreaLoadTests.cs @@ -1,5 +1,4 @@ -using GsaAPI; -using GsaGH.Components; +using GsaGH.Components; using GsaGH.Parameters; using GsaGH.Parameters.Enums; using GsaGHTests.Helpers; diff --git a/GsaGHTests/3_Components/5_Results/GetResultsTest.cs b/GsaGHTests/3_Components/5_Results/GetResultsTest.cs index 50d56087f..5a88bc111 100644 --- a/GsaGHTests/3_Components/5_Results/GetResultsTest.cs +++ b/GsaGHTests/3_Components/5_Results/GetResultsTest.cs @@ -25,7 +25,7 @@ public void TestAnalysisNoInputs() { var comp = (GetResult)ResultsComponentMother(); var result = (GsaResultGoo)ComponentTestHelper.GetOutput(comp); - Assert.Equal(CaseType.AnalysisCase, result.Value.Type); + Assert.Equal(CaseType.AnalysisCase, result.Value.CaseType); Assert.Equal(1, result.Value.CaseId); Assert.Equal(GH_RuntimeMessageLevel.Remark, comp.RuntimeMessageLevel); Assert.Equal("By default, Analysis Case 1 has been selected.", @@ -44,7 +44,7 @@ public void TestAnalysisWithInputs() { ComponentTestHelper.SetInput(comp, 2, 2); var result = (GsaResultGoo)ComponentTestHelper.GetOutput(comp); - Assert.Equal(CaseType.AnalysisCase, result.Value.Type); + Assert.Equal(CaseType.AnalysisCase, result.Value.CaseType); Assert.Equal(2, result.Value.CaseId); Assert.Equal(GH_RuntimeMessageLevel.Blank, comp.RuntimeMessageLevel); } @@ -61,7 +61,7 @@ public void TestCombinationNoPermutation() { ComponentTestHelper.SetInput(comp, 1, 2); var result = (GsaResultGoo)ComponentTestHelper.GetOutput(comp); - Assert.Equal(CaseType.CombinationCase, result.Value.Type); + Assert.Equal(CaseType.CombinationCase, result.Value.CaseType); Assert.Equal(1, result.Value.CaseId); Assert.Equal(new List() { 1, @@ -84,7 +84,7 @@ public void TestCombinationWithPermutation() { ComponentTestHelper.SetInput(comp, 1, 3); var result = (GsaResultGoo)ComponentTestHelper.GetOutput(comp); - Assert.Equal(CaseType.CombinationCase, result.Value.Type); + Assert.Equal(CaseType.CombinationCase, result.Value.CaseType); Assert.Equal(1, result.Value.CaseId); Assert.Equal(new List() { 1, diff --git a/GsaGHTests/3_Components/5_Results/SelectResultsTests.cs b/GsaGHTests/3_Components/5_Results/SelectResultsTests.cs index 65e53bcdd..24820fe81 100644 --- a/GsaGHTests/3_Components/5_Results/SelectResultsTests.cs +++ b/GsaGHTests/3_Components/5_Results/SelectResultsTests.cs @@ -2,7 +2,6 @@ using GsaGH.Parameters; using GsaGHTests.Helper; using GsaGHTests.Helpers; -using GsaGHTests.Model; using OasysGH.Components; using Xunit; diff --git a/GsaGHTests/3_Components/6_Display/LoadDiagramsTests.cs b/GsaGHTests/3_Components/6_Display/LoadDiagramsTests.cs index 23cceb9c5..3d0c1ecbc 100644 --- a/GsaGHTests/3_Components/6_Display/LoadDiagramsTests.cs +++ b/GsaGHTests/3_Components/6_Display/LoadDiagramsTests.cs @@ -54,7 +54,7 @@ public void CaseIdDropdownPopulationTest() { LoadDiagrams comp = LoadDiagramNodeAndElement1dMother(); var diagramGoo = (GsaDiagramGoo)ComponentTestHelper.GetOutput(comp); Assert.Equal("L1", comp._selectedItems[0]); - Assert.Equal(18, comp._dropDownItems[0].Count); + Assert.Equal(19, comp._dropDownItems[0].Count); } [Fact] diff --git a/GsaGHTests/3_Components/ComponentsTests.cs b/GsaGHTests/3_Components/ComponentsTests.cs index c8c092cb6..5a45c056b 100644 --- a/GsaGHTests/3_Components/ComponentsTests.cs +++ b/GsaGHTests/3_Components/ComponentsTests.cs @@ -41,8 +41,8 @@ public class ComponentsTests { [InlineData(typeof(AnalyseModel), 1)] [InlineData(typeof(CreateAnalysisTask), 1)] //Results - [InlineData(typeof(BeamDisplacements), 1)] - [InlineData(typeof(BeamForcesAndMoments), 2)] + [InlineData(typeof(BeamDisplacements), 2)] + [InlineData(typeof(BeamForcesAndMoments), 3)] [InlineData(typeof(BeamStrainEnergyDensity), 1)] [InlineData(typeof(Contour1dResults), 2)] [InlineData(typeof(ResultDiagrams), 2)] @@ -55,11 +55,11 @@ public class ComponentsTests { [InlineData(typeof(Element3dStresses), 1)] [InlineData(typeof(GlobalPerformanceResults), 3)] [InlineData(typeof(ContourNodeResults), 2)] - [InlineData(typeof(NodeDisplacements), 1)] - [InlineData(typeof(ReactionForces), 2)] + [InlineData(typeof(NodeDisplacements), 2)] + [InlineData(typeof(ReactionForces), 3)] [InlineData(typeof(ReactionForceDiagrams), 1)] [InlineData(typeof(SelectResult), 2)] - [InlineData(typeof(SpringReactionForces), 2)] + [InlineData(typeof(SpringReactionForces), 3)] [InlineData(typeof(TotalLoadsAndReactions), 2)] public void WhenInitialiseDropdowns_ThenDropDownItemsCount_ShouldBeValid( Type t, int expectedListCount) { @@ -116,8 +116,8 @@ public void WhenInitialiseDropdowns_ThenDropDownItems_ShouldBeNull(Type t) { [InlineData(typeof(AnalyseModel), "m", "ft")] [InlineData(typeof(CreateAnalysisTask), "Static", "Static")] //Results - [InlineData(typeof(BeamDisplacements), "mm", "ft")] - [InlineData(typeof(BeamForcesAndMoments), "kN", "tf")] + [InlineData(typeof(BeamDisplacements), "All", "Min |R|")] + [InlineData(typeof(BeamForcesAndMoments), "All", "Min |Myz|")] [InlineData(typeof(BeamStrainEnergyDensity), "MJ", "BTU")] [InlineData(typeof(Contour1dResults), "Displacement", "Footfall")] [InlineData(typeof(ResultDiagrams), "Force", "Stress")] @@ -130,22 +130,22 @@ public void WhenInitialiseDropdowns_ThenDropDownItems_ShouldBeNull(Type t) { [InlineData(typeof(Element3dStresses), "MPa", "kipf/ft²")] [InlineData(typeof(GlobalPerformanceResults), "t", "slug")] [InlineData(typeof(ContourNodeResults), "Displacement", "Footfall")] - [InlineData(typeof(NodeDisplacements), "mm", "ft")] - [InlineData(typeof(ReactionForces), "kN", "tf")] + [InlineData(typeof(NodeDisplacements), "All", "Min |R|")] + [InlineData(typeof(ReactionForces), "kN", "tf", 1)] [InlineData(typeof(ReactionForceDiagrams), "Resolved |F|", "Resolved |M|")] [InlineData(typeof(SelectResult), "AnalysisCase", "Combination")] - [InlineData(typeof(SpringReactionForces), "kN", "tf")] + [InlineData(typeof(SpringReactionForces), "kN", "tf", 1)] [InlineData(typeof(TotalLoadsAndReactions), "kN", "tf")] public void WhenSetSelected_ThenSelectedItems_ShouldBeValid( - Type t, string defaultValue, string firstValue) { + Type t, string defaultValue, string firstValue, int index = 0) { var obj = (GH_OasysDropDownComponent)Activator.CreateInstance(t); obj.InitialiseDropdowns(); - Assert.Equal(obj._selectedItems[0].ToString(), defaultValue, true, true, true); + Assert.Equal(obj._selectedItems[index].ToString(), defaultValue, true, true, true); - obj.SetSelected(0, obj._dropDownItems[0].Count - 1); + obj.SetSelected(index, obj._dropDownItems[index].Count - 1); - Assert.Equal(obj._selectedItems[0].ToString(), firstValue, true, true, true); + Assert.Equal(obj._selectedItems[index].ToString(), firstValue, true, true, true); } } } diff --git a/GsaGHTests/TestHelpers/GsaFile.cs b/GsaGHTests/TestHelpers/GsaFile.cs index c2b3b69f7..55a91e635 100644 --- a/GsaGHTests/TestHelpers/GsaFile.cs +++ b/GsaGHTests/TestHelpers/GsaFile.cs @@ -2,6 +2,12 @@ namespace GsaGHTests.Helper { internal static class GsaFile { + private static string steelDesignComplex = ""; + private static string steelDesignSimple = ""; + private static string element2dSimple = ""; + private static string element3dSimple = ""; + private static string springForces = ""; + private static string steelFootfall = ""; internal static string SteelDesignComplex { get { if (steelDesignComplex == "") { @@ -41,18 +47,32 @@ internal static string Element3dSimple { return element3dSimple; } } - private static string steelDesignComplex = ""; - private static string steelDesignSimple = ""; - private static string element2dSimple = ""; - private static string element3dSimple = ""; + internal static string SpringForces { + get { + if (springForces == "") { + springForces = FilePath("spring-reaction-forces.gwb"); + } + + return springForces; + } + } + internal static string SteelFootfall { + get { + if (steelFootfall == "") { + steelFootfall = FilePath("footfall_steel.gwb"); + } + + return steelFootfall; + } + } private static string FilePath(string fileName) { string solutiondir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent - .FullName; + .FullName; return Path.Combine(new string[] { solutiondir, "TestHelpers", - fileName + fileName, }); } } diff --git a/GsaGHTests/TestHelpers/Steel_Design_Complex.gwb b/GsaGHTests/TestHelpers/Steel_Design_Complex.gwb index 9c7faf6f7..8e69713fc 100644 Binary files a/GsaGHTests/TestHelpers/Steel_Design_Complex.gwb and b/GsaGHTests/TestHelpers/Steel_Design_Complex.gwb differ diff --git a/GsaGHTests/TestHelpers/footfall_steel.gwb b/GsaGHTests/TestHelpers/footfall_steel.gwb new file mode 100644 index 000000000..d9a314f5a Binary files /dev/null and b/GsaGHTests/TestHelpers/footfall_steel.gwb differ diff --git a/GsaGHTests/TestHelpers/spring-reaction-forces.gwb b/GsaGHTests/TestHelpers/spring-reaction-forces.gwb new file mode 100644 index 000000000..df5e9afd6 Binary files /dev/null and b/GsaGHTests/TestHelpers/spring-reaction-forces.gwb differ