Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DG1d.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DG
DG1d.jl
Commits
955d5258
Commit
955d5258
authored
2 years ago
by
Florian Atteneder
Browse files
Options
Downloads
Patches
Plain Diff
fix connecting periodic boundaries for tree3d; fix place_boxes algorithm
parent
25e40d85
No related branches found
Branches containing commit
No related tags found
2 merge requests
!43
Rework mesh
,
!31
Draft: refactor mesh infrastructure
Pipeline
#4065
failed
2 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/tree.jl
+30
-14
30 additions, 14 deletions
src/tree.jl
test/dg1dTests/src/test_tree.jl
+9
-6
9 additions, 6 deletions
test/dg1dTests/src/test_tree.jl
with
39 additions
and
20 deletions
src/tree.jl
+
30
−
14
View file @
955d5258
...
...
@@ -439,23 +439,39 @@ function _connect_periodic!(t::Tree3d, ax::Cart3d.Axis)
dirmin
,
dirmax
=
directions
(
ax
)
ortho_ax1
,
ortho_ax2
=
orthogonal
(
ax
)
# filter boundary cells
# filter boundary cells
, returns a list of indices for the t.cells array
i_bdrycells
=
findall
(
t
.
cells
)
do
cell
cell
.
neighbors
[
dirmin
]
==
0
||
cell
.
neighbors
[
dirmax
]
==
0
end
length
(
i_bdrycells
)
==
0
&&
error
(
"Could not find any unconnected boundaries"
)
# determine those is for which a dirmin neighbor is missing
is_of_i_bdrycells_dirmin
=
findall
(
i_bdrycells
)
do
i
cell
=
t
.
cells
[
i
]
cell
.
neighbors
[
dirmin
]
==
0
end
i_bdrycells_dirmin
=
i_bdrycells
[
is_of_i_bdrycells_dirmin
]
# demand that the number of boundary cells connected between the periodic sides is the same
2
*
length
(
i_bdrycells_dirmin
)
!=
length
(
i_bdrycells
)
&&
error
(
"Encountered an unbalanced number of boundaries to connect"
)
i_bdrycells_dirmax
=
setdiff
(
i_bdrycells
,
i_bdrycells_dirmin
)
# connect pairs of cells with same coordinates in orthogonal directions
for
i
in
i_bdrycells
cell
=
t
.
cells
[
i
]
coords
=
t
.
coords
[
i
]
j
=
findfirst
(
i_bdrycells
)
do
jj
jj
!=
i
&&
coords
[
ortho_ax1
]
==
t
.
coords
[
jj
][
ortho_ax1
]
&&
coords
[
ortho_ax2
]
==
t
.
coords
[
jj
][
ortho_ax2
]
&&
return
true
# only iterating the ones which miss a dirmin neighbor
for
i_dirmin
in
i_bdrycells_dirmin
cell
=
t
.
cells
[
i_dirmin
]
coords
=
t
.
coords
[
i_dirmin
]
j
=
findfirst
(
i_bdrycells_dirmax
)
do
jj
coords
[
ortho_ax1
]
==
t
.
coords
[
jj
][
ortho_ax1
]
&&
coords
[
ortho_ax2
]
==
t
.
coords
[
jj
][
ortho_ax2
]
&&
return
true
return
false
coords
[
ortho_ax
]
==
t
.
coords
[
jj
][
ortho_ax
]
&&
return
true
return
false
end
isnothing
(
j
)
&&
error
(
"Could not find opposing cell to '
$
cell'"
)
cell
.
neighbors
[
dirmin
]
=
j
t
.
cells
[
j
]
.
neighbors
[
dirmax
]
=
i
isnothing
(
j
)
&&
error
(
"Could not find opposing cell for '
$
cell'"
)
i_dirmax
=
i_bdrycells_dirmax
[
j
]
cell
.
neighbors
[
dirmin
]
=
i_dirmax
t
.
cells
[
i_dirmax
]
.
neighbors
[
dirmax
]
=
i_dirmin
end
end
...
...
@@ -596,9 +612,9 @@ function place_boxes(t::Tree2d, x_extends, y_extends)
prev_cell
,
cell
=
t
.
cells
[
i
-
1
],
t
.
cells
[
i
]
!
is_neighbor
(
prev_cell
,
cell
)
&&
error_failed_placement
(
cell
,
prev_cell
)
prev_coords
,
coords
=
t
.
coords
[
i
-
1
],
t
.
coords
[
1
]
prev_coords
,
coords
=
t
.
coords
[
i
-
1
],
t
.
coords
[
i
]
touch_at
=
touch_direction
(
prev_coords
,
coords
)
prev_box
=
boxes
[
i
-
1
]
prev_box
=
last
(
boxes
)
(
pxmin
,
pxmax
),
(
pymin
,
pymax
)
=
prev_box
.
extends
xmin
,
xmax
,
ymin
,
ymax
=
if
touch_at
===
Cart2d
.
Xmax
pxmax
,
pxmax
+
dx
,
pymin
,
pymax
...
...
@@ -634,9 +650,9 @@ function place_boxes(t::Tree3d, x_extends, y_extends, z_extends)
prev_cell
,
cell
=
t
.
cells
[
i
-
1
],
t
.
cells
[
i
]
!
is_neighbor
(
prev_cell
,
cell
)
&&
error_failed_placement
(
cell
,
prev_cell
)
prev_coords
,
coords
=
t
.
coords
[
i
-
1
],
t
.
coords
[
1
]
prev_coords
,
coords
=
t
.
coords
[
i
-
1
],
t
.
coords
[
i
]
touch_at
=
touch_direction
(
prev_coords
,
coords
)
prev_box
=
boxes
[
i
-
1
]
prev_box
=
last
(
boxes
)
(
pxmin
,
pxmax
),
(
pymin
,
pymax
),
(
pzmin
,
pzmax
)
=
prev_box
.
extends
xmin
,
xmax
,
ymin
,
ymax
,
zmin
,
zmax
=
if
touch_at
===
Cart3d
.
Xmax
pxmax
,
pxmax
+
dx
,
pymin
,
pymax
,
pzmin
,
pzmax
...
...
This diff is collapsed.
Click to expand it.
test/dg1dTests/src/test_tree.jl
+
9
−
6
View file @
955d5258
...
...
@@ -187,13 +187,16 @@ end
@testset
"Tree"
begin
t1d
=
Tree1d
(
5
)
t2d
=
Tree2d
(
5
,
6
)
t3d
=
Tree3d
(
5
,
6
,
7
)
Nx
,
Ny
,
Nz
=
5
,
6
,
7
@test
n_cells
(
t1d
)
==
5
@test
n_cells
(
t2d
)
==
5
*
6
@test
n_cells
(
t3d
)
==
5
*
6
*
7
# test with periodicity here, because that requires an extra step for setup
t1d
=
Tree1d
(
Nx
,
periodic
=
(
true
,))
t2d
=
Tree2d
(
Nx
,
Ny
,
periodic
=
(
true
,
true
))
t3d
=
Tree3d
(
Nx
,
Ny
,
Nz
,
periodic
=
(
true
,
true
,
true
))
@test
n_cells
(
t1d
)
==
Nx
@test
n_cells
(
t2d
)
==
Nx
*
Ny
@test
n_cells
(
t3d
)
==
Nx
*
Ny
*
Nz
# t1d = Tree1d(5, periodic=(true,))
# t2d = Tree2d(5,6, periodic=(true,false))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment