Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

GSAGH-499: Add modal analysis task #726

Draft
wants to merge 6 commits into
base: release/10.2.14
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GsaGH/Components/4_Analysis/AnalysisTaskInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

using GsaGH.Helpers.GH;
using GsaGH.Parameters;
using GsaGH.Parameters.Enums;
using GsaGH.Properties;

using OasysGH;
Expand Down
140 changes: 90 additions & 50 deletions GsaGH/Components/4_Analysis/CreateAnalysisTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;

using GH_IO.Serialization;

Expand All @@ -15,6 +17,7 @@
using GsaGH.Helpers;
using GsaGH.Helpers.GH;
using GsaGH.Parameters;
using GsaGH.Parameters.Enums;
using GsaGH.Properties;

using OasysGH;
Expand All @@ -37,6 +40,7 @@ internal static readonly IReadOnlyDictionary<string, AnalysisTaskType> _solverTy
{ "Static", AnalysisTaskType.Static },
{ "Static P-delta", AnalysisTaskType.StaticPDelta },
{ "Footfall", AnalysisTaskType.Footfall },
{ "Modal Dynamic", AnalysisTaskType.ModalDynamic },
};

public override Guid ComponentGuid => new Guid("581601cc-c0bc-47fe-ada5-b821327a4409");
Expand All @@ -52,6 +56,14 @@ internal static readonly IReadOnlyDictionary<string, AnalysisTaskType> _solverTy
Optional = true,
};

private readonly InputAttributes _modalDynamicParameterInputAttributes = new InputAttributes {
NickName = GsaModalDynamicAnalysisGoo.NickName,
Name = GsaModalDynamicAnalysisGoo.Name,
Description = GsaModalDynamicAnalysisGoo.Description,
Access = GH_ParamAccess.item,
Optional = true,
};

