Subject: [FEniCS-users] Integral over part of outer boundary

From: Jehanzeb Hameed <[email-masked]>
Date: Wed, 21 Oct 2009 13:34:26 -0500

Hello,

I want to compute a functional over part of boundary of a mesh. ds
gives integral over whole outer boundary. How can I force the integral
to be over part of outer boundary only? Is there any example of this?

Thanks,
-Jehanzeb

---

From: Murtazo Nazarov <[email-masked]>
Date: Wed, 21 Oct 2009 22:46:53 +0200

Hi,

You can define a scalar function , which is 1 in the boundary you want 
to apply BC and 0 otherwise:

// Outlet
class Outlet : public Function
{
public:
  Outlet(Mesh& mesh) : Function(mesh) {}
  void eval(real* values, const real* x) const
  {
    if ( (x[0] > xmax - bmarg) )
      values[0] = 1.0;
    else
      values[0] = 0.0;
  }
};

...

Outlet outlet(mesh);
....

Then in FFC you just call that function and multiply to the boundary 
integral, f.ex:

outlet = Function(scalar)
...
L = .... u*v*outlet*ds

/murtazo

Jehanzeb Hameed wrote:
> _______________________________________________
> FEniCS-users mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/fenics-users
>

---

From: Jehanzeb Hameed <[email-masked]>
Date: Wed, 21 Oct 2009 15:55:43 -0500

Oh yea, thanks.

On Wed, Oct 21, 2009 at 3:46 PM, Murtazo Nazarov <[email-masked]> wrote:
> Hi,
>
> You can define a scalar function , which is 1 in the boundary you want to
> apply BC and 0 otherwise:
>
> // Outlet

---

From: "Garth N. Wells" <[email-masked]>
Date: Wed, 21 Oct 2009 22:37:32 +0100

>     if ( (x[0] > xmax - bmarg) )

Note that this is old syntax. It won't work with the most recent DOLFIN 
release.

> outlet = Function(scalar)

This approach can give erroneous results at the point where the boundary 
condition changes, which is especially the case at corners. The more 
robust alternative is to use sub-domains. See

     demo/pde/elastodynamics/cpp

Garth