Finding a unique solution for pressure solving Stokes equations

Asked by Feruza

Hi,

I am learning Fenics and trying to solve stationary Stokes equations for incompressible fluid with no slip condition on the boundary. The global average of p over the domain is zero but \ int p dx = 0 was not used in variational formulation. The average of p can be adjusted as a post processing step as I found from website: www.tu-chemnitz.de/mathematik/part.../FEniCS/Handout_FEniCS.pd...

int_p = p*dx
average_p = assemble(int_p, mesh = mesh)
p_array = p.vector ().array() - average_p
p.vector()[:] = p_array

But it did not work and gave error:

*** Error: Unable to access vector of degrees of freedom fro function.
*** Reason: Cannot access a non-const vector from a subfunction.
*** Where: This error was encountered inside Function.cpp.

Any suggestions?

Thank you.
Feruza

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Kent-Andre Mardal (kent-and) said :
#1

You can use the real space in a similar fashion as done for the Poisson
Neuman problem.
Have a look at the demo: demo_neuman-poisson.py, can be found eg.
http://bazaar.launchpad.net/~dolfin-core/dolfin/trunk/view/head:/demo/undocumented/neumann-poisson/python/demo_neumann-poisson.py

On 3 April 2012 01:25, Feruza <email address hidden> wrote:

> Question #192460 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/192460
>
> Description changed to:
> Hi,
>
> I am learning Fenics and trying to solve stationary Stokes equations for
> incompressible fluid with no slip condition on the boundary. The global
> average of p over the domain is zero but \ int p dx = 0 was not used in
> variational formulation. The average of p can be adjusted as a post
> processing step as I found from web:
>
> int_p = p*dx
> average_p = assemble(int_p, mesh = mesh)
> p_array = p.vector ().array() - average_p
> p.vector()[:] = p_array
>
> But it did not work and gives error:
>
> *** Error: Unable to access vector of degrees of freedom fro function.
> *** Reason: Cannot access a non-const vector from a subfunction.
> *** Where: This error was encountered inside Function.cpp.
>
> Any suggestions?
>
> Thank you.
> Feruza
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>

Revision history for this message
Kent-Andre Mardal (kent-and) said :
#2

Another alternative that is more efficient on large meshes are here:
http://bazaar.launchpad.net/~cbc.block/cbc.block/dev/view/head:/demo/stokes.py

On 3 April 2012 07:36, Kent-Andre Mardal <email address hidden> wrote:

> You can use the real space in a similar fashion as done for the Poisson
> Neuman problem.
> Have a look at the demo: demo_neuman-poisson.py, can be found eg.
>
> http://bazaar.launchpad.net/~dolfin-core/dolfin/trunk/view/head:/demo/undocumented/neumann-poisson/python/demo_neumann-poisson.py
>
>
> On 3 April 2012 01:25, Feruza <email address hidden>wrote:
>
>> Question #192460 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/192460
>>
>> Description changed to:
>> Hi,
>>
>> I am learning Fenics and trying to solve stationary Stokes equations for
>> incompressible fluid with no slip condition on the boundary. The global
>> average of p over the domain is zero but \ int p dx = 0 was not used in
>> variational formulation. The average of p can be adjusted as a post
>> processing step as I found from web:
>>
>> int_p = p*dx
>> average_p = assemble(int_p, mesh = mesh)
>> p_array = p.vector ().array() - average_p
>> p.vector()[:] = p_array
>>
>> But it did not work and gives error:
>>
>> *** Error: Unable to access vector of degrees of freedom fro function.
>> *** Reason: Cannot access a non-const vector from a subfunction.
>> *** Where: This error was encountered inside Function.cpp.
>>
>> Any suggestions?
>>
>> Thank you.
>> Feruza
>>
>> --
>> You received this question notification because you are a member of
>> DOLFIN Team, which is an answer contact for DOLFIN.
>>
>
>

Can you help with this problem?

Provide an answer of your own, or ask Feruza for more information if necessary.

To post a message you must log in.