Hello I'm solving the Poisson equation numerically and I have to consider the boundaries in a specific way which varies with resolution considered (n_x,n_y,n_z). For example for n_x,y,z = 4 the load vector takes the following form
Load[1,1,1] = "(C__[0,0,0])*u[0,1,1]+(E__[0,0,0])*u[1,0,1]+(G__[0,0,0])*u[1,1,0]"
Load[2,1,1] = "(E__[1,0,0])*u[2,0,1]+(G__[1,0,0])*u[2,1,0]"
Load[3,1,1] = "(B__[2,0,0])*u[4,1,1]+(E__[2,0,0])*u[3,0,1]+(G__[2,0,0])*u[3,1,0]"
Load[1,2,1] = "(C__[0,1,0])*u[0,2,1]+(G__[0,1,0])*u[1,2,0]"
Load[2,2,1] = "(G__[1,1,0])*u[2,2,0]"
Load[3,2,1] = "(B__[2,1,0])*u[4,2,1]+(G__[2,1,0])*u[3,2,0]"
Load[1,3,1] = "(C__[0,2,0])*u[0,3,1]+(D__[0,2,0])*u[1,4,1]+(G__[0,2,0])*u[1,3,0]"
Load[2,3,1] = "(D__[1,2,0])*u[2,4,1]+(G__[1,2,0])*u[2,3,0]"
Load[3,3,1] = "(B__[2,2,0])*u[4,3,1]+(D__[2,2,0])*u[3,4,1]+(G__[2,2,0])*u[3,3,0]"
Load[1,1,2] = "(C__[0,0,1])*u[0,1,2]+(E__[0,0,1])*u[1,0,2]"
Load[2,1,2] = "(E__[1,0,1])*u[2,0,2]"
Load[3,1,2] = "(B__[2,0,1])*u[4,1,2]+(E__[2,0,1])*u[3,0,2]"
Load[1,2,2] = "(C__[0,1,1])*u[0,2,2]"
Load[2,2,2] = "0"
Load[3,2,2] = "(B__[2,1,1])*u[4,2,2]"
Load[1,3,2] = "(C__[0,2,1])*u[0,3,2]+(D__[0,2,1])*u[1,4,2]"
Load[2,3,2] = "(D__[1,2,1])*u[2,4,2]"
Load[3,3,2] = "(B__[2,2,1])*u[4,3,2]+(D__[2,2,1])*u[3,4,2]"
Load[1,1,3] = "(C__[0,0,2])*u[0,1,3]+(E__[0,0,2])*u[1,0,3]+(F__[0,0,2])*u[1,1,4]"
Load[2,1,3] = "(E__[1,0,2])*u[2,0,3]+(F__[1,0,2])*u[2,1,4]"
Load[3,1,3] = "(B__[2,0,2])*u[4,1,3]+(E__[2,0,2])*u[3,0,3]+(F__[2,0,2])*u[3,1,4]"
Load[1,2,3] = "(C__[0,1,2])*u[0,2,3]+(F__[0,1,2])*u[1,2,4]"
Load[2,2,3] = "(F__[1,1,2])*u[2,2,4]"
Load[3,2,3] = "(B__[2,1,2])*u[4,2,3]+(F__[2,1,2])*u[3,2,4]"
Load[1,3,3] = "(C__[0,2,2])*u[0,3,3]+(D__[0,2,2])*u[1,4,3]+(F__[0,2,2])*u[1,3,4]"
Load[2,3,3] = "(D__[1,2,2])*u[2,4,3]+(F__[1,2,2])*u[2,3,4]"
Load[3,3,3] = "(B__[2,2,2])*u[4,3,3]+(D__[2,2,2])*u[3,4,3]+(F__[2,2,2])*u[3,3,4]"
where from A__ to G__ are the "diagonal" components of the Laplacian in the matricial form and u is the initial guess with the desired boundaries, everything is globally defined.
My question is if there is a way to evaluate Load like
Load = eval(Load)
or multithread evaluations in order to avoid for loops, I'm working with n=100 and it is very slow.
Thanks!
Edit: I have a function that creates the structure for the Load vector which output is a string (I used a for loop)
for i in range(1,n_x):
for j in range(1,n_y):
for k in range(1,n_z):
Load[i,j,k] = Function(i,j,k)