Commit 2d559619 authored by Amira Abdel-Rahman's avatar Amira Abdel-Rahman
Browse files

fix 2d 3d and export CAD

parent 4f23fda7
Pipeline #19661 passed with stage
in 35 seconds
This diff is collapsed.
This diff is collapsed.
......@@ -412,7 +412,7 @@ function Uclustering2DStrainLibrary(Macro_struct, Micro_struct,prob,library,verb
xs = 1:Int(nx)
ys = 1:Int(ny)
ress(y,x)=(cos(Θ[Int(x),Int(y)])/3, sin(Θ[Int(x),Int(y)])/3)
ress(y,x)=(cos(Θ[Int(x),Int(y)])/3,- sin(Θ[Int(x),Int(y)])/3)
# col(y,x)=norm(ress(y,x))
xxs = [x for x in xs for y in ys]
......@@ -451,10 +451,10 @@ function Uclustering2DStrainLibrary(Macro_struct, Micro_struct,prob,library,verb
#################
E0 = 1; Emin = 1e-9; nu = 0.3;penal=3;
θ=Int((num-1)*4+1)
display(θ)
θ=Int((num-1)*4+1) +1 #cuboct
# display(θ)
Micro_xPhys,DHs=loadVisualizeLibrary(library)
Micro_x=Micro_xPhys
# t=:dark
t=:darktest
# # theme(t);
......@@ -464,21 +464,39 @@ function Uclustering2DStrainLibrary(Macro_struct, Micro_struct,prob,library,verb
# end
# # cscheme=ColorGradient(cschemeList)
# cscheme=cgrad(cschemeList)
cscheme=cgrad(t, θ, categorical = true)
t=:darktest
cscheme=cgrad(t, θ-1, categorical = true)
cschemeList=[]
# append!(cschemeList,[:white])
for i=1:θ-1
append!(cschemeList,[cscheme[i]])
end
append!(cschemeList,[:black])
cscheme=cgrad(cschemeList)
function findNearestList(theta)
if theta<0
theta+=180
elseif theta>180
theta-=180
end
findnearest(A::AbstractArray,t) = findmin(abs.(A.-t))[2]
values=[]
for i in range(0.0, 180, length=θ)
for i in range(0.0, 180, length=θ-1)
append!(values,[i])
end
return values[findnearest(values,theta)]
end
function findNearestListIndex(theta)
if theta<0
theta+=180
elseif theta>180
theta-=180
end
findnearest(A::AbstractArray,t) = findmin(abs.(A.-t))[2]
values=[]
for i in range(0.0, 180, length=θ)
for i in range(0.0, 180, length=θ-1)
append!(values,[i])
end
return findnearest(values,theta)
......@@ -486,6 +504,15 @@ function Uclustering2DStrainLibrary(Macro_struct, Micro_struct,prob,library,verb
ΘDNearest=findNearestList.(ΘD)
Uclustered=findNearestListIndex.(ΘD)
for i=1:ny
for j=1:nx
Ue = diss[i,j,:];
if sum(Ue)==0 || ratio[i,j]>0.99 ||ratio[i,j]<-0.99
Uclustered[i,j]=θ #if no load cuboct
end
end
end
Macro_masksU=[]
Macro_masks_densU=[]
......
......@@ -564,23 +564,32 @@ function stool(nelx,nely,nelz)
return U,F,freedofs
end
#LOAD TOP
function stressTest3D1(nelx,nely,nelz)
function stressTest3D(nelx,nely,nelz)
ndof=3*(nelx+1)*(nely+1)*(nelz+1);
il = [Int(nelx/2.)];
jl = [ 0];
kl = [Int(nelz/2.)];
ndof=3*(nelx+1)*(nely+1)*(nelz+1);
mid=Int((nelx-1)/2)+1
il = [mid-1 mid-1 mid+0 mid+0];
jl = [mid-1 mid+0 mid-1 mid+0];
kl = [nelz nelz nelz nelz]
m= Matlab.meshgrid(0:nelx, 0:nely, nelz:nelz)
il=m[1]
jl=m[2]
kl=m[3]
loadnid = kl.*(nelx+1).*(nely+1).+il.*(nely+1).+(nely+1 .-jl)
loaddof = 3 .*loadnid[:] .- 1;
loaddof = 3 .*loadnid[:] .- 0; #x is -2 # y is -1 # z is 0
val=-1;
iif = [0 0 nelx nelx];
jf = [0 0 0 0];
kf = [0 nelz 0 nelz];
jf = [0 nely 0 nely];
kf = [0 0 0 0];
m= Matlab.meshgrid(0:nelx, 0:nely, 0:0)
iif=m[1]
jf=m[2]
kf=m[3]
fixednid = kf.*(nelx+1).*(nely+1) .+iif .*(nely .+1) .+(nely .+1 .-jf) # Node IDs
fixeddof = [3 .*fixednid[:]; 3 .*fixednid[:].-1; 3 .*fixednid[:].-2]
......@@ -592,22 +601,21 @@ function stressTest3D(nelx,nely,nelz)
return U,F,freedofs
return U,F,freedofs
end
#LOAD TOP MIDDLE VOXEL
function stressTest3D(nelx,nely,nelz)
ndof=3*(nelx+1)*(nely+1)*(nelz+1);
il = [2 2 3 3];
jl = [2 3 2 3];
mid=Int((nelx-1)/2)+1
il = [mid-1 mid-1 mid+0 mid+0];
jl = [mid-1 mid+0 mid-1 mid+0];
kl = [nelz nelz nelz nelz]
m= Matlab.meshgrid(0:nelx, 0:nely, nelz:nelz)
il=m[1]
jl=m[2]
kl=m[3]
# m= Matlab.meshgrid(0:nelx, 0:nely, nelz:nelz)
# il=m[1]
# jl=m[2]
# kl=m[3]
loadnid = kl.*(nelx+1).*(nely+1).+il.*(nely+1).+(nely+1 .-jl)
loaddof = 3 .*loadnid[:] .- 0; #x is -2 # y is -1 # z is 0
val=-1;
......
......@@ -464,7 +464,7 @@ function displayElementDeformation2D(Ue,unit)
Ueee=reshape(Ue,2,4)
Uee1=reshape(Ue1,2,4)
Uee1.=Uee1.+Ueee[[2,1],:]
pointsX=[];pointsY=[];
for i =1:4
append!(pointsY,[Uee1[1,i]]);append!(pointsX,[Uee1[2,i]]);
......@@ -562,15 +562,34 @@ function loadVisualizeLibrary(library)
# end
# # cscheme=ColorGradient(cschemeList)
# cscheme=cgrad(cschemeList)
cscheme=cgrad(t, θ, categorical = true)
cscheme=cgrad(t, θ-1, categorical = true)
t=:matter
cschemes=cgrad(t, num+1, categorical = true)
cschemeLists=[]
append!(cschemeLists,[:white])
for i=num:-1:1
append!(cschemeLists,[cschemes[i]])
end
for i=2:num
append!(cschemeLists,[cschemes[i]])
end
for i=num-1:-1:1
append!(cschemeLists,[cschemes[i]])
end
for i=2:num
append!(cschemeLists,[cschemes[i]])
end
append!(cschemeLists,[:black])
cschemes1=cgrad(cschemeLists)
# t=:darktest
t=:darktest
# theme(t);
cschemeList=[]
append!(cschemeList,[:white])
for i=1:θ
for i=1:θ-1
append!(cschemeList,[cscheme[i]])
end
append!(cschemeList,[:black])
# cscheme=ColorGradient(cschemeList)
cscheme1=cgrad(cschemeList)
Micro_nely=size(Micro_xPhys[1])[1]
......@@ -584,7 +603,10 @@ function loadVisualizeLibrary(library)
Micro_xPhys_all=hcat(Micro_xPhys_all,space);
end
gr(size=(40*θ,100))
display(Plots.heatmap(Micro_xPhys_all,showaxis = false,xaxis=nothing,yaxis=nothing,legend=nothing,clims=(0, θ),fc=cschemes1,aspect_ratio=:equal))
display(Plots.heatmap(Micro_xPhys_all,showaxis = false,xaxis=nothing,yaxis=nothing,legend=nothing,clims=(0, θ),fc=cscheme1,aspect_ratio=:equal))
gr(size=(400,300))
return Micro_xPhys,DHs
end
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
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