Dear FeniCs community, hope everyone is doing fine.
I have recently solved an electrostatic problem, that can give me the electric field due to a potential change on a mesh, as shown on the upcoming figure.
A minimal reproduction to get to this vector field reads as follows:
from dolfin import *
originx = 0
originy = 0
origin = Point(originx,originy)
bigRectx = 10
bigRecty = 5
bigRect = Point(bigRectx, bigRecty)
rect2_1x = 4
rect2_1y = 2
rect2_1 = Point(rect2_1x,rect2_1y)
rect2_2x = 6
rect2_2y = 5
rect2_2 = Point(rect2_2x,rect2_2y)
rect1 = Rectangle(origin, bigRect)
rect2 = Rectangle(rect2_1, rect2_2)
circle = Circle(Point(5 , 2), 1 )
domain = rect1 - rect2 - circle
mesh = generate_mesh(domain, 100)
V = FunctionSpace(mesh, 'CG', 1)
v_1 = Constant(0)
v_0 = Constant(0)
v_2 = Constant(13500)
def bottom_side(x, on_boundary):
if (near(x[1], 0) ) and on_boundary:
return True
def voltage(x,on_boundary): #Define los lugares en los que hay un voltaje actuando
Bool = False
if on_boundary:
if ((near(x[1],0) or near(x[0],0) or near(x[0],10) or near(x[1],5))):
return Bool
else:
return True
bot_bc = DirichletBC(V, v_0, bottom_side)
drop_bc = DirichletBC(V, v_2, voltage)
bcs = [bot_bc, drop_bc]
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(0)
a = dot(grad(u), grad(v))*dx
L = f*v*dx
u = Function(V)
solve(a == L, u, bcs)
E = project(-grad(u), VectorFunctionSpace(mesh, 'CG', 1))
Now, I’m attempting to interpolate the values of E into a rectangular mesh, in which the values of E read as shown in the following figure, in order to solve a Fluids problem:
Is there any way I could do said interpolation, considering that my meshes are different in nature.