Skip to content

Commit 8614f9a

Browse files
committed
1.1.0 updates to mesh optim. strategies
1 parent 1c95b5e commit 8614f9a

File tree

8 files changed

+276
-336
lines changed

8 files changed

+276
-336
lines changed

src/libcpp/iter_mesh/_zip_mesh_2.inc

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
*
3636
--------------------------------------------------------
3737
*
38-
* Last updated: 11 Dec., 2022
38+
* Last updated: 21 Jan., 2025
3939
*
40-
* Copyright 2013-2022
40+
* Copyright 2013-2025
4141
* Darren Engwirda
4242
* d.engwirda@gmail.com
4343
* https://github.com/dengwirda/
@@ -69,7 +69,9 @@
6969
iptr_type _imrk , // outer iteration marker
7070
iter_opts &_opts , // user options
7171
real_type _QLIM , // cell quality threshold
72+
real_type _QMOV , // cell quality tolerance
7273
real_type _DLIM , // dual quality threshold
74+
real_type _DMOV , // dual quality tolerance
7375
size_t &_nzip , // number of successful zip's
7476
size_t &_ndiv , // number of successful div's
7577
iter_stat &_tcpu // CPU timers/info
@@ -139,13 +141,16 @@
139141
typedef containers::
140142
array<sort_data> sort_list ;
141143

144+
__unreferenced ( _QLIM );
145+
__unreferenced ( _QMOV );
142146
__unreferenced ( _DLIM );
147+
__unreferenced ( _DMOV );
143148

144149
sort_list _sort ;
145150
conn_list _iadj , _jadj, _kadj ;
146151
conn_list _conn , _cset;
147152
conn_list _iset , _jset, _kset ;
148-
real_list _qold , _qnew, _qtmp ;
153+
fp32_list _qold , _qnew, _qtmp ;
149154

150155
_nzip = +0 ; _ndiv = +0 ;
151156

@@ -300,9 +305,10 @@
300305
_imrk, _tadj,
301306
_kern, _move, _nnew,
302307
_iset, _jset, _kset,
303-
_iadj, _jadj, _kadj,
304-
_cset, _qold, _qnew,
305-
_qtmp, _QLIM, _tcpu) ;
308+
_iadj, _jadj,
309+
_kadj, _cset,
310+
_qold, _qnew, _qtmp,
311+
_QLIM, _QMOV, _tcpu) ;
306312

307313
if (_move)
308314
{
@@ -332,7 +338,9 @@
332338
iptr_type _imrk , // outer iteration marker
333339
iter_opts &_opts , // user options
334340
real_type _QLIM , // cell quality threshold
341+
real_type _QMOV , // cell quality tolerance
335342
real_type _DLIM , // dual quality threshold
343+
real_type _DMOV , // dual quality tolerance
336344
size_t &_nzip , // number of successful zip's
337345
size_t &_ndiv , // number of successful div's
338346
iter_stat &_tcpu // CPU timers/info
@@ -400,12 +408,15 @@
400408
typedef containers::
401409
array<sort_data> sort_list ;
402410

411+
__unreferenced ( _QLIM );
412+
__unreferenced ( _QMOV );
403413
__unreferenced ( _DLIM );
414+
__unreferenced ( _DMOV );
404415

405416
sort_list _sort ;
406417
conn_list _aset , _bset, _cset ;
407418
conn_list _conn , _iset, _jset ;
408-
real_list _qold , _qnew, _qtmp ;
419+
fp32_list _qold , _qnew, _qtmp ;
409420

410421
_nzip = +0 ; _ndiv = +0 ;
411422

@@ -501,8 +512,8 @@
501512
_kern, _move, _nnew,
502513
_iset, _jset,
503514
_aset, _bset,
504-
_qold, _qnew,
505-
_qtmp, _QLIM, _tcpu) ;
515+
_qold, _qnew, _qtmp,
516+
_QLIM, _QMOV, _tcpu) ;
506517

