Skip to content

Commit

Permalink
Merge branch 'main' into task/GsaGH-389-remove-tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristjan Nielsen committed Oct 9, 2023
2 parents 9ba5b29 + 45e44f9 commit 9cf2443
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 130 deletions.
28 changes: 15 additions & 13 deletions GsaGH/Components/0_Model/GetModelGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private enum FoldMode {
private FoldMode _mode = FoldMode.List;
private ConcurrentBag<GsaNodeGoo> _supportNodes;
private bool _showSupports = true;
private SolveResults _results;

public GetModelGeometry() : base("Get Model Geometry", "GetGeo",
"Get nodes, elements and members from GSA model", CategoryName.Name(),
Expand Down Expand Up @@ -416,7 +417,6 @@ protected override void SolveInstance(IGH_DataAccess data) {
if (InPreSolve) {
GsaModelGoo modelGoo = null;
data.GetData(0, ref modelGoo);
_boundingBox = modelGoo.Value.BoundingBox;

bool nodeFilterHasInput = false;
bool elementFilterHasInput = false;
Expand Down Expand Up @@ -468,7 +468,7 @@ protected override void SolveInstance(IGH_DataAccess data) {
if (!GetSolveResults(data, out SolveResults results)) {
GsaModelGoo modelGoo = null;
data.GetData(0, ref modelGoo);

GsaListGoo nodeListGoo = null;
string nodeList = "all";
if (data.GetData(1, ref nodeListGoo)) {
Expand Down Expand Up @@ -679,7 +679,7 @@ protected override void SolveInstance(IGH_DataAccess data) {
}

private SolveResults Compute(GsaModel model, string nodeList, string elemList, string memList) {
var results = new SolveResults();
_results = new SolveResults();
var steps = new List<int> {
0, 1, 2,
};
Expand All @@ -688,38 +688,40 @@ private SolveResults Compute(GsaModel model, string nodeList, string elemList, s
model.ModelUnit = _lengthUnit;
}

_boundingBox = model.BoundingBox;

try {
Parallel.ForEach(steps, i => {
switch (i) {
case 0:
results.Nodes = Nodes.GetNodes(
_results.Nodes = Nodes.GetNodes(
nodeList.ToLower() == "all" ? model.ApiNodes : model.Model.Nodes(nodeList),
model.ModelUnit,
model.ApiAxis);
results.DisplaySupports
= new ConcurrentBag<GsaNodeGoo>(results.Nodes.Where(n => n.Value.IsSupport));
_results.DisplaySupports
= new ConcurrentBag<GsaNodeGoo>(_results.Nodes.Where(n => n.Value.IsSupport));
break;

case 1:
var elements = new Elements(model, elemList);
results.Elem1ds = elements.Element1ds;
results.Elem2ds = elements.Element2ds;
results.Elem3ds = elements.Element3ds;
_results.Elem1ds = elements.Element1ds;
_results.Elem2ds = elements.Element2ds;
_results.Elem3ds = elements.Element3ds;
break;

case 2:
var members = new Members(model, memList, this);
results.Mem1ds = members.Member1ds;
results.Mem2ds = members.Member2ds;
results.Mem3ds = members.Member3ds;
_results.Mem1ds = members.Member1ds;
_results.Mem2ds = members.Member2ds;
_results.Mem3ds = members.Member3ds;
break;
}
});
} catch (Exception e) {
this.AddRuntimeWarning(e.InnerException?.Message);
}

return results;
return _results;
}

internal void GraftModeClicked(object sender, EventArgs e) {
Expand Down
4 changes: 4 additions & 0 deletions GsaGH/Components/6_Display/Contour1dResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ var footfallType

var elems = new ConcurrentDictionary<int, Element>(result.Model.Model.Elements(elementlist));
var nodes = new ConcurrentDictionary<int, Node>(result.Model.Model.Nodes());
if (elems.Count == 0) {
this.AddRuntimeError($"Model contains no results for elements in list '{elementlist}'");
return;
};

ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xyzResults
= res.XyzResults;
Expand Down
4 changes: 4 additions & 0 deletions GsaGH/Components/6_Display/Contour2dResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,10 @@ var footfallType

ReadOnlyDictionary<int, Element> elems = result.Model.Model.Elements(elementlist);
ReadOnlyDictionary<int, Node> nodes = result.Model.Model.Nodes();
if (elems.Count == 0) {
this.AddRuntimeError($"Model contains no results for elements in list '{elementlist}'");
return;
};

ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xyzResults
= _isShear ? resShear.XyzResults : res.XyzResults;
Expand Down
9 changes: 6 additions & 3 deletions GsaGH/Components/6_Display/Contour3dResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,10 @@ protected override void SolveInternal(IGH_DataAccess da) {

ReadOnlyDictionary<int, Element> elems = result.Model.Model.Elements(elementlist);
ReadOnlyDictionary<int, Node> nodes = result.Model.Model.Nodes();
if (elems.Count == 0) {
this.AddRuntimeError($"Model contains no results for elements in list '{elementlist}'");
return;
};

ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xyzResults
= res.XyzResults;
Expand Down Expand Up @@ -676,9 +680,8 @@ ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xxyyzzRe
break;
}

for (int i = 0; i < vals.Count - 1;
i++) // start at i=0, now the last index is the centre point in GsaAPI output so to count -1
{
// start at i=0, now the last index is the centre point in GsaAPI output so to count -1
for (int i = 0; i < tempmesh.Vertices.Count; i++) {
double tnorm = (2 * (vals[i].Value - dmin) / (dmax - dmin)) - 1;
Color col = double.IsNaN(tnorm) ? Color.Transparent : ghGradient.ColourAt(tnorm);
tempmesh.VertexColors.Add(col);
Expand Down
4 changes: 4 additions & 0 deletions GsaGH/Components/6_Display/ContourNodeResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,10 @@ var footfallType
}

ReadOnlyDictionary<int, Node> nodes = result.Model.Model.Nodes(nodeList);
if (nodes.Count == 0) {
this.AddRuntimeError($"Model contains no results for nodes in list '{nodeList}'");
return;
}

ConcurrentDictionary<int, ConcurrentDictionary<int, GsaResultQuantity>> xyzResults
= res.XyzResults;
Expand Down
Loading

0 comments on commit 9cf2443

Please sign in to comment.