I’m implementing a finite element code (translating from a working MATLAB version, so I have results to compare to) and for some odd reason, some of my computations are only accurate to around 6 decimal places.
I’m working with doubles and PetscScalars and I’ve double and quadruple checked my code and am fairly certain there is nothing wrong with my implementation. I went back and made sure all of my multiplications are with doubles or PetscScalars, though I’m not sure if that changes anything.
I test on an exact solution where I should get machine precision error. On a refinement study, the coarsest mesh (two-element triangular mesh on $[0,1]^{2}$) I get machine precision error but for every refinement after that, the error bumps up to around $10^{-7}$ and completely flatlines there. For exact solutions that can’t be exactly expressed in terms of the function space, I’m obtaining proper convergence rates for basis degree 1 and 2, and then the rates rapidly drop off for any high degrees.
I’ve been trying to hunt down the error for a while now. This is my first time programming such a large project in C so I’m sure there are some nuances that I just don’t know about, although I think I’m experience enough with C to have not made any errors when translating the working code. Do I have to specify that the PetscScalar’s are doubles? I reconfigured --with-precision=double
but it didn’t change the results.