“u” is the 2D solution result
“InputBC” is a face of 3D mesh
I’m trying the following code:
bc_function = as_vector((u,u,0))
boundary_conditions = { 0 : { ‘InputBC’ : bc_function }}
The error is :
Error: Unable to evaluate function at point.
Reason: The point is not inside the domain. Consider calling "Function::set_allowextrapolation(true)"on this Function to allow extrapolation.
Where: This error was encountered inside Function. cpp.
Process:0
I saw your reply,I’m glad to meet someone who has the same problem as me.
I’m trying to study your topic in the past few days.I feel like I’ve benefited a lot.
I can’t reply to your message in time because my specific description of my problem is not clear enough. I need more research.
I am reorganizing my problems and codes,because my tutor wanted me to avoid interpolation.
If there is any new progress or problem, I’m glad to discuss it with you.
I created a userExpression in 3D and just interpolated the data. Check if this works for you.
V = FunctionSpace(mesh, 'CG', 1)
mesh2D = Mesh('2dmesh.xml')
V2D = FunctionSpace(mesh2D, 'CG', 1)
vel = Function(V) # Function to use in 3D convection-diffusion
vel2D = Function(V2D) # Function to read 2D data
vfile = XDMFFile(MPI.comm_world, 'u_data_2d.xdmf')
vfile.read_checkpoint(vel2D, "u", 0)
vfile.close()
class V0(UserExpression):
def eval(self, values, x):
values[0] = 0
values[1] = 0
values[2] = -vel2D([x[0], x[1]])
def value_shape(self):
return (3,)
print('interpolating 2D velocity field to 3D')
vel = V0()
vel = interpolate(vel, V)
print('Done interpolating')