Boundary specification

Asked by Yaakoub El Khamra

Greetings
I have a problem when specifying boundary conditions for a simple coupled pde system. Essentially Po is equal to Pw and Pw is the Poisson example. Po is as I expect it but Pw looks wrong. Am I specifying the boundary conditions incorrectly? Please advise. Many thanks in advance.

from cbc.pdesys import *
from dolfin import parameters as dolfin_parameters

mesh = UnitSquare(10, 10)
# Change desired items in the problem_parameters dict from cbc.pdesys
problem_parameters['time_integration'] = "Steady" # change this to transient
problem = Problem(mesh, problem_parameters)

solver_parameters['familyname'] = 'Scalar'
solver_parameters['iteration_type'] = 'Newton'
coupled = PDESystem([['Pw', 'Po']], problem, solver_parameters) # Creates FunctionSpace, Functions etc.
coupled.f = Constant(1.)

class Coupled(PDESubSystem):
    def form(self, Pw, v_Pw, Pw_, Po, v_Po, Po_, f, **kwargs): # v_u is the TestFunction
        FPw = inner(grad(Pw), grad(v_Pw))*dx + f*v_Pw*dx
        FPo = Po*v_Po*dx - Pw_*v_Po*dx
        return FPw + FPo

bcs = [DirichletBC(coupled.V['Pw'], (-1.0), "on_boundary"),
       DirichletBC(coupled.V['Po'], (1.0), "on_boundary")]

coupled.add_pdesubsystem(Coupled, ['Pw', 'Po'], bcs=bcs)

problem.solve()

plot(problem.pdesystems['Scalar'].Pw_, interactive=True, title="Pw")
plot(problem.pdesystems['Scalar'].Po_, interactive=True, title="Po")

Question information

Language:
English Edit question
Status:
Solved
For:
CBC.PDESys Edit question
Assignee:
No assignee Edit question
Solved by:
Yaakoub El Khamra
Solved:
Last query:
Last reply:
Revision history for this message
Mikael Mortensen (mikael-mortensen) said :
#1

Hi,

Try this

bcs = [DirichletBC(coupled.V['PwPo'], (1.0, -1.0), "on_boundary")]

instead of

bcs = [DirichletBC(coupled.V['Pw'], (-1.0), "on_boundary"),
          DirichletBC(coupled.V['Po'], (1.0), "on_boundary")]

since you are solving for the coupled system 'PwPo'.

Best regards

Mikael

On 28 August 2012 18:01, Yaakoub El Khamra <
<email address hidden>> wrote:

> New question #207056 on CBC.PDESys:
> https://answers.launchpad.net/cbcpdesys/+question/207056
>
>
> Greetings
> I have a problem when specifying boundary conditions for a simple coupled
> pde system. Essentially Po is equal to Pw and Pw is the Poisson example.
> Po is as I expect it but Pw looks wrong. Am I specifying the boundary
> conditions incorrectly? Please advise. Many thanks in advance.
>
> from cbc.pdesys import *
> from dolfin import parameters as dolfin_parameters
>
> mesh = UnitSquare(10, 10)
> # Change desired items in the problem_parameters dict from cbc.pdesys
> problem_parameters['time_integration'] = "Steady" # change this to
> transient
> problem = Problem(mesh, problem_parameters)
>
> solver_parameters['familyname'] = 'Scalar'
> solver_parameters['iteration_type'] = 'Newton'
> coupled = PDESystem([['Pw', 'Po']], problem, solver_parameters) # Creates
> FunctionSpace, Functions etc.
> coupled.f = Constant(1.)
>
> class Coupled(PDESubSystem):
> def form(self, Pw, v_Pw, Pw_, Po, v_Po, Po_, f, **kwargs): # v_u is
> the TestFunction
> FPw = inner(grad(Pw), grad(v_Pw))*dx + f*v_Pw*dx
> FPo = Po*v_Po*dx - Pw_*v_Po*dx
> return FPw + FPo
>
> bcs = [DirichletBC(coupled.V['Pw'], (-1.0), "on_boundary"),
> DirichletBC(coupled.V['Po'], (1.0), "on_boundary")]
>
> coupled.add_pdesubsystem(Coupled, ['Pw', 'Po'], bcs=bcs)
>
> problem.solve()
>
> plot(problem.pdesystems['Scalar'].Pw_, interactive=True, title="Pw")
> plot(problem.pdesystems['Scalar'].Po_, interactive=True, title="Po")
>
>
> --
> You received this question notification because you are an answer
> contact for CBC.PDESys.
>

Revision history for this message
Yaakoub El Khamra (yelkhamra) said :
#2

Perfect, thank you very much sir.