← Back to team overview

fenics team mailing list archive

Re: double precision of single precision?

 

I might have found out what the problem is, in my main.cpp, I used the following code to get L2 error

---------------------part of Darcyflow.form-----------------------------
# for the error estimates of p
Me  = FiniteElement("Lagrange", "triangle", k+5)
pe = Function(Me)
ph = Function(Mh)
M = dot(ph-pe, ph-pe)*dx
---------------------part of main.cpp----------------------------------------
    DarcyflowFunctional M(ep,p);
    real e0 = sqrt(assemble(M, mesh));
    cout << "L2 error of pressure is " << e0 << endl;
-----------------------------------------------------------------------------------------

There is a "sqrt" there, thus reducing the round off error 1E-14 to 1E-7. 

That is my bad. Sorry about the confusion.

Best,
Chong Luo


----- Original Message ----
From: Anders Logg <logg@xxxxxxxxx>
To: fenics-dev@xxxxxxxxxx
Sent: Saturday, June 7, 2008 3:59:47 PM
Subject: Re: [FEniCS-dev] double precision of single precision?

On Sat, Jun 07, 2008 at 06:51:00PM +0100, Garth N. Wells wrote:
> 
> 
> Jed Brown wrote:
> > On Sat 2008-06-07 19:40, Anders Logg wrote:
> >> On Sat, Jun 07, 2008 at 09:17:03AM -0700, Chong Luo wrote:
> >>> What is the default precision of FEniCS, is it double precision or single
> >>> precision?
> >>>
> >>> I have this question, because for exact solution in P(2), using P(2) element
> >>> gave me an error of order 1E-7 instead of 1E-14.
> >> It doesn't work that way (unfortunately). The error depends on the
> >> mesh size. Or did you refine until convergence?
> > 
> > If the exact solution is really in P_2 then it can be represented exactly in the
> > finite element space.  Is it possible that the quadrature rule was inexact in
> > this case?

I missed that part.

> Yes, because FFC writes C++ code with finite precision. It can be 
> controlled through an FFC flag (or at least it used to be).
> 
> Garth

By default, FFC writes floating point as

  %.15g

so that shouldn't be the problem. There are 3 other sources I can
think of:

1. The precision of the basis functions generated by FIAT. I don't
know what precision FIAT uses, but presumably close to full precision
for P2.

2. The solution of the linear system. Which method was used to solve
the linear system?

3. Postprocessing. How did you measure the error? By writing the
solution to file? How many digits are stored in the output?

-- 
Anders



      

Follow ups