Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b921cad
Add support for RFEM6 free polygon loads
Arne-Martensen Oct 27, 2025
5be0779
Support polygon geometry for area loads in RFEM6 adapter
Arne-Martensen Oct 28, 2025
7901857
Add support for polygon area loads in RFEM6 adapter
Arne-Martensen Oct 28, 2025
673f5d2
Set load projection dynamically based on polygon plane
Arne-Martensen Oct 28, 2025
94fc3b7
Add error handling to CreateLoad_Polygon method
Arne-Martensen Oct 28, 2025
dc91c78
Add warnings for unsupported 'Projected' option with Local axis
Arne-Martensen Nov 3, 2025
14343b2
Warn if load direction is not axis-aligned
Arne-Martensen Nov 3, 2025
6256d15
Update RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs
Arne-Martensen Nov 5, 2025
56d3f53
Update RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs
Arne-Martensen Nov 5, 2025
6557de1
Update RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs
Arne-Martensen Nov 5, 2025
13118ef
Update RFEM6_Adapter/Convert/ToRFEM6/BHoMDataStructure/Loading/Load.cs
Arne-Martensen Nov 5, 2025
9d09184
Update RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs
Arne-Martensen Nov 5, 2025
fba38de
Update RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs
Arne-Martensen Nov 5, 2025
7f69ab5
Update RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs
Arne-Martensen Nov 5, 2025
51100f6
Fix variable name typo and add loadProjection assignment
Arne-Martensen Nov 5, 2025
8c5befa
Fix typos and variable naming in Load.cs files
Arne-Martensen Nov 5, 2025
2dec64a
Remove unused ReadPolygonLoad method
Arne-Martensen Nov 5, 2025
b5d3cbe
Update RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs
Arne-Martensen Nov 5, 2025
621a5bd
Update Load.cs
Arne-Martensen Nov 5, 2025
b6971d0
Merge branch 'RFEM6_Toolkit-#127-AddFreePolygonalLoads' of https://gi…
Arne-Martensen Nov 5, 2025
0d37827
Update Load.cs
Arne-Martensen Nov 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ public void InitializeOpenings()
public void PushPullPanel()
{

adapter.Push(new List<Panel>() { panel1});
//adapter.Push(new List<Panel>() { panel1});

//// Pull it
//FilterRequest panelFilter = new FilterRequest() { Type = typeof(Panel) };
//var panelPulled = adapter.Pull(panelFilter).ToList();
//Panel pp = (Panel)panelPulled[0];
FilterRequest panelFilter = new FilterRequest() { Type = typeof(Panel) };
var panelPulled = adapter.Pull(panelFilter).ToList();
Panel pp = (Panel)panelPulled[0];

//// Check
//Assert.IsNotNull(pp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void InitializeOpenings()
[SetUp]
public void SetUp()
{
adapter.Push(new List<Panel>() { panel1, panel2, panel3 });
//adapter.Push(new List<Panel>() { panel1, panel2, panel3 });
}


Expand Down Expand Up @@ -268,7 +268,19 @@ public void PushOfReversedAreaUniformlyDistributedLoad()
Assert.True(this.reverseAreaLoadList[i].Axis.Equals(areaLoadList[i].Axis));
}

[Test]
public void PullUniformlyDistributedLoad()
{

//Act

// Push

// Pull
FilterRequest loadFilter = new FilterRequest() { Type = typeof(AreaUniformlyDistributedLoad) };
List<AreaUniformlyDistributedLoad> areaLoadList = adapter.Pull(loadFilter).ToList().Select(p => (AreaUniformlyDistributedLoad)p).ToList();
var a = areaLoadList.First();
}
}


Expand Down
22 changes: 22 additions & 0 deletions RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,16 @@
//Container for Potential Surface IDs. Surface IDs are onle relevant when using Free Line Loads
int[] surfaceIds = new int[] { };

foreach (ILoad bhLoad in bhLoads)
{


if (bhLoad is AreaUniformlyDistributedLoad)
{
if (bhLoad.CustomData.Values.Any(l=>l is Polygon)) {
CreateLoad_Polygon(bhLoad as AreaUniformlyDistributedLoad);
continue;
}

Check warning on line 67 in RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs

View check run for this annotation

BHoMBot-CI / code-compliance

RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs#L64-L67

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
CreateLoad(bhLoad as AreaUniformlyDistributedLoad);
continue;
}

Check warning on line 70 in RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs

View check run for this annotation

BHoMBot-CI / code-compliance

RFEM6_Adapter/CRUD/Create/BHoMDataStructure/Loading/Load.cs#L62-L70

The use of CustomData within the code is discouraged except in circumstances where volatile data is being used. - For more information see https://bhom.xyz/documentation/DevOps/Code%20Compliance%20and%20CI/Compliance%20Checks/IsUsingCustomData
Expand Down Expand Up @@ -233,6 +237,24 @@

}

