I have written a program of sorts to calculate the element stiffness matrix of a 2-D rectangular finite element. For brevity's sake I will not post the entire thing, but here is my problem: I have created arrays with elements for which I have assigned numerical values, however these values are not being retained in the contents of the array. For example, when I define the integration weights toward the very beginning of the program, it looks something like this:
I noticed this because the rest of the program relies on these values, and my final product was returning all zeros. I went through line by line and discovered that the arrays I thought had numerical values assigned to them were in fact equal to zero.
I am rather new to C++, but I have exhausted the Xcode manual and my patience with Google so I was hoping someone here could lend a hand. The heading of my program looks like this:
#include <iostream>
using namespace std;
int main()
{ "Finite element program that's way too long to post"
}
So it's pretty basic I think. I'm quite confident there is a much more efficient way to have coded this whole thing, but I'm just a lowly mechanical engineer so my programming experience starts and ends with matlab.
The variables are retaining the values assigned to them, the problem is that what you think is being assigned is incorrect. The variables that you are using are of type int, meaning that they can hold integer values. You are attempting to assign decimal numbers, which are not integers. You will have to use a variable type that allows decimal numbers, such as floating point numbers, or double precision floating point numbers: