This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Applying load on the surface of complicated Geometry, problem with Subdomain

0 votes

Hi,
I am trying to apply a load to a circular area, on the surface of a complicated geometry. I only know the X,Y coordinate of the center of the circle, my geometry is symmetric with respect to Z and it is also on the surface of the structure but since I don't have any function that can give me Z based on the X,Y. However, when I put X[2]>0 it should just
consider the top part of geometry and by on_boundary it should put the force on the surface.
I wrote the following code to define my sub domain but I get zero for my traction term, i checked several thing i get in to get to the conclusion that Fenics cannot identify my sub domain.

class Actuation(SubDomain):
          def inside(self, x, on_boundary):
                 tol = 1E-14 # tolerance for coordinate comparisons
                 circ1 = (x[0]-LoadLocX[0])*(x[0]-LoadLocX[0]) + (x[1]-LoadLocY[0])*(x[1]-LoadLocY[0]) - 1 < tol
                             return ( (circ1) and     (x[2]>0) and on_boundary )

LoadLocX and LoadLocY are in domain but not necessarily on the vertex that is defined by my mesh.
any Idea on how i can fix this problem and define subdomain.

Thanks

asked Jun 26, 2014 by Bahram FEniCS Novice (400 points)

1 Answer

+2 votes

Hi, it is hard to comment without the mesh but here is one possible problem. Consider

from dolfin import *
import numpy as np

domain = Circle(0., 0., 1) + Rectangle(-1.5, -3, 1.5, 0)
mesh = Mesh(domain, 1)

tol = 1E-14
def inside_arch(x, on_boundary):
    on_circle = x[1] > 0 - DOLFIN_EPS and abs(np.hypot(x[0], x[1]) - 1) < tol
    return on_circle and on_boundary

Arch = AutoSubDomain(inside_arch)

check_midpoint_false = FacetFunction('size_t', mesh, 0)
Arch.mark(check_midpoint_false, 1, False)  # Don't check midpoints

check_midpoint_true = FacetFunction('size_t', mesh, 0)
Arch.mark(check_midpoint_true, 1)  # True by default, check midpoints

plot(check_midpoint_false, title='False')
plot(check_midpoint_true, title='True')
interactive()

Only check_midpoint_false has the facets on the arch marked correctly. The reason for this is that when marking facets Arch.mark does not check whether midpoint of a facet which has all its vertices flagged 'inside' is 'inside' as well. By default midpoints are checked and they have the final say (see here) on the flag. But for Arch all midpoints are flagged outside.

answered Jul 2, 2014 by MiroK FEniCS Expert (80,920 points)
...