private void CreateLoad_Polygon(AreaUniformlyDistributedLoad bhLoad)
{
try
{
UpdateLoadIdDictionary(bhLoad);
//Call Panel Load Methond to update the Panel ID Dictionary
this.GetCachedOrReadAsDictionary<int, Panel>();
int id = m_LoadcaseLoadIdDict[bhLoad.Loadcase][bhLoad.GetType().Name];
free_polygon_load rfemAreaLoad = (bhLoad as AreaUniformlyDistributedLoad).ToRFEM6_Polygon(id);
var currrSurfaceIds = (bhLoad as AreaUniformlyDistributedLoad).Objects.Elements.ToList().Select(e => m_PanelIDdict[e as Panel]).ToArray();
rfemAreaLoad.surfaces = currrSurfaceIds;
m_Model.set_free_polygon_load(bhLoad.Loadcase.Number, rfemAreaLoad);

} catch (Exception ex) {
BH.Engine.Base.Compute.RecordError($"The creation of {bhLoad} failed.\nA potential cause is that the applied polygon is non-planar or not parallel to the XY, YZ, or ZX plane.\nException: {ex.Message}\nStackTrace: {ex.StackTrace}");
}
}

private void CreateLoad(BarUniformlyDistributedLoad bhLoad)
{

Expand Down
30 changes: 27 additions & 3 deletions RFEM6_Adapter/CRUD/Read/BHoMDataStructure/Loading/Load.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private List<ILoad> ReadPointLoad(List<string> ids = null)

private List<ILoad> ReadAreaLoad(List<string> ids = null)
{

List<ILoad> loads = new List<ILoad>();

//Find all possible Load cases
Expand All @@ -136,18 +137,41 @@ private List<ILoad> ReadAreaLoad(List<string> ids = null)

if (!(surfaceLoad.load_distribution is rfModel.surface_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM))
{
Engine.Base.Compute.RecordNote("The current RFEM6 includes Surfaceloads with a non-uniformal load distributeion, these Loads will not be pulled.");
Engine.Base.Compute.RecordNote("The current RFEM6 includes Surface loads with a non-uniformal load distributeion, these Loads will not be pulled.");
continue;
}

loads.Add(surfaceLoad.FromRFEM(loadCaseMap[surfaceLoad.load_case], panels));

}

return loads;

rfModel.object_with_children[] numbers_ = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_FREE_POLYGON_LOAD);

//IEnumerable<rfModel.surface_load> foundSurfaceLoad = numbers.ToList().Select(n => m_Model.get_surface_load(n.children[0], n.no));
IEnumerable<rfModel.free_polygon_load> foundPolygonLoad_ = numbers_.SelectMany(n => n.children.Select(child => m_Model.get_free_polygon_load(child, n.no)));

foundPolygonLoad_ = foundPolygonLoad_.OrderBy(n => n.load_case).ThenBy(t => t.no);
foreach (rfModel.free_polygon_load polygonLoad in foundPolygonLoad_)
{
List<Panel> panels = polygonLoad.surfaces.ToList().Select(s => panelMap[s]).ToList();
if (!(polygonLoad.load_distribution is rfModel.free_polygon_load_load_distribution.LOAD_DISTRIBUTION_UNIFORM))
{
Engine.Base.Compute.RecordNote("The current RFEM6 includes Surface loads with a non-uniformal load distributeion, these Loads will not be pulled.");
continue;
}

loads.Add(polygonLoad.FromRFEM(loadCaseMap[polygonLoad.load_case], panels));

}


return loads;
}

private List<ILoad> ReadFreeLineLoad(List<string> ids = null)


private List<ILoad> ReadFreeLineLoad(List<string> ids = null)
{
List<ILoad> loads = new List<ILoad>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private List<RFEMLine> ReadLines(List<string> ids = null)

List<RFEMLine> lineList = new List<RFEMLine>();

var lineNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE);
var lineNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE).Where(l => l.no > 0);
var allRfLInes = lineNumbers.ToList().Select(n => m_Model.get_line(n.no));

