L2-scaling

Asked by Achim Schroll on 2010-05-06

for a plain Poisson eqn with pure Neumann b.c., how to specify the scaling condition u*dx = 0 ?
Best, Achim

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Achim Schroll
Solved:
2010-05-07
Last query:
2010-05-07
Last reply:
2010-05-06
Marie Rognes (meg-simula) said : #1

Achim Schroll wrote:
> New question #109900 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/109900
>
> for a plain Poisson eqn with pure Neumann b.c., how to specify the scaling condition u*dx = 0 ?
>

If you have a recent dolfin, you can introduce a constant c acting as a
Lagrange multiplier corresponding to the constraint. See example below.

from dolfin import *

mesh = UnitSquare(32, 32)
V = FunctionSpace(mesh, "CG", 1)
Q = FunctionSpace(mesh, "R", 0)
M = V * Q

(u, c) = TrialFunctions(M)
(v, d) = TestFunctions(M)

f = Expression("x[0]*x[1]*sin(pi*x[0])")

a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
L = v*f*dx

pde = VariationalProblem(a, L)
u_h = pde.solve()

plot(u_h[0])
interactive()

--
Marie

Garth Wells (garth-wells) said : #2

On 06/05/10 13:52, Marie Rognes wrote:
> Achim Schroll wrote:
>> New question #109900 on DOLFIN:
>> https://answers.launchpad.net/dolfin/+question/109900
>>
>> for a plain Poisson eqn with pure Neumann b.c., how to specify the
>> scaling condition u*dx = 0 ?
>
>
>
> If you have a recent dolfin, you can introduce a constant c acting as a
> Lagrange multiplier corresponding to the constraint. See example below.
>

Nice. What does 'R' stand for in the definition of the space Q?

Garth

> from dolfin import *
>
> mesh = UnitSquare(32, 32)
> V = FunctionSpace(mesh, "CG", 1)
> Q = FunctionSpace(mesh, "R", 0)
> M = V * Q
>
> (u, c) = TrialFunctions(M)
> (v, d) = TestFunctions(M)
>
> f = Expression("x[0]*x[1]*sin(pi*x[0])")
>
> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
> L = v*f*dx
>
> pde = VariationalProblem(a, L)
> u_h = pde.solve()
>
> plot(u_h[0])
> interactive()
>
>
> --
> Marie
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~dolfin
> More help : https://help.launchpad.net/ListHelp

Marie Rognes (meg-simula) said : #3

Garth Wells wrote:
> Question #109900 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/109900
>
> Garth Wells proposed the following answer:
>
> On 06/05/10 13:52, Marie Rognes wrote:
>
>> Achim Schroll wrote:
>>
>>> New question #109900 on DOLFIN:
>>> https://answers.launchpad.net/dolfin/+question/109900
>>>
>>> for a plain Poisson eqn with pure Neumann b.c., how to specify the
>>> scaling condition u*dx = 0 ?
>>>
>>
>> If you have a recent dolfin, you can introduce a constant c acting as a
>> Lagrange multiplier corresponding to the constraint. See example below.
>>
>>
>
> Nice. What does 'R' stand for in the definition of the space Q?
>
>

"Real" (Space of real numbers)

--
Marie

> Garth
>
>
>> from dolfin import *
>>
>> mesh = UnitSquare(32, 32)
>> V = FunctionSpace(mesh, "CG", 1)
>> Q = FunctionSpace(mesh, "R", 0)
>> M = V * Q
>>
>> (u, c) = TrialFunctions(M)
>> (v, d) = TestFunctions(M)
>>
>> f = Expression("x[0]*x[1]*sin(pi*x[0])")
>>
>> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
>> L = v*f*dx
>>
>> pde = VariationalProblem(a, L)
>> u_h = pde.solve()
>>
>> plot(u_h[0])
>> interactive()
>>
>>
>> --
>> Marie
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dolfin
>> Post to : <email address hidden>
>> Unsubscribe : https://launchpad.net/~dolfin
>> More help : https://help.launchpad.net/ListHelp
>>
>
>

Garth Wells (garth-wells) said : #4

