This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

define boundary conditions on parts of a boundary

0 votes

Hi!

I would like to split the boundary of my domain (unit square) into its four edges. In my ufl, I write:

P1 = FiniteElement("Lagrange",triangle,1)
s = Coefficient(P1)
eta = s*ds(1)

I define my boundary part as:

class LowerBoundary : public dolfin::SubDomain{
bool inside(const dolfin::Array<double>& x, bool on_boundary) const
{ return ((x[1] < -1 + DOLFIN_EPS) and on_boundary);}
};

In my c++ Code, I use:

std::shared_ptr<dolfin::Form> a;
a.reset(new my_ufl::Form_eta(mesh);
dolfin::FacetFunction<std::size_t> boundaries(v.function_space()->mesh(),0);
LowerBoundary lowerboundary;
lowerboundary.mark(boundaries,1);
a->set_coefficient("s",dolfin::reference_to_no_delete_pointer(v));
a->ds=boundaries;

When running the code, it breaks down without giving an error statement. If I replace ds(1) by ds in the ufl file, then the code runs correctly. What do I do wrong?

I would be very thankful for any help! Thanks in advance,
frieder

asked May 12, 2017 by frieder FEniCS Novice (340 points)

1 Answer

0 votes

Hi, maybe you don't need to write C++ code. A python implementation to subclass different parts of boundaries can be found here.

Are you sure that ds(1) is defined without actually dividing the boundary?

answered May 12, 2017 by wilhelmbraun FEniCS User (2,070 points)
...