Commit 373457c0 authored by Antoine MARTIN's avatar Antoine MARTIN
parents a007729c beb06cad
......@@ -10,11 +10,22 @@ from matplotlib.ticker import LinearLocator, FormatStrFormatter
def local_project(v,V):
dv = TrialFunction(V)
v_ = TestFunction(V)
a_proj = inner(dv,v_)*dx
b_proj = inner(v,v_)*dx
solver = LocalSolver(a_proj,b_proj)
solver.factorize()
u = Function(V)
solver.solve_local_rhs(u)
return u
#cf 'Contenu des fichiers' à propos de 'reference'
def reference(tabC,res1,c,ec,fr):
#res=256
k,ll,mm,nn=tabC.shape
mesh = UnitSquareMesh(res1, res1, "crossed")
mesh = UnitSquareMesh(res1, res1, "left/right")
class LocalC(UserExpression):
def __init__(self, Cij, mesh):
......@@ -32,7 +43,6 @@ def reference(tabC,res1,c,ec,fr):
return (3, 3)
#Ici on crée, à partir du tableau des tenseurs d'élasticité correspondant au domaine dont on veut calculer le Chom, un tableau Cv représentant le même Cn mais adapté à une résolution plus fine 'res'
# Cv = np.array([[np.zeros((3,3)) for i in range(res)] for j in range(res)])
# for i0 in range(k):
......@@ -101,7 +111,7 @@ def reference(tabC,res1,c,ec,fr):
Re = VectorElement("R", mesh.ufl_cell(), 0)
vertices = np.array([[0, 0], [1, 0], [1, 1], [0, 1]])
W = FunctionSpace(mesh, MixedElement([Ve, Re]), constrained_domain=PeriodicBoundary(vertices, tolerance=1e-10))
V = VectorFunctionSpace(mesh,'CG',degree=2,dim=3)
V = VectorFunctionSpace(mesh,'DG',degree=1,dim=3)
v_,lamb_ = TestFunctions(W)
dv, dlamb = TrialFunctions(W)
......@@ -114,35 +124,35 @@ def reference(tabC,res1,c,ec,fr):
Chom = np.zeros((3, 3))
for (j, case) in enumerate(["Exx", "Eyy", "Exy"]):
ffile = XDMFFile('c='+str(c)+'/ech='+str(ec)+'/frac='+str(fr)+'/Strain_EF_{}.xdmf'.format(case))
ee = np.zeros((3,))
ee[j] = 1
Eps.assign(Constant(ee))
solve(a == L, w, solver_parameters={"linear_solver": "mumps"})#, solver_parameters={"linear_solver": "bicgstab", "preconditioner":"ilu"})
(v, lamb) = split(w)
ffile = XDMFFile('c='+str(c)+'/ech='+str(ec)+'/frac='+str(fr)+'/Strain EF '+case+'.xdmf')
ffile.parameters["functions_share_mesh"] = True
vf = Function(V, name='Strain-'+case)
vf.assign(project(eps(v),V))
ffile.write(vf,0.)
plt.figure()
pp=plot(eps(v)[0])
plt.colorbar(pp)
plt.savefig('c='+str(c)+'/ech='+str(ec)+'/frac='+str(fr)+'/Aloc EF 1'+str(j+1)+'.pdf')
#plt.show()
plt.close()
plt.figure()
pp=plot(eps(v)[1])
plt.colorbar(pp)
plt.savefig('c='+str(c)+'/ech='+str(ec)+'/frac='+str(fr)+'/Aloc EF 2'+str(j+1)+'.pdf')
#plt.show()
plt.close()
plt.figure()
pp=plot(eps(v)[2])
plt.colorbar(pp)
plt.savefig('c='+str(c)+'/ech='+str(ec)+'/frac='+str(fr)+'/Aloc EF 3'+str(j+1)+'.pdf')
#plt.show()
plt.close()
vf.assign(local_project(eps(v), V))
ffile.write_checkpoint(vf, case, 0.)
# plt.figure()
# pp=plot(vf[0])
# plt.colorbar(pp)
# plt.savefig('c='+str(c)+'/ech='+str(ec)+'/frac='+str(fr)+'/Aloc EF 1'+str(j+1)+'.pdf')
# #plt.show()
# plt.close()
# plt.figure()
# pp=plot(vf[1])
# plt.colorbar(pp)
# plt.savefig('c='+str(c)+'/ech='+str(ec)+'/frac='+str(fr)+'/Aloc EF 2'+str(j+1)+'.pdf')
# #plt.show()
# plt.close()
# plt.figure()
# pp=plot(vf[2])
# plt.colorbar(pp)
# plt.savefig('c='+str(c)+'/ech='+str(ec)+'/frac='+str(fr)+'/Aloc EF 3'+str(j+1)+'.pdf')
# #plt.show()
# plt.close()
Sigma = np.zeros((3,))
for kk in range(3):
......
......@@ -168,4 +168,3 @@ for c in [100,0.01]:
\ No newline at end of file
......@@ -36,7 +36,8 @@ for c in [100,0.01]:
for i in range(10):
os.system("mkdir c="+str(c)+"/ech="+str(i))
print("échantillon "+str(i)+'\n')
fi = h5py.File("c="+str(c)+"/c="+str(c)+"ech"+str(i)+".hdf5","a")
fname = "c="+str(c)+"/c="+str(c)+"ech"+str(i)+".hdf5"
fi = h5py.File(fname, "w")
im,f0=image_init(N,D,0.1)
fi['images']=np.zeros((8,N,N))
fi['fractions']=np.zeros((8,))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment