Skip to content

Commit

Permalink
Merge branch '829_Add-AdvanceFEM-to-ModelDeconstruct' into 22.9.0_Dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lorinczandrea committed Oct 23, 2023
2 parents a0f305c + 1bf71c4 commit 6442072
Show file tree
Hide file tree
Showing 84 changed files with 1,756 additions and 418 deletions.
6 changes: 3 additions & 3 deletions FemDesign.Core/FemDesign.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@
<Compile Include="Results\Timber Design\CLTShellUtilization.cs" />
<Compile Include="Shells\SlabStiffnessFactors.cs" />
<Compile Include="Stage\ActivatedLoadCase.cs" />
<Compile Include="AdvancedFem\AdvancedFem.cs" />
<Compile Include="AdvancedFem\Cover.cs" />
<Compile Include="AdvancedFem\CoverReferenceList.cs" />
<Compile Include="ModellingTools\AdvancedFem.cs" />
<Compile Include="ModellingTools\Cover.cs" />
<Compile Include="ModellingTools\CoverReferenceList.cs" />
<Compile Include="Stage\ConstructionStages.cs" />
<Compile Include="Stage\Stage.cs" />
<Compile Include="AuxiliaryResults\LabelledSectionsGeometry.cs" />
Expand Down
6 changes: 5 additions & 1 deletion FemDesign.Core/GenericClasses/GuidListType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ public GuidListType(Guid guid)
this.Guid = guid;
}


/// <summary>
/// Implicit conversion of a Entity to its Global Unique Identifier.
/// </summary>
/// <param name="entity"></param>
public static implicit operator GuidListType(EntityBase entity) => new GuidListType(entity.Guid);

public override string ToString()
{
return $"{this.Guid}";
}
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion FemDesign.Core/Model/Entities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public partial class Entities
public Supports.Supports Supports { get; set; } = new Supports.Supports();

[XmlElement("advanced-fem", Order = 28)]
public AdvancedFem AdvancedFem { get; set; } = new AdvancedFem();
public ModellingTools.AdvancedFem AdvancedFem { get; set; } = new ModellingTools.AdvancedFem();

