From 3e31655737fec668449bb508a81cb5fd1d39879b Mon Sep 17 00:00:00 2001 From: Hongyang Zhou Date: Sat, 16 Jan 2021 20:38:35 +0200 Subject: [PATCH] Add notes on vtk known bug --- docs/src/man/log.md | 4 ++++ src/vtk.jl | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/src/man/log.md b/docs/src/man/log.md index 8601e488..7ef1e89e 100644 --- a/docs/src/man/log.md +++ b/docs/src/man/log.md @@ -77,6 +77,10 @@ Several issues worth noticing: * 3D unformatted output as stored as it is. * The simulation is typically done with multiple MPI processes. In the tree structure, each node only records the MPI process local block index. What makes it more complicated is that the local block indexes on a given MPI process may have skipped numbers because they are not in the physical simulation domain. This means that in order to get the true global block indexes, one needs to count how many blocks are used on all MPI processes with lower ranks, and also the order of the current node based on local block index on this MPI process. * It would be pretty difficult to count the number of elements in the connectivity list. Appending to an array is a very expensive operation: counting the elements in the first loop, preallocating the array and then repeat the same computation to fill in the list results in over 1000 times speedup. +* The implementation in v0.2.3 inherits the bug from BATSRUS `ModWriteTecplot` that will generate duplicate voxel grid. For example, imagine a coarse block which is surrounded by refined blocks all around. On edge 8, the two refined face neighbor will both think they are in charge of writing the connectivity for the cells around the edge. This does not cause any serious issues as of now, so I don't fix it. Speaking of fixing that, there are two ways: + * `fillCellNeighbors!` not only deals with coarsened neighbors, but also the refined neighbors. This means that literally we need to implement the `message_pass_cell` completely. We still do a two-round process, write everything without checking, and in the end before IO remove the duplicate rows. This may be even faster then implementing some complicated writing rules to avoid duplicating. + * Polish the writing rules even further. This requires me to consider all possible cases. As a first step, for the above example case, neither of the two face neighbor should write the connectivity, but instead the edge neighbor should write. +* Many function names are inherited from BATL. I may consider rename them in the future if more general task is required. ### Ordering of connectivity diff --git a/src/vtk.jl b/src/vtk.jl index 3a220a3c..6c499e44 100644 --- a/src/vtk.jl +++ b/src/vtk.jl @@ -779,7 +779,7 @@ function getConnectivity(batl::Batl) fillCellNeighbors!(batl, iCell_G, DiLevelNei_III, iNodeNei_III, nBlock_P) - # In ModWriteTecplot, the first three conditions are needed only for certain 2D cases. + # Check who is in charge of writing following the prescribed rules. if DiLevelNei_III[3,3,2] < 0 iCell_G[end,end,:] .= 0 end @@ -807,11 +807,7 @@ function getConnectivity(batl::Batl) if any(iCell_G[i+1:i+2,j+1:j+2,k+1:k+2] .== 0) continue end - if iRound == 1 - nElem += 1 - else - iElem += 1 - end + iRound == 1 ? nElem += 1 : iElem += 1 if iRound == 2 connectivity[:,iElem] = [ iCell_G[i+1,j+1,k+1], @@ -840,6 +836,10 @@ function getConnectivity(batl::Batl) end end + # The current writing process will generate duplicate connectivity rows at + # edge cells between coarse and fine blocks. WriteTecplot module function + # has the same issue. + #return unique(connectivity, dims=2) return connectivity end