Skip to content

Commit

Permalink
First round of fixes towards PA v0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Aug 23, 2023
1 parent 9c48aa9 commit bc53398
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 259 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#*.msh
*.vtu
*.pvd
*.pvtu
*.bson
*.jl.*.cov
*.jl.cov
*.jl.mem
Expand Down
85 changes: 39 additions & 46 deletions src/ExtraFunctions.jl
Original file line number Diff line number Diff line change
@@ -1,61 +1,54 @@
##Functions for mesh manipulation

function strechMHD(coord;domain=(0.0,1.0,0.0,1.0,0.0,1.0),factor=(1.0,1.0,1.0),dirs=(1,2,3))~
##Mesh streching according to Smolentsev formula
ncoord = collect(coord.data)
for (i,dir) in enumerate(dirs)
ξ0 = domain[i*2-1]
ξ1 = domain[i*2]
l = ξ1 - ξ0
c = (factor[i] + 1)/(factor[i] - 1)
##Mesh streching according to Smolentsev formula
ncoord = collect(coord.data)
for (i,dir) in enumerate(dirs)
ξ0 = domain[i*2-1]
ξ1 = domain[i*2]
l = ξ1 - ξ0
c = (factor[i] + 1)/(factor[i] - 1)

if l > 0
if ξ0 <= coord[dir] <= ξ1
ξx = (coord[dir] - ξ0)/l #ξx from 0 to 1 uniformly distributed
ξx_streched = factor[i]*(c^ξx-1)/(1+c^ξx) #ξx streched from 0 to 1 towards 1
ncoord[dir] = ξx_streched*l + ξ0 #coords streched towards ξ1
end
else
if ξ1 <= coord[dir] <= ξ0
ξx = (coord[dir] - ξ0)/l #ξx from 0 to 1 uniformly distributed
ξx_streched = factor[i]*(c^ξx-1)/(1+c^ξx) #ξx streched from 0 to 1 towards 1
ncoord[dir] = ξx_streched*l + ξ0 #coords streched towards ξ1

end
if l > 0
if ξ0 <= coord[dir] <= ξ1
ξx = (coord[dir] - ξ0)/l # ξx from 0 to 1 uniformly distributed
ξx_streched = factor[i]*(c^ξx-1)/(1+c^ξx) # ξx streched from 0 to 1 towards 1
ncoord[dir] = ξx_streched*l + ξ0 # coords streched towards ξ1
end
else
if ξ1 <= coord[dir] <= ξ0
ξx = (coord[dir] - ξ0)/l # ξx from 0 to 1 uniformly distributed
ξx_streched = factor[i]*(c^ξx-1)/(1+c^ξx) # ξx streched from 0 to 1 towards 1
ncoord[dir] = ξx_streched*l + ξ0 # coords streched towards ξ1
end
end
end
end
VectorValue(ncoord)
return VectorValue(ncoord)
end

function ChangeDensity(coord;domain=(0.0,1.0,0.0,1.0,0.0,1.0),subDomain=(0.0,1.0,0.0,1.0,0.0,1.0),
nodesTot=(1.0,1.0,1.0), nodesSub=(1.0,1.0,1.0), dirs=(1,2,3))
ncoord = collect(coord.data)
for (i,dir) in enumerate(dirs)
ξ0 = domain[i*2-1]
ξ1 = domain[i*2]
Ltot = ξ1 - ξ0
Lsub = subDomain[i*2] - subDomain[i*2-1]

alpha = (Lsub/Ltot)*(nodesTot[i]/nodesSub[i])
betta = ((Ltot-Lsub)/Ltot)*(nodesTot[i]/(nodesTot[i]-nodesSub[i]))

if Ltot != Lsub
ncoord = collect(coord.data)
for (i,dir) in enumerate(dirs)
ξ0 = domain[i*2-1]
ξ1 = domain[i*2]
Ltot = ξ1 - ξ0
Lsub = subDomain[i*2] - subDomain[i*2-1]

alpha = (Lsub/Ltot)*(nodesTot[i]/nodesSub[i])
betta = ((Ltot-Lsub)/Ltot)*(nodesTot[i]/(nodesTot[i]-nodesSub[i]))

if ξ0 <= coord[dir] <= ξ1
if Ltot != Lsub
if ξ0 <= coord[dir] <= ξ1
if coord[dir] <= (Lsub/alpha + ξ0)

ncoord[dir] = alpha*coord[dir] + ξ0*(1-alpha)

else

ncoord[dir] = betta*coord[dir] + ξ0*(1-betta) + Lsub*(1-betta/alpha)

ncoord[dir] = alpha*coord[dir] + ξ0*(1-alpha)
else
ncoord[dir] = betta*coord[dir] + ξ0*(1-betta) + Lsub*(1-betta/alpha)
end
end
end
end
end
end
VectorValue(ncoord)
return VectorValue(ncoord)
end

##Functions for geometry generation
Expand All @@ -77,7 +70,7 @@ function cuboid(;dx=1,dy=1,dz=1,x0=Point(0,0,0),name="cuboid",
geo34 = intersect(plane3,plane4)
geo56 = intersect(plane5,plane6)

intersect(intersect(geo12,geo34),geo56,name=name)
return intersect(intersect(geo12,geo34),geo56,name=name)
end

# Function that given a filter set a name to those elements that satisfy the
Expand Down
Loading

0 comments on commit bc53398

Please sign in to comment.