# Boundary specification

Asked by Yaakoub El Khamra on 2012-08-28

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
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")]

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:
 Mikael Mortensen (mikael-mortensen) said on 2012-08-28: #1

Hi,

Try this

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

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 <

> New question #207056 on CBC.PDESys:
>
>
> 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
>
> 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
> 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")]
>
>
> problem.solve()
>
> plot(problem.pdesystems['Scalar'].Pw_, interactive=True, title="Pw")
> plot(problem.pdesystems['Scalar'].Po_, interactive=True, title="Po")
>
>
> --