-
Notifications
You must be signed in to change notification settings - Fork 11
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-560: Analysis task is missing when adding 1D geometries or Loads from other models #722
base: release/10.2.14
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
using GsaGH.Helpers.Assembly; | ||
using GsaGH.Helpers.GsaApi.EnumMappings; | ||
using GsaGH.Helpers.Import; | ||
using GsaGH.Parameters; | ||
|
||
using GsaGHTests.Helper; | ||
|
@@ -130,5 +131,78 @@ public void TestModelLengthUnit() { | |
|
||
Assert.Equal(LengthUnit.Foot, UnitMapping.GetUnit(m.ApiModel.UiUnits().LengthLarge)); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0)] | ||
[InlineData(1)] | ||
[InlineData(2)] | ||
public void ModalAnalysisTaskAreCopiedInDuplicateModel(int methodId) { | ||
var original = new GsaModel(); | ||
int numberOfMode = 5; | ||
// Task | ||
var massOption = new MassOption(ModalMassOption.LumpMassAtNode, 1); | ||
var additionalMassDerivedFromLoads = new AdditionalMassDerivedFromLoads( | ||
"L1", | ||
Direction.Z, | ||
1 | ||
); | ||
var ModalDamping = new ModalDamping(0.5); | ||
var modalDynamicTaskParameter = new ModalDynamicTaskParameter( | ||
ModeCalculationMethod(methodId, numberOfMode), | ||
massOption, | ||
additionalMassDerivedFromLoads, | ||
ModalDamping | ||
); | ||
|
||
int taskId = original.ApiModel.AddAnalysisTask( | ||
AnalysisTaskFactory.CreateModalDynamicAnalysisTask( | ||
"task1", | ||
modalDynamicTaskParameter | ||
) | ||
); | ||
for (int mode = 1; mode <= numberOfMode; mode++) { | ||
original.ApiModel.AddAnalysisCaseToTask(taskId, "test case", mode); | ||
} | ||
System.Collections.ObjectModel.ReadOnlyDictionary<int, AnalysisTask> taskIn = original.ApiModel.AnalysisTasks(); | ||
|
||
//assemble model and get task | ||
var analysis = new GsaAnalysis(); | ||
foreach (KeyValuePair<int, AnalysisTask> analysisTask in taskIn) { | ||
analysis.AnalysisTasks.Add(new GsaAnalysisTask(analysisTask.Key, analysisTask.Value, original.ApiModel)); | ||
} | ||
var assembly = new ModelAssembly(new GsaModel(), null, null, null, null, null, analysis, | ||
LengthUnit.Meter, Length.Zero, false, null); | ||
var assembled = new GsaModel() { | ||
ApiModel = assembly.GetModel() | ||
}; | ||
System.Collections.ObjectModel.ReadOnlyDictionary<int, AnalysisTask> taskOut = assembled.ApiModel.AnalysisTasks(); | ||
|
||
Assert.Equal(taskIn.Count, taskIn.Count); | ||
foreach (int key in taskIn.Keys) { | ||
Assert.Equal(taskIn[key].Name, taskOut[key].Name); | ||
foreach (int caseId in taskIn[key].Cases) { | ||
Assert.Equal(assembled.ApiModel.AnalysisCaseName(caseId), original.ApiModel.AnalysisCaseName(caseId)); | ||
Assert.Equal(assembled.ApiModel.AnalysisCaseDescription(caseId), original.ApiModel.AnalysisCaseDescription(caseId)); | ||
} | ||
} | ||
} | ||
Comment on lines
+139
to
+188
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is too big Can you create one test per exist condition of your new method? You need 3 tests where the |
||
internal ModeCalculationStrategy ModeCalculationMethod(int Id, int numberOfMode) { | ||
switch (Id) { | ||
case 0: | ||
return new ModeCalculationStrategyByNumberOfModes(numberOfMode); | ||
case 1: | ||
return new ModeCalculationStrategyByFrequency(2, 15, numberOfMode); | ||
case 2: | ||
return new ModeCalculationStrategyByMassParticipation( | ||
85, | ||
92, | ||
10, | ||
numberOfMode, | ||
true | ||
); | ||
default: | ||
throw new InvalidOperationException("not supported"); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you create a test, where we return zero? Why the try catch? Perhaps we do catch on the method above and leave this private one to throw the error?