Skip to content

Commit

Permalink
✨ ShellModel functionality added to Bar class
Browse files Browse the repository at this point in the history
  • Loading branch information
lorinczandrea committed Oct 16, 2024
1 parent b2dbf28 commit a066887
Show file tree
Hide file tree
Showing 4 changed files with 390 additions and 29 deletions.
45 changes: 44 additions & 1 deletion FemDesign.Core/Bars/Bar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using System.Xml.Serialization;
using FemDesign.GenericClasses;
Expand Down Expand Up @@ -88,6 +89,9 @@ public Geometry.Edge Edge
}
}

[XmlAttribute("shell_model")]
public ShellModelType ShellModel = ShellModelType.None;

[XmlAttribute("type")]
public BarType Type { get; set; }

Expand Down Expand Up @@ -391,7 +395,6 @@ public Bar(Geometry.Edge edge, BarType type, Composites.CompositeSection composi
this.BarPart = new BarPart(edge, this.Type, compositeSection, startEccentricity, endEccentricity, startConnectivity, endConnectivity, identifier);
}


/// <summary>
/// Construct a truss element.
/// </summary>
Expand All @@ -411,6 +414,21 @@ public static Bar Truss(Geometry.Edge edge, Materials.Material material, Section
return truss;
}

/// <summary>
/// Change the analytical model of the bar into a shell model.
/// </summary>
/// <param name="type"></param>
/// <exception cref="ArgumentException"></exception>
public void ToShellModel(ShellModelType type)
{
if (this.Type == BarType.Truss)
throw new ArgumentException("Analytical models of Truss objects cannot be altered into shell models!");
if (this.BarPart.HasComplexCompositeRef || this.BarPart.HasDeltaBeamComplexSectionRef)
throw new ArgumentException("Analytical models of composite bars or bars with Deltabeam sections cannot be altered into shell models!");

this.ShellModel = type;
}

public void UpdateSection(Sections.Section section)
{
if(this.Type == BarType.Truss)
Expand Down Expand Up @@ -528,4 +546,29 @@ public override string ToString()
}
}
}

[System.Serializable]
public enum ShellModelType
{
/// <summary>
/// Bar model.
/// </summary>
[Parseable("none", "None", "NONE")]
[XmlEnum("none")]
None,

/// <summary>
/// Shell model. Contains only shell elements.
/// </summary>
[Parseable("simple", "Simple", "SIMPLE")]
[XmlEnum("simple")]
Simple,

/// <summary>
/// Shell model. Fictitious bars on the boundary of the shell model.
/// </summary>
[Parseable("complex", "Complex", "COMPLEX")]
[XmlEnum("complex")]
Complex
}
}
76 changes: 48 additions & 28 deletions FemDesign.Grasshopper/Bars/BarDeconstructModify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FemDesign.Bars;
using FemDesign.Grasshopper.Extension.ComponentExtension;
using FemDesign.Loads;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Special;
using Rhino.Geometry;

