Testfunctions integrate computes wrong results for Cylindrical2D coordinate system #202
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It seems that the testfunction-based integration in
VoronoiFVM
supplies wrong results for theCylindrical2D
coordinate system. @chmerdon and I have provided a MWE with a hotfix that requires some discussion.MWE
We calculate test functions$$T_i:\overline{\Omega}\rightarrow\mathbb{R}$$ , $$i = 2,3$$ on $$\Omega=(0,2)\times (0,2)$$ such that $$T_i=1$$ on $$\Gamma_i$$ and $$T_i=0$$ on $$\partial\Omega\setminus \Gamma_i$$ . We want to test the correct computation of the species mass transfer of a simple function $$u$$ across $$\Gamma_2=\{2\}\times [0,2]$$ or $$\Gamma_3=[0,2]\times\{2\}$$ both in the cartesian and the cylindrical case.
For a given source term$$s$$ , we have that $$u$$ is a solution to the elliptic system
in the cartesian case and
in the axisymmetric cylindrical case (i.e.$$u$$ not varying in $$\theta$$ ) where $$\mathrm{div}_{\mathrm{cyl}}$$ the cylindrical divergence operator:
With the flux$$\mathbf{j}(u)=-\nabla u$$ approximated via central differences, we expect for a simple function $$u_1(x,y) = x$$ or $$u_2(x,y)=y$$ (resp. $$u(r,z)=r$$ and $$u(r,z)=z$$ in the cylindrical case) the following:
Cartesian Case
Cylindrical Case
We denote by$$\hat{\Omega}=\Phi(\Omega\times [0,2\pi))$$ where $$\Phi(r,z,\theta) = [r\cos(\theta), r\sin(\theta),z]$$ . In that case, we have
Results
The$$u_1$$ on $$\Gamma_2$$ and that of $$u_2$$ on $$\Gamma_3$$ are incorrect.
Cartesian2D
cases run through and deliver the expected results. However, in theCylindrical2D
case, the result forPossible Cause and Fix
It seems to us that there might be a missing corrective term for the mass flux in the cylindrical case. To circumvent this issue, we tried a hotfix by setting$$\tilde{T_i}(r,z) = rT_i(r,z)$$ and hijacking the
integrate
function for theCartesian2D
case:Since the last term evaluates to zero, the first one in the sum would correspond to a call to$$\tilde{T} = rT$$ .
integrate
with a scaled test functionThis now produces a correct results. The only thing we keep wondering is that in the case of$$u_1$$ on $$\Gamma_3$$ , we obtain a much worse accuracy than in the other cases where we expect $$0$$ as a result.
We included a test script with the hotfix, but we think this needs some discussion on how to fix this internally.