problem with discontinuous flux at an internal interface
Hello,
I am working with a problem related to different materials and discontinuous flux at the interface.
Here, I am considering the Laplace equation over omega=[0,1]x[0,1]
-div(D(
Let u=u1 and D(x,y)=D1 on [0,1]x[0,1/2], u=u2 and D(x,y)=D2 on [0,1]x[1/2,1],
where u1 = x - 2*D2*y+1/2*D1+D2, u2 = x+D1*y
We can compute the flux at the interface y=1/2
D1*dot(
D2*dot(
Now I want to recover this solution by Fenics. To do this, I applied DirichletBC for extenal boundaries. Since the flux is discontinuous, I added kcoeff*
Thanks a lot,
Best regards,
Dang
My code is following:
ufl file
Poisson.ufl
# Compile this form with FFC: ffc -l dolfin Poisson.ufl.
element = FiniteElement(
u = TrialFunction(
v = TestFunction(
kcoeff = Coefficient(
n = FacetNormal(
f = Coefficient(
a = kcoeff*
L = f*v*dx
FunctionSpace1D
# Compile this form with FFC: ffc -l dolfin FunctionSpace1D
element = FiniteElement("DG", "triangle", 0)
main.cpp
#include <dolfin.h>
#include "Poisson.h"
#include "FunctionSpace1
using namespace dolfin;
double Darray[2] = {3e-3,3e-3};
void ExactSol(Mesh mesh, FunctionSpace V, double*
{
for (VertexIterator v(mesh)
{
Point p = v->point();
double val = 0.0;
if (p.y()<=1.0/2.0) // u1
{
val = p.x()-2.
}
else // u2
{
val = p.x()+Darray[
}
exactsol.
}
}
class Omega0 : public SubDomain
{
bool inside(const Array<double>& x, bool on_boundary) const
{
return x[1] <= 0.5;
}
};
class Interface : public SubDomain
{
bool inside(const Array<double>& x, bool on_boundary) const
{
return fabs(x[1] - 0.5)<1e-10;
}
};
int main()
{
// Create mesh
UnitSquare mesh(8, 8);
Poisson:
Function u0(V);
ExactSol(mesh, V, Darray,u0);
plot(u0);
class DirichletBoundary : public SubDomain
{
bool inside(const Array<double>& x, bool on_boundary) const
{
return on_boundary;
}
};
MeshFunction<
MeshFunction<
// Mark Omega0 as sub domain 0
Omega0 omega0;
omega0.
Interface interface;
interface.
Function interface_fun(V); // for checking the interface
interface_
for (FacetIterator fc(mesh)
{
if (interface_
{
for (VertexIterator v(*fc);
{
}
}
}
plot(
FunctionSpace
Function kcoeff(V1);
// set diffusion coefficients for two subdomains
for (CellIterator c(mesh)
{
kcoeff.
}
plot(kcoeff);
DirichletBoundary dirichlet_boundary;
DirichletBC bc0(V, u0, dirichlet_
// Compute solution
Function u(V);
Poisson:
a.kcoeff = kcoeff;
//a.ds = interface_marker;
Constant f(0.0);
Poisson:
L.f = f;
solve(a == L, u, bc0);
plot(u);
Function error(V);
for (VertexIterator v(mesh)
{
error.
}
plot(error);
return 0;
}
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Nguyen Van Dang
- Solved:
- Last query:
- Last reply: