@@ -123,7 +123,7 @@ MinpvProcessor::process(const std::vector<double>& thickness,
123123 bool c_active = actnum.empty () || actnum[c];
124124 bool c_thin = (thickness[c] <= z_tolerance);
125125 bool c_thin_inactive = !c_active && c_thin;
126- bool c_low_pv_active = pv[c] < minpvv[c] && c_active;
126+ bool c_low_pv_active = ( pv[c] < minpvv[c] && c_active) || (c_thin && c_active) ;
127127
128128 if (c_low_pv_active || c_thin_inactive) {
129129 std::array<double , 8 > cz = getCellZcorn (ii, jj, kk, zcorn);
@@ -166,7 +166,7 @@ MinpvProcessor::process(const std::vector<double>& thickness,
166166 bool active = actnum.empty () || actnum[c_below];
167167 bool thin = (thickness[c_below] <= z_tolerance);
168168 bool thin_inactive = !active && thin;
169- bool low_pv_active = pv[c_below] < minpvv[c_below] && active;
169+ bool low_pv_active = (( pv[c_below] < minpvv[c_below]) && active) || (thin && active) ;
170170
171171
172172 while ( (thin_inactive || low_pv_active) && kk_iter < dims_[2 ] )
@@ -223,13 +223,26 @@ MinpvProcessor::process(const std::vector<double>& thickness,
223223 active = actnum.empty () || actnum[c_below];
224224 thin = (thickness[c_below] <= z_tolerance);
225225 thin_inactive = (!actnum.empty () && !actnum[c_below]) && thin;
226- low_pv_active = pv[c_below] < minpvv[c_below] && active;
226+ low_pv_active = (( pv[c_below] < minpvv[c_below]) && active) || (thin && active) ;
227227 }
228228
229229 // create nnc if false or merge the cells if true
230- if (mergeMinPVCells && c_low_pv_active) {
230+ if (mergeMinPVCells){// && c_low_pv_active) {
231+ // try to make a topological connected grid
232+ // in Flow this is currently called only for edge_conformal grids
233+ // however zcorn inbetween is not modified to make zcorn sorted
231234 // Set lower k coordinates of cell below to upper cells's coordinates.
232235 // i.e fill the void using the cell below
236+ if (kk==0 || kk_iter == dims_[2 ]) {
237+ kk = kk_iter;
238+ continue ;
239+ }
240+ // bottom cell not active, hence no nnc is created
241+ if (!actnum.empty () && !actnum[c_below]) {
242+ kk = kk_iter;
243+ continue ;
244+ }
245+
233246 std::array<double , 8 > cz_below = getCellZcorn (ii, jj, kk_iter, zcorn);
234247 for (int count = 0 ; count < 4 ; ++count) {
235248 cz_below[count] = cz[count];
@@ -258,15 +271,15 @@ MinpvProcessor::process(const std::vector<double>& thickness,
258271 auto above_active = actnum.empty () || actnum[c_above];
259272 auto above_inactive = !actnum.empty () && !actnum[c_above];
260273 auto above_thin = thickness[c_above] < z_tolerance;
261- auto above_small_pv = pv[c_above] < minpvv[c_above];
274+ auto above_small_pv = ( pv[c_above] < minpvv[c_above]) || above_thin ;
262275
263276 if ((above_inactive && above_thin) || (above_active && above_small_pv
264277 && (!pinchNOGAP || above_thin) ) ) {
265278 for (k_above = kk - 2 ; k_above > 0 ; --k_above) {
266279 c_above = ii + dims_[0 ] * (jj + dims_[1 ] * (k_above));
267280 above_active = actnum.empty () || actnum[c_above];
268281 above_inactive = !actnum.empty () && !actnum[c_above];
269- auto above_significant_pv = pv[c_above] > minpvv[c_above];
282+ auto above_significant_pv = !(( pv[c_above] < minpvv[c_above]) || (thickness[c_above] < z_tolerance)) ;
270283 auto above_broad = thickness[c_above] > z_tolerance;
271284
272285 // \todo if condition seems wrong and should be the negation of above?
@@ -291,25 +304,30 @@ MinpvProcessor::process(const std::vector<double>& thickness,
291304 option4ALLZero = option4ALLZero || (!permz.empty () && permz[c_above] == 0.0 ) || multz (c_above) == 0.0 ;
292305 nnc_allowed = nnc_allowed && (computeGap (cz_above, cz_below) < max_gap) && (!pinchOption4ALL || !option4ALLZero) ;
293306
307+ // bool
308+ above_small_pv = (pv[c_above] < minpvv[c_above]) || (thickness[c_above] < z_tolerance);
309+ bool below_small_pv = (pv[c_below] < minpvv[c_below]) || (thickness[c_below] < z_tolerance);
294310 if ( nnc_allowed &&
295311 (actnum.empty () || (actnum[c_above] && actnum[c_below])) &&
296- pv[c_above] > minpvv[c_above] && pv[c_below] > minpvv[c_below]) {
312+ !(above_small_pv) && !(below_small_pv) ) {
297313 result.add_nnc (c_above, c_below);
298314 }
299315 kk = kk_iter;
300316 }
301317 }
302318 else
303319 {
304- if (kk < dims_[2 ] - 1 && (actnum.empty () || actnum[c]) && pv[c] > minpvv[c] &&
320+ if (kk < dims_[2 ] - 1 && (actnum.empty () || actnum[c]) && !(( pv[c] < minpvv[c]) || (thickness[c] < z_tolerance)) &&
305321 multz (c) != 0.0 )
306322 {
307323 // Check whether there is a gap to the neighbor below whose thickness is less
308324 // than MAX_GAP. In that case we need to create an NNC if there is a gap between the two cells.
309325 int kk_below = kk + 1 ;
310326 int c_below = ii + dims_[0 ] * (jj + dims_[1 ] * kk_below);
311327
312- if ((actnum.empty () || actnum[c_below]) && pv[c_below] > minpvv[c_below])
328+ if ( (actnum.empty () || actnum[c_below])
329+ &&
330+ !((pv[c_below] < minpvv[c_below]) || (thickness[c_below] < z_tolerance) ) )
313331 {
314332 // Check MAX_GAP threshold
315333 std::array<double , 8 > cz = getCellZcorn (ii, jj, kk, zcorn);
0 commit comments