Skip to content

Commit

Permalink
added ringsector2d
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fu committed Oct 21, 2021
1 parent 5ce2a2f commit c719905
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ExtendableGrids"
uuid = "cfc395e8-590f-11e8-1f13-43a2532b2fa8"
authors = ["Juergen Fuhrmann <[email protected]>, Christian Merdon <[email protected]>"]
version = "0.8.6"
version = "0.8.7"

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand Down
1 change: 1 addition & 0 deletions src/ExtendableGrids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export grid_unitcube
export grid_lshape
export grid_unitsquare, grid_unitsquare_mixedgeometries
export grid_triangle
export ringsector


include("regionedit.jl")
Expand Down
79 changes: 79 additions & 0 deletions src/commongrids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,82 @@ function grid_unitsquare_mixedgeometries()
return xgrid
end

#################################
# Specific tensor product grids #
#################################

function ringsector(rad,ang; eltype=Triangle2D)
Tv=Float32
Ti=Int32

coord=ElasticArray{Tv,2}(undef,2,0)
cells=ElasticArray{Ti,2}(undef,3,0)
bfaces=ElasticArray{Ti,2}(undef,2,0)
bfaceregions=Vector{Ti}(undef,0)
cellregions=Vector{Ti}(undef,0)

nrad=length(rad)
icell=0
ibface=0

fullcircle= ang[end]-ang[1]2π

narc=length(ang)

for iarc=1:narc
ϕ=ang[iarc]
x=cos(ϕ)
y=sin(ϕ)
for irad=1:nrad
append!(coord,(rad[irad]*x,rad[irad]*y))
icoord=size(coord,2)
if irad<nrad
if iarc<narc
i1=icoord
i2=i1+1
if fullcircle && iarc==narc-1
i3=irad
i4=irad+1
else
i3=i1+nrad
i4=i2+nrad
end
append!(cells,(i1,i2,i3))
push!(cellregions,1)
append!(cells,(i3,i2,i4))
push!(cellregions,1)
end
end
if irad==1 && iarc<narc
if fullcircle && iarc==narc-1
append!(bfaces,(icoord,1))
else
append!(bfaces,(icoord,icoord+nrad))
end
push!(bfaceregions,1)
end
if irad==nrad && iarc<narc
if fullcircle && iarc==narc-1
append!(bfaces,(icoord,irad))
else
append!(bfaces,(icoord,icoord+nrad))
end
push!(bfaceregions,2)
end

if !fullcircle
if iarc==1 && irad<nrad
append!(bfaces,(icoord,icoord+1))
push!(bfaceregions,3)
end

if iarc==narc && irad<nrad
append!(bfaces,(icoord,icoord+1))
push!(bfaceregions,4)
end
end
end
end
simplexgrid(coord,cells,cellregions,bfaces,bfaceregions)
end

2 comments on commit c719905

@j-fu
Copy link
Member Author

@j-fu j-fu commented on c719905 Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/47207

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.8.7 -m "<description of version>" c719905c6ca3e153362caa4c16665a966bbdceef
git push origin v0.8.7

Please sign in to comment.