dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #16350
Re: [Bug 457262] [NEW] function and expression does not give the same result
oelgaard wrote:
> Public bug reported:
>
> The following two files will reproduce the bug.
>
> M.ufl:
>
> exact = FiniteElement("Lagrange", triangle, 6)
> approx = FiniteElement("Lagrange", triangle, 1)
>
> u = Function(exact)
> uh = Function(approx)
>
> M = (uh - u)*(uh - u)*dx
>
>
> main.cpp:
>
> #include <dolfin.h>
> #include "M.h"
>
> using namespace dolfin;
>
> class Expr : public Expression
> {
> public:
>
> Expr() : Expression(2) {}
>
> void eval(double* values, const double* x) const
> {
> values[0] = 10*x[0]*x[1];
> }
>
> };
>
> class Expr2 : public Expression
> {
> public:
>
> Expr2() : Expression(2) {}
>
> void eval(double* values, const double* x) const
> {
> values[0] = sin(5*x[0]);
> }
> };
>
> class Func2 : public Function
> {
> public:
>
> Func2(FunctionSpace& v) : Function(v) {}
>
> void eval(double* values, const double* x) const
> {
> values[0] = sin(5*x[0]);
> }
> };
>
The above class shouldn't be possible with the development version of
DOLFIN. Are you using an older version?
Garth
> int main()
> {
> // Create mesh and function space
> UnitSquare mesh(8, 8);
> M::CoefficientSpace_u Vu(mesh);
> M::CoefficientSpace_uh Vuh(mesh);
>
> Expr exact;
> // Expr2 approx; // 12.5251
> // Func2 approx(Vuh); // 11.1111
> Func2 approx(Vu); // 11.1111
>
> M::Functional m(mesh);
> m.u = exact;
> m.uh = approx;
>
> double error = assemble(m);
>
> std::cout << "error: " << error << std::endl;
>
> return 0;
> }
>
> ** Affects: dolfin
> Importance: Undecided
> Status: New
>
--
function and expression does not give the same result
https://bugs.launchpad.net/bugs/457262
You received this bug notification because you are subscribed to DOLFIN.
Status in DOLFIN: New
Bug description:
The following two files will reproduce the bug.
M.ufl:
exact = FiniteElement("Lagrange", triangle, 6)
approx = FiniteElement("Lagrange", triangle, 1)
u = Function(exact)
uh = Function(approx)
M = (uh - u)*(uh - u)*dx
main.cpp:
#include <dolfin.h>
#include "M.h"
using namespace dolfin;
class Expr : public Expression
{
public:
Expr() : Expression(2) {}
void eval(double* values, const double* x) const
{
values[0] = 10*x[0]*x[1];
}
};
class Expr2 : public Expression
{
public:
Expr2() : Expression(2) {}
void eval(double* values, const double* x) const
{
values[0] = sin(5*x[0]);
}
};
class Func2 : public Function
{
public:
Func2(FunctionSpace& v) : Function(v) {}
void eval(double* values, const double* x) const
{
values[0] = sin(5*x[0]);
}
};
int main()
{
// Create mesh and function space
UnitSquare mesh(8, 8);
M::CoefficientSpace_u Vu(mesh);
M::CoefficientSpace_uh Vuh(mesh);
Expr exact;
// Expr2 approx; // 12.5251
// Func2 approx(Vuh); // 11.1111
Func2 approx(Vu); // 11.1111
M::Functional m(mesh);
m.u = exact;
m.uh = approx;
double error = assemble(m);
std::cout << "error: " << error << std::endl;
return 0;
}
Follow ups
References