namespace FemDesign.Grasshopper
Expand All @@ -14,33 +18,41 @@ public BarDeconstructModify(): base("Bar.Deconstruct.Modify", "Deconstruct.Modif
{

}

protected override void BeforeSolveInstance()
{
ValueListUtils.UpdateValueLists(this, 12, Enum.GetNames(typeof(Bars.ShellModelType)).ToList(), null, GH_ValueListMode.DropDown);
}
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddGenericParameter("Bar", "Bar", "Bar element", GH_ParamAccess.item);
pManager.AddBooleanParameter("NewGuid", "NewGuid", "Generate a new guid for this bar?", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddCurveParameter("Curve", "Curve", "LineCurve or ArcCurve", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Material", "Material", "Material.", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Section", "Section", "Section. If 1 item this item defines both start and end. If two items the first item defines the start and the last item defines the end.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Connectivity", "Connectivity", "Connectivity. If 1 item this item defines both start and end. If two items the first item defines the start and the last item defines the end. Optional, default value if undefined.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Eccentricity", "Eccentricity", "Eccentricity. If 1 item this item defines both start and end. If two items the first item defines the start and the last item defines the end. Optional, default value if undefined.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddVectorParameter("LocalY", "LocalY", "Set local y-axis. Vector must be perpendicular to Curve mid-point local x-axis. This parameter overrides OrientLCS", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Stirrups", "Stirrups", "Stirrups to add to bar. Item or list. New reinforcement will overwrite the original.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("LongitudinalBars", "LongBars", "Longitudinal reinforcement to add to bar. Item or list. New reinforcement will overwrite the original.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("PTC", "PTC", "Post-tensioning cables. New PTC will overwrite the original.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("StiffnessModifier", "StiffnessModifier", "", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddTextParameter("Identifier", "Identifier", "Identifier. Optional, default value if undefined.", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Bar", "Bar", "Bar element", GH_ParamAccess.item);
pManager.AddBooleanParameter("NewGuid", "NewGuid", "Generate a new guid for this bar?", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddCurveParameter("Curve", "Curve", "LineCurve or ArcCurve", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Material", "Material", "Material.", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Section", "Section", "Section. If 1 item this item defines both start and end. If two items the first item defines the start and the last item defines the end.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Connectivity", "Connectivity", "Connectivity. If 1 item this item defines both start and end. If two items the first item defines the start and the last item defines the end. Optional, default value if undefined.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Eccentricity", "Eccentricity", "Eccentricity. If 1 item this item defines both start and end. If two items the first item defines the start and the last item defines the end. Optional, default value if undefined.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddVectorParameter("LocalY", "LocalY", "Set local y-axis. Vector must be perpendicular to Curve mid-point local x-axis. This parameter overrides OrientLCS", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("Stirrups", "Stirrups", "Stirrups to add to bar. Item or list. New reinforcement will overwrite the original.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("LongitudinalBars", "LongBars", "Longitudinal reinforcement to add to bar. Item or list. New reinforcement will overwrite the original.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("PTC", "PTC", "Post-tensioning cables. New PTC will overwrite the original.", GH_ParamAccess.list);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddGenericParameter("StiffnessModifier", "StiffnessModifier", "", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddTextParameter("ShellModel", "ShellModel", "Analytical model of the bar. Optional, default value is 'None'.\nConnect 'ValueList' to get the options:\nNone\nSimple\nComplex\n\n" +
"Note:\n'None' = Bar model;\n'Simple = Shell model. Contains only shell elements;\n'Complex = Shell model. Fictitious bars on the boundary of the shell model;", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;
pManager.AddTextParameter("Identifier", "Identifier", "Identifier. Optional, default value if undefined.", GH_ParamAccess.item);
pManager[pManager.ParamCount - 1].Optional = true;

}
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
Expand All @@ -57,6 +69,7 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager)
pManager.AddGenericParameter("LongitudinalBars", "LongBars", "Longitudinal reinforcement for bar.", GH_ParamAccess.list);
pManager.AddGenericParameter("PTC", "PTC", "Post-tensioning cables.", GH_ParamAccess.list);
pManager.AddGenericParameter("StiffnessModifier", "StiffnessModifier", "", GH_ParamAccess.item);
pManager.AddTextParameter("ShellModel", "ShellModel", "Analytical model of the bar.", GH_ParamAccess.item);
pManager.AddTextParameter("Identifier", "Identifier", "Structural element ID.", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
Expand Down Expand Up @@ -210,8 +223,14 @@ protected override void SolveInstance(IGH_DataAccess DA)
bar.BarPart.StiffnessModifiers = new List<Bars.BarStiffnessFactors>() { stiffnessFactors };
}

string shellModel = ShellModelType.None.ToString();
if (DA.GetData(12, ref shellModel))
{
bar.ShellModel = FemDesign.GenericClasses.EnumParser.Parse<ShellModelType>(shellModel);
}

string identifier = null;
if (DA.GetData(12, ref identifier))
if (DA.GetData(13, ref identifier))
{
bar.Identifier = identifier;
}
Expand Down Expand Up @@ -278,7 +297,8 @@ protected override void SolveInstance(IGH_DataAccess DA)

DA.SetDataList(10, bar.Ptc);
DA.SetData(11, bar.BarPart.StiffnessModifiers);
DA.SetData(12, bar.Name);
DA.SetData(12, bar.ShellModel);
DA.SetData(13, bar.Name);
}
protected override System.Drawing.Bitmap Icon
{
Expand All @@ -289,7 +309,7 @@ protected override System.Drawing.Bitmap Icon
}
public override Guid ComponentGuid
{
get { return new Guid("3A6FD9BA-6EBB-4822-B1A8-B3E3E297ED99"); }
get { return new Guid("{CF1E80D0-6236-4BCC-A8FB-6EBD8DA76CBF}"); }
}
public override GH_Exposure Exposure => GH_Exposure.secondary;

Expand Down
Loading

0 comments on commit a066887

Please sign in to comment.