On 06/05/10 14:22, Marie Rognes wrote:
> Garth Wells wrote:
>> Question #109900 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/109900
>>
>> Garth Wells proposed the following answer:
>>
>> On 06/05/10 13:52, Marie Rognes wrote:
>>> Achim Schroll wrote:
>>>> New question #109900 on DOLFIN:
>>>> https://answers.launchpad.net/dolfin/+question/109900
>>>>
>>>> for a plain Poisson eqn with pure Neumann b.c., how to specify the
>>>> scaling condition u*dx = 0 ?
>>>
>>> If you have a recent dolfin, you can introduce a constant c acting as a
>>> Lagrange multiplier corresponding to the constraint. See example below.
>>>
>>
>> Nice. What does 'R' stand for in the definition of the space Q?
>>
>
> "Real" (Space of real numbers)
>

OK.

It would good to add this example as a demo to DOLFIN.

Garth

>
> --
> Marie
>
>> Garth
>>
>>> from dolfin import *
>>>
>>> mesh = UnitSquare(32, 32)
>>> V = FunctionSpace(mesh, "CG", 1)
>>> Q = FunctionSpace(mesh, "R", 0)
>>> M = V * Q
>>>
>>> (u, c) = TrialFunctions(M)
>>> (v, d) = TestFunctions(M)
>>>
>>> f = Expression("x[0]*x[1]*sin(pi*x[0])")
>>>
>>> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
>>> L = v*f*dx
>>>
>>> pde = VariationalProblem(a, L)
>>> u_h = pde.solve()
>>>
>>> plot(u_h[0])
>>> interactive()
>>>
>>>
>>> --
>>> Marie
>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dolfin
>>> Post to : <email address hidden>
>>> Unsubscribe : https://launchpad.net/~dolfin
>>> More help : https://help.launchpad.net/ListHelp
>>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~dolfin
> More help : https://help.launchpad.net/ListHelp

Marie Rognes (meg-simula) said : #5

Garth N. Wells wrote:
>
>
> On 06/05/10 14:22, Marie Rognes wrote:
>> Garth Wells wrote:
>>> Question #109900 on DOLFIN changed:
>>> https://answers.launchpad.net/dolfin/+question/109900
>>>
>>> Garth Wells proposed the following answer:
>>>
>>> On 06/05/10 13:52, Marie Rognes wrote:
>>>> Achim Schroll wrote:
>>>>> New question #109900 on DOLFIN:
>>>>> https://answers.launchpad.net/dolfin/+question/109900
>>>>>
>>>>> for a plain Poisson eqn with pure Neumann b.c., how to specify the
>>>>> scaling condition u*dx = 0 ?
>>>>
>>>> If you have a recent dolfin, you can introduce a constant c acting
>>>> as a
>>>> Lagrange multiplier corresponding to the constraint. See example
>>>> below.
>>>>
>>>
>>> Nice. What does 'R' stand for in the definition of the space Q?
>>>
>>
>> "Real" (Space of real numbers)
>>
>
> OK.
>
> It would good to add this example as a demo to DOLFIN.
>

Maybe someone with pushing rights to DOLFIN could do so.... ;)

--
Marie

> Garth
>
>>
>> --
>> Marie
>>
>>> Garth
>>>
>>>> from dolfin import *
>>>>
>>>> mesh = UnitSquare(32, 32)
>>>> V = FunctionSpace(mesh, "CG", 1)
>>>> Q = FunctionSpace(mesh, "R", 0)
>>>> M = V * Q
>>>>
>>>> (u, c) = TrialFunctions(M)
>>>> (v, d) = TestFunctions(M)
>>>>
>>>> f = Expression("x[0]*x[1]*sin(pi*x[0])")
>>>>
>>>> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
>>>> L = v*f*dx
>>>>
>>>> pde = VariationalProblem(a, L)
>>>> u_h = pde.solve()
>>>>
>>>> plot(u_h[0])
>>>> interactive()
>>>>
>>>>
>>>> --
>>>> Marie
>>>>
>>>>
>>>> _______________________________________________
>>>> Mailing list: https://launchpad.net/~dolfin
>>>> Post to : <email address hidden>
>>>> Unsubscribe : https://launchpad.net/~dolfin
>>>> More help : https://help.launchpad.net/ListHelp
>>>
>>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dolfin
>> Post to : <email address hidden>
>> Unsubscribe : https://launchpad.net/~dolfin
>> More help : https://help.launchpad.net/ListHelp

