Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

23.9.0 #1133

Merged
merged 10 commits into from
Dec 30, 2024
Merged

23.9.0 #1133

Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 2 additions & 17 deletions FemDesign.Core/FemDesignConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -622,21 +622,6 @@ public Loads.Loads GetLoads()
return dictLoadComb;
}

/// <summary>
/// Read and parse result data from .csv files
/// </summary>
public List<T> ParseCsvFiles<T>(List<string> csvPaths) where T : Results.IResult
{
List<T> results = new List<T>();
foreach (string resultFile in csvPaths)
{
results.AddRange(
Results.ResultsReader.Parse(resultFile).ConvertAll(r => (T)r)
);
}
return results;
}

/// <summary>
/// Retrieve node geometry data from the finite element mesh.
/// </summary>
Expand Down Expand Up @@ -758,7 +743,7 @@ public List<T> GetResultsOnPoints<T>(List<CmdResultPoint> resultPoints, Results.
var script = new FdScript(logfile, scriptCommands.ToArray());
this.RunScript(script, $"Get{typeof(T).Name}Results");

return ParseCsvFiles<T>(csvPaths);
return Results.ResultsReader.ParseCsvFiles<T>(csvPaths);
}

/// <summary>
Expand Down Expand Up @@ -1237,7 +1222,7 @@ private List<T> _readResults<T>(Func<ListProc, bool> filter, List<string> loadCa
// Generate .csv result files
_listResultsByFdScript($"Get{typeof(T).Name}Results" + currentTime, bscPaths, csvPaths, elements);

return ParseCsvFiles<T>(csvPaths);
return Results.ResultsReader.ParseCsvFiles<T>(csvPaths);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion FemDesign.Core/Geometry/Contour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public Contour(List<Point3d> points)
/// <summary>
/// Reverse direction of edges in this contour
/// </summary>
internal void Reverse()
public void Reverse()
{
// reverse every edge
foreach (Edge edge in this.Edges)
Expand Down
14 changes: 14 additions & 0 deletions FemDesign.Core/Geometry/Region.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ internal Region()
public Region(List<Contour> contours)
{
this.Contours = contours;
this.Plane = contours[0].Edges[0].Plane;
}

public Region(List<Contour> contours, Plane plane)
Expand All @@ -87,6 +88,19 @@ public Region(List<Contour> contours, Plane plane)
this.Plane = plane;
}

/// <summary>
/// Construct a region with holes from an outer contour and inner contours.
/// The direction of the holes contours are assumed to be opposite to the outer.
/// </summary>
/// <param name="outerContour"></param>
/// <param name="holesContours"></param>
public Region(Contour outerContour, List<Contour> holesContours)
{
this.Contours = new List<Contour> { outerContour };
this.Contours.AddRange(holesContours);
this.Plane = outerContour.Edges[0].Plane;
}

public bool IsPlanar
{
get
Expand Down
4 changes: 2 additions & 2 deletions FemDesign.Core/Properties/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
// Revision
//

[assembly: AssemblyVersion("23.8.0")]
[assembly: AssemblyFileVersion("23.8.0")]
[assembly: AssemblyVersion("23.9.0")]
[assembly: AssemblyFileVersion("23.9.0")]
8 changes: 5 additions & 3 deletions FemDesign.Core/Results/RC design/RCBarUtilization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class RCBarUtilization : IResult
/// Bar name identifier
/// </summary>
public string Id { get; }
/// <summary>
/// Maximum utilization
/// </summary>
public double Max { get; }
/// <summary>
/// Section utilization
Expand All @@ -38,7 +41,6 @@ public class RCBarUtilization : IResult
/// Torsional utilization
/// </summary>
public double T { get; }

/// <summary>
/// Utilization for crack width
/// </summary>
Expand Down Expand Up @@ -93,8 +95,8 @@ internal static RCBarUtilization Parse(string[] row, CsvParser reader, Dictionar
double c = row[4] == "-" ? 0 : double.Parse(row[4], CultureInfo.InvariantCulture);
double t = row[5] == "-" ? 0 : double.Parse(row[5], CultureInfo.InvariantCulture);
double cw = row[6] == "-" ? 0 : double.Parse(row[6], CultureInfo.InvariantCulture);
string lc = HeaderData["casename"]; ;
return new RCBarUtilization(id, max, sec, st, c, t, cw, lc);
string lc = HeaderData["casename"];
return new RCBarUtilization(id, max, sec, st, c, t, cw, lc);
}
else
{
Expand Down
15 changes: 15 additions & 0 deletions FemDesign.Core/Results/ResultsReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ private bool parseHeaderDefault(string line, CsvParser reader)
return reader.ParseAll();
}

/// <summary>
/// Read and parse result data from .csv files
/// </summary>
public static List<T> ParseCsvFiles<T>(List<string> csvPaths) where T : Results.IResult
{
List<T> results = new List<T>();
foreach (string resultFile in csvPaths)
{
results.AddRange(
Results.ResultsReader.Parse(resultFile).ConvertAll(r => (T)r)
);
}
return results;
}

/// <summary>
/// Tries to figure out the corresponding type of the upcoming lines that are being read.
/// </summary>
Expand Down
19 changes: 19 additions & 0 deletions FemDesign.Core/Shells/Slab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ public static Slab Plate(string identifier, Materials.Material material, Geometr
return shell;
}

public static Slab Plate(string identifier, Materials.Material material, Geometry.Region region, EdgeConnection shellEdgeConnection, ShellEccentricity eccentricity, ShellOrthotropy orthotropy, double thickness)
{
var thicknesses = new List<Thickness>();
var corner = region.Contours[0].Edges[0].Points[0];
thicknesses.Add(new Thickness(corner, thickness));
var shell = Slab.Plate(identifier, material, region, shellEdgeConnection, eccentricity, orthotropy, thicknesses);
return shell;
}

/// <summary>
/// Construct a rectangular slab in the XY plane
/// </summary>
Expand Down Expand Up @@ -228,6 +237,16 @@ public static Slab Wall(string identifier, Materials.Material material, Geometry
return shell;
}

public static Slab Wall(string identifier, Materials.Material material, Geometry.Region region, EdgeConnection shellEdgeConnection, ShellEccentricity eccentricity, ShellOrthotropy orthotropy, double thickness)
{
var thicknesses = new List<Thickness>();
var corner = region.Contours[0].Edges[0].Points[0];
thicknesses.Add(new Thickness(corner, thickness));

var shell = Slab.Wall(identifier, material, region, shellEdgeConnection, eccentricity, orthotropy, thicknesses);
return shell;
}

/// <summary>
/// Set EdgeConnections by indices.
/// </summary>
Expand Down
20 changes: 15 additions & 5 deletions FemDesign.Grasshopper/Calculate/ApplicationRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override bool Read(GH_IReader reader)

protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddGenericParameter("Model", "Model", "Model to open.", GH_ParamAccess.item);
pManager.AddGenericParameter("Model", "Model", "Model to open. File as .str and .struxml are also accepted", GH_ParamAccess.item);
pManager.AddGenericParameter("Analysis", "Analysis", "Analysis.", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Design", "Design", "Design.", GH_ParamAccess.item);
Expand Down Expand Up @@ -89,7 +89,7 @@ protected override void RegisterInputParams(GH_InputParamManager pManager)

pManager.AddTextParameter("DocxTemplatePath", "DocxTemplatePath", "File path to documentation template file (.dsc). The documentation will be saved in the `FEM-Design API` folder. Optional parameter.", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddTextParameter("SaveFilePath", "SaveFilePath", "File path where to save the model as .struxml.\nIf not specified, the file will be saved in the `FEM-Design API` folder adjacent to your .gh script.", GH_ParamAccess.item);
pManager.AddTextParameter("SaveFilePath", "SaveFilePath", "File path where to save the model as .struxml or .str.\nIf not specified, the file will be saved in the `FEM-Design API` folder adjacent to your .gh script.", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddBooleanParameter("RunNode", "RunNode", "If true node will execute. If false node will not execute.", GH_ParamAccess.item, false);
pManager[pManager.ParamCount - 1].Optional = true;
Expand All @@ -107,7 +107,7 @@ public dynamic _getResults(FemDesignConnection connection, Type resultType, Resu
{
List<Results.IResult> mixedResults = new List<Results.IResult>();
MethodInfo genericMethod = typeof(FemDesign.FemDesignConnection).GetMethod("_getResults", BindingFlags.Instance | BindingFlags.NonPublic).MakeGenericMethod(resultType);
dynamic result = genericMethod.Invoke(connection, new object[] { units, options, elements, true });
dynamic result = genericMethod.Invoke(connection, new object[] { units, options, elements, false });
mixedResults.AddRange(result);
return mixedResults;
}
Expand Down Expand Up @@ -205,6 +205,16 @@ protected override void SolveInstance(IGH_DataAccess DA)
string tempPath = System.IO.Path.GetTempPath();
System.IO.Directory.SetCurrentDirectory(tempPath);
}
else if(saveFilePath != null)
{
var currentDir = System.IO.Path.GetDirectoryName(saveFilePath);
// check if folder exist. If not, create a new one
if (!System.IO.Directory.Exists(currentDir))
{
System.IO.Directory.CreateDirectory(currentDir);
}
System.IO.Directory.SetCurrentDirectory(currentDir);
}
else
{
var filePath = OnPingDocument().FilePath;
Expand Down Expand Up @@ -300,7 +310,7 @@ protected override void SolveInstance(IGH_DataAccess DA)
{
foreach (var type in types)
{
var res = _getResults(connection, type, units, options);
var res = _getResults(connection, type, units, options, null);
resultsTree.AddRange(res, new GH_Path(iteration, i));
i++;
}
Expand Down Expand Up @@ -364,7 +374,7 @@ protected override System.Drawing.Bitmap Icon
}
public override Guid ComponentGuid
{
get { return new Guid("{D8FB0474-D57A-4DFC-80E3-2D1D0F5D2FD4}"); }
get { return new Guid("{64EF2A60-5694-4901-B493-57AF83C04969}"); }
}

public override GH_Exposure Exposure => GH_Exposure.primary;
Expand Down
Loading
Loading