private readonly Dictionary<ExcitationMethod, string> _excitationMethod = new Dictionary<ExcitationMethod, string> {
{ ExcitationMethod.SelfExcitation, "Self excitation" },
{ ExcitationMethod.FullExcitationRigorous, "Rigorous excitation" },
Expand Down Expand Up @@ -84,7 +96,7 @@ internal static readonly IReadOnlyDictionary<string, AnalysisTaskType> _solverTy
public const string defaultValueForNode = "all";

private readonly FootfallInputManager _footfallInputManager;
private AnalysisTaskType _type = AnalysisTaskType.Static;
private AnalysisTaskType _analysisTaskType = AnalysisTaskType.Static;
public const string _unableToConvertResponseDirectionInputMessage = "Unable to convert response direction input";
public const string _unableToConvertWeightOptionInputMessage = "Unable to convert frequency weighting curve input";
public const string _unableToConvertsExcitationForcesInputMessage
Expand All @@ -99,14 +111,18 @@ public CreateAnalysisTask() : base($"Create {GsaAnalysisTaskGoo.Name}",

public override bool Read(GH_IReader reader) {
_casesParamIndex = reader.GetInt32("_casesParamIndex");
_analysisTaskType = (AnalysisTaskType)reader.GetInt32("_analysisTaskType");
return base.Read(reader);
}

public override void SetSelected(int i, int j) {
_selectedItems[i] = _dropDownItems[i][j];

if (i == 0) {
_type = _solverTypes[_selectedItems[0]];
AnalysisTaskType type = _solverTypes[_selectedItems[0]];
if (type == _analysisTaskType) {
return;
}
_analysisTaskType = type;
UpdateDropdownItems();
}

Expand All @@ -116,7 +132,7 @@ public override void SetSelected(int i, int j) {
}

public override void VariableParameterMaintenance() {
switch (_type) {
switch (_analysisTaskType) {
case AnalysisTaskType.StaticPDelta:
SetInputAttributes(_casesParamIndex, _analysisCaseInputAttributes);
PDeltaCases selectedPDeltaCase = GetKeyFromMatchingValue(_selectedItems[1]);
Expand All @@ -133,14 +149,17 @@ public override void VariableParameterMaintenance() {
}

break;

case AnalysisTaskType.Footfall:
SetFootfallInput();
break;
case AnalysisTaskType.ModalDynamic:
SetInputAttributes(_casesParamIndex, _modalDynamicParameterInputAttributes);
break;
case AnalysisTaskType.Static:
default:
SetInputAttributes(_casesParamIndex, _analysisCaseInputAttributes);
break;
default:
break;
}
}

Expand All @@ -150,6 +169,7 @@ private PDeltaCases GetKeyFromMatchingValue(string valueToMatch) {

public override bool Write(GH_IWriter writer) {
writer.SetInt32("_casesParamIndex", _casesParamIndex);
writer.SetInt32("_analysisTaskType", (int)_analysisTaskType);
return base.Write(writer);
}

Expand Down Expand Up @@ -185,15 +205,15 @@ protected override void SolveInternal(IGH_DataAccess da) {
int id = 0;
da.GetData(0, ref id);

string name = _type.ToString();
string name = _analysisTaskType.ToString();
da.GetData(1, ref name);

if (!GetAnalysisCases(da, name, out List<GsaAnalysisCase> cases)) {
if (!GetAnalysisCases(da, out List<GsaAnalysisCase> cases)) {
return;
}

AnalysisTask task = null;
switch (_type) {
switch (_analysisTaskType) {
case AnalysisTaskType.Static:
task = AnalysisTaskFactory.CreateStaticAnalysisTask(name);
break;
Expand All @@ -206,11 +226,15 @@ protected override void SolveInternal(IGH_DataAccess da) {
if (!CreateFootfallTask(da, name, out task)) {
return;
}

break;

case AnalysisTaskType.ModalDynamic:
if (!CreateModalDynamicTask(da, name, out task)) {
return;
}
break;
default:
this.AddRuntimeWarning(GetAnalysisCaseErrorMessage(_type));
this.AddRuntimeWarning(GetAnalysisCaseErrorMessage(_analysisTaskType));
break;
}

Expand All @@ -223,37 +247,41 @@ protected override void SolveInternal(IGH_DataAccess da) {
da.SetData(0, new GsaAnalysisTaskGoo(gsaAnalysisTask));
}

private bool GetAnalysisCases(IGH_DataAccess da, string name, out List<GsaAnalysisCase> cases) {
private bool GetAnalysisCases(IGH_DataAccess da, out List<GsaAnalysisCase> cases) {
cases = null;
var ghTypes = new List<GH_ObjectWrapper>();
if (_type != AnalysisTaskType.Footfall) {
if (da.GetDataList(_casesParamIndex, ghTypes)) {
cases = new List<GsaAnalysisCase>();
for (int i = 0; i < ghTypes.Count; i++) {
GH_ObjectWrapper ghTypeWrapper = ghTypes[i];
if (ghTypeWrapper == null) {
this.AddRuntimeWarning($"Analysis Case input (index: {i}) is null and has been ignored");
continue;
}

if (ghTypeWrapper.Value is GsaAnalysisCaseGoo goo) {
cases.Add(goo.Value.Duplicate());
} else {
UnsupportedValueError(ghTypeWrapper);
return false;
switch (_analysisTaskType) {
case AnalysisTaskType.Static:
case AnalysisTaskType.StaticPDelta:
var ghTypes = new List<GH_ObjectWrapper>();
if (da.GetDataList(_casesParamIndex, ghTypes)) {
cases = new List<GsaAnalysisCase>();
for (int i = 0; i < ghTypes.Count; i++) {
GH_ObjectWrapper ghTypeWrapper = ghTypes[i];
if (ghTypeWrapper == null) {
this.AddRuntimeWarning($"Analysis Case input (index: {i}) is null and has been ignored");
continue;
}

if (ghTypeWrapper.Value is GsaAnalysisCaseGoo goo) {
cases.Add(goo.Value.Duplicate());
} else {
UnsupportedValueError(ghTypeWrapper);
}
}
}
}

if (cases == null) {
this.AddRuntimeRemark("Default Task has been created; it will by default contain all cases found in model");
}
} else {
cases = new List<GsaAnalysisCase> {
new GsaAnalysisCase(name, "Footfall")
break;
case AnalysisTaskType.Footfall:
cases = new List<GsaAnalysisCase> {
new GsaAnalysisCase("", "Footfall")
};
break;
default:
break;
}
if (cases == null) {
this.AddRuntimeRemark("Default Task has been created; it will by default contain all cases found in model");
return false;
}

return true;
}

Expand Down Expand Up @@ -360,6 +388,17 @@ private bool CreateFootfallTask(IGH_DataAccess da, string name, out AnalysisTask
return true;
}

private static bool CreateModalDynamicTask(IGH_DataAccess da, string name, out AnalysisTask task) {
task = null;
GsaModalDynamicAnalysisGoo gsaModalDynamicAnalysisGoo = null;
if (da.GetData(2, ref gsaModalDynamicAnalysisGoo)) {
GsaModalDynamicAnalysis dynamicAnalysisParameter = gsaModalDynamicAnalysisGoo.Value;
task = AnalysisTaskFactory.CreateModalDynamicAnalysisTask(name, new ModalDynamicTaskParameter(dynamicAnalysisParameter.ModeCalculationStrategy, dynamicAnalysisParameter.MassOption, dynamicAnalysisParameter.AdditionalMassDerivedFromLoads, dynamicAnalysisParameter.ModalDamping));
return true;
}
return false;
}

private static bool HasValidFrequencyWeightingOption(
int weightingOption, out WeightingOption frequencyWeightingCurve) {
bool hasValidFrequencyWeighting = true;
Expand Down Expand Up @@ -472,16 +511,9 @@ private static bool HasDirectionFromString(out ResponseDirection responseDirecti
return true;
}

protected override void UpdateUIFromSelectedItems() {
_type = _solverTypes[_selectedItems[0]];
UpdateParameters();

base.UpdateUIFromSelectedItems();
}

private void UpdateParameters() {
UnregisterInputsOverTwo();
switch (_type) {
switch (_analysisTaskType) {
case AnalysisTaskType.Static:
_casesParamIndex = 2;
Params.RegisterInputParam(new Param_GenericObject());
Expand Down Expand Up @@ -524,7 +556,12 @@ private void UpdateParameters() {
_casesParamIndex = !IsSelfExcitationSelected() ? 9 : 8;

break;
default: break;
case AnalysisTaskType.ModalDynamic:
Params.RegisterInputParam(new GsaModalDynamicAnalysisParameter());
_casesParamIndex = 2;
break;
default:
break;
}
}

Expand All @@ -537,7 +574,7 @@ private void UpdateDropdownItems() {
"Solver",
});

switch (_type) {
switch (_analysisTaskType) {
case AnalysisTaskType.StaticPDelta:
_spacerDescriptions.Add("P-delta Case");

Expand All @@ -559,14 +596,17 @@ private void UpdateDropdownItems() {
_selectedItems.Add(_excitationMethod[ExcitationMethod.SelfExcitation]);

break;

case AnalysisTaskType.ModalDynamic:
_dropDownItems.Add(_solverTypes.Keys.ToList());
_selectedItems.Add(_dropDownItems[0][3]);
break;
case AnalysisTaskType.Static:
default:
_dropDownItems.Add(_solverTypes.Keys.ToList());
_selectedItems.Add(_dropDownItems[0][0]);
break;
default:
break;
}

ReDrawComponent();
}

Expand Down
Loading
Loading