Garth Wells (garth-wells) said : #6

On 06/05/10 14:29, Marie Rognes wrote:
> Garth N. Wells wrote:
>>
>>
>> On 06/05/10 14:22, Marie Rognes wrote:
>>> Garth Wells wrote:
>>>> Question #109900 on DOLFIN changed:
>>>> https://answers.launchpad.net/dolfin/+question/109900
>>>>
>>>> Garth Wells proposed the following answer:
>>>>
>>>> On 06/05/10 13:52, Marie Rognes wrote:
>>>>> Achim Schroll wrote:
>>>>>> New question #109900 on DOLFIN:
>>>>>> https://answers.launchpad.net/dolfin/+question/109900
>>>>>>
>>>>>> for a plain Poisson eqn with pure Neumann b.c., how to specify the
>>>>>> scaling condition u*dx = 0 ?
>>>>>
>>>>> If you have a recent dolfin, you can introduce a constant c acting
>>>>> as a
>>>>> Lagrange multiplier corresponding to the constraint. See example
>>>>> below.
>>>>>
>>>>
>>>> Nice. What does 'R' stand for in the definition of the space Q?
>>>>
>>>
>>> "Real" (Space of real numbers)
>>>
>>
>> OK.
>>
>> It would good to add this example as a demo to DOLFIN.
>>
>
> Maybe someone with pushing rights to DOLFIN could do so.... ;)
>

But who would then write the documentation page,

   http://www.fenics.org/newdoc/demos/python/index.html

? :)

Garth

> --
> Marie
>
>> Garth
>>
>>>
>>> --
>>> Marie
>>>
>>>> Garth
>>>>
>>>>> from dolfin import *
>>>>>
>>>>> mesh = UnitSquare(32, 32)
>>>>> V = FunctionSpace(mesh, "CG", 1)
>>>>> Q = FunctionSpace(mesh, "R", 0)
>>>>> M = V * Q
>>>>>
>>>>> (u, c) = TrialFunctions(M)
>>>>> (v, d) = TestFunctions(M)
>>>>>
>>>>> f = Expression("x[0]*x[1]*sin(pi*x[0])")
>>>>>
>>>>> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
>>>>> L = v*f*dx
>>>>>
>>>>> pde = VariationalProblem(a, L)
>>>>> u_h = pde.solve()
>>>>>
>>>>> plot(u_h[0])
>>>>> interactive()
>>>>>
>>>>>
>>>>> --
>>>>> Marie
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Mailing list: https://launchpad.net/~dolfin
>>>>> Post to : <email address hidden>
>>>>> Unsubscribe : https://launchpad.net/~dolfin
>>>>> More help : https://help.launchpad.net/ListHelp
>>>>
>>>
>>>
>>> _______________________________________________
>>> Mailing list: https://launchpad.net/~dolfin
>>> Post to : <email address hidden>
>>> Unsubscribe : https://launchpad.net/~dolfin
>>> More help : https://help.launchpad.net/ListHelp
>

Anders Logg (logg) said : #7

On Thu, May 06, 2010 at 02:52:33PM +0200, Marie Rognes wrote:
> Achim Schroll wrote:
> >New question #109900 on DOLFIN:
> >https://answers.launchpad.net/dolfin/+question/109900
> >
> >for a plain Poisson eqn with pure Neumann b.c., how to specify the scaling condition u*dx = 0 ?
>
>
>
> If you have a recent dolfin, you can introduce a constant c acting
> as a Lagrange multiplier corresponding to the constraint. See
> example below.
>
> from dolfin import *
>
> mesh = UnitSquare(32, 32)
> V = FunctionSpace(mesh, "CG", 1)
> Q = FunctionSpace(mesh, "R", 0)
> M = V * Q
>
> (u, c) = TrialFunctions(M)
> (v, d) = TestFunctions(M)
>
> f = Expression("x[0]*x[1]*sin(pi*x[0])")
>
> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
> L = v*f*dx
>
> pde = VariationalProblem(a, L)
> u_h = pde.solve()
>
> plot(u_h[0])
> interactive()

But make sure to not name that space 'M' if you try this with a UFL
file or you will get a strange error (since 'M' is reserved in form
files).

