BriefFiniteElementNet / BriefFiniteElement.Net

BriefFiniteElementDotNET (BFE.NET) is a library for linear-static Finite Element Method (FEM) analysis of solids and structures in .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add code example: Start Coding with BFE in Vb.Net

epsi1on opened this issue · comments

Dim Model = New BriefFiniteElementNet.Model()

Dim n1 As New Node(0, 0, 0)

Dim n2 As New Node(1, 0, 0)

n1.Constraints = Constraints.Fixed

n2.Constraints = Constraint.Released

Model.Nodes.Add(n1)

Model.Nodes.Add(n2)

Dim elm = New BarElement(n1, n2)

Model.Elements.Add(elm)

elm.Section = New BriefFiniteElementNet.Sections.UniformParametric1DSection(0.01, 0.0000083, 0.0000083, 0.0000166) 'section's second area moments Iy and Iz = 8.3*10^-6, area = 0.01

elm.Material = BriefFiniteElementNet.Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210000000000.0, 0.3) 'Elastic mudule Is 210E9 And poisson ratio Is 0.3

Dim Load = New BriefFiniteElementNet.NodalLoad()

Dim frc = New Force()

frc.Fz = 1000 ' 1kN force In Z direction

Load.Force = frc

n2.Loads.Add(Load)

Model.Solve_MPC() 'Or model.Solve()

Dim d2 = n2.GetNodalDisplacement()

MessageBox.Show("Nodal displacement in Z direction is {0} meters (thus {1} mm)" + d2.DZ.ToString + " - " + (d2.DZ * 1000).ToString) 'print the Dz Of n2 into console

MessageBox.Show("Nodal rotation in Y direction is {0} radians (thus {1} degrees)" + d2.RY.ToString + "-" + (d2.RY * 180.0 / Math.PI).ToString) 'print the Rz Of n2 into console

also add two Imports directives on top of file:

Imports BriefFiniteElementNet
Imports BriefFiniteElementNet.Elements

Following the steps in your getting started documentation (replacing the C# Console App with a Visual Basic Console App) I was able to get your provided VB code to run and properly display an output in the console.

Imports BriefFiniteElementNet
Imports BriefFiniteElementNet.Elements

Module Program
    Sub Main()
        Dim Model As New Model()

        Dim n1 As New Node(0, 0, 0)
        Dim n2 As New Node(1, 0, 0)

        n1.Constraints = Constraints.Fixed
        n2.Constraints = Constraints.Released

        Model.Nodes.Add(n1)
        Model.Nodes.Add(n2)

        Dim elm = New BarElement(n1, n2)

        Model.Elements.Add(elm)

        'Section's second area moments Iy and Iz = 8.3*10^-6, area = 0.01
        elm.Section = New Sections.UniformParametric1DSection(0.01, 0.0000083, 0.0000083, 0.0000166)

        'Elastic mudule Is 210E9 And poisson ratio Is 0.3
        elm.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210000000000.0, 0.3)

        Dim Load As New NodalLoad()
        Dim frc As New Force()

        frc.Fz = 1000 '1kN force In Z direction
        Load.Force = frc

        n2.Loads.Add(Load)

        Model.Solve_MPC() 'Or model.Solve()

        Dim d2 = n2.GetNodalDisplacement()

        Dim v11 = Math.Round(d2.DZ, 6).ToString
        Dim v12 = Math.Round((d2.DZ * 1000), 6).ToString
        Dim v21 = Math.Round(d2.RY, 6).ToString
        Dim v22 = Math.Round((d2.RY * 180.0 / Math.PI), 6).ToString

        Dim OutputString As New Text.StringBuilder
        With OutputString
            .AppendLine($"The Nodal displacement in the z-axis is: {v11} m (Or: {v12} mm)")
            .AppendLine($"The Nodal rotation along the y-axis is: {v11} rad (Or: {v22} deg)")
        End With

        Console.WriteLine(OutputString.ToString)
    End Sub
End Module

@Brlaney thanks for information.
There is a visual basic project in samples section:
https://github.com/BriefFiniteElementNet/BriefFiniteElement.Net/blob/master/Samples/Examples.VisualBasic/Module1.vb

If you mind, you can add the code into this file and make a pull request. Otherwise I'll add the code to the file in this week.

I'd be glad to! I'll be able to later today actually.

Also, it's nice to meet you @epsi1on
You'll be seeing more of me as I am very excited to see your project and I am going to try and regularly contribute in any way possible.

Have a nice day!

OK, just did merged the pull request.
Thank you