-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(CSi) : Improved analytical results (#3028)
* attach results to element instead of in giant list with other results * added analytical nodes * add element2D output * further improvements * remove cache object * remove unused code * assign results as objects are converted as opposed to all at once * more changes per PR comments * remove unused code * remove int extensions * remove elses --------- Co-authored-by: Connor Ivy <[email protected]>
- Loading branch information
Showing
26 changed files
with
1,373 additions
and
911 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using CSiAPIv1; | ||
|
||
namespace ConnectorCSIShared.Util | ||
{ | ||
internal static class ResultUtils | ||
{ | ||
public static List<string> GetNamesOfAllLoadCasesAndCombos(cSapModel sapModel) | ||
{ | ||
List<string> names = new(); | ||
|
||
int numberOfLoadCombinations = 0; | ||
string[] loadCombinationNames = null; | ||
sapModel.RespCombo.GetNameList(ref numberOfLoadCombinations, ref loadCombinationNames); | ||
names.AddRange(loadCombinationNames); | ||
|
||
sapModel.LoadCases.GetNameList(ref numberOfLoadCombinations, ref loadCombinationNames); | ||
names.AddRange(loadCombinationNames); | ||
|
||
return names; | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
Objects/Converters/ConverterCSI/ConverterCSIShared/AnalysisResultUtils.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using ConverterCSIShared.Extensions; | ||
using ConverterCSIShared.Models; | ||
using CSiAPIv1; | ||
|
||
namespace ConverterCSIShared | ||
{ | ||
internal static class AnalysisResultUtils | ||
{ | ||
public delegate int ApiResultMethod( | ||
string name, | ||
eItemTypeElm eItemType, | ||
ref int numItems, | ||
ref string[] objs, | ||
ref string[] elms, | ||
ref string[] loadCombos, | ||
ref string[] stepTypes, | ||
ref double[] stepNum, | ||
ref double[] x, | ||
ref double[] y, | ||
ref double[] z, | ||
ref double[] xx, | ||
ref double[] yy, | ||
ref double[] zz); | ||
|
||
public static bool TryGetAPIResult( | ||
ApiResultMethod apiResultMethod, | ||
string nodeName, | ||
out int numberResults, | ||
out string[] obj, | ||
out string[] elm, | ||
out string[] loadCases, | ||
out string[] stepType, | ||
out double[] stepNum, | ||
out double[] F1, | ||
out double[] F2, | ||
out double[] F3, | ||
out double[] M1, | ||
out double[] M2, | ||
out double[] M3, | ||
bool shouldGetResults = true) | ||
{ | ||
numberResults = 0; | ||
obj = null; | ||
elm = null; | ||
loadCases = null; | ||
stepType = null; | ||
stepNum = null; | ||
F1 = null; | ||
F2 = null; | ||
F3 = null; | ||
M1 = null; | ||
M2 = null; | ||
M3 = null; | ||
|
||
if (!shouldGetResults) | ||
{ | ||
return false; | ||
} | ||
|
||
int success = apiResultMethod( | ||
nodeName, | ||
eItemTypeElm.Element, | ||
ref numberResults, | ||
ref obj, | ||
ref elm, | ||
ref loadCases, | ||
ref stepType, | ||
ref stepNum, | ||
ref F1, | ||
ref F2, | ||
ref F3, | ||
ref M1, | ||
ref M2, | ||
ref M3); | ||
return ApiResultValidator.IsSuccessful(success); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Objects/Converters/ConverterCSI/ConverterCSIShared/Constants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace ConverterCSIShared | ||
{ | ||
internal static class Constants | ||
{ | ||
// these three slugs were previously used by the connector and now only serve to maintain backwards | ||
// compatibility with the slugs that may be saved to a user's existing stream card | ||
public const string LEGACY_SEND_NODE_RESULTS = "sendNodeResults"; | ||
public const string LEGACY_SEND_1D_RESULTS = "send1DResults"; | ||
public const string LEGACY_SEND_2D_RESULTS = "send2DResults"; | ||
|
||
public const string RESULTS_NODE_SLUG = "node-results"; | ||
public const string RESULTS_1D_SLUG = "1d-results"; | ||
public const string RESULTS_2D_SLUG = "2d-results"; | ||
public const string RESULTS_LOAD_CASES_SLUG = "load-cases"; | ||
|
||
public const string BEAM_FORCES = "Beam Forces"; | ||
public const string BRACE_FORCES = "Brace Forces"; | ||
public const string COLUMN_FORCES = "Column Forces"; | ||
public const string OTHER_FORCES = "Other Forces"; | ||
public const string FORCES = "Forces"; | ||
public const string STRESSES = "Stresses"; | ||
public const string DISPLACEMENTS = "Displacements"; | ||
public const string VELOCITIES = "Velocities"; | ||
public const string ACCELERATIONS = "Accelerations"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
Objects/Converters/ConverterCSI/ConverterCSIShared/Models/ApiResultValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using Speckle.Core.Kits; | ||
|
||
namespace ConverterCSIShared.Models | ||
{ | ||
public static class ApiResultValidator | ||
{ | ||
public static bool IsSuccessful(int success) | ||
{ | ||
return success == 0; | ||
} | ||
public static void ThrowIfUnsuccessful(int success, string message) | ||
{ | ||
if (IsSuccessful(success)) | ||
{ | ||
return; | ||
} | ||
|
||
throw new ConversionException(message); | ||
} | ||
public static void ThrowIfUnsuccessful<T>(int success, string message) | ||
where T : Exception | ||
{ | ||
if (IsSuccessful(success)) | ||
{ | ||
return; | ||
} | ||
|
||
throw (T)Activator.CreateInstance(typeof(T), message); | ||
} | ||
} | ||
} |
Oops, something went wrong.