507518
if (_move)
508519
{
@@ -554,8 +565,8 @@
554565
_kern, _move, _nnew,
555566
_iset, _jset,
556567
_aset, _bset, _cset,
557-
_qold, _qnew,
558-
_qtmp, _QLIM, _tcpu) ;
568+
_qold, _qnew, _qtmp,
569+
_QLIM, _QMOV, _tcpu) ;
559570

560571
if (_move)
561572
{
@@ -585,7 +596,9 @@
585596
iptr_type _imrk , // outer iteration marker
586597
iter_opts &_opts , // user options
587598
real_type _QLIM , // cell quality threshold
599+
real_type _QMOV , // cell quality tolerance
588600
real_type _DLIM , // dual quality threshold
601+
real_type _DMOV , // dual quality tolerance
589602
size_t &_nzip , // number of successful zip's
590603
size_t &_ndiv , // number of successful div's
591604
iter_stat &_tcpu // CPU timers/info
@@ -604,15 +617,15 @@
604617

605618
/*--------------------- zip//div topo. cell hierarchy */
606619
_zip_fcel( _geom, _mesh, _hfun,
607-
_kern, _hval,
608-
_nset, _mark, _imrk,
609-
_opts, _QLIM, _DLIM,
620+
_kern, _hval, _nset, _mark,
621+
_imrk, _opts,
622+
_QLIM, _QMOV, _DLIM, _DMOV,
610623
_nzip, _ndiv, _tcpu) ;
611624

612625
_zip_ecel( _geom, _mesh, _hfun,
613-
_kern, _hval,
614-
_nset, _mark, _imrk,
615-
_opts, _QLIM, _DLIM,
626+
_kern, _hval, _nset, _mark,
627+
_imrk, _opts,
628+
_QLIM, _QMOV, _DLIM, _DMOV,
616629
_nzip, _ndiv, _tcpu) ;
617630

618631
# ifdef __use_timers

src/libcpp/iter_mesh/cost_mesh_2.inc

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
*
3636
--------------------------------------------------------
3737
*
38-
* Last updated: 10 Jun., 2022
38+
* Last updated: 07 Apr., 2024
3939
*
40-
* Copyright 2013-2022
40+
* Copyright 2013-2024
4141
* Darren Engwirda
4242
* d.engwirda@gmail.com
4343
* https://github.com/dengwirda/
@@ -56,8 +56,8 @@
5656

5757
__static_call
5858
__normal_call void_type move_okay (
59-
real_list &_cdst , // list of new adj. costs
60-
real_list &_csrc , // list of old adj. costs
59+
fp32_list &_cdst , // list of new adj. costs
60+
fp32_list &_csrc , // list of old adj. costs
6161
iptr_type &_move , // > +0 if move acceptable
6262
real_type _good = +9.25E-01,
6363
real_type _qtol = +1.00E-04,
@@ -72,55 +72,55 @@
7272
if (_csrc.empty()) return ;
7373

7474
/*--------------------- calc. min. + mean metrics */
75-
real_type _zero =
76-
+std::numeric_limits
77-
<real_type>::epsilon ();
78-
real_type _0src =
79-
+std::numeric_limits
80-
<real_type>::infinity();
81-
real_type _0dst =
82-
+std::numeric_limits
83-
<real_type>::infinity();
75+
double _zero =
76+
+std::numeric_limits<double>::epsilon ();
77+
double _0src =
78+
+std::numeric_limits<double>::infinity();
79+
double _0dst =
80+
+std::numeric_limits<double>::infinity();
8481

8582
/*--------------------- compute harmonic averages */
8683
_good = std::pow(_good, +7./8.);
8784

88-
real_type _msrc, _mdst;
89-
_msrc = (real_type) +0. ;
90-
_mdst = (real_type) +0. ;
85+
double _msrc = (double)+0.;
86+
double _mdst = (double)+0.;
9187

9288
for (auto _iter = _csrc.head(),
9389
_tend = _csrc.tend();
9490
_iter != _tend;
9591
++_iter )
9692
{
93+
double _cost = (double)*_iter;
94+
9795
_0src =
98-
std::min(_0src, *_iter) ;
96+
std::min(_0src, _cost ) ;
9997

100-
_msrc += std::pow(
101-
(real_type)1. / *_iter, +8);
98+
_msrc += std::pow (
99+
(double)(1. / _cost), 8 ) ;
102100
}
103101
for (auto _iter = _cdst.head(),
104102
_tend = _cdst.tend();
105103
_iter != _tend;
106104
++_iter )
107105
{
106+
double _cost = (double)*_iter;
107+
108108
_0dst =
109-
std::min(_0dst, *_iter) ;
110-
109+
std::min(_0dst, _cost ) ;
110+
111111
_mdst += std::pow (
112-
(real_type)1. / *_iter, +8);
112+
(double)(1. / _cost), 8 ) ;
113113
}
114114

115115
_msrc = std::pow(
116-
_csrc.count() / _msrc, +1./8.0);
116+
_csrc.count() / _msrc, 1/8.) ;
117117
_mdst = std::pow(
118-
_cdst.count() / _mdst, +1./8.0);
118+
_cdst.count() / _mdst, 1/8.) ;
119119

