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

Is there a way to apply several boundary conditions on the same mesh with new dolfin version ?

–2 votes

Dear all,

I use FEniCS with c++ interface to solve multiscale FEM. I only succeed with version 1.0 because I need to define two or more periodic boundary conditions on the same mesh. It seems to be impossible with the new version.

Is there a way to apply more than one boundary condition on the same mesh in version 1.2 ?

For example in the version 1.0 I define two sub-domains for a UnitSquare mesh :

/**
* Sub-domain to define the periodicity for height.
*
*/
bool MicroScale::PeriodicSubdomainHeight::inside(const Array& x, bool on_boundary) const {

return fabs(x[1]) < 0.00005;
}

void MicroScale::PeriodicSubdomainHeight::map(const Array& x, Array& y) const {

y[0] = x[0];
y[1] = x[1] - 1;
}

/**
* Sub-domain to define the periodicity for width.
*
*/
bool MicroScale::PeriodicSubdomainWidth::inside(const Array& x, bool on_boundary) const {

return fabs(x[0]) < 0.00005;
}

void MicroScale::PeriodicSubdomainWidth::map(const Array& x, Array& y) const {

y[0] = x[0] - 1;
y[1] = x[1];
}

\And then, later in the code I declare the two periodic boundary conditions :

// Set up boundary condition for height
PeriodicSubdomainHeight psh;
PeriodicBC pbch(V, psh);

// Set up Boundary condition for width
PeriodicSubdomainWidth psw;
PeriodicBC pbcw(V, psw);

// Collect boundary conditions
std::vector bcs;
bcs.push_back(&pbcw);
bcs.push_back(&pbch);

// Define variational problem
//[...] I skip the definition part cause it is not really interesting, I think.
LinearVariationalProblem problem(a, L, u, bcs);

It works perfectly well with this version, but when I try to do it in version 1.1,
an error occurs. I can only use one boundary condition. (I haven't try yet with the version 1.2).

And I have an other problem: is there a way to replace the second part of equation u(X) - u(X') = 0 in the new version ? I need to replace the 0 by another member.

For the second question, I can modify the periodic boundary myself, if there is no other solution, but the first question is a real problem for me. I can't update my version.

thank you for your help and your attention,
Abdallah.

closed with the note: Question needs more work.
asked Jun 7, 2013 by Abdallah Ben Othman FEniCS Novice (100 points)
closed Jun 10, 2013 by logg
Please, edit your question and use markdown syntax - indent code by four spaces. Also when you claim that error occurs you should tell us in which place of your code snippet and provide error message.
...