Anyway, I'm wondering about the dofmap for the "R" element. It sets
_global_dimension to m.num_entities[2] which is the global number of
cells, but then it maps all dofs to 0. Is that right? Shouldn't the
global dimension be 1?

--
Anders

Marie Rognes (meg-simula) said : #8

Anders Logg wrote:
> Question #109900 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/109900
>
> Anders Logg proposed the following answer:
> On Thu, May 06, 2010 at 02:52:33PM +0200, Marie Rognes wrote:
>
>> Achim Schroll wrote:
>>
>>> New question #109900 on DOLFIN:
>>> https://answers.launchpad.net/dolfin/+question/109900
>>>
>>> for a plain Poisson eqn with pure Neumann b.c., how to specify the scaling condition u*dx = 0 ?
>>>
>>
>> If you have a recent dolfin, you can introduce a constant c acting
>> as a Lagrange multiplier corresponding to the constraint. See
>> example below.
>>
>> from dolfin import *
>>
>> mesh = UnitSquare(32, 32)
>> V = FunctionSpace(mesh, "CG", 1)
>> Q = FunctionSpace(mesh, "R", 0)
>> M = V * Q
>>
>> (u, c) = TrialFunctions(M)
>> (v, d) = TestFunctions(M)
>>
>> f = Expression("x[0]*x[1]*sin(pi*x[0])")
>>
>> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
>> L = v*f*dx
>>
>> pde = VariationalProblem(a, L)
>> u_h = pde.solve()
>>
>> plot(u_h[0])
>> interactive()
>>
>
> But make sure to not name that space 'M' if you try this with a UFL
> file or you will get a strange error (since 'M' is reserved in form
> files).
>
> Anyway, I'm wondering about the dofmap for the "R" element. It sets
> _global_dimension to m.num_entities[2] which is the global number of
> cells, but then it maps all dofs to 0. Is that right? Shouldn't the
> global dimension be 1?
>
>

Yes, it is a bug for non-mixed elements(!). I noticed but didn't really
want to start fixing before
the weekend. It's on the todo-list though.

--
Marie

Anders Logg (logg) said : #9

On Thu, May 06, 2010 at 08:42:19PM -0000, Marie Rognes wrote:
> Question #109900 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/109900
>
> Marie Rognes proposed the following answer:
> Anders Logg wrote:
> > Question #109900 on DOLFIN changed:
> > https://answers.launchpad.net/dolfin/+question/109900
> >
> > Anders Logg proposed the following answer:
> > On Thu, May 06, 2010 at 02:52:33PM +0200, Marie Rognes wrote:
> >
> >> Achim Schroll wrote:
> >>
> >>> New question #109900 on DOLFIN:
> >>> https://answers.launchpad.net/dolfin/+question/109900
> >>>
> >>> for a plain Poisson eqn with pure Neumann b.c., how to specify the scaling condition u*dx = 0 ?
> >>>
> >>
> >> If you have a recent dolfin, you can introduce a constant c acting
> >> as a Lagrange multiplier corresponding to the constraint. See
> >> example below.
> >>
> >> from dolfin import *
> >>
> >> mesh = UnitSquare(32, 32)
> >> V = FunctionSpace(mesh, "CG", 1)
> >> Q = FunctionSpace(mesh, "R", 0)
> >> M = V * Q
> >>
> >> (u, c) = TrialFunctions(M)
> >> (v, d) = TestFunctions(M)
> >>
> >> f = Expression("x[0]*x[1]*sin(pi*x[0])")
> >>
> >> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
> >> L = v*f*dx
> >>
> >> pde = VariationalProblem(a, L)
> >> u_h = pde.solve()
> >>
> >> plot(u_h[0])
> >> interactive()
> >>
> >
> > But make sure to not name that space 'M' if you try this with a UFL
> > file or you will get a strange error (since 'M' is reserved in form
> > files).
> >
> > Anyway, I'm wondering about the dofmap for the "R" element. It sets
> > _global_dimension to m.num_entities[2] which is the global number of
> > cells, but then it maps all dofs to 0. Is that right? Shouldn't the
> > global dimension be 1?
> >
> >
>
>
> Yes, it is a bug for non-mixed elements(!). I noticed but didn't really
> want to start fixing before
> the weekend. It's on the todo-list though.

