Commit bb4517f6 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

fix x on bnd

parent 8e672f2a
......@@ -17,15 +17,18 @@ class fluid_problem :
def __init__(self, mesh_file_name, mu, rho, alpha, autoEpsilon, strong_boundaries):
nsb = len(strong_boundaries)
def apply_bnd(n, xp, vp, b) :
x = numpy.frombuffer(cast(xp, POINTER(int(n)*2*c_double)).contents)
v = numpy.frombuffer(cast(vp, POINTER(int(n)*c_double)).contents)
if callable(b) :
v[:] = b(x)
else :
v[:] = b
asb = (StrongBoundary*nsb)(*[StrongBoundary(i[0].encode(),i[1],BNDCB(lambda n,x,v : apply_bnd(n,x,v,i[2]))) for i in strong_boundaries])
class Bnd :
def __init__(self, b) :
self._b = b
def apply(self, n, xp, vp) :
x = numpy.frombuffer(cast(xp, POINTER(int(n)*2*c_double)).contents).reshape([n,2])
v = numpy.frombuffer(cast(vp, POINTER(int(n)*c_double)).contents)
if callable(self._b) :
v[:] = self._b(x)
else :
v[:] = self._b
asb = (StrongBoundary*nsb)(*[StrongBoundary(i[0].encode(),i[1],BNDCB(Bnd(i[2]).apply)) for i in strong_boundaries])
self.asb = asb
lib.fluid_problem_new.restype = c_void_p
self._fp = c_void_p(lib.fluid_problem_new(mesh_file_name.encode(), c_double(mu), c_double(rho), c_double(alpha), c_bool(autoEpsilon), nsb, asb))
......
......@@ -276,8 +276,8 @@ static void apply_boundary_conditions(const Mesh *mesh, double *solution, int nB
double *v = malloc(mesh->phys_n_nodes[iphys]*sizeof(double));
for (int i = 0; i < mesh->phys_n_nodes[iphys]; ++i){
int j = mesh->phys_nodes[iphys][i];
x[i*2+0] = mesh->x[j*2+0];
x[i*2+1] = mesh->x[j*2+1];
x[i*2+0] = mesh->x[j*3+0];
x[i*2+1] = mesh->x[j*3+1];
}
bnd->apply(mesh->phys_n_nodes[iphys], x, v);
for (int i = 0; i < mesh->phys_n_nodes[iphys]; ++i)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment