Skip to content

Commit

Permalink
Merge pull request #22 from runtosolve/fix-partial-load-span-bug
Browse files Browse the repository at this point in the history
Fix partial load span bug
  • Loading branch information
SaMohamed authored Feb 4, 2025
2 parents db1aaba + ade8807 commit 2ff5c93
Show file tree
Hide file tree
Showing 12 changed files with 403 additions and 9 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/doc_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Your GitHub workflow file under .github/workflows/
# Trigger the action on push to main
on:
push:
branches:
- main
paths:
- docs/**/*.{md,yml}
- toc.yml
- index.md
- docfx.json
- .github/workflows/doc_deploy.yml

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
actions: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
publish-docs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Dotnet Setup
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.x

- run: dotnet tool update -g docfx
- run: docfx docfx.json

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '_site'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
38 changes: 37 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,43 @@
.idea/
.vs/
FEALiTE2D/obj
FEALiTE2D/bin
FEALiTE2D.Tests/bin
FEALiTE2D.Tests/obj
FEALiTE2D.Plotting/bin
FEALiTE2D.Plotting/obj
FEALiTE2D.Plotting/obj

_site/**/*
api/**/*

# User specific
**/.idea/**/workspace.xml
**/.idea/**/tasks.xml
**/.idea/shelf/*
**/.idea/dictionaries
**/.idea/httpRequests/

# Sensitive or high-churn files
**/.idea/**/dataSources/
**/.idea/**/dataSources.ids
**/.idea/**/dataSources.xml
**/.idea/**/dataSources.local.xml
**/.idea/**/sqlDataSources.xml
**/.idea/**/dynamic.xml

# Rider
# Rider auto-generates .iml files, and contentModel.xml
**/.idea/**/*.iml
**/.idea/**/contentModel.xml
**/.idea/**/modules.xml

*.suo
*.user
[Bb]in/
[Oo]bj/
_UpgradeReport_Files/
[Pp]ackages/

Thumbs.db
Desktop.ini
.DS_Store
6 changes: 3 additions & 3 deletions FEALiTE2D.Tests/Loads/FrameLinearLoadTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void Setup()

