Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b681a6f
Transfer to Clean branch
EmmaSander Apr 11, 2025
74522ad
Working combined method node result
EmmaSander Apr 11, 2025
797a662
Added Bar Results
EmmaSander Apr 15, 2025
9a146cb
added MeshResult and errors
EmmaSander Apr 15, 2025
d2b7193
Fixed sorting by loadCase
EmmaSander Apr 16, 2025
b7f9a56
Updated references
EmmaSander Apr 16, 2025
a09998d
Update MidasCivil_Adapter.csproj
EmmaSander Apr 16, 2025
deb8cb0
Installer error fix test
EmmaSander Apr 17, 2025
1cb3444
Start of updates
EmmaSander Apr 17, 2025
c51cb5a
Requested Updates
EmmaSander Apr 24, 2025
aa2c1fb
Minor updates
EmmaSander Apr 24, 2025
1af4564
Remove memory reference, case sorting temp. disabled
EmmaSander May 28, 2025
13aa4f2
Merge branch 'develop' into MidasCivil_Toolkit-#402-PullResultsAPI
EmmaSander May 28, 2025
72a3f1d
reinstated case filter
EmmaSander Jun 6, 2025
f0df2fc
Reference Update
EmmaSander Jun 6, 2025
a889052
Update MidasCivil_Adapter.csproj
EmmaSander Jun 6, 2025
31fd906
Update MidasCivil_Adapter/PrivateHelpers/AppendCaseTypes.cs
EmmaSander Jun 16, 2025
25291bb
Update MidasCivil_Adapter/PrivateHelpers/ReadResultAPI.cs
EmmaSander Jun 16, 2025
575f309
Update MidasCivil_Adapter/PrivateHelpers/ReadResultAPI.cs
EmmaSander Jun 16, 2025
e3ef64d
Update MidasCivil_Adapter/PrivateHelpers/AppendCaseTypes.cs
EmmaSander Jun 16, 2025
81c9539
Requested Updates
EmmaSander Jun 16, 2025
0ac3844
Add GET units for Open in Execute actions
peterjamesnugent Jun 16, 2025
9c53615
Add unit conversion for result reading
peterjamesnugent Jun 16, 2025
48aba28
Updated meshstress and removed double unit conversion
EmmaSander Jun 30, 2025
4aa1660
Fixed bugs added versioning
EmmaSander Jul 17, 2025
b5b90c9
Added LayerFiltering for Meshstresses
EmmaSander Jul 18, 2025
ac648a7
Add in sigXY
EmmaSander Jul 18, 2025
992d9f4
Formatting and correcting layer positions
EmmaSander Jul 18, 2025
414802f
Revert addition of SigmaXY as it's shear stress in MidasCivil but nor…
peterjamesnugent Jul 18, 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
402 changes: 208 additions & 194 deletions MidasCivil_Adapter/AdapterActions/Execute.cs

Large diffs are not rendered by default.

46 changes: 30 additions & 16 deletions MidasCivil_Adapter/CRUD/Read/Results/BarResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using System.Linq;
using System;
using System.IO;
using System.Threading.Tasks;

