In a 2d elasticity model i use a BC neuman compress condition which depends from a function like:
k=1.5
yl_max=564.0
yr_max=675.5430
left_function = Expression(("0.027*k*(yl_max-x[1])", 0), degree=1, k=k, yl_max=yl_max) #Compression in left Boundary
rigth_function = Expression(("-0.027*k*(yr_max-x[1])", 0), degree=1, k=k, yr_max=yr_max) #Compression in rigth Boundary
left = AutoSubDomain(lambda x: near(x[0],0.0,tol))
rigth = AutoSubDomain(lambda x: near(x[0],x_max,tol))
# Definition of Neumann boundary condition domain
boundaries = MeshFunction("size_t", mesh, mesh.topology().dim() - 1)
boundaries.set_all(0)
left.mark(boundaries, 1)
rigth.mark(boundaries, 2)
ds = ds(subdomain_data=boundaries)
In this case, i know the max value for “y” in rigth and left bonudaries.
Now im created a 3D model, like a box whit topography at the top side like:
but, i have diferents z max value along the faces to define the compression funcion and i need to create a funcion depend from the diferent values. I have not found a corret way to do this. I hope you can help me.