Skip to content

Commit

Permalink
Update Lusas gravity load conversion to push and pull. (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraser Greenroyd authored Nov 29, 2023
2 parents b9a7f9e + fbecebc commit a680c5b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Lusas_Adapter/CRUD/Create/Loads/GravityLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using BH.oM.Structure.Loads;
using BH.Engine.Adapter;
using Lusas.LPI;
using BH.oM.Geometry;

namespace BH.Adapter.Lusas
{
Expand All @@ -47,15 +48,15 @@ private IFLoadingBody CreateGravityLoad(GravityLoad gravityLoad, IFGeometry[] lu
{
IFLoadingBody lusasGravityLoad;
IFLoadcase assignedLoadcase = (IFLoadcase)d_LusasData.getLoadset(gravityLoad.Loadcase.AdapterId<int>(typeof(LusasId)));

if (d_LusasData.existsAttribute("Loading", gravityLoad.Name))
{
lusasGravityLoad = (IFLoadingBody)d_LusasData.getAttributes("Loading", gravityLoad.Name);
}
else
{
lusasGravityLoad = d_LusasData.createLoadingBody(gravityLoad.Name);
lusasGravityLoad.setBody(gravityLoad.GravityDirection.X, gravityLoad.GravityDirection.Y, gravityLoad.GravityDirection.Z);
lusasGravityLoad.setBody(gravityLoad.GravityDirection.X * m_g, gravityLoad.GravityDirection.Y * m_g, gravityLoad.GravityDirection.Z * m_g);
}

IFAssignment lusasAssignment = m_LusasApplication.assignment();
Expand Down
4 changes: 2 additions & 2 deletions Lusas_Adapter/CRUD/Read/Loads/GravityLoads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ private List<ILoad> ReadGravityLoads(List<string> ids = null)
foreach (IEnumerable<IFAssignment> groupedAssignment in groupedByLoadcases)
{
List<string> analysisName = new List<string> { lusasBodyForce.getAttributeType() };

GravityLoad gravityLoad = Adapters.Lusas.Convert.ToGravityLoad(
lusasBodyForce, groupedAssignment, nodes, bars, panels);
lusasBodyForce, groupedAssignment, nodes, bars, panels, m_g);
gravityLoad.Tags = new HashSet<string>(analysisName);
gravityLoads.Add(gravityLoad);
}
Expand Down
10 changes: 6 additions & 4 deletions Lusas_Adapter/Convert/ToBHoM/Loads/ToGravityLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ public static GravityLoad ToGravityLoad(IFLoading lusasGravityLoad,
IEnumerable<IFAssignment> lusasAssignments,
Dictionary<string, Node> nodes,
Dictionary<string, Bar> bars,
Dictionary<string, Panel> panels)
Dictionary<string, Panel> panels,
double g)

{
IFLoadcase assignedLoadcase = (IFLoadcase)lusasAssignments.First().getAssignmentLoadset();
Loadcase loadcase = ToLoadcase(assignedLoadcase);
Vector gravityVector = new Vector
{
X = lusasGravityLoad.getValue("accX"),
Y = lusasGravityLoad.getValue("accY"),
Z = lusasGravityLoad.getValue("accZ")
X = lusasGravityLoad.getValue("accX") / g,
Y = lusasGravityLoad.getValue("accY") / g,
Z = lusasGravityLoad.getValue("accZ") / g
};

IEnumerable<BHoMObject> assignedObjects = GetGeometryAssignments(
Expand Down
3 changes: 3 additions & 0 deletions Lusas_Adapter/LusasAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ public LusasV17Adapter(string filePath, LusasSettings lusasSettings = null, bool
m_mergeTolerance = lusasSettings.MergeTolerance;
d_LusasData.getOptions().setDouble("TOLMRG", m_mergeTolerance);
}

if (lusasSettings != null) { m_g = lusasSettings.StandardGravity; }
}
}
}
Expand All @@ -190,6 +192,7 @@ public static bool IsApplicationRunning()

private string m_directory;
public double m_mergeTolerance = double.NaN;
public double m_g = 9.80665;
public LusasWinApp m_LusasApplication;
public IFDatabase d_LusasData;
private Dictionary<Type, Dictionary<int, HashSet<string>>> m_tags = new Dictionary<Type, Dictionary<int, HashSet<string>>>();
Expand Down
5 changes: 4 additions & 1 deletion Lusas_Engine/Create/LusasSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public static partial class Create
[Description("Lusas adapter settings.")]
[Input("mergeTolerance", "Sets the merging tolerance used in Lusas.")]
[Input("librarySettings", "Sets the library settings.")]
[Input("g", "Sets the standard gravity i.e. the acceleration due to gravity. This is used when GravityLoads are pushed/pulled from Lusas as the BHoM uses a factor of g, whereas Lusas uses a specific acceleration.")]
[Output("Lusas specific adapter settings to be used by the adapter.")]
public static LusasSettings LusasSettings(double mergeTolerance, LibrarySettings librarySettings = null)
public static LusasSettings LusasSettings(double mergeTolerance, LibrarySettings librarySettings = null, double g = 9.80665)
{
LusasSettings lusasSettings = new LusasSettings();

Expand All @@ -46,6 +47,8 @@ public static LusasSettings LusasSettings(double mergeTolerance, LibrarySettings
if (librarySettings != null)
lusasSettings.LibrarySettings = librarySettings;

lusasSettings.StandardGravity = g;

return lusasSettings;
}
/***************************************************/
Expand Down
5 changes: 5 additions & 0 deletions Lusas_oM/Lusas_oM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@
<HintPath>$(ProgramData)\BHoM\Assemblies\Geometry_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Quantities_oM">
<HintPath>$(ProgramData)\BHoM\Assemblies\Quantities_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
7 changes: 6 additions & 1 deletion Lusas_oM/Settings/LusasSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using BH.oM.Base;
using System.ComponentModel;
using BH.oM.Adapter;
using BH.oM.Quantities.Attributes;

namespace BH.oM.Adapters.Lusas
{
Expand All @@ -31,13 +32,17 @@ public class LusasSettings : AdapterSettings
/***************************************************/
/**** Public Properties ****/
/***************************************************/

[Description("Sets the merging tolerance used in Lusas.")]
public virtual double MergeTolerance { get; set; } = double.NaN;

[Description("Sets the library settings.")]
public virtual LibrarySettings LibrarySettings { get; set; } = new LibrarySettings();

[Acceleration]
[Description("Sets the standard gravity i.e. the acceleration due to gravity. This is used when GravityLoads are pushed/pulled from Lusas as the BHoM uses a factor of g, whereas Lusas uses a specific acceleration.")]
public virtual double StandardGravity { get; set; } = 9.80665;

/***************************************************/
}
}
Expand Down

0 comments on commit a680c5b

Please sign in to comment.