I’m not sure what the best method for completing this process, so I apologize if my attempt is wildly inaccurate.
The issue is as follows:
- A cubic mesh receives a heat load in the form of a volume flux
- This flux is derived from a dataset (simply a 3D array, where at every point in the mesh, a discrete heat load is determined
- The number of cells in the 3D array is not equal to those in the mesh, but the relative dimension are all equal (they are both cubes)
How might one go about creating either an expression or simply interpolating the array and putting it in such a form such that the weak form solver will recognize the appropriate heat load at each point in space?
Here are code samples to give a better idea of what the question is:
# Heat Structure
patt2D = [[0, 0, 1, 2, 3, 3],
[0, 0, 1, 2, 2, 3],
[0, 0, 0, 1, 2, 2],
[0, 0, 0, 0, 1, 1],
[0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0]]
empty = [[0 for _ in range(6)] for _ in range(6)]
thickness = 2
patt3D = np.array([patt2D if i < thickness else empty for i in range(6)])
from scipy.interpolate import RegularGridInterpolator as rgi
x = np.arange(6)
y = np.arange(6)
z = np.arange(6)
interp = rgi((x, y, z), patt3D)
Vq = ???
# Weak form
F = (
fn.inner(k * fn.grad(u), fn.grad(v)) * (dx) # Base FEM terms over the entire volume
+ (sc.sigma * epsilon * (q(u_0) - T_s4) * v) * (ds) # Radiation term for all surfaces
+ r * (u - T_s) * v * (ds) # Convection term for all surfaces
- Vq * v * (dx) # Heat generation in volume
)
a, L = fn.lhs(F), fn.rhs(F)
# Write solution to file
file = fn.File("Solutions/output_heat_gen_cube.pvd")
u = fn.Function(V) # new unknown function
last_eps = 0
while eps > tol and iter < maxiter:
iter += itermod
fn.solve(a == L, u)
diff = np.array(u.vector()) - np.array(u_0.vector())
eps = np.linalg.norm(diff, ord=np.Inf)
print('iter=%d: norm=%g' % (iter, eps))
u_0.assign(u) # update for next iteration
last_eps = eps
file << u, iter
This allowed some level of interpolation of the points, however, it wasn’t completely successful in covering the entire mesh in some value (or approximation of the value) that can be recognized as a heat load.
Is there a way of doing an expression fit of sorts instead, such that it can approximate that heat load with an expression?
Thank you in advance for any help.