120120
_qtol /=
121-
std::pow(_csrc.count(), 1./8.0);
121+
std::pow(_csrc.count(),1/8.) ;
122122
_qtol /=
123-
std::pow(_cdst.count(), 1./8.0);
123+
std::pow(_cdst.count(),1/8.) ;
124124

125125
/*---------------------------- test move = "okay" */
126126
if (_0dst >= _good)
@@ -142,9 +142,9 @@
142142

143143
if (_move > +0) return ;
144144
}
145-
146145
}
147146

147+
148148
/*
149149
--------------------------------------------------------
150150
* LOOP-COST: cost vector for 1-neighbourhood.
@@ -155,7 +155,7 @@
155155
__normal_call real_type loop_cost (
156156
mesh_type &_mesh , // mesh object
157157
conn_list &_cset , // list of adj. cells
158-
real_list &_cost , // list of adj. costs
158+
fp32_list &_cost , // list of adj. costs
159159
cell_kind const& // cell costs on CSET
160160
)
161161
{
@@ -211,10 +211,9 @@
211211
}
212212
}
213213

214-
_qmin =
215-
std::min (_qmin, _cscr) ;
214+
_qmin = std::min(_qmin, _cscr) ;
216215

217-
_cost.push_tail (_cscr) ;
216+
_cost.push_tail ((float)_cscr) ;
218217
}
219218

220219
return ( _qmin ) ;
@@ -224,7 +223,7 @@
224223
__normal_call real_type loop_cost (
225224
mesh_type &_mesh , // mesh object
226225
conn_list &_cset , // list of adj. cells
227-
real_list &_cost , // list of adj. costs
226+
fp32_list &_cost , // list of adj. costs
228227
dual_kind const& // dual costs on CSET
229228
)
230229
{
@@ -280,10 +279,9 @@
280279
}
281280
}
282281

283-
_qmin =
284-
std::min (_qmin, _cscr) ;
282+
_qmin = std::min(_qmin, _cscr) ;
285283

286-
_cost.push_tail (_cscr) ;
284+
_cost.push_tail ((float)_cscr) ;
287285
}
288286

289287
return ( _qmin ) ;

src/libcpp/iter_mesh/iter_divs_2.inc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
*
3636
--------------------------------------------------------
3737
*
38-
* Last updated: 11 Jun., 2022
38+
* Last updated: 21 Jan., 2025
3939
*
40-
* Copyright 2013-2022
40+
* Copyright 2013-2025
4141
* Darren Engwirda
4242
* d.engwirda@gmail.com
4343
* https://github.com/dengwirda/
@@ -70,15 +70,16 @@
7070
conn_list &_cnew , // space for adj. cells
7171
conn_list &_iset , // space for adj. cells
7272
conn_list &_jset , // space for adj. cells
73-
real_list &_qsrc , // space for adj. costs
74-
real_list &_qdst , // space for adj. costs
75-
real_list &_qtmp , // space for adj. costs
73+
fp32_list &_qsrc , // space for adj. costs
74+
fp32_list &_qdst , // space for adj. costs
75+
fp32_list &_qtmp , // space for adj. costs
7676
real_type _QLIM , // cell quality threshold
77+
real_type _QMOV , // cell quality tolerance
7778
iter_stat &_tcpu , // cpu timers/info
7879
real_type _lmin // div. spacing threshold
79-
= (real_type) +1.000E+00 ,
80+
= (real_type) +1.16667E+00 ,
8081
real_type _qinc // div. quality threshold
81-
= (real_type) +3.333E-03
82+
= (real_type) +3.33333E-03
8283
)
8384
{
8485
iptr_type static constexpr
@@ -187,7 +188,7 @@
187188
_hbar * _lmax )
188189
{
189190
// if more regular geom. is constructed via the edge
190-
// div, make it easier to do so!
191+
// div, make it easier to do so
191192

192193
_qinc = (real_type)(1./2. *
193194
(_hbar / std::sqrt(_lsqr) - 1.0)) ;
@@ -198,7 +199,7 @@
198199
{
199200
// try to reduce large vertex valence via refinement
200201

201-
real_type _qerr = (real_type) -1./16. ;
202+
real_type _qerr = -std::min(1./12., 1. - _QMOV) ;
202203
_qerr*= std::max (_ierr, _jerr ) ;
203204
_qerr/= std::pow (_iout, +1./2.) ; // stop oscl.
204205
_qinc = std::min (_qinc,
@@ -207,11 +208,11 @@
207208
}
208209
else
209210
if ( _ierr > 0 && _jerr > 0 &&
210-
(_ierr + _jerr) >= 3 )
211+
(_ierr + _jerr) >= 2 )
211212
{
212213
// try to reduce large vertex valence via refinement
213214

214-
real_type _qerr = (real_type) -1./16. ;
215+
real_type _qerr = -std::min(1./12., 1. - _QMOV) ;
215216
_qerr*= std::max (_ierr, _jerr ) ;
216217
_qerr/= std::pow (_iout, +1./2.) ; // stop oscl.
217218
_qinc = std::min (_qinc,
@@ -238,7 +239,7 @@
238239
typename mesh_type::quad_type _qdat ;
239240

240241
for (auto _idim =
241-
pred_type::real_dims; _idim-- != 0; )
242+
pred_type::geom_dims; _idim-- != 0; )
242243
{
243244
_ndat.pval(_idim) = _ball[_idim];
244245
}
@@ -390,7 +391,7 @@
390391
_opts, _nptr, _prev,
391392
_kern, _move, _cnew,
392393
_qtmp, _qdst,
393-
_minC, _QLIM, _QLIM,
394+
_minC, _QLIM, _QMOV,
394395
_tcpu) ;
395396

396397
if (_move <= +0 ) break;
@@ -405,11 +406,10 @@
405406
_cnew, _qdst, cell_kind()) ;
406407

407408
move_okay( _qdst, _qsrc, _move,
408-
std::sqrt( _QLIM) ,
409-
_qinc) ;
409+
_QMOV, _qinc) ;
410410

411-
if((_okay = _move > 0 &&
412-
_QMIN >= _qmin+_qinc))
411+
if((_okay = (_move > 0) &&
412+
_QMIN >= (_qmin + _qinc)))
413413
{
414414
/*--------------------------------- delete old cavity */
415415
for (auto _cell = _cset.head() ;

0 commit comments

Comments
 (0)