I would like to perform local mesh refinement depending on physical results obtained with a prior simulation. I am using GMSH and the setSizeCallback(meshSizeCallBack)
function to apply the desired mesh size in the refinement region. The obtained results are not the ones expected. I reproduce the issue on a simple example:
The 2 first columns of the data.csv
file are the X and Y coordinates of the points that I want to modify. The 3rd column contains the desired mesh size. Note that this file has been truncated because of the text body character limit of the forum, but the issue is still repeatable with the fragment given below.
0.76968 0.26118 0.35535
0.78003 0.26118 0.35535
0.79047 0.26118 0.36046
0.80103 0.26118 0.36046
0.81168 0.26118 0.36286
0.82244 0.26118 0.36515
0.83332 0.26118 0.36954
0.84429 0.26118 0.36954
0.85538 0.26118 0.37177
0.86658 0.26118 0.37402
0.72933 0.26452 0.33849
0.73927 0.26452 0.33849
0.7493 0.26452 0.33584
0.75944 0.26452 0.34139
0.76968 0.26452 0.34139
0.78003 0.26452 0.34956
0.79047 0.26452 0.35461
0.80103 0.26452 0.35461
0.81168 0.26452 0.3538
0.82244 0.26452 0.3538
0.83332 0.26452 0.35864
0.84429 0.26452 0.35864
0.85538 0.26452 0.36109
0.86658 0.26452 0.36354
0.8779 0.26452 0.36845
0.88932 0.26452 0.36845
0.90086 0.26452 0.37091
0.91251 0.26452 0.37579
0.92429 0.26452 0.37579
0.93618 0.26452 0.37821
0.70009 0.26785 0.32107
0.70974 0.26785 0.32409
0.71949 0.26785 0.32708
0.72933 0.26785 0.33297
0.73927 0.26785 0.33297
0.7493 0.26785 0.33584
0.75944 0.26785 0.34139
0.76968 0.26785 0.34139
0.78003 0.26785 0.34127
0.79047 0.26785 0.34127
0.80103 0.26785 0.34375
0.81168 0.26785 0.34626
0.82244 0.26785 0.35621
0.83332 0.26785 0.35621
0.84429 0.26785 0.35864
0.85538 0.26785 0.35887
0.86658 0.26785 0.35887
0.8779 0.26785 0.36393
0.88932 0.26785 0.36393
0.90086 0.26785 0.36897
0.91251 0.26785 0.36897
0.92429 0.26785 0.37821
0.93618 0.26785 0.37821
0.94818 0.26785 0.37642
0.96031 0.26785 0.37887
0.97256 0.26785 0.3837
0.98493 0.26785 0.3837
0.99743 0.26785 0.38609
0.69054 0.27117 0.31086
0.70009 0.27117 0.31086
0.70974 0.27117 0.31391
0.71949 0.27117 0.31991
0.72933 0.27117 0.31991
0.73927 0.27117 0.32283
0.7493 0.27117 0.32845
0.75944 0.27117 0.32845
0.76968 0.27117 0.33112
0.78003 0.27117 0.33374
0.79047 0.27117 0.34375
0.80103 0.27117 0.34375
0.81168 0.27117 0.34626
0.82244 0.27117 0.34877
0.83332 0.27117 0.34934
0.84429 0.27117 0.34934
0.85538 0.27117 0.35887
0.86658 0.27117 0.35887
0.8779 0.27117 0.36393
0.88932 0.27117 0.36393
0.90086 0.27117 0.36897
0.91251 0.27117 0.36897
0.92429 0.27117 0.37395
0.93618 0.27117 0.37395
0.94818 0.27117 0.37642
0.96031 0.27117 0.37499
0.97256 0.27117 0.3837
0.98493 0.27117 0.3837
0.99743 0.27117 0.38609
1.01 0.27117 0.39081
1.0228 0.27117 0.39081
1.0357 0.27117 0.39546
0.68109 0.27446 0.30468
0.69054 0.27446 0.31086
0.70009 0.27446 0.31086
0.70974 0.27446 0.31391
0.71949 0.27446 0.31991
0.72933 0.27446 0.31991
0.73927 0.27446 0.32283
0.7493 0.27446 0.32845
0.75944 0.27446 0.32845
0.76968 0.27446 0.33112
0.78003 0.27446 0.3318
0.79047 0.27446 0.3318
0.80103 0.27446 0.33717
0.81168 0.27446 0.33717
0.82244 0.27446 0.33985
0.83332 0.27446 0.34252
0.84429 0.27446 0.34785
0.85538 0.27446 0.34785
0.86658 0.27446 0.35051
0.8779 0.27446 0.3558
0.88932 0.27446 0.3558
0.90086 0.27446 0.35843
0.91251 0.27446 0.36365
0.92429 0.27446 0.36365
0.93618 0.27446 0.3688
0.94818 0.27446 0.3688
0.96031 0.27446 0.37499
0.97256 0.27446 0.37638
0.98493 0.27446 0.37638
0.99743 0.27446 0.38134
1.01 0.27446 0.38134
1.0228 0.27446 0.38621
1.0357 0.27446 0.38621
1.0487 0.27446 0.38862
1.0618 0.27446 0.39337
1.0751 0.27446 0.39337
1.0885 0.27446 0.40121
0.67172 0.27774 0.29569
0.68109 0.27774 0.29569
0.69054 0.27774 0.2988
0.70009 0.27774 0.30188
0.70974 0.27774 0.30492
0.71949 0.27774 0.31084
0.72933 0.27774 0.31084
0.73927 0.27774 0.31652
0.7493 0.27774 0.31652
0.75944 0.27774 0.31931
0.76968 0.27774 0.32486
0.78003 0.27774 0.32486
0.79047 0.27774 0.3318
0.80103 0.27774 0.33717
0.81168 0.27774 0.33717
0.82244 0.27774 0.33985
0.83332 0.27774 0.34252
0.84429 0.27774 0.34785
0.85538 0.27774 0.34785
0.86658 0.27774 0.35051
0.8779 0.27774 0.3558
0.88932 0.27774 0.3558
0.90086 0.27774 0.35843
0.91251 0.27774 0.36365
0.92429 0.27774 0.36365
0.93618 0.27774 0.3688
0.94818 0.27774 0.3688
0.96031 0.27774 0.37387
0.97256 0.27774 0.37387
0.98493 0.27774 0.37638
0.99743 0.27774 0.38134
1.01 0.27774 0.38134
1.0228 0.27774 0.38621
1.0357 0.27774 0.38621
1.0487 0.27774 0.38788
1.0618 0.27774 0.38788
1.0751 0.27774 0.39029
1.0885 0.27774 0.39505
1.102 0.27774 0.39505
1.1157 0.27774 0.39973
1.1295 0.27774 0.39973
1.1434 0.27774 0.40435
0.67172 0.281 0.29569
0.68109 0.281 0.29569
0.69054 0.281 0.2988
0.70009 0.281 0.30188
0.70974 0.281 0.30076
0.71949 0.281 0.30372
0.72933 0.281 0.3137
0.73927 0.281 0.3137
0.7493 0.281 0.31524
0.75944 0.281 0.31524
0.76968 0.281 0.31808
0.78003 0.281 0.32373
0.79047 0.281 0.32373
0.80103 0.281 0.32654
0.81168 0.281 0.32934
0.82244 0.281 0.33491
0.83332 0.281 0.33491
0.84429 0.281 0.33767
0.85538 0.281 0.34043
0.86658 0.281 0.34591
0.8779 0.281 0.34591
0.88932 0.281 0.34864
0.90086 0.281 0.35135
0.91251 0.281 0.35404
0.92429 0.281 0.35938
0.93618 0.281 0.35938
0.94818 0.281 0.36465
0.96031 0.281 0.36465
0.97256 0.281 0.36725
0.98493 0.281 0.3724
0.99743 0.281 0.3724
1.01 0.281 0.37494
1.0228 0.281 0.38301
1.0357 0.281 0.38301
1.0487 0.281 0.38788
1.0618 0.281 0.38788
1.0751 0.281 0.39029
1.0885 0.281 0.39505
1.102 0.281 0.39505
1.1157 0.281 0.39973
1.1295 0.281 0.39973
1.1434 0.281 0.40435
1.1575 0.281 0.40435
1.1717 0.281 0.40663
1.1861 0.281 0.40623
0.67172 0.28425 0.28457
0.68109 0.28425 0.29077
0.69054 0.28425 0.29077
0.70009 0.28425 0.30076
0.70974 0.28425 0.30076
0.71949 0.28425 0.30372
0.72933 0.28425 0.30563
0.73927 0.28425 0.30563
0.7493 0.28425 0.31524
0.75944 0.28425 0.31524
0.76968 0.28425 0.31808
0.78003 0.28425 0.32373
0.79047 0.28425 0.32373
0.80103 0.28425 0.32579
0.81168 0.28425 0.32579
0.82244 0.28425 0.32862
0.83332 0.28425 0.33767
0.84429 0.28425 0.33767
0.85538 0.28425 0.34043
0.86658 0.28425 0.34591
0.8779 0.28425 0.34591
0.88932 0.28425 0.34864
0.90086 0.28425 0.34809
0.91251 0.28425 0.35404
0.92429 0.28425 0.35621
0.93618 0.28425 0.35621
0.94818 0.28425 0.36154
0.96031 0.28425 0.36154
0.97256 0.28425 0.36725
0.98493 0.28425 0.3724
0.99743 0.28425 0.3724
1.01 0.28425 0.37494
1.0228 0.28425 0.37705
1.0357 0.28425 0.37705
1.0487 0.28425 0.38206
1.0618 0.28425 0.38206
1.0751 0.28425 0.38699
1.0885 0.28425 0.38699
1.102 0.28425 0.38943
1.1157 0.28425 0.39424
1.1295 0.28425 0.39424
1.1434 0.28425 0.39662
1.1575 0.28425 0.39899
1.1717 0.28425 0.40366
1.1861 0.28425 0.40366
1.2006 0.28425 0.40852
1.2152 0.28425 0.41078
1.23 0.28425 0.41056
0.63519 0.28747 0.27185
0.64419 0.28747 0.27505
0.67172 0.28747 0.28085
0.68109 0.28747 0.28394
0.69054 0.28747 0.287
0.70009 0.28747 0.29003
0.70974 0.28747 0.29679
0.71949 0.28747 0.3027
0.72933 0.28747 0.3027
0.73927 0.28747 0.30563
0.7493 0.28747 0.3079
0.75944 0.28747 0.3079
0.76968 0.28747 0.31722
0.78003 0.28747 0.31722
0.79047 0.28747 0.31665
0.80103 0.28747 0.31955
0.81168 0.28747 0.32242
0.82244 0.28747 0.32529
0.83332 0.28747 0.33424
0.84429 0.28747 0.33424
0.85538 0.28747 0.33704
0.86658 0.28747 0.34259
0.8779 0.28747 0.34259
0.88932 0.28747 0.34534
0.90086 0.28747 0.35081
0.91251 0.28747 0.35081
0.92429 0.28747 0.35319
0.93618 0.28747 0.35589
0.94818 0.28747 0.35589
0.96031 0.28747 0.36124
0.97256 0.28747 0.36124
0.98493 0.28747 0.36388
0.99743 0.28747 0.36911
1.01 0.28747 0.36911
1.0228 0.28747 0.37426
1.0357 0.28747 0.37426
1.0487 0.28747 0.3768
1.0618 0.28747 0.38183
1.0751 0.28747 0.38183
1.0885 0.28747 0.38431
1.102 0.28747 0.38678
1.1157 0.28747 0.38923
1.1295 0.28747 0.39165
1.1434 0.28747 0.39406
1.1575 0.28747 0.39883
1.1717 0.28747 0.39883
1.1861 0.28747 0.40353
1.2006 0.28747 0.40353
1.2152 0.28747 0.40586
1.23 0.28747 0.40817
1.245 0.28747 0.41275
1.2601 0.28747 0.41275
1.2753 0.28747 0.41502
0.57465 0.29068 0.24829
0.58304 0.29068 0.24829
0.59152 0.29068 0.25117
0.60008 0.29068 0.25117
0.60872 0.29068 0.25825
0.61746 0.29068 0.25783
0.62628 0.29068 0.26443
0.63519 0.29068 0.26443
0.64419 0.29068 0.2677
0.65327 0.29068 0.2777
0.66245 0.29068 0.2777
0.67172 0.29068 0.28085
0.68109 0.29068 0.28394
0.69054 0.29068 0.287
0.70009 0.29068 0.29003
0.70974 0.29068 0.29253
0.71949 0.29068 0.29253
0.72933 0.29068 0.29555
0.73927 0.29068 0.29855
0.7493 0.29068 0.30453
0.75944 0.29068 0.30453
0.76968 0.29068 0.30749
0.78003 0.29068 0.31375
0.79047 0.29068 0.31665
0.80103 0.29068 0.31955
0.81168 0.29068 0.32242
0.82244 0.29068 0.32529
0.83332 0.29068 0.32814
0.84429 0.29068 0.32787
0.85538 0.29068 0.33662
0.86658 0.29068 0.33662
0.8779 0.29068 0.3392
0.88932 0.29068 0.3392
0.90086 0.29068 0.342
0.91251 0.29068 0.35047
0.92429 0.29068 0.35047
0.93618 0.29068 0.35589
0.94818 0.29068 0.35589
0.96031 0.29068 0.36124
0.97256 0.29068 0.36124
0.98493 0.29068 0.36388
0.99743 0.29068 0.36911
1.01 0.29068 0.36911
1.0228 0.29068 0.37426
1.0357 0.29068 0.37426
1.0487 0.29068 0.3768
1.0618 0.29068 0.38183
1.0751 0.29068 0.38183
1.0885 0.29068 0.38173
1.102 0.29068 0.3867
1.1157 0.29068 0.3867
1.1295 0.29068 0.38915
1.1434 0.29068 0.39401
1.1575 0.29068 0.39401
1.1717 0.29068 0.40119
1.1861 0.29068 0.40119
1.2006 0.29068 0.40353
1.2152 0.29068 0.40586
1.23 0.29068 0.40817
1.245 0.29068 0.41275
1.2601 0.29068 0.41275
1.2753 0.29068 0.41502
1.2907 0.29068 0.41728
1.3063 0.29068 0.41959
1.322 0.29068 0.41959
1.3378 0.29068 0.42407
0.5419 0.29386 0.22779
0.54996 0.29386 0.22779
0.55811 0.29386 0.2343
0.56634 0.29386 0.2343
0.57465 0.29386 0.24091
0.58304 0.29386 0.24091
0.59152 0.29386 0.24757
0.60008 0.29386 0.24757
0.60872 0.29386 0.25424
0.61746 0.29386 0.25424
0.62628 0.29386 0.26087
0.63519 0.29386 0.26087
0.64419 0.29386 0.26415
0.65327 0.29386 0.26739
0.66245 0.29386 0.27411
0.67172 0.29386 0.27725
0.68109 0.29386 0.27997
0.69054 0.29386 0.27997
0.70009 0.29386 0.28306
0.70974 0.29386 0.29253
0.71949 0.29386 0.29253
0.72933 0.29386 0.29555
0.73927 0.29386 0.29855
0.7493 0.29386 0.2983
0.75944 0.29386 0.30453
0.76968 0.29386 0.30749
0.78003 0.29386 0.30729
0.79047 0.29386 0.31026
0.80103 0.29386 0.31615
0.81168 0.29386 0.31615
0.82244 0.29386 0.32198
0.83332 0.29386 0.32198
0.84429 0.29386 0.32488
0.85538 0.29386 0.32776
0.86658 0.29386 0.33063
0.8779 0.29386 0.33348
0.88932 0.29386 0.342
0.90086 0.29386 0.342
0.91251 0.29386 0.34478
0.92429 0.29386 0.34472
0.93618 0.29386 0.34749
0.94818 0.29386 0.35298
0.96031 0.29386 0.35298
0.97256 0.29386 0.35569
0.98493 0.29386 0.35839
0.99743 0.29386 0.36106
1.01 0.29386 0.36372
1.0228 0.29386 0.36897
1.0357 0.29386 0.36897
1.0487 0.29386 0.37669
1.0618 0.29386 0.37669
1.0751 0.29386 0.38173
1.0885 0.29386 0.38173
1.102 0.29386 0.3867
1.1157 0.29386 0.3867
1.1295 0.29386 0.38915
1.1434 0.29386 0.39401
1.1575 0.29386 0.39401
1.1717 0.29386 0.39641
1.1861 0.29386 0.40117
1.2006 0.29386 0.40117
1.2152 0.29386 0.40352
1.23 0.29386 0.40818
1.245 0.29386 0.40818
1.2601 0.29386 0.41049
1.2753 0.29386 0.41506
1.2907 0.29386 0.41506
1.3063 0.29386 0.41959
1.322 0.29386 0.41959
1.3378 0.29386 0.42407
1.3539 0.29386 0.42407
1.3701 0.29386 0.42426
1.3864 0.29386 0.42852
0.51818 0.29703 0.21828
0.52601 0.29703 0.21828
0.53391 0.29703 0.22458
0.5419 0.29703 0.22458
0.54996 0.29703 0.22779
0.55811 0.29703 0.2343
0.56634 0.29703 0.2343
0.57465 0.29703 0.24091
0.58304 0.29703 0.24091
0.59152 0.29703 0.24757
0.60008 0.29703 0.24757
0.60872 0.29703 0.25424
0.61746 0.29703 0.25424
0.62628 0.29703 0.26087
0.63519 0.29703 0.26087
0.64419 0.29703 0.26415
0.65327 0.29703 0.26739
0.66245 0.29703 0.27374
0.67172 0.29703 0.27374
0.68109 0.29703 0.27997
0.69054 0.29703 0.27997
0.70009 0.29703 0.28306
0.70974 0.29703 0.28919
0.71949 0.29703 0.28919
0.72933 0.29703 0.29224
0.73927 0.29703 0.29528
0.7493 0.29703 0.30131
0.75944 0.29703 0.30131
0.76968 0.29703 0.30431
0.78003 0.29703 0.30424
0.79047 0.29703 0.31022
0.80103 0.29703 0.31022
0.81168 0.29703 0.31318
0.82244 0.29703 0.31907
0.83332 0.29703 0.31907
0.84429 0.29703 0.32199
0.85538 0.29703 0.32778
0.86658 0.29703 0.32778
0.8779 0.29703 0.33352
0.88932 0.29703 0.33352
0.90086 0.29703 0.33636
0.91251 0.29703 0.33919
0.92429 0.29703 0.34479
0.93618 0.29703 0.34479
0.94818 0.29703 0.35032
0.96031 0.29703 0.35032
0.97256 0.29703 0.35577
0.98493 0.29703 0.35577
0.99743 0.29703 0.36115
1.01 0.29703 0.36115
1.0228 0.29703 0.36645
1.0357 0.29703 0.36645
1.0487 0.29703 0.36907
1.0618 0.29703 0.37167
1.0751 0.29703 0.37425
1.0885 0.29703 0.37681
1.102 0.29703 0.38188
1.1157 0.29703 0.38188
1.1295 0.29703 0.38687
1.1434 0.29703 0.38687
1.1575 0.29703 0.38934
1.1717 0.29703 0.39179
1.1861 0.29703 0.39422
1.2006 0.29703 0.39887
1.2152 0.29703 0.40125
1.23 0.29703 0.40361
1.245 0.29703 0.40615
1.2601 0.29703 0.40615
1.2753 0.29703 0.41082
1.2907 0.29703 0.41082
1.3063 0.29703 0.41544
1.322 0.29703 0.41544
1.3378 0.29703 0.42001
1.3539 0.29703 0.42001
1.3701 0.29703 0.42453
1.3864 0.29703 0.42453
1.4029 0.29703 0.42903
1.4196 0.29703 0.42903
0.48763 0.30017 0.20023
0.49516 0.30017 0.20312
0.50275 0.30017 0.20316
0.51043 0.30017 0.20907
0.51818 0.30017 0.20907
0.52601 0.30017 0.21515
0.53391 0.30017 0.21515
0.5419 0.30017 0.21825
0.54996 0.30017 0.22456
0.55811 0.30017 0.22456
0.56634 0.30017 0.23099
0.57465 0.30017 0.23099
0.58304 0.30017 0.23753
0.59152 0.30017 0.23753
0.60008 0.30017 0.24082
0.60872 0.30017 0.24413
0.61746 0.30017 0.25409
0.62628 0.30017 0.25409
0.63519 0.30017 0.26068
0.64419 0.30017 0.26068
0.65327 0.30017 0.26392
0.66245 0.30017 0.26712
0.67172 0.30017 0.27032
0.68109 0.30017 0.2735
0.69054 0.30017 0.27665
0.70009 0.30017 0.27975
0.70974 0.30017 0.27975
0.71949 0.30017 0.28288
0.72933 0.30017 0.28599
0.73927 0.30017 0.28908
0.7493 0.30017 0.29216
0.75944 0.30017 0.30124
0.76968 0.30017 0.30124
0.78003 0.30017 0.30424
0.79047 0.30017 0.31022
0.80103 0.30017 0.31022
0.81168 0.30017 0.31318
0.82244 0.30017 0.31907
0.83332 0.30017 0.31907
0.84429 0.30017 0.32199
0.85538 0.30017 0.32778
0.86658 0.30017 0.32778
0.8779 0.30017 0.33352
0.88932 0.30017 0.33352
0.90086 0.30017 0.33636
0.91251 0.30017 0.33919
0.92429 0.30017 0.34479
0.93618 0.30017 0.34479
0.94818 0.30017 0.35032
0.96031 0.30017 0.35032
0.97256 0.30017 0.35577
0.98493 0.30017 0.35577
0.99743 0.30017 0.36115
1.01 0.30017 0.36115
1.0228 0.30017 0.36645
1.0357 0.30017 0.36645
1.0487 0.30017 0.36907
1.0618 0.30017 0.37167
1.0751 0.30017 0.37425
1.0885 0.30017 0.37681
1.102 0.30017 0.38188
1.1157 0.30017 0.38188
1.1295 0.30017 0.38687
1.1434 0.30017 0.38687
1.1575 0.30017 0.38934
1.1717 0.30017 0.39202
1.1861 0.30017 0.39202
1.2006 0.30017 0.39446
1.2152 0.30017 0.39929
1.23 0.30017 0.39929
1.245 0.30017 0.40168
1.2601 0.30017 0.40643
1.2753 0.30017 0.40643
1.2907 0.30017 0.40878
1.3063 0.30017 0.41343
1.322 0.30017 0.41343
1.3378 0.30017 0.42001
1.3539 0.30017 0.42001
1.3701 0.30017 0.42034
1.3864 0.30017 0.42262
1.4029 0.30017 0.42489
1.4196 0.30017 0.42715
1.4364 0.30017 0.4294
1.4534 0.30017 0.43165
1.4706 0.30017 0.43793
0.43702 0.3033 0.17856
0.44404 0.3033 0.17856
0.45112 0.3033 0.18117
0.45828 0.3033 0.1865
0.46551 0.3033 0.1865
0.47281 0.3033 0.19197
0.48019 0.3033 0.19197
0.48763 0.3033 0.19758
0.49516 0.3033 0.19758
0.50275 0.3033 0.20316
0.51043 0.3033 0.20907
0.51818 0.3033 0.20907
0.52601 0.3033 0.21515
0.53391 0.3033 0.21515
0.5419 0.3033 0.21825
0.54996 0.3033 0.22456
0.55811 0.3033 0.22456
0.56634 0.3033 0.23099
0.57465 0.3033 0.23099
0.58304 0.3033 0.23753
0.59152 0.3033 0.23753
0.60008 0.3033 0.24082
0.60872 0.3033 0.24413
0.61746 0.3033 0.24743
0.62628 0.3033 0.25073
0.63519 0.3033 0.25073
0.64419 0.3033 0.25723
0.65327 0.3033 0.25723
0.66245 0.3033 0.26048
0.67172 0.3033 0.26373
0.68109 0.3033 0.2702
0.69054 0.3033 0.2734
0.70009 0.3033 0.27975
0.70974 0.3033 0.27975
0.71949 0.3033 0.28288
0.72933 0.3033 0.28599
0.73927 0.3033 0.28908
0.7493 0.3033 0.29216
0.75944 0.3033 0.29522
0.76968 0.3033 0.29826
0.78003 0.3033 0.30431
0.79047 0.3033 0.30431
0.80103 0.3033 0.31031
0.81168 0.3033 0.31031
0.82244 0.3033 0.31624
0.83332 0.3033 0.31624
0.84429 0.3033 0.31918
0.85538 0.3033 0.32502
0.86658 0.3033 0.32502
0.8779 0.3033 0.32792
0.88932 0.3033 0.3308
0.90086 0.3033 0.33366
0.91251 0.3033 0.3339
0.92429 0.3033 0.33675
0.93618 0.3033 0.33959
0.94818 0.3033 0.3452
0.96031 0.3033 0.3452
0.97256 0.3033 0.34798
0.98493 0.3033 0.35074
0.99743 0.3033 0.35621
1.01 0.3033 0.35621
1.0228 0.3033 0.35891
1.0357 0.3033 0.36426
1.0487 0.3033 0.36426
1.0618 0.3033 0.36691
1.0751 0.3033 0.37214
1.0885 0.3033 0.37214
1.102 0.3033 0.3773
1.1157 0.3033 0.3773
1.1295 0.3033 0.38238
1.1434 0.3033 0.38238
1.1575 0.3033 0.38739
1.1717 0.3033 0.38739
1.1861 0.3033 0.39202
1.2006 0.3033 0.39446
1.2152 0.3033 0.39929
1.23 0.3033 0.39929
1.245 0.3033 0.40202
1.2601 0.3033 0.40202
1.2753 0.3033 0.40878
1.2907 0.3033 0.40878
1.3063 0.3033 0.41343
1.322 0.3033 0.41343
1.3378 0.3033 0.41613
1.3539 0.3033 0.41613
1.3701 0.3033 0.41844
1.3864 0.3033 0.42074
1.4029 0.3033 0.42531
1.4196 0.3033 0.42531
1.4364 0.3033 0.4294
1.4534 0.3033 0.43165
1.4706 0.3033 0.43211
1.488 0.3033 0.43436
1.5055 0.3033 0.43885
1.5232 0.3033 0.43885
0.37692 0.3064 0.15421
0.38333 0.3064 0.1565
0.38981 0.3064 0.15883
0.39636 0.3064 0.16119
0.40297 0.3064 0.16357
0.40964 0.3064 0.16615
0.41639 0.3064 0.16615
0.4232 0.3064 0.16862
0.43007 0.3064 0.17112
0.43702 0.3064 0.17365
0.44404 0.3064 0.17621
0.45112 0.3064 0.17881
0.45828 0.3064 0.18143
0.46551 0.3064 0.18409
0.47281 0.3064 0.18678
0.48019 0.3064 0.1895
0.48763 0.3064 0.19226
0.49516 0.3064 0.19506
0.50275 0.3064 0.20076
0.51043 0.3064 0.20076
0.51818 0.3064 0.20661
0.52601 0.3064 0.20661
0.53391 0.3064 0.20959
0.5419 0.3064 0.21566
0.54996 0.3064 0.21566
0.55811 0.3064 0.22186
0.56634 0.3064 0.22186
0.57465 0.3064 0.22819
0.58304 0.3064 0.22819
0.59152 0.3064 0.2346
0.60008 0.3064 0.2346
0.60872 0.3064 0.24106
0.61746 0.3064 0.24106
0.62628 0.3064 0.25073
0.63519 0.3064 0.25073
0.64419 0.3064 0.25081
0.65327 0.3064 0.25406
0.66245 0.3064 0.26058
0.67172 0.3064 0.26058
0.68109 0.3064 0.26709
0.69054 0.3064 0.26709
0.70009 0.3064 0.27357
0.70974 0.3064 0.27357
0.71949 0.3064 0.27999
0.72933 0.3064 0.27999
0.73927 0.3064 0.28317
0.7493 0.3064 0.28944
0.75944 0.3064 0.28944
0.76968 0.3064 0.29561
0.78003 0.3064 0.29561
0.79047 0.3064 0.30173
0.80103 0.3064 0.30173
0.81168 0.3064 0.3105
0.82244 0.3064 0.3105
0.83332 0.3064 0.31348
0.84429 0.3064 0.31644
0.85538 0.3064 0.31969
0.86658 0.3064 0.31969
0.8779 0.3064 0.32815
0.88932 0.3064 0.32815
0.90086 0.3064 0.3339
0.91251 0.3064 0.3339
0.92429 0.3064 0.33675
0.93618 0.3064 0.33959
0.94818 0.3064 0.3452
0.96031 0.3064 0.3452
0.97256 0.3064 0.34798
0.98493 0.3064 0.35074
0.99743 0.3064 0.35621
1.01 0.3064 0.35621
1.0228 0.3064 0.35891
1.0357 0.3064 0.36426
1.0487 0.3064 0.36426
1.0618 0.3064 0.3646
1.0751 0.3064 0.37214
1.0885 0.3064 0.37214
1.102 0.3064 0.37508
1.1157 0.3064 0.37508
1.1295 0.3064 0.38021
1.1434 0.3064 0.38021
1.1575 0.3064 0.38526
1.1717 0.3064 0.38526
1.1861 0.3064 0.38987
1.2006 0.3064 0.39233
1.2152 0.3064 0.39721
1.23 0.3064 0.39721
1.245 0.3064 0.40202
1.2601 0.3064 0.40202
1.2753 0.3064 0.40441
1.2907 0.3064 0.40913
1.3063 0.3064 0.40913
1.322 0.3064 0.41148
1.3378 0.3064 0.41613
1.3539 0.3064 0.41613
1.3701 0.3064 0.41844
1.3864 0.3064 0.42074
1.4029 0.3064 0.42531
1.4196 0.3064 0.42531
1.4364 0.3064 0.42808
1.4534 0.3064 0.42808
1.4706 0.3064 0.43211
1.488 0.3064 0.43263
1.5055 0.3064 0.43489
1.5232 0.3064 0.43715
1.5411 0.3064 0.44166
1.5591 0.3064 0.44166
The GMSH code run with Python API is given below:
import gmsh
import numpy as np
from scipy.interpolate import NearestNDInterpolator
import matplotlib.pyplot as plt
import numpy
import csv
def meshSizeCallback(dim, tag, x, y, z, lc):
return min(lc, background_field(x,y))
gmsh.initialize()
lc=0.2
gmsh.option.setNumber("Mesh.CharacteristicLengthMax", lc)
# Building the geometry
gmsh.model.occ.addPoint(0,0,0,lc)
gmsh.model.occ.addPoint(0,0.5,0,lc)
gmsh.model.occ.addPoint(3,0.5,0,lc)
gmsh.model.occ.addPoint(3,0,0,lc)
gmsh.model.occ.addLine(1,2)
gmsh.model.occ.addLine(2,3)
gmsh.model.occ.addLine(3,4)
gmsh.model.occ.addLine(4,1)
gmsh.model.occ.addCurveLoop([1,2,3,4],1)
gmsh.model.occ.addPlaneSurface([1],2)
gmsh.model.occ.synchronize()
# Reading the data.csv file containing the point coordinates as well as the desired cell size
background_field = []
with open('coord_regions_int_maillage_B_threshold_14_maj_Delta_2D.csv','r',encoding="utf8", errors='ignore') as csvfile:
points = csv.reader(csvfile, delimiter = ',')
for [x,y,ls] in points: # for each point in the csv file
background_field.append([float(x), float(y), float(ls)/10]) #the mesh size is divided by 10 in order to clearly separate the refinement region from the rest of the mesh
background_field = np.array(background_field)
X = background_field[:,0]
Y = background_field[:,1]
# Interpolating the background field (required for the call back function)
background_field = NearestNDInterpolator(background_field[:,0:2], background_field[:,2]) # First input: point coordinates, Second input: value
gmsh.model.mesh.setSizeCallback(meshSizeCallback) # Keep the minimum cell size between the background and the intial mesh size
# Generating 2D mesh
gmsh.model.mesh.generate(2)
# Writing the mesh
gmsh.write("maillage_auto.msh")
gmsh.fltk.run()
gmsh.finalize()
# Plot the surface in Python to compare with the GMSH results
plt.scatter(X, Y, c=background_field(X,Y))
plt.xlabel("X")
plt.ylabel("Y")
plt.colorbar()
plt.show()
Unfortunately, the refined area obtained with GMSH is different from the refined area given by the background_field (see attached pictures). May someone help me to understand why the refined area obtained in GMSH does not correspond with the region described in data.csv
? Moreover, the mesh size is the non refined region is smaller than the prescribed mesh size lc=0.2
. What is the reason for this result ?
Thanks a lot for your answer!