Hi,
I can implemented a heterogeneous material e.g. using the following lines:
V_material = FunctionSpace(mesh, ‘DG’, 0)
E_trial, E_test = TrialFunction(V_material), TestFunction(V_material)
E = Function(V_material) # The Young modulus
el = V_material.ufl_element()
a = E_trialE_testdx
L = Expression(‘x[0]+ 1’, element=el)E_testdx
solve(a == L, E)
mu = E / (2.0*(1.0 + nu))
lmbda = Enu / ((1.0 + nu)(1.0 - 2.0*nu))
def sigma(v):
return 2.0musym(grad(v)) + lmbda*tr(sym(grad(v)))*Identity(3)
where E is, for example, Young modulus. I know that we can also do it using project(). The issue is that using either solve() or project() in a high dimensional time-consuming problem with several iterations and spatially dependent properties it becomes very inefficient. Is there any other more efficient approach for this purpose? For example, I can think of something similar to the following:
def sigma(x, v):
E = x[0]+ 1
mu = E / (2.0*(1.0 + nu))
lmbda = Enu / ((1.0 + nu)(1.0 - 2.0nu))
return 2.0musym(grad(v)) + lmbdatr(sym(grad(v)))*Identity(3)
Thank you,
Hi, you can just interpolate your expression instead of projecting
Thank you bleyerj, I would be grateful if you could be more specific and provide me with some hints, specially, in terms of the code.
You haven’t properly formatted your code using ``` in your post so I cannot easily see if it is correct but something like E.interpolate(expr) where expr is your expression should do it.
Thanks for your response,
I have used your suggested code. It works but it takes, more or less, the same time as solve(). Is there any other way that we introduce spatially dependent properties without interpolating, projecting, or solving variational formulation? The reason is that the latter is not really efficient when it comes to time-consuming problems (I work on poroelasticity)
I am searching for something like below:
def sigma(x, v):
E = x[0]+ 1
mu = E / (2.0*(1.0 + nu))
lmbda = E* nu
lmbda = E* nu / ((1.0 + nu)* (1.0 - 2.0* nu))
return 2.0* mu* sym(grad(v)) + lmbda*tr(sym(grad(v)))*Identity(3)
In fact, the only missing point is that I need to have the coordinate info (x[0], x[1], and x[2]) when I am defining the constitutive equation.
You can always use the ufl spatial coordinates, minimal example, assuming u, v are trial and test functions
x = SpatialCoordinate(mesh)
F= inner(x[0]*x[1]*u, v)*ex
1 Like
Dear dokken,
Thanks a lot. This is exactly what I needed.