// confirmed with robot
[Test]
public void FrameUnifromLoadStraightTest()
public void FrameUniformLoadStraightTest()
{
Console.WriteLine(e1.LocalCoordinateSystemMatrix.PrintDenseMatrix());

Expand All @@ -51,7 +51,7 @@ public void FrameUnifromLoadStraightTest()

// confirmed with robot
[Test]
public void FrameUnifromLoadLocalStraightTest2()
public void FrameUniformLoadLocalStraightTest2()
{
e1.EndNode = new Node2D(10, 10, "n2");
e1.Initialize();
Expand Down Expand Up @@ -82,7 +82,7 @@ public void FrameUnifromLoadLocalStraightTest2()

// confirmed with robot
[Test]
public void FrameUnifromLoadGlobalStraightTest3()
public void FrameUniformLoadGlobalStraightTest3()
{
e1.EndNode = new Node2D(10, 10, "n2");
e1.Initialize();
Expand Down
159 changes: 159 additions & 0 deletions FEALiTE2D.Tests/Structure/PostProcessorTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
using System;
using FEALiTE2D.CrossSections;
using FEALiTE2D.Elements;
using FEALiTE2D.Loads;
using FEALiTE2D.Materials;
using NUnit.Framework;

namespace FEALiTE2D.Tests.Structure
{
[TestFixture]
public class PostProcessorTest
{
private FEALiTE2D.Structure.Structure _structure;
private FrameElement2D _elem;
private LoadCase _lc;
private const double _L = 1.0;

[SetUp]
public void SetUp()
{
var material = new GenericIsotropicMaterial()
{
E = 1000.0,
U = 0.3,
Label = "Mat1"
};
var section = new Generic2DSection(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, material);

_structure = new FEALiTE2D.Structure.Structure();

var n1 = new Node2D(0.0, 0.0, "n1");
var n2 = new Node2D(_L, 0.0, "n2");

n1.Support = new NodalSupport(true, true, false);
n2.Support = new NodalSupport(false, true, false);

_elem = new FrameElement2D(n1, n2, "e1")
{
CrossSection = section,
};

_lc = new LoadCase("General", LoadCaseType.Dead);

_structure.AddElement(_elem, true);
_structure.LoadCasesToRun.Add(_lc);
}

[Test]
public void GetElementInternalForcesAt_WithUniformLoad_ReturnsCorrectForce()
{
_elem.Loads.Add(new FrameUniformLoad(0.0, -1.0, LoadDirection.Local, _lc));

_structure.Solve();

var postProcessor = _structure.Results;

var f1 = postProcessor.GetElementInternalForcesAt(_elem, _lc, 0.0);
var f2 = postProcessor.GetElementInternalForcesAt(_elem, _lc, 1.0);

var expectedLeftEndForce = new double[] {0.0, 0.5, 0.0}; // Fx, Fy, Mz
var expectedRightEndForce = new double[] {0.0, -0.5, 0.0}; // Fx, Fy, Mz

Assert.Multiple(() =>
{
Assert.That(new double[] { f1.Fx, f1.Fy, f1.Mz }, Is.EqualTo(expectedLeftEndForce).Within(1E-3));
Assert.That(new double[] { f2.Fx, f2.Fy, f2.Mz }, Is.EqualTo(expectedRightEndForce).Within(1E-3));
});
}

[Test]
public void GetElementInternalForcesAt_WithPartialUniformLoad_EdgeSegment_ReturnsCorrectForce()
{
var w = 0.39023287672392115;
var a = 0.16751904679908325;
var b = 0.637225136662688 - a;
var c = _L - a - b;

_elem.Loads.Add(new FrameUniformLoad(0.0, w, LoadDirection.Local, _lc, a, c));

_structure.LinearMesher.NumberSegements = 4;
_structure.Solve();

var postProcessor = _structure.Results;

var x = 1.0;
var expectedForce = new[] {0.0, 0.0737, 0.0}; // Fx, Fy, Mz

var f = postProcessor.GetElementInternalForcesAt(_elem, _lc, x);
var actualForce = new[] { f.Fx, f.Fy, f.Mz };

Assert.That(actualForce, Is.EqualTo(expectedForce).Within(1E-3));
}


[Test]
public void GetElementInternalForcesAt_WithPartialUniformLoad_ReturnsCorrectForce()
{
var w = -1.0;
var a = 0.25;
var b = 0.5;
var c = _L - a - b;

_elem.Loads.Add(new FrameUniformLoad(0.0, w, LoadDirection.Local, _lc, a, c));
_structure.Solve();

var postProcessor = _structure.Results;

var x = 0.5;
var R1 = Math.Abs(w) * b / (2 * _L) * (2 * c + b);
var Mmax = R1 * (a + R1 / (2 * Math.Abs(w)));
var expectedForce = new[] {0.0, 0.0, -Mmax}; // Fx, Fy, Mz

var f = postProcessor.GetElementInternalForcesAt(_elem, _lc, x);
var actualForce = new[] { f.Fx, f.Fy, f.Mz };

Assert.That(actualForce, Is.EqualTo(expectedForce).Within(1E-3));
}

[Test]
public void GetElementInternalForcesAt_WithTrapezoidalLoad_ReturnsCorrectForce()
{
var w = -1.0;
_elem.Loads.Add(new FrameTrapezoidalLoad(0.0, 0.0, 0.0, w, LoadDirection.Local, _lc));

_structure.Solve();

var postProcessor = _structure.Results;

var W = Math.Abs(w) * _L / 2;
var x = 0.5;
var Mx = W * x / (3 * _L * _L) * (_L * _L - x * x);
var Vx = W / 3 - W * x * x / (_L * _L);
var expectedForce = new[] {0.0, Vx, -Mx}; // Fx, Fy, Mz

var f = postProcessor.GetElementInternalForcesAt(_elem, _lc, x);
var actualForce = new[] { f.Fx, f.Fy, f.Mz };

Assert.That(actualForce, Is.EqualTo(expectedForce).Within(1E-3));
}

[Test]
public void GetElementInternalForcesAt_WithPartialTrapezoidalLoad_ReturnCorrectForce()
{
var w = -1.0;
var a = 0.25;
var b = 0.5;
var c = _L - a - b;
_elem.Loads.Add(new FrameTrapezoidalLoad(0.0, 0.0, 0.0, w, LoadDirection.Local, _lc, a, c));

_structure.Solve();

var x = 0.5;

var postProcessor = _structure.Results;
var f = postProcessor.GetElementInternalForcesAt(_elem, _lc, x);
var actualForce = new[] { f.Fx, f.Fy, f.Mz };
}
}
}
7 changes: 3 additions & 4 deletions FEALiTE2D/FEALiTE2D.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net45;netstandard2.0;net8.0</TargetFrameworks>
<Authors>Mohamed Salah Ibrahim</Authors>
<Copyright>Copyright © 2021 Mohamed Salah Ibrahim Civilms@outlook.com</Copyright>
<Description>A fast and reliable finite element analysis library for 2D frame, beam and truss elements using C#.</Description>
Expand All @@ -12,9 +12,8 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<EnableNETAnalyzers>false</EnableNETAnalyzers>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Version>1.1.0</Version>
<PackageReleaseNotes>- Dxf Plotter.
- Additional meshing points at any location on the frame element.</PackageReleaseNotes>
<Version>1.1.2</Version>
<PackageReleaseNotes>Fix bug in element with parital uniform loading (works this time)</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/FEALiTE/FEALiTE2D</PackageProjectUrl>
</PropertyGroup>

Expand Down
5 changes: 4 additions & 1 deletion FEALiTE2D/Structure/PostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ public double[] GetElementLocalEndDisplacement(IElement element, LoadCase loadCa
if (uL.L1 <= x)
{
// get uniform load in lcs.
FrameUniformLoad uniformLoad = uL.GetLoadValueAt(element, x) as FrameUniformLoad;
// CD: uniformLoad is used only for global-local transformation. Must never be null.
// CD: Replace x with uL.L1 to avoid null.
FrameUniformLoad uniformLoad = uL.GetLoadValueAt(element, uL.L1) as FrameUniformLoad;

double wx = uniformLoad.Wx,
wy = uniformLoad.Wy,
x1 = uL.L1,
Expand Down
45 changes: 45 additions & 0 deletions docfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"metadata": [
{
"src": [
{
"src": "./FEALiTE2D",
"files": [
"**/*.csproj"
]
}
],
"dest": "api"
}
],
"build": {
"content": [
{
"files": [
"**/*.{md,yml}"
],
"exclude": [
"_site/**"
]
}
],
"resource": [
{
"files": [
"images/**"
]
}
],
"output": "_site",
"template": [
"default",
"modern"
],
"globalMetadata": {
"_appName": "FEALiTE2D",
"_appTitle": "FEALiTE2D",
"_enableSearch": true,
"pdf": false
}
}
}
2 changes: 2 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Getting Started
Update in future
2 changes: 2 additions & 0 deletions docs/introduction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Introduction
Update in future
4 changes: 4 additions & 0 deletions docs/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- name: Introduction
href: introduction.md
- name: Getting Started
href: getting-started.md
Loading

0 comments on commit 2ff5c93

Please sign in to comment.