dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #24401
Re: [noreply@xxxxxxxxxxxxx: [Branch ~dolfin-core/dolfin/main] Rev 6178: Fix problem with pugixml reducing precision of doubles.]
-
To:
"Garth N. Wells" <gnw20@xxxxxxxxx>
-
From:
Anders Logg <logg@xxxxxxxxx>
-
Date:
Mon, 12 Sep 2011 16:09:45 +0200
-
Cc:
DOLFIN Mailing List <dolfin@xxxxxxxxxxxxxxxxxxx>
-
In-reply-to:
<CAA4C66NMng212W=MGV7_XGbHcKQm5_dRxHbnGxw6932JjgN3jw@mail.gmail.com>
-
User-agent:
Mutt/1.5.21 (2010-09-15)
On Mon, Sep 12, 2011 at 03:04:19PM +0100, Garth N. Wells wrote:
> On 12 September 2011 13:42, Anders Logg <logg@xxxxxxxxx> wrote:
> > Why 20? Any perhaps this should be made into a global parameter value?
> >
>
> That's just a left over debugging line. I've removed it now.
I see that now.
--
Anders
> Garth
>
> >
> >
> > ---------- Forwarded message ----------
> > From: noreply@xxxxxxxxxxxxx
> > To: Anders Logg <logg@xxxxxxxxx>
> > Date: Mon, 12 Sep 2011 12:07:16 -0000
> > Subject: [Branch ~dolfin-core/dolfin/main] Rev 6178: Fix problem with pugixml reducing precision of doubles.
> > ------------------------------------------------------------
> > revno: 6178
> > committer: Garth N. Wells <gnw20@xxxxxxxxx>
> > branch nick: dolfin-all
> > timestamp: Mon 2011-09-12 12:52:42 +0100
> > message:
> > Fix problem with pugixml reducing precision of doubles.
> >
> > Solution is to cast double to a string before passing to pugixml, thereby avoiding a cast inside pugixml.
> > modified:
> > dolfin/io/XMLArray.h
> >
> >
> >
> > Your team DOLFIN Core Team is subscribed to branch lp:dolfin.
> > To unsubscribe from this branch go to https://code.launchpad.net/~dolfin-core/dolfin/main/+edit-subscription
> >
> > === modified file 'dolfin/io/XMLArray.h'
> > --- dolfin/io/XMLArray.h 2011-07-02 14:50:50 +0000
> > +++ dolfin/io/XMLArray.h 2011-09-12 11:52:42 +0000
> > @@ -23,6 +23,7 @@
> >
> > #include <ostream>
> > #include <string>
> > +#include <boost/lexical_cast.hpp>
> > #include "dolfin/common/Array.h"
> > #include "dolfin/log/log.h"
> > #include "pugixml.hpp"
> > @@ -90,12 +91,16 @@
> > array_node.append_attribute("type") = type.c_str();
> > array_node.append_attribute("size") = size;
> >
> > + std::cout << std::setprecision(20);
> > +
> > // Add data
> > for (uint i = 0; i < size; ++i)
> > {
> > pugi::xml_node element_node = array_node.append_child("element");
> > element_node.append_attribute("index") = i;
> > - element_node.append_attribute("value") = x[i];
> > + // NOTE: Casting to a string to avoid loss of precision when
> > + // pugixml performs double-to-char conversion
> > + element_node.append_attribute("value") = boost::lexical_cast<std::string>(x[i]).c_str();
> > }
> > }
> > //-----------------------------------------------------------------------------
> >
> >
> > _______________________________________________
> > Mailing list: https://launchpad.net/~dolfin
> > Post to : dolfin@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~dolfin
> > More help : https://help.launchpad.net/ListHelp
> >
> >
References