-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kristjan Nielsen
committed
Oct 17, 2023
1 parent
3a50700
commit bb438e0
Showing
15 changed files
with
169 additions
and
78 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
70 changes: 59 additions & 11 deletions
70
GsaGH/Parameters/5_Results/ResultCollection/GsaNodeDisplacements.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 |
---|---|---|
@@ -1,16 +1,64 @@ | ||
using GsaGH.Parameters.Results; | ||
using System; | ||
using GsaAPI; | ||
using GsaGH.Parameters.Results; | ||
using OasysUnits; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace GsaGH.Parameters { | ||
|
||
public class GsaNodeDisplacements : IResults<GsaDisplacementQuantity> { | ||
public IResultDictionary<IResultCollection<GsaDisplacementQuantity>> ResultCache { | ||
get => throw new NotImplementedException(); | ||
set => throw new NotImplementedException(); | ||
namespace GsaGH.Parameters.Results { | ||
// For now, to be refactored | ||
public class GsaNodeDisplacements : IResultSubset<IDisplacement> { | ||
public IDisplacement Max { get; private set; } | ||
public IDisplacement Min { get; private set; } | ||
public List<int> Ids => Results.Keys.OrderBy(x => x).ToList(); | ||
|
||
/// <summary> | ||
/// Combination Case Node Displacement Result VALUES Dictionary | ||
/// Append to this dictionary to chache results | ||
/// key = nodeId | ||
/// value = Collection of permutations(permutationsResults) | ||
/// </summary> | ||
public ConcurrentDictionary<int, Collection<IDisplacement>> Results { get; } | ||
= new ConcurrentDictionary<int, Collection<IDisplacement>>(); | ||
|
||
internal GsaNodeDisplacements(ReadOnlyDictionary<int, NodeResult> apiAnalysisCaseResults) { | ||
Parallel.ForEach(apiAnalysisCaseResults.Keys, nodeId => { | ||
var res = new GsaDisplacementQuantity(apiAnalysisCaseResults[nodeId].Displacement); | ||
Results.TryAdd(nodeId, new Collection<IDisplacement>() { res }); | ||
}); | ||
UpdateMaxMin(); | ||
} | ||
|
||
internal GsaNodeDisplacements(ReadOnlyDictionary<int, ReadOnlyCollection<NodeResult>> apiCombinationCaseResults) { | ||
Parallel.ForEach(apiCombinationCaseResults.Keys, nodeId => { | ||
var permutationResults = new Collection<IDisplacement>(); | ||
foreach (NodeResult permutationResult in apiCombinationCaseResults[nodeId]) { | ||
permutationResults.Add(new GsaDisplacementQuantity(permutationResult.Displacement)); | ||
} | ||
|
||
Results.TryAdd(nodeId, permutationResults); | ||
}); | ||
UpdateMaxMin(); | ||
} | ||
|
||
public IResultSubset<GsaDisplacementQuantity> GetResultSet(string definition) { | ||
throw new NotImplementedException(); | ||
private void UpdateMaxMin() { | ||
double maxX = Results.AsParallel().Select(list => list.Value.Select(res => res.X.Value).Max()).Max(); | ||
double maxY = Results.AsParallel().Select(list => list.Value.Select(res => res.Y.Value).Max()).Max(); | ||
double maxZ = Results.AsParallel().Select(list => list.Value.Select(res => res.Z.Value).Max()).Max(); | ||
double maxXx = Results.AsParallel().Select(list => list.Value.Select(res => res.Xx.Value).Max()).Max(); | ||
double maxYy = Results.AsParallel().Select(list => list.Value.Select(res => res.Yy.Value).Max()).Max(); | ||
double maxZz = Results.AsParallel().Select(list => list.Value.Select(res => res.Zz.Value).Max()).Max(); | ||
Max = new GsaDisplacementQuantity(new Double6(maxX, maxY, maxZ, maxXx, maxYy, maxZz)); | ||
|
||
double minX = Results.AsParallel().Select(list => list.Value.Select(res => res.X.Value).Min()).Min(); | ||
double minY = Results.AsParallel().Select(list => list.Value.Select(res => res.Y.Value).Min()).Min(); | ||
double minZ = Results.AsParallel().Select(list => list.Value.Select(res => res.Z.Value).Min()).Min(); | ||
double minXx = Results.AsParallel().Select(list => list.Value.Select(res => res.Xx.Value).Min()).Min(); | ||
double minYy = Results.AsParallel().Select(list => list.Value.Select(res => res.Yy.Value).Min()).Min(); | ||
double minZz = Results.AsParallel().Select(list => list.Value.Select(res => res.Zz.Value).Min()).Min(); | ||
Min = new GsaDisplacementQuantity(new Double6(minX, minY, minZ, minXx, minYy, minZz)); | ||
} | ||
} | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
GsaGH/Parameters/5_Results/ResultCollection/GsaResult2.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,101 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using GsaAPI; | ||
using GsaGH.Helpers; | ||
|
||
namespace GsaGH.Parameters.Results { | ||
|
||
public class GsaResult2 { | ||
// API Global results | ||
internal AnalysisCaseResult AnalysisCaseResult { get; set; } | ||
internal CombinationCaseResult CombinationCaseResult { get; set; } | ||
|
||
// API Node results (will not be needed after GSA-7517) | ||
internal Dictionary<string, ReadOnlyDictionary<int, NodeResult>> AnalysisCaseNodeResults { get; set; } | ||
= new Dictionary<string, ReadOnlyDictionary<int, NodeResult>>(); | ||
|
||
internal Dictionary<string, ReadOnlyDictionary<int, ReadOnlyCollection<NodeResult>>> | ||
CombinationCaseNodeResults { get; set; } | ||
= new Dictionary<string, ReadOnlyDictionary<int, ReadOnlyCollection<NodeResult>>>(); | ||
|
||
// Caches | ||
internal Dictionary<string, GsaNodeDisplacements> NodeDisplacementCache { get; set; } | ||
= new Dictionary<string, GsaNodeDisplacements>(); | ||
|
||
// Other members | ||
internal int CaseId { get; set; } | ||
internal string CaseName { get; set; } | ||
internal GsaModel Model { get; set; } | ||
|
||
internal List<int> SelectedPermutationIds { get; set; } | ||
internal CaseType CaseType { get; set; } | ||
|
||
public GsaResult2() { } | ||
|
||
internal GsaResult2(GsaModel model, AnalysisCaseResult result, int caseId) { | ||
Model = model; | ||
AnalysisCaseResult = result; | ||
CaseType = CaseType.AnalysisCase; | ||
CaseId = caseId; | ||
CaseName = model.Model.AnalysisCaseName(CaseId); | ||
} | ||
|
||
internal GsaResult2( | ||
GsaModel model, CombinationCaseResult result, int caseId, IEnumerable<int> permutations) { | ||
Model = model; | ||
CombinationCaseResult = result; | ||
CaseType = CaseType.CombinationCase; | ||
CaseId = caseId; | ||
SelectedPermutationIds = permutations.OrderBy(x => x).ToList(); | ||
} | ||
|
||
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 GsaNodeDisplacements NodeDisplacementValues(string nodelist) { | ||
if (nodelist.ToLower() == "all" || nodelist == string.Empty) { | ||
nodelist = "All"; | ||
} | ||
|
||
if (!NodeDisplacementCache.ContainsKey(nodelist)) { | ||
switch (CaseType) { | ||
case CaseType.AnalysisCase: | ||
if (!AnalysisCaseNodeResults.ContainsKey(nodelist)) { | ||
AnalysisCaseNodeResults.Add(nodelist, AnalysisCaseResult.NodeResults(nodelist)); | ||
} | ||
|
||
NodeDisplacementCache.Add(nodelist, new GsaNodeDisplacements(AnalysisCaseNodeResults[nodelist])); | ||
break; | ||
|
||
case CaseType.CombinationCase: | ||
if (!CombinationCaseNodeResults.ContainsKey(nodelist)) { | ||
CombinationCaseNodeResults.Add(nodelist, CombinationCaseResult.NodeResults(nodelist)); | ||
} | ||
|
||
NodeDisplacementCache.Add(nodelist, new GsaNodeDisplacements(CombinationCaseNodeResults[nodelist])); | ||
break; | ||
} | ||
} | ||
|
||
return NodeDisplacementCache[nodelist]; | ||
} | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
GsaGH/Parameters/5_Results/ResultCollection/IElement1dResult.cs
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
GsaGH/Parameters/5_Results/ResultCollection/IElement2dResult.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
GsaGH/Parameters/5_Results/ResultCollection/IResultCollection.cs
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
GsaGH/Parameters/5_Results/ResultCollection/IResultDictionary.cs
This file was deleted.
Oops, something went wrong.
11 changes: 7 additions & 4 deletions
11
GsaGH/Parameters/5_Results/ResultCollection/IResultSubset.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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace GsaGH.Parameters.Results { | ||
public interface IResultSubset<IResult> : IResultDictionary<IResult> { | ||
public IResult Max { get; set; } | ||
public IResult Min { get; set; } | ||
public interface IResultSubset<IResult> { | ||
public IResult Max { get; } | ||
public IResult Min { get; } | ||
public List<int> Ids { get; } | ||
public ConcurrentDictionary<int, Collection<IResult>> Results { get; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.