|
[Sponsors] |
June 11, 2020, 06:55 |
Reverse sort of a list in parallel
|
#1 |
New Member
Pietro Tavazzi
Join Date: Aug 2019
Location: Milan, Italy
Posts: 8
Rep Power: 7 |
Hi everyone,
I'm working on adaptive mesh refinement with dynamicRefineFvMesh class I'm stuck at the definition of a list of scalars that need to be sorted from the highest to the lowest value. The use of SortableList::reverseSort() member function holds until mpirun is used. Let me explain a little bit more: in dynamicRefineFvMesh the scalarField named cellError is evaluated. I need to sort these scalars, thus I pass them to a sortableList and then I use the reverseSort() function. This solution works just fine only with one processor. Should I exploit the ListListOps::combine function? Or should I exploit the ParSortableList implementing a new member function to handle a "reverse sort"? I'm sure I'm getting lost in a glass of water but I'm wasting a lot of time with this issue. |
|
January 20, 2022, 05:05 |
|
#2 |
New Member
Pietro Tavazzi
Join Date: Aug 2019
Location: Milan, Italy
Posts: 8
Rep Power: 7 |
Well, I totally forgot about this post. I'll try to give it a closure.
I was dealing with the following problem related to Adaptive Mesh Refinement in OpenFOAM: the code in dynamicRefineFvMesh was implemented in such a way that, when the user specifies a maximum number of cells for the simulation, there is no guarantee the code will comply with it. This is because each cell candidate has the same importance as any other candidate. Solution to the problem: We want to give higher importance to those cells with higher cellError; we want to consider andidates from the its highest value to the lowest. This requires the sorting of the scalarField from the maximum to the minimum value, giving us the ordered indices of the cells. Once we have the proper ordering of cells indexing, we start marking cells for refinement until the maxCells limit is reached. The only problem is the sorting of a list during parallel computing. Code definition: The first thing to do is to collect all the cellError values from each processor. We can do that by simply transfer all the list of scalars in a list of list of scalars; we gather those lists (Pstream::gatherList) and re-distribute the result among all processors (Pstream::scatterList). Now each processor combines all cell values in a SortableList (ListListOps::combine) and sorts from the maximum value to the minimum one (SortableList::reverseSort). This way each processors sees the global indices of the cells in a specific order. We start considering the candidate cells for refinemente from the highest value of cellError; we take the cell global index, we find the processor in which this cell is defined and look for the associated local index and mark the corresponding cell if it satisfies all requirements. Code: Here below can be found the changes applied to the dynamicRefineFvMesh.C file. Those changes are for the the functions selectRefineCandidates, selectRefineCells and update. (Awareness of a possible inaccuracies source is mentioned in the update function image) selectRefineCandidates.png selectRefineCells.jpg update.png |
|
Tags |
dynamicrefinefvmesh, reversesort, sort |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] funkyDoCalc with OF2.3 massflow | NiFl | OpenFOAM Community Contributions | 14 | November 25, 2020 04:30 |
polynomial BC | srv537 | OpenFOAM Pre-Processing | 4 | December 3, 2016 10:07 |
simpleFoam parallel | AndrewMortimer | OpenFOAM Running, Solving & CFD | 12 | August 7, 2015 19:45 |
simpleFoam in parallel issue | plucas | OpenFOAM Running, Solving & CFD | 3 | July 17, 2013 12:30 |
DxFoam reader update | hjasak | OpenFOAM Post-Processing | 69 | April 24, 2008 02:24 |