Skip to main content

Posts

Showing posts from May, 2018

Finite Element Method Programming - 1D bar element, C# methods, C# loops

On the previous post, we established 1D bar finite element. This time we will go more into the programming in C# and try to make some automation in our code. I will try to explain: - loops: for - methods in C# - arrays 1D and 2D In the beginning, we have to build a task for us, to not feel that we are losing time. So, let's imagine that we want to check the result for the same bar, but with several divisions. For example: Does the result will change if I will create 2 finite elements instead of 1? The beginning of the code will be looking the same: namespace FEM1d_basic_1 {      class Program     {          static void Main(string[] args)         {              // The heading of the code              Console .WriteLine("FEM 1D program for bar");             // The variables              double emodulus = 210000; // 1000[kN/m2]=1GPa              double barlength = 10; // [m] meters              double elementarea = 0.01; // [m2] meter x meter