Hello FEniCS family,
Problem in finding Functionspace specific to subdomain region of mesh to project sigma.
For periodic homogenization tutorial, Periodic homogenization of linear elastic materials — Numerical tours of continuum mechanics using FEniCS master documentation
dx = Measure('dx')(domain=mesh, subdomain_data=subdomains)
Ve = VectorElement("CG", mesh.ufl_cell(), 2)
Re = VectorElement("R", mesh.ufl_cell(), 0)
W = FunctionSpace(mesh, MixedElement([Ve, Re]), constrained_domain=PeriodicBoundary(vertices, tolerance=1e-10))
V = FunctionSpace(mesh, Ve)
v_,lamb_ = TestFunctions(W)
dv, dlamb = TrialFunctions(W)
w = Function(W)
dx = Measure('dx')(subdomain_data=subdomains)
Eps = Constant(((1, 0), (0, 0)))
F = sum([inner(sigma(dv, i, Eps), eps(v_))*dx(i) for i in range(nphases)])
a, L = lhs(F), rhs(F)
a += dot(lamb_,dv)*dx + dot(dlamb,v_)*dx
solve (a==L,w,[])
def sigma_vec(v, i,Eps):
E,nu=material_parameters[i]
if i==0:
lmbda = E*nu/((1+nu)*(1-2*nu))
mu = E/(2*(1+nu))
C1=lmbda+2*mu
C=as_tensor([(C1,lmbda,lmbda,0,0,0),(lmbda,C1,lmbda,0,0,0),(lmbda,lmbda,C1,0,0,0),(0,0,0,mu,0,0),(0,0,0,0,mu,0),(0,0,0,0,0,mu)])
s1= dot(C,eps(v)+Eps)
else:
lmbda = E*nu/((1+nu)*(1-2*nu))
mu = E/(2*(1+nu))
C1=lmbda+2*mu
C=as_tensor([(C1,lmbda,lmbda,0,0,0),(lmbda,C1,lmbda,0,0,0),(lmbda,lmbda,C1,0,0,0),(0,0,0,mu,0,0),(0,0,0,0,mu,0),(0,0,0,0,0,mu)])
s1= dot(C,eps(v)+Eps)
return s1
I want to find the stress distribution through project command.
sigma_w = project(sigma_vec(w,0,Eps), W)
where 0 defines subdomain 0. Its calculated sigma using only one material stiffness matrix.
I tried with
sigma_w = project(sum([sigma_vec(w,i,Eps) for i in range(nphases)]), W)
but, this gave summation of stress at each element taken both material properties seperately.
How can I get the sigma projection taking respective material stiffness matrix based on its subdomain of 0 or 1 ?
I realize, this coul be done using Submesh feature to define 2 different Function Space, but, didn’t know exactly what to do.
Any help is greatly appreciated!