This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

The error of Stokes problem with mini element

+2 votes

Hi every one
The error of stokes problem with mini element has obsessed me. I have not fixed it. The error exists. When I run the code, the error appears:
evaluate_dof(s) for enriched element not implemented.

Could you give some suggestions? Any comments are appreciated.

Stokes.ufl code:

P1 = VectorElement("Lagrange", triangle, 1)
B = VectorElement("Bubble", triangle, 3)
Q = FiniteElement("Lagrange", triangle, 1)
MixElement = (P1 + B) * Q   
f=Coefficient (P1)
(u, p) = TrialFunctions(MixElement)
(v, q) = TestFunctions(MixElement)
a=inner (grad(u), grad(v))*dx - p*div(v)*dx + q*div(u)*dx  
L=inner(f,v)*dx

My main cpp:

#include <dolfin.h>
#include "Stokes.h"
using namespace dolfin;
class Source : public Expression
{
 public:
 Source() : Expression(2) {}
 void eval(Array<double>& values, const Array<double>& x) const
 {
  values[0] = -20.0*x[1]*x[1]*x[1] +20.0 * (2*x[1]-1);
  values[1] = -20.0*x[0]*x[0]*x[0] +20.0 * (2*x[0]-1);
  }
 };

// Exact solution velocity
class ExactSolutionVelocity : public Expression
{
public:
ExactSolutionVelocity() : Expression(2) {}
void eval(Array<double>& values, const Array<double>& x) const
{
  values[0] = x[1]*x[1]*x[1]*x[1]*x[1];
  values[1] = x[0]*x[0]*x[0]*x[0]*x[0];
}
};
// Exact solution pressure
class ExactSolutionPressure : public Expression
{
public:
void eval(Array<double>& values, const Array<double>& x) const
{
  values[0] = 10.0*(2*x[0]-1) * (2*x[1]-1);
  }
 };

class DirichletBoundary : public SubDomain
{
 bool inside(const Array<double>& x, bool on_boundary) const
{
return on_boundary;
}
};

int main()
{
int n=64;
UnitSquareMesh mesh(n,n);
Stokes:: FunctionSpace W(mesh);
SubSpace W0(W,0);
SubSpace W1(W,1);
DirichletBoundary boundary;
ExactSolutionVelocity u_boundary;
DirichletBC bc(W0, u_boundary, boundary);
Source f;  
Stokes:: BilinearForm a(W,W);
Stokes:: LinearForm L(W);
L.f=f;
Function w(W);
solve(a==L, w, bc);
Function u = w[0];
Function p = w[1]; 
return 0;
}
asked Jun 5, 2016 by Guodong Zhang FEniCS Novice (420 points)

1 Answer

+4 votes
 
Best answer

Nodal basis for enriched elements is not supported yet, see https://bitbucket.org/fenics-project/ffc/issues/69/. As a result following features in DOLFIN do not work:

  • interpolation to enriched space,
  • projection from enriched to another mesh,
  • using expressions and constants in Dirichlet BCs on enriched space

The rest should be working.

Problem is probably in DirichletBC and workaround is described in http://fenicsproject.org/documentation/dolfin/1.6.0/python/demo/documented/stokes-mini/python/documentation.html .

answered Jun 5, 2016 by Jan Blechta FEniCS Expert (51,420 points)
selected Jun 16, 2016 by Garth N. Wells

Thank you! Jan Blechta. And are there some methods to make the mini element work? Or, we
have to turn to Taylor hood element?

Basis works. Nodes do not. Only mentioned operations on the element do not work. Assembly works so that you can solve your problem. See the mentioned demo.

Hi Jan Blechta
So, we can assemble stiff matrix, but we can not implement DirichletBC on enriched, No the DirichletBC, we also can not solve stokes. Is that right? Thank you!

No, it isn't. You can use DirichletBC but not with Expression or Constant. You need to supply Function on the matching space. See the mentioned demo. It works.

Hi Jan Blechta, I solved the problem by following you suggestions. Thank you for you kind help!
Guodong zhang

I am trying to get this workaround, but the web page is not available anymore.

Thank, but it is strange, this example is not working anymore.

The error start at:

V = P1 + B

TypeError: unsupported operand type(s) for +: 'FunctionSpace' and 'FunctionSpace'

The new version change the way to enrich the element function?

In other words, costly building of intermediate function spaces P1, B, V is avoided.

...