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.4.0 #1028

Merged
merged 21 commits into from
Jul 1, 2024
Merged

23.4.0 #1028

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
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
57 changes: 57 additions & 0 deletions FemDesign.Core/Bars/BarPart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ public BarPart(Geometry.Edge edge, BarType type, Materials.Material material, Se
this.EccentricityCalc = true;
this.Identifier = identifier;
}

this.CheckMaterialAndSectionType();
}

/// <summary>
Expand All @@ -529,6 +531,8 @@ public BarPart(Geometry.Edge edge, BarType type, Materials.Material material, Se
this.EccentricityCalc = true;
this.Identifier = identifier;
}

this.CheckMaterialAndSectionType();
}

/// <summary>
Expand All @@ -551,6 +555,8 @@ public BarPart(Geometry.Edge edge, BarType type, Materials.Material material, Se
this.EccentricityCalc = true;
this.Identifier = identifier;
}

this.CheckMaterialAndSectionType();
}

/// <summary>
Expand All @@ -573,6 +579,8 @@ public BarPart(Geometry.Edge edge, BarType type, Materials.Material material, Se
this.EccentricityCalc = true;
this.Identifier = identifier;
}

this.CheckMaterialAndSectionType();
}

/// <summary>
Expand All @@ -595,6 +603,8 @@ public BarPart(Geometry.Edge edge, BarType type, Materials.Material material, Se
this.EccentricityCalc = true;
this.Identifier = identifier;
}

this.CheckMaterialAndSectionType();
}

/// <summary>
Expand All @@ -615,6 +625,8 @@ public BarPart(Geometry.Edge edge, BarType type, Materials.Material material, Se
this.TrussUniformSectionObj = section;
this.Identifier = identifier;
}

this.CheckMaterialAndSectionType();
}

/// <summary>
Expand All @@ -626,5 +638,50 @@ public void OrientCoordinateSystemToGCS()
cs.AlignYAroundXToGcs();
this.Plane = cs;
}

/// <summary>
/// This method checks if the material type of a bar is consistent with the materials used in its sections.<br></br>
/// If the bar's material is custom, the check is skipped.
/// </summary>
/// <exception cref="ArgumentException">Thrown when the material type of the bar does not match the material type of any section.</exception>
private void CheckMaterialAndSectionType()
{
// get BarPart's material
var material = this.ComplexMaterialObj.Family;

// section type check for custom material is unneccessary
if (material == Materials.Family.Custom)
return;


// get BarPart's sections materials
List<string> secMats = null;
if (this.ComplexSectionObj != null) // if it is not a composite bar
{
secMats = this.ComplexSectionObj.Sections.Select(s => s.MaterialFamily).ToList();
}
else if (this.TrussUniformSectionObj != null) // if it is a truss
{
secMats = new List<string> { this.TrussUniformSectionObj.MaterialFamily };
}

// check section material type
if(secMats != null)
{
foreach(var item in secMats)
{
string mat;
if (item == "Custom")
continue;
if (item == "Hollow")
mat = "Concrete";
else
mat = item;

if (mat != material.ToString())
throw new ArgumentException($"Material Family ({material}) must be the same as the Section MaterialFamily ({mat})!");
}
}
}
}
}
7 changes: 7 additions & 0 deletions FemDesign.Core/Calculate/Analysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,13 @@ public void SetCombAnalysis(FemDesignConnection connection)
// ordered load combinations in the model
var loadCombination = connection.GetLoadCombinations();

var nullCombItems = this.Comb.CombItem.Where(x => x.CombName == null).Count();
var namedCombItems = this.Comb.CombItem.Where(x => x.CombName != null).Count();

if(nullCombItems != 0 && namedCombItems != 0)
throw new Exception("CombItem in Analysis contains both named and unnamed CombItems. This is not allowed.");


_setCombAnalysis(loadCombination.Values.ToList());
}

Expand Down
35 changes: 13 additions & 22 deletions FemDesign.Core/Calculate/CombItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,11 @@ public bool Calc
}
}