namespace BH.Adapter.MidasCivil
{
Expand All @@ -40,27 +41,40 @@ public partial class MidasCivilAdapter

public IEnumerable<IResult> ReadResults(BarResultRequest request, ActionConfig actionConfig)
{
List<IResult> results;
List<IResult> results = new List<IResult>();
List<int> objectIds = GetObjectIDs(request);
List<string> loadCases = GetLoadcaseIDs(request);

switch (request.ResultType)
switch (m_midasCivilVersion)
{
case BarResultType.BarForce:
results = ExtractBarForce(objectIds, loadCases).ToList();
break;
case BarResultType.BarStrain:
results = ExtractBarStrain(objectIds, loadCases).ToList();
break;
case BarResultType.BarStress:
results = ExtractBarStress(objectIds, loadCases).ToList();
break;
case BarResultType.BarDisplacement:
results = ExtractBarDisplacement(objectIds, loadCases).ToList();
case "9.5.0.nx":
case "9.5.5.nx":
List<string> loadCasesNX = Task.Run(() => AppendCaseTypes(request)).Result;
string divisions = SetBarDivisions(request);

if (loadCasesNX != null)
results = Task.Run(() => ReadResult(request.ResultType.ToString(), objectIds, loadCasesNX, divisions)).Result.ToList();
break;
default:
Engine.Base.Compute.RecordError($"Result of type {request.ResultType} is not yet supported in the MidasCivil_Toolkit.");
results = new List<IResult>();
List<string> loadCases = GetLoadcaseIDs(request);
switch (request.ResultType)
{
case BarResultType.BarForce:
results = ExtractBarForce(objectIds, loadCases).ToList();
break;
case BarResultType.BarStrain:
results = ExtractBarStrain(objectIds, loadCases).ToList();
break;
case BarResultType.BarStress:
results = ExtractBarStress(objectIds, loadCases).ToList();
break;
case BarResultType.BarDisplacement:
results = ExtractBarDisplacement(objectIds, loadCases).ToList();
break;
default:
Engine.Base.Compute.RecordError($"Result of type {request.ResultType} is not yet supported in the MidasCivil_Toolkit.");
results = new List<IResult>();
break;
}
break;
}
results.Sort();
Expand Down
46 changes: 29 additions & 17 deletions MidasCivil_Adapter/CRUD/Read/Results/MeshResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace BH.Adapter.MidasCivil
{
public partial class MidasCivilAdapter
Expand All @@ -40,27 +41,38 @@ public partial class MidasCivilAdapter

public IEnumerable<IResult> ReadResults(MeshResultRequest request, ActionConfig actionConfig)
{
List<IResult> results;
List<IResult> results = new List<IResult>();
List<int> objectIds = GetObjectIDs(request);
List<string> loadCases = GetLoadcaseIDs(request);

switch (request.ResultType)
switch (m_midasCivilVersion)
{
case MeshResultType.Displacements:
results = ExtractMeshDisplacement(objectIds, loadCases).ToList();
break;
case MeshResultType.Forces:
results = ExtractMeshForce(objectIds, loadCases).ToList();
break;
case MeshResultType.Stresses:
results = ExtractMeshStress(objectIds, loadCases, request.Layer).ToList();
break;
case MeshResultType.VonMises:
results = ExtractMeshVonMises(objectIds, loadCases, request.Layer).ToList();
case "9.5.0.nx":
case "9.5.5.nx":
List<string> loadCasesNX = Task.Run(() => AppendCaseTypes(request)).Result;
if (loadCasesNX != null)
results = Task.Run(() => ReadResult(request.ResultType.ToString(), objectIds, loadCasesNX, "", request)).Result.ToList();
break;
default:
Engine.Base.Compute.RecordError($"Result of type {request.ResultType} is not yet supported in the MidasCivil_Toolkit.");
results = new List<IResult>();
List<string> loadCases = GetLoadcaseIDs(request);

switch (request.ResultType)
{
case MeshResultType.Displacements:
results = ExtractMeshDisplacement(objectIds, loadCases).ToList();
break;
case MeshResultType.Forces:
results = ExtractMeshForce(objectIds, loadCases).ToList();
break;
case MeshResultType.Stresses:
results = ExtractMeshStress(objectIds, loadCases, request.Layer).ToList();
break;
case MeshResultType.VonMises:
results = ExtractMeshVonMises(objectIds, loadCases, request.Layer).ToList();
break;
default:
Engine.Base.Compute.RecordError($"Result of type {request.ResultType} is not yet supported in the MidasCivil_Toolkit.");
results = new List<IResult>();
break;
}
break;
}
results.Sort();
Expand Down
33 changes: 23 additions & 10 deletions MidasCivil_Adapter/CRUD/Read/Results/NodeResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace BH.Adapter.MidasCivil
{
Expand All @@ -41,21 +42,33 @@ public partial class MidasCivilAdapter

public IEnumerable<IResult> ReadResults(NodeResultRequest request, ActionConfig actionConfig)
{
List<IResult> results;
List<IResult> results = new List<IResult>();
List<int> objectIds = GetObjectIDs(request);
List<string> loadCases = GetLoadcaseIDs(request);

switch (request.ResultType)
switch (m_midasCivilVersion)
{
case NodeResultType.NodeReaction:
results = ExtractNodeReaction(objectIds, loadCases).ToList();
break;
case NodeResultType.NodeDisplacement:
results = ExtractNodeDisplacement(objectIds, loadCases).ToList();
case "9.5.0.nx":
case "9.5.5.nx":
List<string> loadCasesNX = Task.Run(() => AppendCaseTypes(request)).Result;
if (loadCasesNX != null)
results = Task.Run(() => ReadResult(request.ResultType.ToString(), objectIds, loadCasesNX)).Result.ToList();
break;
default:
Engine.Base.Compute.RecordError($"Result of type {request.ResultType} is not yet supported in the MidasCivil_Toolkit.");
results = new List<IResult>();
List<string> loadCases = GetLoadcaseIDs(request);

switch (request.ResultType)
{
case NodeResultType.NodeReaction:
results = ExtractNodeReaction(objectIds, loadCases).ToList();
break;
case NodeResultType.NodeDisplacement:
results = ExtractNodeDisplacement(objectIds, loadCases).ToList();
break;
default:
Engine.Base.Compute.RecordError($"Result of type {request.ResultType} is not yet supported in the MidasCivil_Toolkit.");
results = new List<IResult>();
break;
}
break;
}
results.Sort();
Expand Down
39 changes: 24 additions & 15 deletions MidasCivil_Adapter/CRUD/Read/Results/ReadResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ private List<int> GetObjectIDs(IResultRequest request)

if (ids == null || ids.Count == 0)
{
return GetAllIds(request as dynamic);
switch (m_midasCivilVersion)
{
case "9.5.0.nx":
case "9.5.5.nx":
List<int> emptyIds = new List<int>();
return emptyIds;
default:
return GetAllIds(request as dynamic);
}
}
else
{
Expand Down Expand Up @@ -130,7 +138,7 @@ private List<string> GetLoadcaseIDs(IResultRequest request)
IList cases = request.Cases;
List<string> caseNames = new List<string>();
if (cases == null || cases.Count == 0)
{
{
caseNames = GetSectionText("STLDCASE").Select(x => x.Split(',')[0].Trim()).ToList();

List<string> loadCombinationText = GetSectionText("LOADCOMB");
Expand All @@ -139,19 +147,21 @@ private List<string> GetLoadcaseIDs(IResultRequest request)
caseNames.Add(loadCombinationText[i].Split(',')[0].Split('=')[1].Trim());
}
}
foreach (object thisCase in cases)

foreach (object thisCase in cases)
{
if (thisCase is ICase)
{
if (thisCase is ICase)
{
ICase bhCase = thisCase as ICase;
caseNames.Add(bhCase.Name.ToString());
}
else if (thisCase is string)
{
string caseId = thisCase as string;
caseNames.Add(caseId);
}
ICase bhCase = thisCase as ICase;
caseNames.Add(bhCase.Name.ToString());
}
else if (thisCase is string)
{
string caseId = thisCase as string;
caseNames.Add(caseId);
}
}

return caseNames;
}

Expand All @@ -172,7 +182,7 @@ private static string ExcelToCsv(string path)
Application excel = new Application();
Workbook xlsFile = excel.Workbooks.Open(path);
Worksheet sheet = (Microsoft.Office.Interop.Excel.Worksheet)xlsFile.Sheets[1];

sheet.SaveAs(
csvPath,
Microsoft.Office.Interop.Excel.XlFileFormat.xlCSV,
Expand Down Expand Up @@ -202,7 +212,6 @@ private static string GetCSVFile(string path)
}

/***************************************************/

}
}

Expand Down
1 change: 1 addition & 0 deletions MidasCivil_Adapter/Convert/ToBHoM/Elements/ToRigidLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static RigidLink ToRigidLink(string rigidLink, Dictionary<string, Node> n
case "9.4.5":
case "9.5.0":
case "9.5.0.nx":
case "9.5.5.nx":
primaryId = delimitted[0].Trim();
fixity = delimitted[1].Replace(" ", "");
secondaryIds = delimitted[2].Split(' ').Where(m => !string.IsNullOrWhiteSpace(m)).ToList();
Expand Down
27 changes: 27 additions & 0 deletions MidasCivil_Adapter/Convert/ToBHoM/Results/ToBarForce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Linq;
using System.Collections.Generic;
using BH.Adapter.Adapters.MidasCivil;
using System.Text.Json;

namespace BH.Adapter.MidasCivil
{
Expand Down Expand Up @@ -60,6 +61,32 @@ public static BarForce ToBarForce(this List<string> delimitted, string forceUnit
return barforce;
}

/***************************************************/
public static BarForce ToBarForce(List<object> item)
{
double position = GetBarResultPosition(item[3].ToString());
//TODO: resolve below identifiers extractable through the API
int mode = -1;
double timeStep = 0;
int divisions = 0;

BarForce barforce = new BarForce(
System.Convert.ToInt32(item[1].ToString()),
item[2].ToString(),
mode,
timeStep,
position,
divisions,
System.Convert.ToDouble(item[4].ToString()),
System.Convert.ToDouble(item[5].ToString()),
System.Convert.ToDouble(item[6].ToString()),
System.Convert.ToDouble(item[7].ToString()),
-System.Convert.ToDouble(item[8].ToString()), //Moments reversed to follow structural convension
-System.Convert.ToDouble(item[9].ToString())
);
return barforce;
}

/***************************************************/
/**** Private Methods ****/
/***************************************************/
Expand Down
43 changes: 43 additions & 0 deletions MidasCivil_Adapter/Convert/ToBHoM/Results/ToBarStress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
using System.Linq;
using System.Collections.Generic;
using BH.Adapter.Adapters.MidasCivil;
using System.Text.Json;
using System;

namespace BH.Adapter.MidasCivil
{
Expand Down Expand Up @@ -65,6 +67,47 @@ public static BarStress ToBarStress(this List<string> delimitted, string forceUn

/***************************************************/

public static BarStress ToBarStress(List<object> item)
{
double position = GetBarResultPosition(item[3].ToString());

List<double> combBends = new List<double> {
System.Convert.ToDouble(item[11].ToString()),
System.Convert.ToDouble(item[12].ToString()),
System.Convert.ToDouble(item[13].ToString()),
System.Convert.ToDouble(item[14].ToString())
};

double combBendPos = combBends.Max();
double combBendNeg = combBends.Min();

//TODO: resolve below identifiers extractable through the API
int mode = -1;
double timeStep = 0;
int divisions = 0;

BarStress barstress = new BarStress(
System.Convert.ToInt32(item[1].ToString()),
item[2].ToString(),
mode,
timeStep,
position,
divisions,
System.Convert.ToDouble(item[4].ToString()),
System.Convert.ToDouble(item[5].ToString()),
System.Convert.ToDouble(item[6].ToString()),
System.Convert.ToDouble(item[7].ToString()),
System.Convert.ToDouble(item[8].ToString()),
System.Convert.ToDouble(item[9].ToString()),
System.Convert.ToDouble(item[10].ToString()),
combBendPos,
combBendNeg
);

return barstress;
}

/***************************************************/
}
}

Expand Down
21 changes: 21 additions & 0 deletions MidasCivil_Adapter/Convert/ToBHoM/Results/ToMeshForce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Collections.Generic;
using BH.oM.Geometry;
using BH.Adapter.Adapters.MidasCivil;
using System.Text.Json;

namespace BH.Adapter.MidasCivil
{
Expand Down Expand Up @@ -55,6 +56,26 @@ public static MeshForce ToMeshForce(this List<string> delimitted, string forceUn
}

/***************************************************/
public static MeshForce ToMeshForce(List<object> item)
{
//TODO: resolve below identifiers extractable through the API
int mode = -1;
double timeStep = 0;
MeshForce Meshforce = new MeshForce(System.Convert.ToInt32(item[1].ToString()), item[3].ToString(), 0,
item[2].ToString(), mode, timeStep, MeshResultLayer.Middle, 0.5, MeshResultSmoothingType.None, null,
System.Convert.ToDouble(item[4].ToString()),
System.Convert.ToDouble(item[5].ToString()),
System.Convert.ToDouble(item[6].ToString()),
System.Convert.ToDouble(item[7].ToString()),
System.Convert.ToDouble(item[8].ToString()),
System.Convert.ToDouble(item[9].ToString()),
System.Convert.ToDouble(item[10].ToString()),
System.Convert.ToDouble(item[11].ToString()));

return Meshforce;
}

/***************************************************/

}
}
Expand Down
Loading
Loading