Skip to content

Commit

Permalink
Merge branch 'main' into release/GsaGH-1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kpne authored Oct 6, 2023
2 parents cc0cc54 + 80a217a commit 3be9f6c
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 117 deletions.
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 @@ -502,6 +502,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
178 changes: 129 additions & 49 deletions GsaGH/Helpers/GsaAPI/Results/AnalysisCaseQuantities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ internal static GsaResultsValues GetElement1DResultValues(
ReadOnlyCollection<Double6> values = elementResults.Force;
Parallel.For(0, values.Count, i => {
Double6 result = values[i];
xyzRes[i] = GetQuantityResult(result, forceUnit, true);
xxyyzzRes[i] = GetQuantityResult(result, momentUnit, true);
if (!double.IsNaN(values[i].X) && !double.IsNaN(values[i].Y) && !double.IsNaN(values[i].Z)) {
xyzRes[i] = GetQuantityResult(result, forceUnit, true);
}

if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) && !double.IsNaN(values[i].ZZ)) {
xxyyzzRes[i] = GetQuantityResult(result, momentUnit, true);
}
});
r.XyzResults.TryAdd(key, xyzRes);
r.XxyyzzResults.TryAdd(key, xxyyzzRes);
Expand Down Expand Up @@ -105,8 +110,13 @@ internal static GsaResultsValues GetElement1DResultValues(
ReadOnlyCollection<Double6> values = elementResults.Displacement;
Parallel.For(0, values.Count, i => {
Double6 result = values[i];
xyzRes[i] = GetQuantityResult(result, resultLengthUnit);
xxyyzzRes[i] = GetQuantityResult(result, AngleUnit.Radian);
if (!double.IsNaN(values[i].X) && !double.IsNaN(values[i].Y) && !double.IsNaN(values[i].Z)) {
xyzRes[i] = GetQuantityResult(result, resultLengthUnit);
}

if (!double.IsNaN(values[i].XX) && !double.IsNaN(values[i].YY) && !double.IsNaN(values[i].ZZ)) {
xxyyzzRes[i] = GetQuantityResult(result, AngleUnit.Radian);
}
});
r.XyzResults.TryAdd(key, xyzRes);
r.XxyyzzResults.TryAdd(key, xxyyzzRes);
Expand Down Expand Up @@ -141,16 +151,26 @@ internal static GsaResultsValues GetElement2DResultValues(
return;
}

if (i < stresses.Count) {
if (i < stresses.Count && !double.IsNaN(stresses[i].XX) &&
!double.IsNaN(stresses[i].YY) && !double.IsNaN(stresses[i].ZZ)) {
xyzRes[i] = GetQuantityResult(stresses[i], stressUnit);
} else {
} else if (!double.IsNaN(stresses[i - stresses.Count].XY)
&& !double.IsNaN(stresses[i - stresses.Count].YZ)
&& !double.IsNaN(stresses[i - stresses.Count].ZX)) {
xxyyzzRes[i - stresses.Count]
= GetQuantityResult(stresses[i - stresses.Count], stressUnit, true);
}
});
xyzRes[stresses.Count]
= GetQuantityResult(stresses[0], stressUnit); // add centre point at the end
xxyyzzRes[stresses.Count] = GetQuantityResult(stresses[0], stressUnit, true);

if (!double.IsNaN(stresses[0].XX) && !double.IsNaN(stresses[0].YY)
&& !double.IsNaN(stresses[0].ZZ)) {
xyzRes[stresses.Count] = GetQuantityResult(stresses[0], stressUnit); // add centre point at the end
}

if (!double.IsNaN(stresses[0].XY) && !double.IsNaN(stresses[0].YZ)
&& !double.IsNaN(stresses[0].ZX)) {
xxyyzzRes[stresses.Count] = GetQuantityResult(stresses[0], stressUnit, true);
}

r.XyzResults.TryAdd(key, xyzRes);
r.XxyyzzResults.TryAdd(key, xxyyzzRes);
Expand Down Expand Up @@ -180,9 +200,16 @@ internal static GsaResultsValues GetElement2DResultValues(
xxyyzzRes.AsParallel().AsOrdered();

ReadOnlyCollection<Vector2> shears = elementResults.Shear;
Parallel.For(1, shears.Count, i => xyzRes[i] = GetQuantityResult(shears[i], forceUnit));
xyzRes[shears.Count]
= GetQuantityResult(shears[0], forceUnit); // add centre point at the end
Parallel.For(1, shears.Count, i => {
if (!double.IsNaN(shears[i].X) && !double.IsNaN(shears[i].Y)) {
xyzRes[i] = GetQuantityResult(shears[i], forceUnit);
}
});

if (!double.IsNaN(shears[0].X) && !double.IsNaN(shears[0].Y)) {
// add centre point at the end
xyzRes[shears.Count] = GetQuantityResult(shears[0], forceUnit);
}

r.XyzResults.TryAdd(key, xyzRes);
r.XxyyzzResults.TryAdd(key, xxyyzzRes);
Expand Down Expand Up @@ -220,15 +247,26 @@ internal static GsaResultsValues GetElement2DResultValues(
return;
}

if (i < forces.Count) {
if (i < forces.Count && !double.IsNaN(forces[i].XX) && !double.IsNaN(forces[i].YY)
&& !double.IsNaN(forces[i].XY)) {
xyzRes[i] = GetQuantityResult(forces[i], forceUnit);
} else {
} else if (!double.IsNaN(moments[i - forces.Count].XX)
&& !double.IsNaN(moments[i - forces.Count].YY)
&& !double.IsNaN(moments[i - forces.Count].XY)) {
xxyyzzRes[i - forces.Count] = GetQuantityResult(moments[i - forces.Count], momentUnit);
}
});
xyzRes[forces.Count]
= GetQuantityResult(forces[0], forceUnit); // add centre point at the end
xxyyzzRes[moments.Count] = GetQuantityResult(moments[0], momentUnit);

