Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: monitor the correct sub-domain with ProbeVolume #144

Merged
merged 1 commit into from
Jun 6, 2019
Merged

Conversation

mesnardo
Copy link
Member

@mesnardo mesnardo commented Jun 6, 2019

I found a minor bug in the ProbeVolume class.
Before this pull-request, the probe was monitoring a field solution in a sub-domain different than the one configured in the YAML input file.
The bug only affects simulations with more than one MPI process, when we want to monitor the solution in a sub-volume of the computational domain.
The bug was introduced in version 0.4 of PetIBM.

PetIBM implements a class called ProbeVolume that can be used to monitor more frequently the field solution in a sub-region of the computational domain.
This is done by creating a sub-vector of a given PETSc Vec object with the routine VecGetSubVector.
The routine takes an index set (IS) as input.
Before this pull-request, the index set stored the index of the points located in the sub-domain using the natural ordering.
However, we need to provide the indices following the PETSc ordering, not the natural ordering.
(Natural ordering and PETSc ordering are different when using more than one MPI process.)

To convert the list of integer indices from natural ordering to PETSc ordering, we now (1) create an Application Ordering object from the DMDA on which is based the field to monitor and (2) use the routine AOApplicationToPetsc.

To illustrate the problem, I used the 2D flow around a cylinder (Re=40) as an example.
I ran the petibm-decoupledibpm executable to compute 1000 time steps, with PetIBM-0.4 and the version provided in this patch, using 4 MPI processes.
During the simulation, the x-component of the velocity vector field was monitored in the sub-domain [0.691297, 0.782822] x [-1.033947, 1.033947].
The solution in the sub-domain was accumulated over 100 time steps, averaged, and then saved to a HDF5 file.

The figures below were obtained with PetIBM-0.4 (top) and this commit (bottom).
The left panel shows the contour of the x-velocity after 1000 time steps.
On top of this field, we plot the contour of the monitored solution in the sub-domain (which corresponds to the time-averaged solution between 900 and 1000 time steps).
Using PetIBM-0.4, the sub-domain solution does not match the full-domain solution; it does with this commit.
The right panel of the figures show the profile of the x-velocity behind the cylinder (at x/c = 0.75) after 900 and 1000 time steps, as well as the profile from the probe.
With this commit, the velocity profile from the probe is now similar to the ones after 900 and 1000 time steps.

figure-0 4

figure-bugfix

I found a minor bug in the `ProbeVolume` class.
Before this pull-request, the probe was monitoring a field solution
in a sub-domain different than the one configured in the YAML input file.
The bug only affects simulations with more than one MPI process, when we
want to monitor the solution in a sub-volume of the computational domain.
The bug was introduced in version `0.4` of PetIBM.
@mesnardo mesnardo requested a review from piyueh June 6, 2019 21:35
@mesnardo mesnardo added the bug label Jun 6, 2019
@labarba
Copy link
Member

labarba commented Jun 6, 2019

Nice one! 🚀

@piyueh piyueh merged commit 5bfc3b6 into master Jun 6, 2019
@mesnardo mesnardo deleted the bug-probes branch July 18, 2019 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants