Hello All,
I am trying to solve the Poisson equation in electrostatics:
$$ -\nabla^2 \varphi(r) = 0 $$
so there is no source term, and no surface normals.
My python code works fine, but converting it to C++ generates an error.
*** Error: Unable to assemble form.
*** Reason: Geometric dimension of Mesh does not match value shape of coordinate element in form.
*** Where: This error was encountered inside AssemblerBase.cpp.
*** Process: 0
Here are the relevant snippets of my code:
int nx=30,ny=30,nz=30;
Point a0(-halfxlength,-halfylength,-halfzlength);
Point a1(halfxlength, halfylength, halfzlength);
// mesh and function space
auto mesh = std::make_shared<BoxMesh>(a0,a1,nx,ny,nz);
auto V = std::make_shared<Poisson::FunctionSpace>(mesh);
// Define boundary conditions
auto u0 = std::make_shared<Constant>(0.0);
auto u1 = std::make_shared<Constant>(1.0);
auto rboundary = std::make_shared<red>();
auto bboundary = std::make_shared<blue>();
DirichletBC bc1(V, u0, bboundary); // bc 1
DirichletBC bc2(V, u1, rboundary); // bc 2
std::vector<const DirichletBC*> bcs; // Create an array of boundary conditions
bcs.push_back(&bc1);
bcs.push_back(&bc2);
Poisson::BilinearForm a(V,V);
Poisson::LinearForm L(V);
auto f = std::make_shared<Constant>(0.0);
L.f = f;
//L = std::make_shared<Constant>(0.0);
Function u(V);
solve(a == L, u, bcs);
and my Poisson.ufl file is this:
element = FiniteElement("Lagrange", triangle, 1)
u = TrialFunction(element)
v = TestFunction(element)
f = Coefficient(element)
a = inner(grad(u), grad(v))*dx
L = f*v*dx
Thanks,
Victor.