ok! I thought I might have missed the point but then I think I know
what's going on. Very cool feature.

Btw, you can add that demo now. ;-)

--
Anders

Marie Rognes (meg-simula) said : #10

Anders Logg wrote:
> On Thu, May 06, 2010 at 08:42:19PM -0000, Marie Rognes wrote:
>
>> Question #109900 on DOLFIN changed:
>> https://answers.launchpad.net/dolfin/+question/109900
>>
>> Marie Rognes proposed the following answer:
>> Anders Logg wrote:
>>
>>> Question #109900 on DOLFIN changed:
>>> https://answers.launchpad.net/dolfin/+question/109900
>>>
>>> Anders Logg proposed the following answer:
>>> On Thu, May 06, 2010 at 02:52:33PM +0200, Marie Rognes wrote:
>>>
>>>
>>>> Achim Schroll wrote:
>>>>
>>>>
>>>>> New question #109900 on DOLFIN:
>>>>> https://answers.launchpad.net/dolfin/+question/109900
>>>>>
>>>>> for a plain Poisson eqn with pure Neumann b.c., how to specify the scaling condition u*dx = 0 ?
>>>>>
>>>>>
>>>> If you have a recent dolfin, you can introduce a constant c acting
>>>> as a Lagrange multiplier corresponding to the constraint. See
>>>> example below.
>>>>
>>>> from dolfin import *
>>>>
>>>> mesh = UnitSquare(32, 32)
>>>> V = FunctionSpace(mesh, "CG", 1)
>>>> Q = FunctionSpace(mesh, "R", 0)
>>>> M = V * Q
>>>>
>>>> (u, c) = TrialFunctions(M)
>>>> (v, d) = TestFunctions(M)
>>>>
>>>> f = Expression("x[0]*x[1]*sin(pi*x[0])")
>>>>
>>>> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
>>>> L = v*f*dx
>>>>
>>>> pde = VariationalProblem(a, L)
>>>> u_h = pde.solve()
>>>>
>>>> plot(u_h[0])
>>>> interactive()
>>>>
>>>>
>>> But make sure to not name that space 'M' if you try this with a UFL
>>> file or you will get a strange error (since 'M' is reserved in form
>>> files).
>>>
>>> Anyway, I'm wondering about the dofmap for the "R" element. It sets
>>> _global_dimension to m.num_entities[2] which is the global number of
>>> cells, but then it maps all dofs to 0. Is that right? Shouldn't the
>>> global dimension be 1?
>>>
>>>
>>>
>> Yes, it is a bug for non-mixed elements(!). I noticed but didn't really
>> want to start fixing before
>> the weekend. It's on the todo-list though.
>>
>
> ok! I thought I might have missed the point but then I think I know
> what's going on. Very cool feature.
>
>

It is a true hack that I added for testing purposes. But it seems
useful, so let's keep it. I'll clean it up a bit (and fix that bug.)

> Btw, you can add that demo now. ;-)
>
>

Great.

--
Marie

Thanks, see you next week in Stockholm. Achim

Marie Rognes (meg-simula) said : #12

