From c9f2334ee1202204101917c525a4276c0ffe0b36 Mon Sep 17 00:00:00 2001 From: chu ding Date: Tue, 15 Oct 2024 11:24:23 -0500 Subject: [PATCH 1/9] Add DocFX --- docfx.json | 45 ++++++++++++++++++++++ docs/introduction.md | 2 + docs/toc.yml | 4 ++ index.md | 90 ++++++++++++++++++++++++++++++++++++++++++++ toc.yml | 4 ++ 5 files changed, 145 insertions(+) create mode 100644 docfx.json create mode 100644 docs/introduction.md create mode 100644 docs/toc.yml create mode 100644 index.md create mode 100644 toc.yml diff --git a/docfx.json b/docfx.json new file mode 100644 index 0000000..2acd123 --- /dev/null +++ b/docfx.json @@ -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 + } + } +} \ No newline at end of file diff --git a/docs/introduction.md b/docs/introduction.md new file mode 100644 index 0000000..18e0b73 --- /dev/null +++ b/docs/introduction.md @@ -0,0 +1,2 @@ +# Introduction +Update in future diff --git a/docs/toc.yml b/docs/toc.yml new file mode 100644 index 0000000..d7e9ea8 --- /dev/null +++ b/docs/toc.yml @@ -0,0 +1,4 @@ +- name: Introduction + href: introduction.md +- name: Getting Started + href: getting-started.md \ No newline at end of file diff --git a/index.md b/index.md new file mode 100644 index 0000000..72bc12d --- /dev/null +++ b/index.md @@ -0,0 +1,90 @@ +# FEALiTE2D +A fast and reliable finite element analysis library for 2D frame, beam and truss elements using C#. + +| [![NuGet](https://img.shields.io/nuget/dt/FEALiTE2D.svg)](https://www.nuget.org/packages/FEALiTE2D/) | FEALiTE2D | +------------ | ------------- +| [![NuGet](https://img.shields.io/nuget/dt/FEALiTE2D.Plotting.svg)](https://www.nuget.org/packages/FEALiTE2D.Plotting/) | FEALiTE2D.Plotting | + +## Features +* [x] Analysis of frame, beam, truss/link members. +* [x] Various load types: + * [x] Frame point load. + * [x] Frame uniform load. + * [x] Frame trapezoidal load. + * [x] Nodal point load. + * [x] Support displacement. +* [x] Loads can be set in global and element's local coordinate system. +* [x] Nodes can have local and global coordinate system. +* [x] Loads can be assigned in variant load cases of different natures. +* [x] Loads can be combined in a load combination with load magnification factors. +* [x] Rigid Supports of 3 degrees of freedom. +* [x] Elastic supports using translational and rotational springs. +* [x] Variety of predefined cross-sections. +* [x] Linear mesher for better analysis results. + + +## Sign convention for loads in global and local coordinate system. +![Loads - Global Local](https://user-images.githubusercontent.com/21183259/110838377-0d5ab900-82ab-11eb-838c-655865ae767b.png) + + +## Example +Here is a 2D framed strcture subjected to various loading conditions +![Example1-Loads](https://user-images.githubusercontent.com/21183259/110694187-fce60800-81f0-11eb-8c27-06d883906f06.png) + +```C# + +public void TestStructure() +{ + // units are kN, m + FEALiTE2D.Structure.Structure structure = new FEALiTE2D.Structure.Structure(); + + Node2D n1 = new Node2D(0, 0, "n1"); + Node2D n2 = new Node2D(9, 0, "n2"); + Node2D n3 = new Node2D(0, 6, "n3"); + Node2D n4 = new Node2D(9, 6, "n4"); + Node2D n5 = new Node2D(0, 12, "n5"); + n1.Restrain(NodalDegreeOfFreedom.UX, NodalDegreeOfFreedom.UY, NodalDegreeOfFreedom.RZ); //fully restrained + n2.Restrain(NodalDegreeOfFreedom.UX, NodalDegreeOfFreedom.UY, NodalDegreeOfFreedom.RZ); //fully restrained + + structure.AddNode(n1, n2, n3, n4, n5); + IMaterial material = new GenericIsotropicMaterial() { E = 30E6, U = 0.2, Label = "Steel", Alpha = 0.000012, Gama = 39885, MaterialType = MaterialType.Steel }; + IFrame2DSection section = new Generic2DSection(0.075, 0.075, 0.075, 0.000480, 0.000480, 0.000480 * 2, 0.1, 0.1, material); + + FrameElement2D e1 = new FrameElement2D(n1, n3, "e1") { CrossSection = section }; + FrameElement2D e2 = new FrameElement2D(n2, n4, "e2") { CrossSection = section }; + FrameElement2D e3 = new FrameElement2D(n3, n5, "e3") { CrossSection = section }; + FrameElement2D e4 = new FrameElement2D(n3, n4, "e4") { CrossSection = section }; + FrameElement2D e5 = new FrameElement2D(n4, n5, "e5") { CrossSection = section }; + structure.AddElement(new[] { e1, e2, e3, e4, e5 }); + + LoadCase loadCase = new LoadCase("live", LoadCaseType.Live); + structure.LoadCasesToRun.Add(loadCase); + n2.SupportDisplacementLoad.Add(new SupportDisplacementLoad(10E-3, -5E-3, -2.5 * Math.PI / 180, loadCase)); + e3.Loads.Add(new FramePointLoad(0, 0, 7.5, e3.Length / 2, LoadDirection.Global, loadCase)); + e4.Loads.Add(new FrameTrapezoidalLoad(0, 0, -15, -7, LoadDirection.Global, loadCase, 0.9, 2.7)); + e5.Loads.Add(new FrameUniformLoad(0, -12, LoadDirection.Local, loadCase)); + n3.NodalLoads.Add(new NodalLoad(80, 0, 0, LoadDirection.Global, loadCase)); + n5.NodalLoads.Add(new NodalLoad(40, 0, 0, LoadDirection.Global, loadCase)); + n1.NodalLoads.Add(new NodalLoad(40, 0, 0, LoadDirection.Global, loadCase)); + + structure.LinearMesher.NumberSegements = 35; + structure.Solve(); +} +``` + +## Ploting internal forces and displacments +Use ploting Library ```FEALiTE2D.Plotting```, create dxf plotter with correct options and save the file on your local machine. + + ```C# + var op = new FEALiTE2D.Plotting.Dxf.PlottingOption + { + NFDScaleFactor = 0.01, + SFDScaleFactor = 0.01, + BMDScaleFactor = 0.01, + DisplacmentScaleFactor = 1, + DiagramsHorizontalOffsets = 10 + }; +var plotter = new FEALiTE2D.Plotting.Dxf.Plotter(structure, op); +plotter.Plot("D:\\internal forces.dxf", loadCase); +``` +![internal forces](https://user-images.githubusercontent.com/21183259/133887224-05bf37e7-9cd4-43e9-bde1-00a0f5eb48eb.png) diff --git a/toc.yml b/toc.yml new file mode 100644 index 0000000..061acc6 --- /dev/null +++ b/toc.yml @@ -0,0 +1,4 @@ +- name: Docs + href: docs/ +- name: API + href: api/ \ No newline at end of file From f0c6269c5572d49b2ccea26d6eb1871e25346448 Mon Sep 17 00:00:00 2001 From: chu ding Date: Tue, 15 Oct 2024 11:26:19 -0500 Subject: [PATCH 2/9] Starter file in docs folder --- docs/getting-started.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 docs/getting-started.md diff --git a/docs/getting-started.md b/docs/getting-started.md new file mode 100644 index 0000000..62ed9ba --- /dev/null +++ b/docs/getting-started.md @@ -0,0 +1,2 @@ +# Getting Started +Update in future \ No newline at end of file From 9b3afb5da7ef15f7d9d27aca996a866231aab6b3 Mon Sep 17 00:00:00 2001 From: cding91 <43915456+cding91@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:33:15 -0500 Subject: [PATCH 3/9] Create doc_deploy.yml --- .github/workflows/doc_deploy.yml | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/doc_deploy.yml diff --git a/.github/workflows/doc_deploy.yml b/.github/workflows/doc_deploy.yml new file mode 100644 index 0000000..4df2852 --- /dev/null +++ b/.github/workflows/doc_deploy.yml @@ -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 From 073cf575f5e4d85c871b3334f563162410d090de Mon Sep 17 00:00:00 2001 From: cding91 <43915456+cding91@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:42:24 -0500 Subject: [PATCH 4/9] Delete index.md --- index.md | 90 -------------------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 index.md diff --git a/index.md b/index.md deleted file mode 100644 index 72bc12d..0000000 --- a/index.md +++ /dev/null @@ -1,90 +0,0 @@ -# FEALiTE2D -A fast and reliable finite element analysis library for 2D frame, beam and truss elements using C#. - -| [![NuGet](https://img.shields.io/nuget/dt/FEALiTE2D.svg)](https://www.nuget.org/packages/FEALiTE2D/) | FEALiTE2D | ------------- | ------------- -| [![NuGet](https://img.shields.io/nuget/dt/FEALiTE2D.Plotting.svg)](https://www.nuget.org/packages/FEALiTE2D.Plotting/) | FEALiTE2D.Plotting | - -## Features -* [x] Analysis of frame, beam, truss/link members. -* [x] Various load types: - * [x] Frame point load. - * [x] Frame uniform load. - * [x] Frame trapezoidal load. - * [x] Nodal point load. - * [x] Support displacement. -* [x] Loads can be set in global and element's local coordinate system. -* [x] Nodes can have local and global coordinate system. -* [x] Loads can be assigned in variant load cases of different natures. -* [x] Loads can be combined in a load combination with load magnification factors. -* [x] Rigid Supports of 3 degrees of freedom. -* [x] Elastic supports using translational and rotational springs. -* [x] Variety of predefined cross-sections. -* [x] Linear mesher for better analysis results. - - -## Sign convention for loads in global and local coordinate system. -![Loads - Global Local](https://user-images.githubusercontent.com/21183259/110838377-0d5ab900-82ab-11eb-838c-655865ae767b.png) - - -## Example -Here is a 2D framed strcture subjected to various loading conditions -![Example1-Loads](https://user-images.githubusercontent.com/21183259/110694187-fce60800-81f0-11eb-8c27-06d883906f06.png) - -```C# - -public void TestStructure() -{ - // units are kN, m - FEALiTE2D.Structure.Structure structure = new FEALiTE2D.Structure.Structure(); - - Node2D n1 = new Node2D(0, 0, "n1"); - Node2D n2 = new Node2D(9, 0, "n2"); - Node2D n3 = new Node2D(0, 6, "n3"); - Node2D n4 = new Node2D(9, 6, "n4"); - Node2D n5 = new Node2D(0, 12, "n5"); - n1.Restrain(NodalDegreeOfFreedom.UX, NodalDegreeOfFreedom.UY, NodalDegreeOfFreedom.RZ); //fully restrained - n2.Restrain(NodalDegreeOfFreedom.UX, NodalDegreeOfFreedom.UY, NodalDegreeOfFreedom.RZ); //fully restrained - - structure.AddNode(n1, n2, n3, n4, n5); - IMaterial material = new GenericIsotropicMaterial() { E = 30E6, U = 0.2, Label = "Steel", Alpha = 0.000012, Gama = 39885, MaterialType = MaterialType.Steel }; - IFrame2DSection section = new Generic2DSection(0.075, 0.075, 0.075, 0.000480, 0.000480, 0.000480 * 2, 0.1, 0.1, material); - - FrameElement2D e1 = new FrameElement2D(n1, n3, "e1") { CrossSection = section }; - FrameElement2D e2 = new FrameElement2D(n2, n4, "e2") { CrossSection = section }; - FrameElement2D e3 = new FrameElement2D(n3, n5, "e3") { CrossSection = section }; - FrameElement2D e4 = new FrameElement2D(n3, n4, "e4") { CrossSection = section }; - FrameElement2D e5 = new FrameElement2D(n4, n5, "e5") { CrossSection = section }; - structure.AddElement(new[] { e1, e2, e3, e4, e5 }); - - LoadCase loadCase = new LoadCase("live", LoadCaseType.Live); - structure.LoadCasesToRun.Add(loadCase); - n2.SupportDisplacementLoad.Add(new SupportDisplacementLoad(10E-3, -5E-3, -2.5 * Math.PI / 180, loadCase)); - e3.Loads.Add(new FramePointLoad(0, 0, 7.5, e3.Length / 2, LoadDirection.Global, loadCase)); - e4.Loads.Add(new FrameTrapezoidalLoad(0, 0, -15, -7, LoadDirection.Global, loadCase, 0.9, 2.7)); - e5.Loads.Add(new FrameUniformLoad(0, -12, LoadDirection.Local, loadCase)); - n3.NodalLoads.Add(new NodalLoad(80, 0, 0, LoadDirection.Global, loadCase)); - n5.NodalLoads.Add(new NodalLoad(40, 0, 0, LoadDirection.Global, loadCase)); - n1.NodalLoads.Add(new NodalLoad(40, 0, 0, LoadDirection.Global, loadCase)); - - structure.LinearMesher.NumberSegements = 35; - structure.Solve(); -} -``` - -## Ploting internal forces and displacments -Use ploting Library ```FEALiTE2D.Plotting```, create dxf plotter with correct options and save the file on your local machine. - - ```C# - var op = new FEALiTE2D.Plotting.Dxf.PlottingOption - { - NFDScaleFactor = 0.01, - SFDScaleFactor = 0.01, - BMDScaleFactor = 0.01, - DisplacmentScaleFactor = 1, - DiagramsHorizontalOffsets = 10 - }; -var plotter = new FEALiTE2D.Plotting.Dxf.Plotter(structure, op); -plotter.Plot("D:\\internal forces.dxf", loadCase); -``` -![internal forces](https://user-images.githubusercontent.com/21183259/133887224-05bf37e7-9cd4-43e9-bde1-00a0f5eb48eb.png) From 4bb220054c880f60f00482d7235931c953a159ce Mon Sep 17 00:00:00 2001 From: chu ding Date: Tue, 15 Oct 2024 11:46:35 -0500 Subject: [PATCH 5/9] Update ignore --- .gitignore | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ffa2608..e8bc80e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,43 @@ +.idea/ .vs/ FEALiTE2D/obj FEALiTE2D/bin FEALiTE2D.Tests/bin FEALiTE2D.Tests/obj FEALiTE2D.Plotting/bin -FEALiTE2D.Plotting/obj \ No newline at end of file +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 From c497d4db268021a4400c813f63fe257dcfd6a099 Mon Sep 17 00:00:00 2001 From: chu ding Date: Tue, 15 Oct 2024 11:47:35 -0500 Subject: [PATCH 6/9] Add back symbolic link --- index.md | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 index.md diff --git a/index.md b/index.md new file mode 100644 index 0000000..72bc12d --- /dev/null +++ b/index.md @@ -0,0 +1,90 @@ +# FEALiTE2D +A fast and reliable finite element analysis library for 2D frame, beam and truss elements using C#. + +| [![NuGet](https://img.shields.io/nuget/dt/FEALiTE2D.svg)](https://www.nuget.org/packages/FEALiTE2D/) | FEALiTE2D | +------------ | ------------- +| [![NuGet](https://img.shields.io/nuget/dt/FEALiTE2D.Plotting.svg)](https://www.nuget.org/packages/FEALiTE2D.Plotting/) | FEALiTE2D.Plotting | + +## Features +* [x] Analysis of frame, beam, truss/link members. +* [x] Various load types: + * [x] Frame point load. + * [x] Frame uniform load. + * [x] Frame trapezoidal load. + * [x] Nodal point load. + * [x] Support displacement. +* [x] Loads can be set in global and element's local coordinate system. +* [x] Nodes can have local and global coordinate system. +* [x] Loads can be assigned in variant load cases of different natures. +* [x] Loads can be combined in a load combination with load magnification factors. +* [x] Rigid Supports of 3 degrees of freedom. +* [x] Elastic supports using translational and rotational springs. +* [x] Variety of predefined cross-sections. +* [x] Linear mesher for better analysis results. + + +## Sign convention for loads in global and local coordinate system. +![Loads - Global Local](https://user-images.githubusercontent.com/21183259/110838377-0d5ab900-82ab-11eb-838c-655865ae767b.png) + + +## Example +Here is a 2D framed strcture subjected to various loading conditions +![Example1-Loads](https://user-images.githubusercontent.com/21183259/110694187-fce60800-81f0-11eb-8c27-06d883906f06.png) + +```C# + +public void TestStructure() +{ + // units are kN, m + FEALiTE2D.Structure.Structure structure = new FEALiTE2D.Structure.Structure(); + + Node2D n1 = new Node2D(0, 0, "n1"); + Node2D n2 = new Node2D(9, 0, "n2"); + Node2D n3 = new Node2D(0, 6, "n3"); + Node2D n4 = new Node2D(9, 6, "n4"); + Node2D n5 = new Node2D(0, 12, "n5"); + n1.Restrain(NodalDegreeOfFreedom.UX, NodalDegreeOfFreedom.UY, NodalDegreeOfFreedom.RZ); //fully restrained + n2.Restrain(NodalDegreeOfFreedom.UX, NodalDegreeOfFreedom.UY, NodalDegreeOfFreedom.RZ); //fully restrained + + structure.AddNode(n1, n2, n3, n4, n5); + IMaterial material = new GenericIsotropicMaterial() { E = 30E6, U = 0.2, Label = "Steel", Alpha = 0.000012, Gama = 39885, MaterialType = MaterialType.Steel }; + IFrame2DSection section = new Generic2DSection(0.075, 0.075, 0.075, 0.000480, 0.000480, 0.000480 * 2, 0.1, 0.1, material); + + FrameElement2D e1 = new FrameElement2D(n1, n3, "e1") { CrossSection = section }; + FrameElement2D e2 = new FrameElement2D(n2, n4, "e2") { CrossSection = section }; + FrameElement2D e3 = new FrameElement2D(n3, n5, "e3") { CrossSection = section }; + FrameElement2D e4 = new FrameElement2D(n3, n4, "e4") { CrossSection = section }; + FrameElement2D e5 = new FrameElement2D(n4, n5, "e5") { CrossSection = section }; + structure.AddElement(new[] { e1, e2, e3, e4, e5 }); + + LoadCase loadCase = new LoadCase("live", LoadCaseType.Live); + structure.LoadCasesToRun.Add(loadCase); + n2.SupportDisplacementLoad.Add(new SupportDisplacementLoad(10E-3, -5E-3, -2.5 * Math.PI / 180, loadCase)); + e3.Loads.Add(new FramePointLoad(0, 0, 7.5, e3.Length / 2, LoadDirection.Global, loadCase)); + e4.Loads.Add(new FrameTrapezoidalLoad(0, 0, -15, -7, LoadDirection.Global, loadCase, 0.9, 2.7)); + e5.Loads.Add(new FrameUniformLoad(0, -12, LoadDirection.Local, loadCase)); + n3.NodalLoads.Add(new NodalLoad(80, 0, 0, LoadDirection.Global, loadCase)); + n5.NodalLoads.Add(new NodalLoad(40, 0, 0, LoadDirection.Global, loadCase)); + n1.NodalLoads.Add(new NodalLoad(40, 0, 0, LoadDirection.Global, loadCase)); + + structure.LinearMesher.NumberSegements = 35; + structure.Solve(); +} +``` + +## Ploting internal forces and displacments +Use ploting Library ```FEALiTE2D.Plotting```, create dxf plotter with correct options and save the file on your local machine. + + ```C# + var op = new FEALiTE2D.Plotting.Dxf.PlottingOption + { + NFDScaleFactor = 0.01, + SFDScaleFactor = 0.01, + BMDScaleFactor = 0.01, + DisplacmentScaleFactor = 1, + DiagramsHorizontalOffsets = 10 + }; +var plotter = new FEALiTE2D.Plotting.Dxf.Plotter(structure, op); +plotter.Plot("D:\\internal forces.dxf", loadCase); +``` +![internal forces](https://user-images.githubusercontent.com/21183259/133887224-05bf37e7-9cd4-43e9-bde1-00a0f5eb48eb.png) From 1145aaa0554797a5284d647c74b24e4ff4ccef93 Mon Sep 17 00:00:00 2001 From: chu ding Date: Mon, 4 Nov 2024 14:50:42 -0600 Subject: [PATCH 7/9] Fix typo --- FEALiTE2D.Tests/Loads/FrameLinearLoadTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FEALiTE2D.Tests/Loads/FrameLinearLoadTest.cs b/FEALiTE2D.Tests/Loads/FrameLinearLoadTest.cs index 423ea85..ab2a8b0 100644 --- a/FEALiTE2D.Tests/Loads/FrameLinearLoadTest.cs +++ b/FEALiTE2D.Tests/Loads/FrameLinearLoadTest.cs @@ -35,7 +35,7 @@ public void Setup() // confirmed with robot [Test] - public void FrameUnifromLoadStraightTest() + public void FrameUniformLoadStraightTest() { Console.WriteLine(e1.LocalCoordinateSystemMatrix.PrintDenseMatrix()); @@ -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(); @@ -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(); From 45e88e55664847fb7826baa9644bacf196ee3826 Mon Sep 17 00:00:00 2001 From: chu ding Date: Mon, 4 Nov 2024 14:51:41 -0600 Subject: [PATCH 8/9] Fix bug for null object in test case with partial uniform load on element --- .../Structure/PostProcessorTest.cs | 135 ++++++++++++++++++ FEALiTE2D/Structure/PostProcessor.cs | 7 + 2 files changed, 142 insertions(+) create mode 100644 FEALiTE2D.Tests/Structure/PostProcessorTest.cs diff --git a/FEALiTE2D.Tests/Structure/PostProcessorTest.cs b/FEALiTE2D.Tests/Structure/PostProcessorTest.cs new file mode 100644 index 0000000..e523622 --- /dev/null +++ b/FEALiTE2D.Tests/Structure/PostProcessorTest.cs @@ -0,0 +1,135 @@ +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_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 }; + } + } +} \ No newline at end of file diff --git a/FEALiTE2D/Structure/PostProcessor.cs b/FEALiTE2D/Structure/PostProcessor.cs index c4754c1..e91cf79 100644 --- a/FEALiTE2D/Structure/PostProcessor.cs +++ b/FEALiTE2D/Structure/PostProcessor.cs @@ -300,6 +300,13 @@ public double[] GetElementLocalEndDisplacement(IElement element, LoadCase loadCa { // get uniform load in lcs. FrameUniformLoad uniformLoad = uL.GetLoadValueAt(element, x) as FrameUniformLoad; + + // Null may be returned if ul end is before the segment + if (uniformLoad == null) + { + continue; + } + double wx = uniformLoad.Wx, wy = uniformLoad.Wy, x1 = uL.L1, From ade8807de320db1e839de6c68627e3fb7f2ba189 Mon Sep 17 00:00:00 2001 From: chu ding Date: Tue, 5 Nov 2024 11:06:17 -0600 Subject: [PATCH 9/9] Fix the frame uniform load bug once for all --- .../Structure/PostProcessorTest.cs | 26 ++++++++++++++++++- FEALiTE2D/FEALiTE2D.csproj | 7 +++-- FEALiTE2D/Structure/PostProcessor.cs | 10 +++---- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/FEALiTE2D.Tests/Structure/PostProcessorTest.cs b/FEALiTE2D.Tests/Structure/PostProcessorTest.cs index e523622..6db02dd 100644 --- a/FEALiTE2D.Tests/Structure/PostProcessorTest.cs +++ b/FEALiTE2D.Tests/Structure/PostProcessorTest.cs @@ -66,7 +66,32 @@ public void GetElementInternalForcesAt_WithUniformLoad_ReturnsCorrectForce() 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() { @@ -76,7 +101,6 @@ public void GetElementInternalForcesAt_WithPartialUniformLoad_ReturnsCorrectForc var c = _L - a - b; _elem.Loads.Add(new FrameUniformLoad(0.0, w, LoadDirection.Local, _lc, a, c)); - _structure.Solve(); var postProcessor = _structure.Results; diff --git a/FEALiTE2D/FEALiTE2D.csproj b/FEALiTE2D/FEALiTE2D.csproj index ebf56cc..8d6ba8d 100644 --- a/FEALiTE2D/FEALiTE2D.csproj +++ b/FEALiTE2D/FEALiTE2D.csproj @@ -1,7 +1,7 @@ - net45;netstandard2.0 + net45;netstandard2.0;net8.0 Mohamed Salah Ibrahim Copyright © 2021 Mohamed Salah Ibrahim Civilms@outlook.com A fast and reliable finite element analysis library for 2D frame, beam and truss elements using C#. @@ -12,9 +12,8 @@ true false MIT - 1.1.0 - - Dxf Plotter. -- Additional meshing points at any location on the frame element. + 1.1.2 + Fix bug in element with parital uniform loading (works this time) https://github.com/FEALiTE/FEALiTE2D diff --git a/FEALiTE2D/Structure/PostProcessor.cs b/FEALiTE2D/Structure/PostProcessor.cs index e91cf79..b5a38eb 100644 --- a/FEALiTE2D/Structure/PostProcessor.cs +++ b/FEALiTE2D/Structure/PostProcessor.cs @@ -299,13 +299,9 @@ public double[] GetElementLocalEndDisplacement(IElement element, LoadCase loadCa if (uL.L1 <= x) { // get uniform load in lcs. - FrameUniformLoad uniformLoad = uL.GetLoadValueAt(element, x) as FrameUniformLoad; - - // Null may be returned if ul end is before the segment - if (uniformLoad == null) - { - continue; - } + // 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,