Subject: [Fenics] New feature: integration over regions

From: Martin Sandve Alnæs <[email-masked]>
Date: Wed, 30 Jan 2013 09:54:39 +0100

In addition to integration over the entire domain, explained in another
post, we have introduced a concept called 'regions' in ufl. For this post,
assume a single mesh. Support for multiple meshes will get some attention
in the future.

The ufl language changes for expressing domain relations is work in
progress, but some useful features are already possible in trunk. We keep
the concept of disjoint numbered subdomains, which can be easily
represented as a single meshfunction in dolfin, having a single integer
label for each cell. In addition we introduce the concept of a region,
which is the union of any number of subdomains. Thus regions of one domain
can be overlapping by including some of the same subdomain(s). With some
automatic symbolic manipulation in ufl, we can now express integrals over
overlapping regions with zero additional cost at assembly time.

Here's the currently simplest syntax for integrals over regions:

# Define regions as tuples of subdomain labels
DL, DM, DR = (1,2), (2,), (2,3) # ***

# Define new measures associated with the interior domains
dx = Measure("dx")[domains]

# Make forms for equation
a = u*v*dx() + alpha*dot(grad(u), grad(v))*dx() # Integrals over entire
domain
L = f*v*dx(DR) + g*v*dx(DL) - (f+g)/2*v*dx(DM) # Integrals over regions

For the full running code, see this demo in the latest dolfin:
  demo/undocumented/overlapping-regions/python/demo_overlapping-regions.py

Martin

---

From: Anders Logg <[email-masked]>
Date: Wed, 30 Jan 2013 12:15:51 +0100

On Wed, Jan 30, 2013 at 09:54:39AM +0100, Martin Sandve Alnæs wrote:
>    post, we have introduced a concept called 'regions' in ufl. For this
>    post, assume a single mesh. Support for multiple meshes will get some
>    attention in the future.
>    progress, but some useful features are already possible in trunk. We
>    keep the concept of disjoint numbered subdomains, which can be easily
>    which is the union of any number of subdomains. Thus regions of one
>    domain can be overlapping by including some of the same subdomain(s).
>    With some automatic symbolic manipulation in ufl, we can now express
>    integrals over overlapping regions with zero additional cost at
>    assembly time.

Nice!

>    DL, DM, DR = (1,2), (2,), (2,3) # ***

I guess 'DM = 2' will also work fine here? It will be passed to dx(DM)
so that will result in an integral over subdomain 2.

>    a = u*v*dx() + alpha*dot(grad(u), grad(v))*dx() # Integrals over entire

Is the '()' necessary here in 'dx()'? Will it work with just dx?

--
Anders

> _______________________________________________
> Mailing list: https://launchpad.net/~fenics
> Post to     : [email-masked]
> Unsubscribe : https://launchpad.net/~fenics
> More help   : https://help.launchpad.net/ListHelp

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Wed, 30 Jan 2013 12:31:25 +0100

Yes and yes. The dx() notation is just to be more explicit and distinguish
it from the old dx=dx(0) notation. I might add an optional warning for uses
like f*dx+g*dx(1), which could be forms intending dx(0) or dx().

Martin

---

From: Anders Logg <[email-masked]>
Date: Wed, 30 Jan 2013 12:32:50 +0100

ok.

--
Anders

On Wed, Jan 30, 2013 at 12:31:25PM +0100, Martin Sandve Alnæs wrote:
>    Yes and yes. The dx() notation is just to be more explicit and
>    distinguish it from the old dx=dx(0) notation. I might add an optional
>    warning for uses like f*dx+g*dx(1), which could be forms intending
>    dx(0) or dx().
>    Martin
>
>    On 30 January 2013 12:15, Anders Logg <[1][email-masked]> wrote:
>
>      > Mailing list: [2]https://launchpad.net/~fenics
>      > Post to     : [3][email-masked]
>      > Unsubscribe : [4]https://launchpad.net/~fenics
>      > More help   : [5]https://help.launchpad.net/ListHelp
>
> Referenser
>
>    1. mailto:[email-masked]
>    2. https://launchpad.net/~fenics
>    3. mailto:[email-masked]
>    4. https://launchpad.net/~fenics
>    5. https://help.launchpad.net/ListHelp