Marie Rognes wrote:
> Anders Logg wrote:
>> On Thu, May 06, 2010 at 08:42:19PM -0000, Marie Rognes wrote:
>>
>>> Question #109900 on DOLFIN changed:
>>> https://answers.launchpad.net/dolfin/+question/109900
>>>
>>> Marie Rognes proposed the following answer:
>>> Anders Logg wrote:
>>>
>>>> Question #109900 on DOLFIN changed:
>>>> https://answers.launchpad.net/dolfin/+question/109900
>>>>
>>>> Anders Logg proposed the following answer:
>>>> On Thu, May 06, 2010 at 02:52:33PM +0200, Marie Rognes wrote:
>>>>
>>>>
>>>>> Achim Schroll wrote:
>>>>>
>>>>>
>>>>>> New question #109900 on DOLFIN:
>>>>>> https://answers.launchpad.net/dolfin/+question/109900
>>>>>>
>>>>>> for a plain Poisson eqn with pure Neumann b.c., how to specify
>>>>>> the scaling condition u*dx = 0 ?
>>>>>>
>>>>>>
>>>>> If you have a recent dolfin, you can introduce a constant c acting
>>>>> as a Lagrange multiplier corresponding to the constraint. See
>>>>> example below.
>>>>>
>>>>> from dolfin import *
>>>>>
>>>>> mesh = UnitSquare(32, 32)
>>>>> V = FunctionSpace(mesh, "CG", 1)
>>>>> Q = FunctionSpace(mesh, "R", 0)
>>>>> M = V * Q
>>>>>
>>>>> (u, c) = TrialFunctions(M)
>>>>> (v, d) = TestFunctions(M)
>>>>>
>>>>> f = Expression("x[0]*x[1]*sin(pi*x[0])")
>>>>>
>>>>> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
>>>>> L = v*f*dx
>>>>>
>>>>> pde = VariationalProblem(a, L)
>>>>> u_h = pde.solve()
>>>>>
>>>>> plot(u_h[0])
>>>>> interactive()
>>>>>
>>>>>
>>>> But make sure to not name that space 'M' if you try this with a UFL
>>>> file or you will get a strange error (since 'M' is reserved in form
>>>> files).
>>>>
>>>> Anyway, I'm wondering about the dofmap for the "R" element. It sets
>>>> _global_dimension to m.num_entities[2] which is the global number of
>>>> cells, but then it maps all dofs to 0. Is that right? Shouldn't the
>>>> global dimension be 1?
>>>>
>>>>
>>>>
>>> Yes, it is a bug for non-mixed elements(!). I noticed but didn't really
>>> want to start fixing before
>>> the weekend. It's on the todo-list though.
>>>
>>
>> ok! I thought I might have missed the point but then I think I know
>> what's going on. Very cool feature.
>>
>>
>
> It is a true hack that I added for testing purposes. But it seems
> useful, so let's keep it. I'll clean it up a bit (and fix that bug.)
>

Bug fixed.

--
Marie

Marie Rognes (meg-simula) said : #13

Marie Rognes wrote:
> Anders Logg wrote:
>> On Thu, May 06, 2010 at 08:42:19PM -0000, Marie Rognes wrote:
>>
>>> Question #109900 on DOLFIN changed:
>>> https://answers.launchpad.net/dolfin/+question/109900
>>>
>>> Marie Rognes proposed the following answer:
>>> Anders Logg wrote:
>>>
>>>> Question #109900 on DOLFIN changed:
>>>> https://answers.launchpad.net/dolfin/+question/109900
>>>>
>>>> Anders Logg proposed the following answer:
>>>> On Thu, May 06, 2010 at 02:52:33PM +0200, Marie Rognes wrote:
>>>>
>>>>
>>>>> Achim Schroll wrote:
>>>>>
>>>>>
>>>>>> New question #109900 on DOLFIN:
>>>>>> https://answers.launchpad.net/dolfin/+question/109900
>>>>>>
>>>>>> for a plain Poisson eqn with pure Neumann b.c., how to specify
>>>>>> the scaling condition u*dx = 0 ?
>>>>>>
>>>>>>
>>>>> If you have a recent dolfin, you can introduce a constant c acting
>>>>> as a Lagrange multiplier corresponding to the constraint. See
>>>>> example below.
>>>>>
>>>>> from dolfin import *
>>>>>
>>>>> mesh = UnitSquare(32, 32)
>>>>> V = FunctionSpace(mesh, "CG", 1)
>>>>> Q = FunctionSpace(mesh, "R", 0)
>>>>> M = V * Q
>>>>>
>>>>> (u, c) = TrialFunctions(M)
>>>>> (v, d) = TestFunctions(M)
>>>>>
>>>>> f = Expression("x[0]*x[1]*sin(pi*x[0])")
>>>>>
>>>>> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
>>>>> L = v*f*dx
>>>>>
>>>>> pde = VariationalProblem(a, L)
>>>>> u_h = pde.solve()
>>>>>
>>>>> plot(u_h[0])
>>>>> interactive()
>>>>>
>>>>>
>>>> But make sure to not name that space 'M' if you try this with a UFL
>>>> file or you will get a strange error (since 'M' is reserved in form
>>>> files).
>>>>
>>>> Anyway, I'm wondering about the dofmap for the "R" element. It sets
>>>> _global_dimension to m.num_entities[2] which is the global number of
>>>> cells, but then it maps all dofs to 0. Is that right? Shouldn't the
>>>> global dimension be 1?
>>>>
>>>>
>>>>
>>> Yes, it is a bug for non-mixed elements(!). I noticed but didn't really
>>> want to start fixing before
>>> the weekend. It's on the todo-list though.
>>>
>>
>> ok! I thought I might have missed the point but then I think I know
>> what's going on. Very cool feature.
>>
>>
>
> It is a true hack that I added for testing purposes. But it seems
> useful, so let's keep it. I'll clean it up a bit (and fix that bug.)
>
>> Btw, you can add that demo now. ;-)
>>
>
> Great.