if (!double.IsNaN(forces[0].XX) && !double.IsNaN(forces[0].YY)
&& !double.IsNaN(forces[0].XY)) {
// add centre point at the end
xyzRes[forces.Count] = GetQuantityResult(forces[0], forceUnit);
}

if (!double.IsNaN(moments[0].XX) && !double.IsNaN(moments[0].YY)
&& !double.IsNaN(moments[0].XY)) {
xxyyzzRes[moments.Count] = GetQuantityResult(moments[0], momentUnit);
}

Parallel.ForEach(xxyyzzRes.Keys, i => {
xyzRes[i].Xyz = new Force(
Expand Down Expand Up @@ -272,15 +310,24 @@ internal static GsaResultsValues GetElement2DResultValues(
return;
}

if (i < disp.Count) {
if (i < disp.Count && !double.IsNaN(disp[i].X) && !double.IsNaN(disp[i].Y)
&& !double.IsNaN(disp[i].Z)) {
xyzRes[i] = GetQuantityResult(disp[i], resultLengthUnit);
} else {
} else if (!double.IsNaN(disp[i - disp.Count].XX)
&& !double.IsNaN(disp[i - disp.Count].YY)
&& !double.IsNaN(disp[i - disp.Count].ZZ)) {
xxyyzzRes[i - disp.Count] = GetQuantityResult(disp[i - disp.Count], AngleUnit.Radian);
}
});
xyzRes[disp.Count]
= GetQuantityResult(disp[0], resultLengthUnit); // add centre point at the end
xxyyzzRes[disp.Count - disp.Count] = GetQuantityResult(disp[0], AngleUnit.Radian);

if (!double.IsNaN(disp[0].X) && !double.IsNaN(disp[0].Y) && !double.IsNaN(disp[0].Z)) {
// add centre point at the end
xyzRes[disp.Count] = GetQuantityResult(disp[0], resultLengthUnit);
}

if (!double.IsNaN(disp[0].XX) && !double.IsNaN(disp[0].YY) && !double.IsNaN(disp[0].ZZ)) {
xxyyzzRes[disp.Count] = GetQuantityResult(disp[0], AngleUnit.Radian);
}

r.XyzResults.TryAdd(key, xyzRes);
r.XxyyzzResults.TryAdd(key, xxyyzzRes);
Expand Down Expand Up @@ -308,10 +355,17 @@ internal static GsaResultsValues GetElement3DResultValues(
xyzRes.AsParallel().AsOrdered();

ReadOnlyCollection<Double3> transVals = elementResults.Displacement;
Parallel.For(1, transVals.Count,
i => xyzRes[i] = GetQuantityResult(transVals[i], resultLengthUnit));
xyzRes[transVals.Count]
= GetQuantityResult(transVals[0], resultLengthUnit); // add centre point at the end
Parallel.For(1, transVals.Count, i => {
if (!double.IsNaN(transVals[i].X) && !double.IsNaN(transVals[i].Y) && !double.IsNaN(transVals[i].Z)) {
xyzRes[i] = GetQuantityResult(transVals[i], resultLengthUnit);
}
});

if (!double.IsNaN(transVals[0].X) && !double.IsNaN(transVals[0].Y) && !double.IsNaN(transVals[0].Z)) {
// add centre point at the end
xyzRes[transVals.Count] = GetQuantityResult(transVals[0], resultLengthUnit);
}

r.XyzResults.TryAdd(key, xyzRes);
});

Expand Down Expand Up @@ -344,16 +398,27 @@ internal static GsaResultsValues GetElement3DResultValues(
return;
}

if (i < stressVals.Count) {
if (i < stressVals.Count && !double.IsNaN(stressVals[i].XX)
&& !double.IsNaN(stressVals[i].YY) && !double.IsNaN(stressVals[i].ZZ)) {
xyzRes[i] = GetQuantityResult(stressVals[i], stressUnit);
} else {
} else if (!double.IsNaN(stressVals[i - stressVals.Count].XY)
&& !double.IsNaN(stressVals[i - stressVals.Count].YZ)
&& !double.IsNaN(stressVals[i - stressVals.Count].ZX)) {
xxyyzzRes[i - stressVals.Count]
= GetQuantityResult(stressVals[i - stressVals.Count], stressUnit, true);
}
});
xyzRes[stressVals.Count]
= GetQuantityResult(stressVals[0], stressUnit); // add centre point at the end
xxyyzzRes[stressVals.Count] = GetQuantityResult(stressVals[0], stressUnit, true);

