-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* updated component Elem2d Forces and Moments * fix * fix extrema helper * wip * wip * fix footfall * fix unit tests * fix deserialisation * #595 (comment) --------- Co-authored-by: DominikaLos <[email protected]>
- Loading branch information
1 parent
aadcdfb
commit a208e5b
Showing
9 changed files
with
590 additions
and
376 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,42 @@ | ||
using GsaAPI; | ||
using GsaGH.Parameters; | ||
using GsaGH.Parameters.Results; | ||
using Rhino.Geometry; | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace GsaGH.Helpers { | ||
public static class Quarterion { | ||
internal static Entity1dDisplacements CoordinateTransformationTo(ConcurrentDictionary<int, Collection<IEntity1dDisplacement>> displacementSubset, Plane plane, Model model) { | ||
var values = new ConcurrentDictionary<int, Collection<IEntity1dDisplacement>>(); | ||
Parallel.ForEach(displacementSubset, kvp => { | ||
var localAxes = new LocalAxes(model.ElementDirectionCosine(kvp.Key)); | ||
var local = new Plane(Point3d.Origin, localAxes.X, localAxes.Y); | ||
var q = Quaternion.Rotation(plane, local); | ||
q.GetRotation(out double angle, out Vector3d axis); | ||
if (angle > Math.PI) { | ||
angle -= 2 * Math.PI; | ||
} | ||
|
||
var permutationResults = new Collection<IEntity1dDisplacement>(); | ||
foreach (IEntity1dDisplacement permutation in kvp.Value) { | ||
var results = new Collection<Double6>(); | ||
foreach (IDisplacement result in permutation.Results.Values) { | ||
var d = new Point3d(result.X.Meters, result.Y.Meters, result.Z.Meters); | ||
d.Transform(Transform.Rotation(angle, axis, Point3d.Origin)); | ||
var r = new Point3d(result.Xx.Radians, result.Yy.Radians, result.Zz.Radians); | ||
r.Transform(Transform.Rotation(angle, axis, Point3d.Origin)); | ||
results.Add(new Double6(d.X, d.Y, d.Z, r.X, r.Y, r.Z)); | ||
} | ||
permutationResults.Add(new Entity1dDisplacement(new ReadOnlyCollection<Double6>(results), | ||
new ReadOnlyCollection<double>(permutation.Results.Keys.ToList()))); | ||
} | ||
values.TryAdd(kvp.Key, permutationResults); | ||
}); | ||
return new Entity1dDisplacements(values); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
GsaGH/Parameters/5_Results/4_Subsets/Entity1dResultsUtility.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,33 @@ | ||
using OasysUnits; | ||
using OasysUnits.Units; | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace GsaGH.Parameters.Results { | ||
public static partial class ResultsUtility { | ||
public static ConcurrentDictionary<int, List<IQuantity>> GetResultComponent<T1, T2>( | ||
ConcurrentDictionary<int, Collection<T1>> subset, Func<T2, IQuantity> selector, int permutation = 0) | ||
where T1 : IEntity1dQuantity<T2> where T2 : IResultItem { | ||
var vals = new ConcurrentDictionary<int, List<IQuantity>>(); | ||
Parallel.ForEach(subset, kvp => | ||
vals.TryAdd(kvp.Key, kvp.Value[permutation].Results.Values.Select(selector).ToList())); | ||
return vals; | ||
} | ||
|
||
public static ConcurrentDictionary<int, (List<double> x, List<double> y, List<double> z)> GetResultResultanTranslation( | ||
ConcurrentDictionary<int, Collection<IEntity1dDisplacement>> subset, LengthUnit unit, int permutation = 0) { | ||
var vals = new ConcurrentDictionary<int, (List<double> x, List<double> y, List<double> z)>(); | ||
Parallel.ForEach(subset, kvp => | ||
vals.TryAdd(kvp.Key, ( | ||
kvp.Value[permutation].Results.Values.Select(r => r.X.As(unit)).ToList(), | ||
kvp.Value[permutation].Results.Values.Select(r => r.Y.As(unit)).ToList(), | ||
kvp.Value[permutation].Results.Values.Select(r => r.Z.As(unit)).ToList() | ||
))); | ||
return vals; | ||
} | ||
} | ||
} |
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,40 @@ | ||
using GsaAPI; | ||
using OasysUnits; | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace GsaGH.Parameters.Results { | ||
public static partial class ResultsUtility { | ||
internal static (ConcurrentDictionary<int, List<IQuantity>> values, ICollection<int> nodeIds) | ||
MapNodeResultToElements<T1, T2>( | ||
ReadOnlyDictionary<int, Element> elements, INodeResultCache<T1, T2> nodeResultsCache, | ||
Func<T1, IQuantity> selector, int permutation = 0) where T1 : IResultItem { | ||
var vals = new ConcurrentDictionary<int, List<IQuantity>>(); | ||
var topology = new ConcurrentBag<int>(); | ||
Parallel.ForEach(elements, kvp => { | ||
var list = new List<IQuantity>(); | ||
IDictionary<int, Collection<T1>> subset = nodeResultsCache.ResultSubset(kvp.Value.Topology).Subset; | ||
if (subset.Count == 0) { | ||
return; | ||
} | ||
|
||
foreach (int nodeId in kvp.Value.Topology) { | ||
list.Add(subset[nodeId].Select(selector).ElementAt(permutation)); | ||
topology.Add(nodeId); | ||
} | ||
|
||
if (kvp.Value.Topology.Count > 2) { | ||
list.Add(list.Average(list[0].Unit)); | ||
} | ||
|
||
vals.TryAdd(kvp.Key, list); | ||
}); | ||
|
||
return (vals, topology.Distinct().ToList()); | ||
} | ||
} | ||
} |
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
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