(Deleted) Assign BC to a MixedElement space (Complex, vector-valued PDE)


92
views
0
4 months ago by
Hello,

My question is related to my previous one https://www.allanswered.com/post/lkonj/vector-valued-pde-with-complex-nmbers/

I am not sure how to use a MixedElement space and assign boundary conditions accordingly when we use VectorElements instead of FiniteElements. For the latter I've followed the tutorial here https://fenicsproject.org/pub/tutorial/pdf/fenics-tutorial-vol1.pdf and everything works fine, but when moving to VectorElelements something is not correct.

In particular, I'd like to have a solution of the form [ux_real + 1j*ux_imag; uy_real + 1j*uy_imag] \in \mathbb{C}^2, i.e. each one of the two components is a complex number. As boundary conditions, I'd like to set the first component to 0 (both real and imaginary part) on the vertical boundaries, and the second component equal to 0 on the horizonatal boundaries. I'd also like to save the solution at a specific location.

Here's my code:
# Create Spaces, test and trial functions
# ---------------------------------------
Vr = VectorElement('CG', mesh.ufl_cell(), pdim)
Vi = VectorElement('CG', mesh.ufl_cell(), pdim)
V = FunctionSpace(mesh, MixedElement([Vr, Vi])) # the option above is identical
u_r, u_i = TrialFunctions(V)
phi_r, phi_i = TestFunctions(V)	


# Impose Boundary Conditions 
# --------------------------
boundaries = FacetFunction("size_t", mesh, 0) 

Horizontal().mark(boundaries, 1) 
Vertical().mark(boundaries, 2) 

ux_0, uy_0 = Constant((0.0,0.0)), Constant((0.0,0.0)) # both real and imaginary parts are set to 0 

bcH = DirichletBC(V.sub(1), uy_0, boundaries, 1)
bcV = DirichletBC(V.sub(0), ux_0, boundaries, 2)
bcs = [bcH, bcV]

# Create Functions
# ---------------- 
u = Function(V)
u_real, u_imag = Function(V), Function(V)

# Solve the problem 
# -----------------
A, b = assemble(A_tot), assemble(b_tot)
[bc.apply(A,b) for bc in bcs]
solve(A, u.vector(), b)
(u_real, u_imag) = u.split(True)

# Save the solution at point P(xs,ys)
# -----------------------------------
exact_point = Point(np.array((xs,ys)))
uRvalue = u_real(exact_point)
uIvalue = u_imag(exact_point)
F_values_x = uRvalue[0]+1j*uIvalue[0]
F_values_y = uRvalue[1]+1j*uIvalue[1]​



I can also provide the full code if needed.

Thank you!!
Community: FEniCS Project

1 Answer


0
4 months ago by
I've tried something different, but still results are still not correct.

- I've tried to define u = TrialFunction(V) and then split
- I've assigned BC to each component separately

Vr = VectorElement('CG', mesh.ufl_cell(), pdim)
Vi = VectorElement('CG', mesh.ufl_cell(), pdim)
V = FunctionSpace(mesh, MixedElement([Vr, Vi]))
u = TrialFunction(V)
u_r, u_i = split(u)
phi = TestFunction(V)
phi_r, phi_i = split(phi)

# Impose Boundary Conditions 
# --------------------------
boundaries = FacetFunction("size_t", mesh, 0) 

Horizontal().mark(boundaries, 1) 
Vertical().mark(boundaries, 2) 

ux_0, uy_0 = Constant(0.),Constant(0.)
bcHr = DirichletBC(V.sub(0).sub(1), uy_0, boundaries, 1)
bcHi = DirichletBC(V.sub(1).sub(1), uy_0, boundaries, 1)
bcVr = DirichletBC(V.sub(0).sub(0), ux_0, boundaries, 2)
bcVi = DirichletBC(V.sub(1).sub(0), ux_0, boundaries, 2)
bcs = [bcHr,bcHi, bcVr, bcVi]


# Solve & Save
# ------------
solve(A, u.vector(), b)
(u_real, u_imag) = u.split(True)
exact_point = Point(np.array((xs,ys)))
uRvalue = u_real(exact_point)
uIvalue = u_imag(exact_point)
F_values_x = uRvalue[0]+1j*uIvalue[0]
F_values_y = uRvalue[1]+1j*uIvalue[1]​
Please login to add an answer/comment or follow this question.
The thread is closed. No new answer/comment may be added.

Similar posts:
Search »
  • Nothing matches yet.