/// <summary>
/// Write only property. If true, no calculations will be executed for load combinations.
/// </summary>
[XmlIgnore]
public bool NoCalc
{
set
{
Calc = !value;
}
}

[XmlAttribute("NLE")]
public int _nle { get; set; }

/// <summary>
/// Consider elastic nonlinear behaviour of structural elements.
/// Consider elastic nonlinear behaviour of structural elements. If false, 'NLE' must be false.
/// </summary>
[XmlIgnore]
public bool NLE
Expand All @@ -69,12 +57,11 @@ public bool NLE
}
}


[XmlAttribute("PL")]
public int _pl { get; set; }

/// <summary>
/// Consider plastic behaviour of structural elements.
/// Consider plastic behaviour of structural elements. If true, 'NLE' must be true.
/// </summary>
[XmlIgnore]
public bool PL
Expand All @@ -90,7 +77,6 @@ public bool PL
}
}


[XmlAttribute("NLS")]
public int _nls { get; set; }

Expand All @@ -108,7 +94,7 @@ public bool NLS
public int _cr { get; set; }

/// <summary>
/// Cracked section analysis. Note that Cr only executes properly in RCDesign with DesignCheck set to true.
/// Cracked section analysis. If true, 'PL' must be false. Note that Cr only executes properly in RCDesign with DesignCheck set to true.
/// </summary>
[XmlIgnore]
public bool Cr
Expand All @@ -124,21 +110,26 @@ public bool Cr
}
}


[XmlAttribute("f2nd")]
public int _f2nd { get; set; }

/// <summary>
/// 2nd order analysis.
/// 2nd order analysis. If true, 'PL' must be false.
/// </summary>
[XmlIgnore]
public bool f2nd
{
get { return Convert.ToBoolean(_f2nd); }
set { _f2nd = Convert.ToInt32(value); }
get
{
return Convert.ToBoolean(_f2nd);
}
set
{
_f2nd = Convert.ToInt32(value);
if (value) PL = false;
}
}


[XmlAttribute("Im")]
public int Im { get; set; }

Expand Down
25 changes: 25 additions & 0 deletions FemDesign.Core/FemDesign.Core.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FemDesign.Core", "FemDesign.Core.csproj", "{2FEEBF30-2D04-4EA3-BEE9-5A25466AC396}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2FEEBF30-2D04-4EA3-BEE9-5A25466AC396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2FEEBF30-2D04-4EA3-BEE9-5A25466AC396}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FEEBF30-2D04-4EA3-BEE9-5A25466AC396}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FEEBF30-2D04-4EA3-BEE9-5A25466AC396}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {21F6B73C-23CA-4DD5-B61A-CA07CFADE079}
EndGlobalSection
EndGlobal
10 changes: 6 additions & 4 deletions FemDesign.Core/FemDesignConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ public void RunAnalysis(Analysis analysis)