Added. Where should I put documentation?

--
Marie

Anders Logg (logg) said : #14

On Mon, May 10, 2010 at 12:00:35PM -0000, Marie Rognes wrote:
> Question #109900 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/109900
>
> Marie Rognes posted a new comment:
> Marie Rognes wrote:
> > Anders Logg wrote:
> >> On Thu, May 06, 2010 at 08:42:19PM -0000, Marie Rognes wrote:
> >>
> >>> Question #109900 on DOLFIN changed:
> >>> https://answers.launchpad.net/dolfin/+question/109900
> >>>
> >>> Marie Rognes proposed the following answer:
> >>> Anders Logg wrote:
> >>>
> >>>> Question #109900 on DOLFIN changed:
> >>>> https://answers.launchpad.net/dolfin/+question/109900
> >>>>
> >>>> Anders Logg proposed the following answer:
> >>>> On Thu, May 06, 2010 at 02:52:33PM +0200, Marie Rognes wrote:
> >>>>
> >>>>
> >>>>> Achim Schroll wrote:
> >>>>>
> >>>>>
> >>>>>> New question #109900 on DOLFIN:
> >>>>>> https://answers.launchpad.net/dolfin/+question/109900
> >>>>>>
> >>>>>> for a plain Poisson eqn with pure Neumann b.c., how to specify
> >>>>>> the scaling condition u*dx = 0 ?
> >>>>>>
> >>>>>>
> >>>>> If you have a recent dolfin, you can introduce a constant c acting
> >>>>> as a Lagrange multiplier corresponding to the constraint. See
> >>>>> example below.
> >>>>>
> >>>>> from dolfin import *
> >>>>>
> >>>>> mesh = UnitSquare(32, 32)
> >>>>> V = FunctionSpace(mesh, "CG", 1)
> >>>>> Q = FunctionSpace(mesh, "R", 0)
> >>>>> M = V * Q
> >>>>>
> >>>>> (u, c) = TrialFunctions(M)
> >>>>> (v, d) = TestFunctions(M)
> >>>>>
> >>>>> f = Expression("x[0]*x[1]*sin(pi*x[0])")
> >>>>>
> >>>>> a = dot(grad(v), grad(u))*dx + d*u*dx + c*v*dx
> >>>>> L = v*f*dx
> >>>>>
> >>>>> pde = VariationalProblem(a, L)
> >>>>> u_h = pde.solve()
> >>>>>
> >>>>> plot(u_h[0])
> >>>>> interactive()
> >>>>>
> >>>>>
> >>>> But make sure to not name that space 'M' if you try this with a UFL
> >>>> file or you will get a strange error (since 'M' is reserved in form
> >>>> files).
> >>>>
> >>>> Anyway, I'm wondering about the dofmap for the "R" element. It sets
> >>>> _global_dimension to m.num_entities[2] which is the global number of
> >>>> cells, but then it maps all dofs to 0. Is that right? Shouldn't the
> >>>> global dimension be 1?
> >>>>
> >>>>
> >>>>
> >>> Yes, it is a bug for non-mixed elements(!). I noticed but didn't really
> >>> want to start fixing before
> >>> the weekend. It's on the todo-list though.
> >>>
> >>
> >> ok! I thought I might have missed the point but then I think I know
> >> what's going on. Very cool feature.
> >>
> >>
> >
> > It is a true hack that I added for testing purposes. But it seems
> > useful, so let's keep it. I'll clean it up a bit (and fix that bug.)
> >
> >> Btw, you can add that demo now. ;-)
> >>
> >
> > Great.
>
>
> Added. Where should I put documentation?

Here:

https://launchpad.net/fenics-doc

--
Anders