//var lineSupportNumbers = m_Model.get_all_object_numbers_by_type(rfModel.object_types.E_OBJECT_TYPE_LINE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ public static partial class Convert
public static Panel FromRFEM(this rfModel.surface rfSurface, Dictionary<int, Edge> edgeDict, Dictionary<int, ISurfaceProperty> surfaceProperty, HashSet<int> openingIDs, Dictionary<int, RFEMOpening> surfaceOpening)
{

//HashSet<int> openingIDs = new HashSet<int>();

//openingIDDict.TryGetValue(rfPanelNo,out openingIDs);


List<int> rfEdgeNumbers = rfSurface.boundary_lines.ToList();
List<Edge> bhEdges = rfEdgeNumbers.Select(n => edgeDict[n]).ToList();
Expand Down
115 changes: 115 additions & 0 deletions RFEM6_Adapter/Convert/FromRFEM6/BHoMDataStructure/Loading/Load.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,121 @@ public static PointLoad FromRFEM(this rfModel.nodal_load nodeLoad, List<Node> bh
return bhLoad;
}

public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.free_polygon_load polygonLoad, Loadcase loadcase, List<Panel> panels)
{

Vector forceDirection;
bool isProjected = false;
LoadAxis axis = LoadAxis.Global;
List<double> firstCoordinate = polygonLoad.load_location.ToList().Select(r => r.row.first_coordinate).ToList();
List<double> secondCoordinate = polygonLoad.load_location.ToList().Select(r => r.row.second_coordinate).ToList();
List<double> thirdCoordinate = Enumerable.Repeat(0.0, firstCoordinate.Count).ToList();
List<Point> loadPolygon;

switch (polygonLoad.load_projection)
{
case free_polygon_load_load_projection.LOAD_PROJECTION_XY_OR_UV:

loadPolygon = firstCoordinate.Select((x, i) => new Point()
{
X = x,
Y = secondCoordinate[i],
Z = thirdCoordinate[i]
}).ToList();


break;

case free_polygon_load_load_projection.LOAD_PROJECTION_YZ_OR_VW:

loadPolygon = firstCoordinate.Select((x, i) => new Point()
{
X = thirdCoordinate[i],
Y = x,
Z = secondCoordinate[i]
}).ToList();

break;

default:

loadPolygon = firstCoordinate.Select((x, i) => new Point()
{
X = secondCoordinate[i],
Y = thirdCoordinate[i],
Z = x
}).ToList();

break;


}

var polygon = BH.Engine.Geometry.Create.Polygon(loadPolygon);

switch (polygonLoad.load_direction)
{
//case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_TRUE:
case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_X_TRUE:
forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0);
break;
//case surface_load_load_direction.LOAD_DIRECTION_LOCAL_X:
case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_X:
forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0);
axis = LoadAxis.Local;
break;

//case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_TRUE:
case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_TRUE:
forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0);
break;
//case surface_load_load_direction.LOAD_DIRECTION_LOCAL_Y:
case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Y:
forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0);
axis = LoadAxis.Local;
break;

//case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_TRUE:
case free_polygon_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_TRUE:
forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform);
break;
//case surface_load_load_direction.LOAD_DIRECTION_LOCAL_Z:
case free_polygon_load_load_direction.LOAD_DIRECTION_LOCAL_Z:
forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform);
axis = LoadAxis.Local;
break;

//case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_X_OR_USER_DEFINED_U_PROJECTED:
case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_U_PROJECTED:
forceDirection = BH.Engine.Geometry.Create.Vector(polygonLoad.magnitude_uniform, 0, 0);
isProjected = true;
break;

//case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Y_OR_USER_DEFINED_V_PROJECTED:
case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_V_PROJECTED:
forceDirection = BH.Engine.Geometry.Create.Vector(0, polygonLoad.magnitude_uniform, 0);
isProjected = true;
break;

//case surface_load_load_direction.LOAD_DIRECTION_GLOBAL_Z_OR_USER_DEFINED_W_PROJECTED:
case free_polygon_load_load_direction.LOAD_DIRECTION_USER_DEFINED_W_PROJECTED:
forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform);
isProjected = true;
break;

default:
forceDirection = BH.Engine.Geometry.Create.Vector(0, 0, polygonLoad.magnitude_uniform);
break;
}


AreaUniformlyDistributedLoad bhAreaload = BH.Engine.Structure.Create.AreaUniformlyDistributedLoad(loadcase, forceDirection, panels, axis, isProjected, polygonLoad.comment);
bhAreaload = bhAreaload.SetHashFragment("Polygon");
bhAreaload.SetPropertyValue("Polygon", polygon);

return bhAreaload;
}

public static AreaUniformlyDistributedLoad FromRFEM(this rfModel.surface_load surfaceload, Loadcase loadcase, List<Panel> panels)
{

Expand Down
Loading
Loading