[XmlElement("storeys", Order = 29)]
public StructureGrid.Storeys Storeys { get; set; }
Expand Down
107 changes: 97 additions & 10 deletions FemDesign.Core/Model/Model.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ public static Model DeserializeFromFilePath(string filePath)
model.GetPointConnections();
if (model.Entities.AdvancedFem.ConnectedLines.Any())
model.GetLineConnections();
if (model.Entities.AdvancedFem.SurfaceConnections.Any())
model.GetSurfaceConnections();
if (model.ConstructionStages != null && model.ConstructionStages.Stages.Any())
model.GetConstructionStages();
if (model.Entities?.Loads?.LoadCombinations != null && model.Entities.Loads.LoadCombinations.Any())
Expand Down Expand Up @@ -435,7 +437,7 @@ public string SerializeToString()
/// <summary>
/// Add entities to Model.
/// </summary>
public Model AddEntities(List<Bars.Bar> bars, List<ModellingTools.FictitiousBar> fictitiousBars, List<Shells.Slab> shells, List<ModellingTools.FictitiousShell> fictitiousShells, List<Shells.Panel> panels, List<Cover> covers, List<object> loads, List<Loads.LoadCase> loadCases, List<Loads.LoadCombination> loadCombinations, List<ISupportElement> supports, List<StructureGrid.Storey> storeys, List<StructureGrid.Axis> axes, List<Loads.ModelGeneralLoadGroup> loadGroups, bool overwrite)
public Model AddEntities(List<Bars.Bar> bars, List<ModellingTools.FictitiousBar> fictitiousBars, List<Shells.Slab> shells, List<ModellingTools.FictitiousShell> fictitiousShells, List<Shells.Panel> panels, List<ModellingTools.Cover> covers, List<object> loads, List<Loads.LoadCase> loadCases, List<Loads.LoadCombination> loadCombinations, List<ISupportElement> supports, List<StructureGrid.Storey> storeys, List<StructureGrid.Axis> axes, List<Loads.ModelGeneralLoadGroup> loadGroups, bool overwrite)
{
// check if model contains entities, sections and materials
if (this.Entities == null)
Expand Down Expand Up @@ -502,7 +504,7 @@ public Model AddEntities(List<Bars.Bar> bars, List<ModellingTools.FictitiousBar>

if (covers != null)
{
foreach (Cover cover in covers)
foreach (ModellingTools.Cover cover in covers)
{
this.AddCover(cover, overwrite);
}
Expand Down Expand Up @@ -900,7 +902,7 @@ private void AddComplexComposite(StruSoft.Interop.StruXml.Data.Complex_composite
/// <summary>
/// Add Cover to Model.
/// </summary>
private void AddCover(Cover obj, bool overwrite)
private void AddCover(ModellingTools.Cover obj, bool overwrite)
{
// in model?
bool inModel = this.CoverInModel(obj);
Expand All @@ -924,9 +926,9 @@ private void AddCover(Cover obj, bool overwrite)
/// <summary>
/// Check if Cover in Model.
/// </summary>
private bool CoverInModel(Cover obj)
private bool CoverInModel(ModellingTools.Cover obj)
{
foreach (Cover elem in this.Entities.AdvancedFem.Covers)
foreach (ModellingTools.Cover elem in this.Entities.AdvancedFem.Covers)
{
if (elem.Guid == obj.Guid)
{
Expand All @@ -936,12 +938,79 @@ private bool CoverInModel(Cover obj)
return false;
}

private void AddSurfaceConnection(ModellingTools.SurfaceConnection obj, bool overwrite)
{
// advanced fem null?
if (this.Entities.AdvancedFem == null)
{
this.Entities.AdvancedFem = new ModellingTools.AdvancedFem();
}

// surface connection null?
if (this.Entities.AdvancedFem.SurfaceConnections == null)
{
this.Entities.AdvancedFem.SurfaceConnections = new List<ModellingTools.SurfaceConnection>();
}

// in model?
bool inModel = this.Entities.AdvancedFem.SurfaceConnections.Any(x => x.Guid == obj.Guid);

// in model, don't overwrite
if (inModel && !overwrite)
{
throw new System.ArgumentException($"{obj.GetType().FullName} with guid: {obj.Guid} has already been added to model. Are you adding the same element twice?");
}

// in model, overwrite
else if (inModel && overwrite)
{
this.Entities.AdvancedFem.SurfaceConnections.RemoveAll(x => x.Guid == obj.Guid);
}

// add surface connection
this.Entities.AdvancedFem.SurfaceConnections.Add(obj);

// add predefined rigidity
if (obj.PredefRigidity != null)
{
this.AddSurfaceConnectionLibItem(obj.PredefRigidity, overwrite);
}
}

private void AddSurfaceConnectionLibItem(Releases.RigidityDataLibType1 obj, bool overwrite)
{
// if null create new element
if (this.SurfaceConnectionTypes == null)
{
this.SurfaceConnectionTypes = new LibraryItems.SurfaceConnectionTypes();
this.SurfaceConnectionTypes.PredefinedTypes = new List<Releases.RigidityDataLibType1>();
}

// in model?
bool inModel = this.SurfaceConnectionTypes.PredefinedTypes.Any(x => x.Guid == obj.Guid);

// in model, don't overwrite
if (inModel && !overwrite)
{
throw new System.ArgumentException($"{obj.GetType().FullName} with guid: {obj.Guid} has already been added to model. Are you adding the same element twice?");
}

// in model, overwrite
else if (inModel && overwrite)
{
this.SurfaceConnectionTypes.PredefinedTypes.RemoveAll(x => x.Guid == obj.Guid);
}

// add lib item
this.SurfaceConnectionTypes.PredefinedTypes.Add(obj);
}

private void AddConnectedLine(ModellingTools.ConnectedLines obj, bool overwrite)
{
// advanced fem null?
if (this.Entities.AdvancedFem == null)
{
this.Entities.AdvancedFem = new AdvancedFem();
this.Entities.AdvancedFem = new ModellingTools.AdvancedFem();
}

// connected lines null?
Expand Down Expand Up @@ -1008,7 +1077,7 @@ private void AddConnectedPoints(ModellingTools.ConnectedPoints obj, bool overwri
// advanced fem null?
if (this.Entities.AdvancedFem == null)
{
this.Entities.AdvancedFem = new AdvancedFem();
this.Entities.AdvancedFem = new ModellingTools.AdvancedFem();
}

// connected points null?
Expand Down Expand Up @@ -1993,7 +2062,7 @@ private void AddPredefinedRigidity(Releases.RigidityDataLibType3 obj, bool overw
}

/// <summary>
/// Check if Material (reinforcring) in Model.
/// Check if predefined rigidity.
/// </summary>
private bool PredefRigidityInModel(Releases.RigidityDataLibType3 obj)
{
Expand Down Expand Up @@ -3405,13 +3474,13 @@ public Model AddSupports<T>(params T[] supports) where T : ISupportElement
private void AddEntity(Reinforcement.Ptc obj, bool overwrite) => AddPtc(obj, overwrite);


private void AddEntity(Cover obj, bool overwrite) => AddCover(obj, overwrite);
private void AddEntity(ModellingTools.Cover obj, bool overwrite) => AddCover(obj, overwrite);

private void AddEntity(ModellingTools.FictitiousShell obj, bool overwrite) => AddFictShell(obj, overwrite);
private void AddEntity(ModellingTools.FictitiousBar obj, bool overwrite) => AddFictBar(obj, overwrite);
private void AddEntity(ModellingTools.ConnectedPoints obj, bool overwrite) => AddConnectedPoints(obj, overwrite);
private void AddEntity(ModellingTools.ConnectedLines obj, bool overwrite) => AddConnectedLine(obj, overwrite);
//private void AddEntity(ModellingTools.SurfaceConnection obj, bool overwrite) => AddSurfaceConnection(obj, overwrite);
private void AddEntity(ModellingTools.SurfaceConnection obj, bool overwrite) => AddSurfaceConnection(obj, overwrite);
private void AddEntity(ModellingTools.Diaphragm obj, bool overwrite) => AddDiaphragm(obj, overwrite);

private void AddEntity(AuxiliaryResults.LabelledSection obj, bool overwrite) => AddLabelledSection(obj, overwrite);
Expand Down Expand Up @@ -3910,6 +3979,24 @@ internal void GetLineConnections()
}
}

internal void GetSurfaceConnections()
{
foreach (ModellingTools.SurfaceConnection connectedSurf in this.Entities.AdvancedFem.SurfaceConnections)
{
// predefined rigidity
if (this.SurfaceConnectionTypes != null && this.SurfaceConnectionTypes.PredefinedTypes != null)
{
foreach (Releases.RigidityDataLibType1 predefinedType in this.SurfaceConnectionTypes.PredefinedTypes)
{
if (connectedSurf._predefRigidityRef != null && predefinedType.Guid == connectedSurf._predefRigidityRef.Guid)
{
connectedSurf.PredefRigidity = predefinedType;
}
}
}
}
}

internal void GetConstructionStages()
{
var loadCaseNames = this.Entities.Loads.LoadCases?.ToDictionary(lc => lc.Guid, lc => lc.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Xml.Serialization;


namespace FemDesign
namespace FemDesign.ModellingTools
{
/// <summary>
/// Connections and virtual objects
Expand All @@ -12,22 +12,22 @@ namespace FemDesign
public partial class AdvancedFem
{
[XmlElement("connected_points", Order = 1)]
public List<ModellingTools.ConnectedPoints> ConnectedPoints { get; set; } = new List<ModellingTools.ConnectedPoints>();
public List<ConnectedPoints> ConnectedPoints { get; set; } = new List<ConnectedPoints>();

[XmlElement("connected_lines", Order = 2)]
public List<ModellingTools.ConnectedLines> ConnectedLines { get; set; } = new List<ModellingTools.ConnectedLines>();
public List<ConnectedLines> ConnectedLines { get; set; } = new List<ConnectedLines>();

[XmlElement("surface_connection", Order = 3)]
public ModellingTools.SurfaceConnection[] SurfaceConnections { get; set; }
public List<SurfaceConnection> SurfaceConnections { get; set; } = new List<SurfaceConnection>();

[XmlElement("virtual_bar", Order = 4)]
public List<ModellingTools.FictitiousBar> FictitiousBars = new List<ModellingTools.FictitiousBar>();
public List<FictitiousBar> FictitiousBars = new List<FictitiousBar>();

[XmlElement("virtual_shell", Order = 5)]
public List<ModellingTools.FictitiousShell> FictitiousShells = new List<ModellingTools.FictitiousShell>();
public List<FictitiousShell> FictitiousShells = new List<FictitiousShell>();

[XmlElement("diaphragm", Order = 6)]
public List<ModellingTools.Diaphragm> Diaphragms { get; set; } = new List<ModellingTools.Diaphragm>();
public List<Diaphragm> Diaphragms { get; set; } = new List<Diaphragm>();


[XmlElement("steel_joint", Order = 7)]
Expand Down
Loading

0 comments on commit 6442072

Please sign in to comment.