how to set multiple neumann conditions in cbc.pdesys

Asked by Richard on 2012-02-01

Hello,
I am trying to use cbc.pdesys to solve a system of pdes. However I am unable to see how to use a meshfunction to tag different boundaries. I have been able to specify Dirichlet conditions but not Neumann conditions as in the FEniCS tutorial section 5.3.

Example Lshape.py gives an example of using meshfunctions, however it uses NSProblem class. How do we do the same with only the pdesys classes? There are no pdesys examples that use different Neumann boundary conditions on different surfaces.

Any help would be greatly appreciated.
Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
CBC.PDESys Edit question
Assignee:
No assignee Edit question
Solved by:
Richard
Solved:
Last query:
Last reply:

Hi Rochan,

I don't think I've used multiple Neuman conditions myself, but there
shouldn't be any new problems with this. Just mark the boundaries like in
Lshape using a FacetFunction and then add the required ds() terms to your
equation (form). The Navier-Stokes solvers in pdesys recognize the
meshfunction if it's attached to a SubDomain and adds the required ds
terms. See, e.g., add_exterior in cbc/cfd/icns/NSCoupled for how this can
be done. The PDESubSystem has a parameter exterior_facet_domains that must
be set to point to the mesh function. Something like this:

# set up FacetFunction
mf = FacetFunction(mesh)
mf.set_all(0)
somesubdomain1.mark(mf, 1)
somesubdomain2.mark(mf, 2)

# Create a new PDESystem and add to problem
scalar = PDESystem(['c'], problem, solver_parameters)

# Create an equation (PDESubSystem) for 'c' with ds terms
class Scalar(PDESubSystem):
    def form(self, c, v_c, g, **kwargs):
        return inner(grad(c), grad(v_c))*dx + inner(g1, v_c)*ds(1) +
inner(g2, v_c)*ds(2) +++

scalar.g1 = Constant(1)
scalar.g2 = Constant(2)
scalar.pdesubsystems['c'] = Scalar(vars(scalar), ['c'],
exterior_facet_domains=mf)

problem.solve()

Something like that. Hope it works:-)

Mikael

On 1 February 2012 23:05, Rochan <email address hidden>wrote:

> New question #186556 on CBC.PDESys:
> https://answers.launchpad.net/cbcpdesys/+question/186556
>
> Hello,
> I am trying to use cbc.pdesys to solve a system of pdes. However I am
> unable to see how to use a meshfunction to tag different boundaries. I have
> been able to specify Dirichlet conditions but not Neumann conditions as in
> the FEniCS tutorial section 5.3.
>
> Example Lshape.py gives an example of using meshfunctions, however it uses
> NSProblem class. How do we do the same with only the pdesys classes? There
> are no pdesys examples that use different Neumann boundary conditions on
> different surfaces.
>
> Any help would be greatly appreciated.
> Thanks.
>
> --
> You received this question notification because you are an answer
> contact for CBC.PDESys.
>

Richard (richard-upton) said : #2

Hi Mikael,
I was able to figure it out. I had done something like what you suggested but had left out passing the arguments 'exterior_facet_domains = ...', while defining pdesubsystems. Doing that I can implement multiple Neumann conditions.
Meanwhile thanks for setting up the cbc.pdesys. This has enormously simplified my work ....
Regards,
Rochan

On Feb 1, 2012, at 11:55 PM, Rochan wrote:

> Question #186556 on CBC.PDESys changed:
> https://answers.launchpad.net/cbcpdesys/+question/186556
>
> Status: Answered => Solved
>
> Rochan confirmed that the question is solved:
> Hi Mikael,
> I was able to figure it out. I had done something like what you suggested but had left out passing the arguments 'exterior_facet_domains = ...', while defining pdesubsystems. Doing that I can implement multiple Neumann conditions.
> Meanwhile thanks for setting up the cbc.pdesys. This has enormously simplified my work ….

No problem, I'm very happy to hear others can find it useful as well:-)

Best regards

Mikael

> Regards,
> Rochan
>
> --
> You received this question notification because you are an answer
> contact for CBC.PDESys.