---

From: Martin Sandve Alnæs <[email-masked]>
Date: Wed, 30 Jan 2013 13:41:00 +0100

A note to developers on this: You can no longer use
ufc::form::num_cell_domains() etc to check if a form has integrals of that
type. Instead use ufc::form::has_cell_integrals(). See the assemblers for
how to use these, and the UFC.cpp file. I've added some inline helper
functions to UFC.h, get_cell_integral(domain), which handle proper fallback
to default and removes some boilerplate code from the assemblers.

Martin

---

From: Anders Logg <[email-masked]>
Date: Wed, 30 Jan 2013 13:42:26 +0100

Very nice.

--
Anders

On Wed, Jan 30, 2013 at 01:41:00PM +0100, Martin Sandve Alnæs wrote:
>    ufc::form::num_cell_domains() etc to check if a form has integrals of
>    that type. Instead use ufc::form::has_cell_integrals(). See the
>    assemblers for how to use these, and the UFC.cpp file. I've added some
>    inline helper functions to UFC.h, get_cell_integral(domain), which
>    handle proper fallback to default and removes some boilerplate code
>    from the assemblers.
>    Martin
>
>    On 30 January 2013 12:32, Anders Logg <[1][email-masked]> wrote:
>
>      ok.
>
>    >    On 30 January 2013 12:15, Anders Logg <[1][2][email-masked]>
>    wrote:
>    >
>    >    >    In addition to integration over the entire domain, explained
>    in
>    >    another
>    >    >    post, we have introduced a concept called 'regions' in ufl.
>    For
>    >    this
>    >    >    post, assume a single mesh. Support for multiple meshes will
>    get
>    >    some
>    >    >    attention in the future.
>    >    >    The ufl language changes for expressing domain relations is
>    work
>    >    in
>    >    >    progress, but some useful features are already possible in
>    trunk.
>    >    We
>    >    >    keep the concept of disjoint numbered subdomains, which can
>    be
>    >    easily
>    >    >    represented as a single meshfunction in dolfin, having a
>    single
>    >    integer
>    >    >    label for each cell. In addition we introduce the concept of
>    a
>    >    region,
>    >    >    which is the union of any number of subdomains. Thus regions
>    of
>    >    one
>    >    >    a = u*v*dx() + alpha*dot(grad(u), grad(v))*dx() # Integrals
>    over
>    >    entire
>    >    >    domain
>    >
>    >    >    L = f*v*dx(DR) + g*v*dx(DL) - (f+g)/2*v*dx(DM) # Integrals
>    over
>    >    regions
>      >      > Mailing list: [2][3]https://launchpad.net/~fenics
>      >      > Post to     : [3][4][email-masked]
>      >      > Unsubscribe : [4][5]https://launchpad.net/~fenics
>      >      > More help   : [5][6]https://help.launchpad.net/ListHelp
>      >
>      > Referenser
>      >
>      >    1. mailto:[7][email-masked]
>      >    2. [8]https://launchpad.net/~fenics
>      >    3. mailto:[9][email-masked]
>      >    4. [10]https://launchpad.net/~fenics
>      >    5. [11]https://help.launchpad.net/ListHelp
>
> Referenser
>
>    1. mailto:[email-masked]
>    2. mailto:[email-masked]
>    3. https://launchpad.net/~fenics
>    4. mailto:[email-masked]
>    5. https://launchpad.net/~fenics
>    6. https://help.launchpad.net/ListHelp
>    7. mailto:[email-masked]
>    8. https://launchpad.net/~fenics
>    9. mailto:[email-masked]
>   10. https://launchpad.net/~fenics
>   11. https://help.launchpad.net/ListHelp