if (!double.IsNaN(stressVals[0].XX)
&& !double.IsNaN(stressVals[0].YY) && !double.IsNaN(stressVals[0].ZZ)) {
// add centre point at the end
xyzRes[stressVals.Count] = GetQuantityResult(stressVals[0], stressUnit);
}

if (!double.IsNaN(stressVals[0].XY)
&& !double.IsNaN(stressVals[0].YZ) && !double.IsNaN(stressVals[0].ZX)) {
xxyyzzRes[stressVals.Count] = GetQuantityResult(stressVals[0], stressUnit, true);
}

r.XyzResults.TryAdd(key, xyzRes);
r.XxyyzzResults.TryAdd(key, xxyyzzRes);
Expand Down Expand Up @@ -389,12 +454,17 @@ internal static GsaResultsValues GetNodeReactionForceResultValues(
}
}

var xyz = new ConcurrentDictionary<int, GsaResultQuantity>();
xyz.TryAdd(0, GetQuantityResult(values, forceUnit));
r.XyzResults.TryAdd(nodeId, xyz);
var xxyyzz = new ConcurrentDictionary<int, GsaResultQuantity>();
xxyyzz.TryAdd(0, GetQuantityResult(values, momentUnit));
r.XxyyzzResults.TryAdd(nodeId, xxyyzz);
if (!double.IsNaN(values.X) && !double.IsNaN(values.Y) && !double.IsNaN(values.Z)) {
var xyz = new ConcurrentDictionary<int, GsaResultQuantity>();
xyz.TryAdd(0, GetQuantityResult(values, forceUnit));
r.XyzResults.TryAdd(nodeId, xyz);
}

if (!double.IsNaN(values.XX) && !double.IsNaN(values.YY) && !double.IsNaN(values.ZZ)) {
var xxyyzz = new ConcurrentDictionary<int, GsaResultQuantity>();
xxyyzz.TryAdd(0, GetQuantityResult(values, momentUnit));
r.XxyyzzResults.TryAdd(nodeId, xxyyzz);
}
});

r.UpdateMinMax();
Expand All @@ -417,12 +487,17 @@ internal static GsaResultsValues GetNodeResultValues(
NodeResult result = globalResults[nodeId];
Double6 values = result.Displacement;

var xyz = new ConcurrentDictionary<int, GsaResultQuantity>();
xyz.TryAdd(0, GetQuantityResult(values, resultLengthUnit));
r.XyzResults.TryAdd(nodeId, xyz);
var xxyyzz = new ConcurrentDictionary<int, GsaResultQuantity>();
xxyyzz.TryAdd(0, GetQuantityResult(values, AngleUnit.Radian));
r.XxyyzzResults.TryAdd(nodeId, xxyyzz);
if (!double.IsNaN(values.X) && !double.IsNaN(values.Y) && !double.IsNaN(values.Z)) {
var xyz = new ConcurrentDictionary<int, GsaResultQuantity>();
xyz.TryAdd(0, GetQuantityResult(values, resultLengthUnit));
r.XyzResults.TryAdd(nodeId, xyz);
}

if (!double.IsNaN(values.XX) && !double.IsNaN(values.YY) && !double.IsNaN(values.ZZ)) {
var xxyyzz = new ConcurrentDictionary<int, GsaResultQuantity>();
xxyyzz.TryAdd(0, GetQuantityResult(values, AngleUnit.Radian));
r.XxyyzzResults.TryAdd(nodeId, xxyyzz);
}
});

r.UpdateMinMax();
Expand Down Expand Up @@ -456,12 +531,17 @@ internal static GsaResultsValues GetNodeSpringForceResultValues(
}
}

var xyz = new ConcurrentDictionary<int, GsaResultQuantity>();
xyz.TryAdd(0, GetQuantityResult(values, forceUnit));
r.XyzResults.TryAdd(nodeId, xyz);
var xxyyzz = new ConcurrentDictionary<int, GsaResultQuantity>();
xxyyzz.TryAdd(0, GetQuantityResult(values, momentUnit));
r.XxyyzzResults.TryAdd(nodeId, xxyyzz);
if (!double.IsNaN(values.X) && !double.IsNaN(values.Y) && !double.IsNaN(values.Z)) {
var xyz = new ConcurrentDictionary<int, GsaResultQuantity>();
xyz.TryAdd(0, GetQuantityResult(values, forceUnit));
r.XyzResults.TryAdd(nodeId, xyz);
}

if (!double.IsNaN(values.XX) && !double.IsNaN(values.YY) && !double.IsNaN(values.ZZ)) {
var xxyyzz = new ConcurrentDictionary<int, GsaResultQuantity>();
xxyyzz.TryAdd(0, GetQuantityResult(values, momentUnit));
r.XxyyzzResults.TryAdd(nodeId, xxyyzz);
}
});

r.UpdateMinMax();
Expand Down
Loading

0 comments on commit 3be9f6c

Please sign in to comment.