if (analysis.Comb != null)
{
analysis.SetCombAnalysis(this);
if(analysis.Comb.CombItem.Any(CombItem => CombItem.CombName != null) || analysis.Comb.CombItem.Count() == 0)
{
analysis.SetCombAnalysis(this);
}
script = new FdScript(
logfile,
new CmdUser(CmdUserModule.RESMODE),
Expand Down Expand Up @@ -739,9 +742,8 @@ public List<T> GetResultsOnPoints<T>(List<CmdResultPoint> resultPoints, Results.
/// <param name="outputCsvPath"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public string GetResultsFromBsc(string inputBscPath, string outputCsvPath = null)
public List<string> GetResultsFromBsc(string inputBscPath, string outputCsvPath = null)
{

// Check input
if (outputCsvPath == null)
{
Expand All @@ -754,7 +756,7 @@ public string GetResultsFromBsc(string inputBscPath, string outputCsvPath = null
_listResultsByFdScript("GetResultsFromBsc", new List<string> { inputBscPath }, new List<string> { outputCsvPath });

// Read results
var results = System.IO.File.ReadAllText(outputCsvPath, System.Text.Encoding.UTF8).Replace("\t", ",");
var results = System.IO.File.ReadAllLines(outputCsvPath, System.Text.Encoding.UTF8).Select(x => x.Replace("\t", ",")).ToList();

return results;
}
Expand Down
24 changes: 24 additions & 0 deletions FemDesign.Core/GenericClasses/RestrictedDouble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ internal static double NonNegMax_1e5(double val)
return RestrictedDouble.ValueInClosedInterval(val, 0, 1E5);
}

/// <summary>
/// non_neg_max_1e7
/// </summary>
internal static double NonNegMax_1e7(double val)
{
return RestrictedDouble.ValueInClosedInterval(val, 0, 1E7);
}

/// <summary>
/// non_neg_max_1e10
/// </summary>
Expand All @@ -183,6 +191,14 @@ internal static double NonNegMax_1e15(double val)
return RestrictedDouble.ValueInClosedInterval(val, 0, 1E15);
}

/// <summary>
/// Checks if the value is a positive, non-zero number that is no greater than 1e15.
/// </summary>
internal static double NonZeroMax_1e15(double val)
{
return RestrictedDouble.ValueInClosedInterval(val, 1E-5, 1E15);
}

/// <summary>
/// non_neg_max_1e20
/// </summary>
Expand All @@ -191,6 +207,14 @@ internal static double NonNegMax_1e20(double val)
return RestrictedDouble.ValueInClosedInterval(val, 0, 1E20);
}

/// <summary>
/// Checks if the value is a positive, non-zero number that is no greater than 1e15.
/// </summary>
internal static double NonZeroMax_1e20(double val)
{
return RestrictedDouble.ValueInClosedInterval(val, 1E-5, 1E20);
}

/// <summary>
/// non_neg_max_1e30
/// </summary>
Expand Down
27 changes: 24 additions & 3 deletions FemDesign.Core/Geometry/Region.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public void SetEdgeConnection(Shells.EdgeConnection edgeConnection, int index)

Shells.EdgeConnection ec = Shells.EdgeConnection.CopyExisting(edgeConnection, name);
edge.EdgeConnection = ec;
edge.EdgeConnection.Normal = this.LocalZ;
}
return;
}
Expand Down Expand Up @@ -260,8 +261,7 @@ public void SetEdgeConnections(Shells.EdgeConnection edgeConnection)
string name = "CE." + cInstance.ToString();
Shells.EdgeConnection ec = Shells.EdgeConnection.CopyExisting(edgeConnection, name);
edge.EdgeConnection = ec;
// edge connection Normal are opposite to the normal of the contour
edge.EdgeConnection.Normal = this.LocalZ.Reverse();
edge.EdgeConnection.Normal = this.LocalZ;
}
}
else
Expand All @@ -276,6 +276,27 @@ public void SetEdgeConnections(Shells.EdgeConnection edgeConnection)
}
}

public void SetEdgeConnections(List<Shells.EdgeConnection> edgeConnections)
{
if (edgeConnections?.Count == 0)
{
// pass; keep edges as before
}
else if (edgeConnections.Count == 1)
{
this.SetEdgeConnections(edgeConnections[0]);
}
else if (edgeConnections.Count == this.GetEdgeConnections().Count)
{
for (int i = 0; i < edgeConnections.Count; i++)
this.SetEdgeConnection(edgeConnections[i], i);
}
else
{
throw new ArgumentException($"The number of edge connections must be 1 or equal to the number of surface edges!");
}
}

/// <summary>
/// Get all EdgeConnection from all Edges in Region.
/// </summary>
Expand All @@ -290,7 +311,7 @@ public void SetEdgeConnections(Shells.EdgeConnection edgeConnection)
if(edgeConnection != null)
{
edgeConnection.Edge = edge;
edgeConnection.Normal = this.LocalZ.Reverse();
edgeConnection.Normal = this.LocalZ;
}
edgeConnections.Add(edgeConnection);
}
Expand Down
Loading
Loading