-
Notifications
You must be signed in to change notification settings - Fork 0
/
gmsh.jl
7381 lines (6423 loc) · 286 KB
/
gmsh.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
#
# See the LICENSE.txt file in the Gmsh root directory for license information.
# Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
# This file defines the Gmsh Julia API (v4.9.5).
#
# Do not edit this file directly: it is automatically generated by `api/gen.py'.
#
# By design, the Gmsh Julia API is purely functional, and only uses elementary
# Julia types. See `tutorials/julia' and `examples/api' for tutorials and
# examples.
"""
module gmsh
Top-level functions
"""
module gmsh
const GMSH_API_VERSION = "4.9.5"
const GMSH_API_VERSION_MAJOR = 4
const GMSH_API_VERSION_MINOR = 9
const GMSH_API_VERSION_PATCH = 5
const libdir = dirname(@__FILE__)
const libname = Sys.iswindows() ? "gmsh-4.9.dll" : "libgmsh"
import Libdl
const lib = Libdl.find_library([libname], [libdir])
"""
gmsh.initialize(argv = Vector{String}(), readConfigFiles = true, run = false)
Initialize the Gmsh API. This must be called before any call to the other
functions in the API. If `argc` and `argv` (or just `argv` in Python or Julia)
are provided, they will be handled in the same way as the command line arguments
in the Gmsh app. If `readConfigFiles` is set, read system Gmsh configuration
files (gmshrc and gmsh-options). If `run` is set, run in the same way as the
Gmsh app, either interactively or in batch mode depending on the command line
arguments. If `run` is not set, initializing the API sets the options
"General.AbortOnError" to 2 and "General.Terminal" to 1. If compiled with OpenMP
support, it also sets the number of threads to "General.NumThreads".
"""
function initialize(argv = Vector{String}(), readConfigFiles = true, run = false)
ierr = Ref{Cint}()
ccall((:gmshInitialize, lib), Cvoid,
(Cint, Ptr{Ptr{Cchar}}, Cint, Cint, Ptr{Cint}),
length(argv), argv, readConfigFiles, run, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
"""
gmsh.isInitialized()
Return 1 if the Gmsh API is initialized, and 0 if not.
Return an integer value.
"""
function isInitialized()
ierr = Ref{Cint}()
api_result_ = ccall((:gmshIsInitialized, lib), Cint,
(Ptr{Cint},),
ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return api_result_
end
const is_initialized = isInitialized
"""
gmsh.finalize()
Finalize the Gmsh API. This must be called when you are done using the Gmsh API.
"""
function finalize()
ierr = Ref{Cint}()
ccall((:gmshFinalize, lib), Cvoid,
(Ptr{Cint},),
ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
"""
gmsh.open(fileName)
Open a file. Equivalent to the `File->Open` menu in the Gmsh app. Handling of
the file depends on its extension and/or its contents: opening a file with model
data will create a new model.
"""
function open(fileName)
ierr = Ref{Cint}()
ccall((:gmshOpen, lib), Cvoid,
(Ptr{Cchar}, Ptr{Cint}),
fileName, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
"""
gmsh.merge(fileName)
Merge a file. Equivalent to the `File->Merge` menu in the Gmsh app. Handling of
the file depends on its extension and/or its contents. Merging a file with model
data will add the data to the current model.
"""
function merge(fileName)
ierr = Ref{Cint}()
ccall((:gmshMerge, lib), Cvoid,
(Ptr{Cchar}, Ptr{Cint}),
fileName, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
"""
gmsh.write(fileName)
Write a file. The export format is determined by the file extension.
"""
function write(fileName)
ierr = Ref{Cint}()
ccall((:gmshWrite, lib), Cvoid,
(Ptr{Cchar}, Ptr{Cint}),
fileName, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
"""
gmsh.clear()
Clear all loaded models and post-processing data, and add a new empty model.
"""
function clear()
ierr = Ref{Cint}()
ccall((:gmshClear, lib), Cvoid,
(Ptr{Cint},),
ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
"""
module gmsh.option
Option handling functions
"""
module option
import ..gmsh
"""
gmsh.option.setNumber(name, value)
Set a numerical option to `value`. `name` is of the form "Category.Option" or
"Category[num].Option". Available categories and options are listed in the Gmsh
reference manual.
"""
function setNumber(name, value)
ierr = Ref{Cint}()
ccall((:gmshOptionSetNumber, gmsh.lib), Cvoid,
(Ptr{Cchar}, Cdouble, Ptr{Cint}),
name, value, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const set_number = setNumber
"""
gmsh.option.getNumber(name)
Get the `value` of a numerical option. `name` is of the form "Category.Option"
or "Category[num].Option". Available categories and options are listed in the
Gmsh reference manual.
Return `value`.
"""
function getNumber(name)
api_value_ = Ref{Cdouble}()
ierr = Ref{Cint}()
ccall((:gmshOptionGetNumber, gmsh.lib), Cvoid,
(Ptr{Cchar}, Ptr{Cdouble}, Ptr{Cint}),
name, api_value_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return api_value_[]
end
const get_number = getNumber
"""
gmsh.option.setString(name, value)
Set a string option to `value`. `name` is of the form "Category.Option" or
"Category[num].Option". Available categories and options are listed in the Gmsh
reference manual.
"""
function setString(name, value)
ierr = Ref{Cint}()
ccall((:gmshOptionSetString, gmsh.lib), Cvoid,
(Ptr{Cchar}, Ptr{Cchar}, Ptr{Cint}),
name, value, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const set_string = setString
"""
gmsh.option.getString(name)
Get the `value` of a string option. `name` is of the form "Category.Option" or
"Category[num].Option". Available categories and options are listed in the Gmsh
reference manual.
Return `value`.
"""
function getString(name)
api_value_ = Ref{Ptr{Cchar}}()
ierr = Ref{Cint}()
ccall((:gmshOptionGetString, gmsh.lib), Cvoid,
(Ptr{Cchar}, Ptr{Ptr{Cchar}}, Ptr{Cint}),
name, api_value_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
value = unsafe_string(api_value_[])
return value
end
const get_string = getString
"""
gmsh.option.setColor(name, r, g, b, a = 255)
Set a color option to the RGBA value (`r`, `g`, `b`, `a`), where where `r`, `g`,
`b` and `a` should be integers between 0 and 255. `name` is of the form
"Category.Color.Option" or "Category[num].Color.Option". Available categories
and options are listed in the Gmsh reference manual. For conciseness "Color."
can be ommitted in `name`.
"""
function setColor(name, r, g, b, a = 255)
ierr = Ref{Cint}()
ccall((:gmshOptionSetColor, gmsh.lib), Cvoid,
(Ptr{Cchar}, Cint, Cint, Cint, Cint, Ptr{Cint}),
name, r, g, b, a, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const set_color = setColor
"""
gmsh.option.getColor(name)
Get the `r`, `g`, `b`, `a` value of a color option. `name` is of the form
"Category.Color.Option" or "Category[num].Color.Option". Available categories
and options are listed in the Gmsh reference manual. For conciseness "Color."
can be ommitted in `name`.
Return `r`, `g`, `b`, `a`.
"""
function getColor(name)
api_r_ = Ref{Cint}()
api_g_ = Ref{Cint}()
api_b_ = Ref{Cint}()
api_a_ = Ref{Cint}()
ierr = Ref{Cint}()
ccall((:gmshOptionGetColor, gmsh.lib), Cvoid,
(Ptr{Cchar}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
name, api_r_, api_g_, api_b_, api_a_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return api_r_[], api_g_[], api_b_[], api_a_[]
end
const get_color = getColor
end # end of module option
"""
module gmsh.model
Model functions
"""
module model
import ..gmsh
"""
gmsh.model.add(name)
Add a new model, with name `name`, and set it as the current model.
"""
function add(name)
ierr = Ref{Cint}()
ccall((:gmshModelAdd, gmsh.lib), Cvoid,
(Ptr{Cchar}, Ptr{Cint}),
name, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
"""
gmsh.model.remove()
Remove the current model.
"""
function remove()
ierr = Ref{Cint}()
ccall((:gmshModelRemove, gmsh.lib), Cvoid,
(Ptr{Cint},),
ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
"""
gmsh.model.list()
List the names of all models.
Return `names`.
"""
function list()
api_names_ = Ref{Ptr{Ptr{Cchar}}}()
api_names_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelList, gmsh.lib), Cvoid,
(Ptr{Ptr{Ptr{Cchar}}}, Ptr{Csize_t}, Ptr{Cint}),
api_names_, api_names_n_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
tmp_api_names_ = unsafe_wrap(Array, api_names_[], api_names_n_[], own = true)
names = [unsafe_string(tmp_api_names_[i]) for i in 1:length(tmp_api_names_) ]
return names
end
"""
gmsh.model.getCurrent()
Get the name of the current model.
Return `name`.
"""
function getCurrent()
api_name_ = Ref{Ptr{Cchar}}()
ierr = Ref{Cint}()
ccall((:gmshModelGetCurrent, gmsh.lib), Cvoid,
(Ptr{Ptr{Cchar}}, Ptr{Cint}),
api_name_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
name = unsafe_string(api_name_[])
return name
end
const get_current = getCurrent
"""
gmsh.model.setCurrent(name)
Set the current model to the model with name `name`. If several models have the
same name, select the one that was added first.
"""
function setCurrent(name)
ierr = Ref{Cint}()
ccall((:gmshModelSetCurrent, gmsh.lib), Cvoid,
(Ptr{Cchar}, Ptr{Cint}),
name, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const set_current = setCurrent
"""
gmsh.model.getFileName()
Get the file name (if any) associated with the current model. A file name is
associated when a model is read from a file on disk.
Return `fileName`.
"""
function getFileName()
api_fileName_ = Ref{Ptr{Cchar}}()
ierr = Ref{Cint}()
ccall((:gmshModelGetFileName, gmsh.lib), Cvoid,
(Ptr{Ptr{Cchar}}, Ptr{Cint}),
api_fileName_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
fileName = unsafe_string(api_fileName_[])
return fileName
end
const get_file_name = getFileName
"""
gmsh.model.setFileName(fileName)
Set the file name associated with the current model.
"""
function setFileName(fileName)
ierr = Ref{Cint}()
ccall((:gmshModelSetFileName, gmsh.lib), Cvoid,
(Ptr{Cchar}, Ptr{Cint}),
fileName, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const set_file_name = setFileName
"""
gmsh.model.getEntities(dim = -1)
Get all the entities in the current model. If `dim` is >= 0, return only the
entities of the specified dimension (e.g. points if `dim` == 0). The entities
are returned as a vector of (dim, tag) integer pairs.
Return `dimTags`.
"""
function getEntities(dim = -1)
api_dimTags_ = Ref{Ptr{Cint}}()
api_dimTags_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetEntities, gmsh.lib), Cvoid,
(Ptr{Ptr{Cint}}, Ptr{Csize_t}, Cint, Ptr{Cint}),
api_dimTags_, api_dimTags_n_, dim, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
tmp_api_dimTags_ = unsafe_wrap(Array, api_dimTags_[], api_dimTags_n_[], own = true)
dimTags = [ (tmp_api_dimTags_[i], tmp_api_dimTags_[i+1]) for i in 1:2:length(tmp_api_dimTags_) ]
return dimTags
end
const get_entities = getEntities
"""
gmsh.model.setEntityName(dim, tag, name)
Set the name of the entity of dimension `dim` and tag `tag`.
"""
function setEntityName(dim, tag, name)
ierr = Ref{Cint}()
ccall((:gmshModelSetEntityName, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Cchar}, Ptr{Cint}),
dim, tag, name, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const set_entity_name = setEntityName
"""
gmsh.model.getEntityName(dim, tag)
Get the name of the entity of dimension `dim` and tag `tag`.
Return `name`.
"""
function getEntityName(dim, tag)
api_name_ = Ref{Ptr{Cchar}}()
ierr = Ref{Cint}()
ccall((:gmshModelGetEntityName, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Ptr{Cchar}}, Ptr{Cint}),
dim, tag, api_name_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
name = unsafe_string(api_name_[])
return name
end
const get_entity_name = getEntityName
"""
gmsh.model.getPhysicalGroups(dim = -1)
Get all the physical groups in the current model. If `dim` is >= 0, return only
the entities of the specified dimension (e.g. physical points if `dim` == 0).
The entities are returned as a vector of (dim, tag) integer pairs.
Return `dimTags`.
"""
function getPhysicalGroups(dim = -1)
api_dimTags_ = Ref{Ptr{Cint}}()
api_dimTags_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetPhysicalGroups, gmsh.lib), Cvoid,
(Ptr{Ptr{Cint}}, Ptr{Csize_t}, Cint, Ptr{Cint}),
api_dimTags_, api_dimTags_n_, dim, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
tmp_api_dimTags_ = unsafe_wrap(Array, api_dimTags_[], api_dimTags_n_[], own = true)
dimTags = [ (tmp_api_dimTags_[i], tmp_api_dimTags_[i+1]) for i in 1:2:length(tmp_api_dimTags_) ]
return dimTags
end
const get_physical_groups = getPhysicalGroups
"""
gmsh.model.getEntitiesForPhysicalGroup(dim, tag)
Get the tags of the model entities making up the physical group of dimension
`dim` and tag `tag`.
Return `tags`.
"""
function getEntitiesForPhysicalGroup(dim, tag)
api_tags_ = Ref{Ptr{Cint}}()
api_tags_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetEntitiesForPhysicalGroup, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Ptr{Cint}}, Ptr{Csize_t}, Ptr{Cint}),
dim, tag, api_tags_, api_tags_n_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
tags = unsafe_wrap(Array, api_tags_[], api_tags_n_[], own = true)
return tags
end
const get_entities_for_physical_group = getEntitiesForPhysicalGroup
"""
gmsh.model.getPhysicalGroupsForEntity(dim, tag)
Get the tags of the physical groups (if any) to which the model entity of
dimension `dim` and tag `tag` belongs.
Return `physicalTags`.
"""
function getPhysicalGroupsForEntity(dim, tag)
api_physicalTags_ = Ref{Ptr{Cint}}()
api_physicalTags_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetPhysicalGroupsForEntity, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Ptr{Cint}}, Ptr{Csize_t}, Ptr{Cint}),
dim, tag, api_physicalTags_, api_physicalTags_n_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
physicalTags = unsafe_wrap(Array, api_physicalTags_[], api_physicalTags_n_[], own = true)
return physicalTags
end
const get_physical_groups_for_entity = getPhysicalGroupsForEntity
"""
gmsh.model.addPhysicalGroup(dim, tags, tag = -1)
Add a physical group of dimension `dim`, grouping the model entities with tags
`tags`. Return the tag of the physical group, equal to `tag` if `tag` is
positive, or a new tag if `tag` < 0.
Return an integer value.
"""
function addPhysicalGroup(dim, tags, tag = -1)
ierr = Ref{Cint}()
api_result_ = ccall((:gmshModelAddPhysicalGroup, gmsh.lib), Cint,
(Cint, Ptr{Cint}, Csize_t, Cint, Ptr{Cint}),
dim, convert(Vector{Cint}, tags), length(tags), tag, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return api_result_
end
const add_physical_group = addPhysicalGroup
"""
gmsh.model.removePhysicalGroups(dimTags = Tuple{Cint,Cint}[])
Remove the physical groups `dimTags` from the current model. If `dimTags` is
empty, remove all groups.
"""
function removePhysicalGroups(dimTags = Tuple{Cint,Cint}[])
api_dimTags_ = collect(Cint, Iterators.flatten(dimTags))
api_dimTags_n_ = length(api_dimTags_)
ierr = Ref{Cint}()
ccall((:gmshModelRemovePhysicalGroups, gmsh.lib), Cvoid,
(Ptr{Cint}, Csize_t, Ptr{Cint}),
api_dimTags_, api_dimTags_n_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const remove_physical_groups = removePhysicalGroups
"""
gmsh.model.setPhysicalName(dim, tag, name)
Set the name of the physical group of dimension `dim` and tag `tag`.
"""
function setPhysicalName(dim, tag, name)
ierr = Ref{Cint}()
ccall((:gmshModelSetPhysicalName, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Cchar}, Ptr{Cint}),
dim, tag, name, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const set_physical_name = setPhysicalName
"""
gmsh.model.removePhysicalName(name)
Remove the physical name `name` from the current model.
"""
function removePhysicalName(name)
ierr = Ref{Cint}()
ccall((:gmshModelRemovePhysicalName, gmsh.lib), Cvoid,
(Ptr{Cchar}, Ptr{Cint}),
name, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const remove_physical_name = removePhysicalName
"""
gmsh.model.getPhysicalName(dim, tag)
Get the name of the physical group of dimension `dim` and tag `tag`.
Return `name`.
"""
function getPhysicalName(dim, tag)
api_name_ = Ref{Ptr{Cchar}}()
ierr = Ref{Cint}()
ccall((:gmshModelGetPhysicalName, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Ptr{Cchar}}, Ptr{Cint}),
dim, tag, api_name_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
name = unsafe_string(api_name_[])
return name
end
const get_physical_name = getPhysicalName
"""
gmsh.model.setTag(dim, tag, newTag)
Set the tag of the entity of dimension `dim` and tag `tag` to the new value
`newTag`.
"""
function setTag(dim, tag, newTag)
ierr = Ref{Cint}()
ccall((:gmshModelSetTag, gmsh.lib), Cvoid,
(Cint, Cint, Cint, Ptr{Cint}),
dim, tag, newTag, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const set_tag = setTag
"""
gmsh.model.getBoundary(dimTags, combined = true, oriented = true, recursive = false)
Get the boundary of the model entities `dimTags`. Return in `outDimTags` the
boundary of the individual entities (if `combined` is false) or the boundary of
the combined geometrical shape formed by all input entities (if `combined` is
true). Return tags multiplied by the sign of the boundary entity if `oriented`
is true. Apply the boundary operator recursively down to dimension 0 (i.e. to
points) if `recursive` is true.
Return `outDimTags`.
"""
function getBoundary(dimTags, combined = true, oriented = true, recursive = false)
api_dimTags_ = collect(Cint, Iterators.flatten(dimTags))
api_dimTags_n_ = length(api_dimTags_)
api_outDimTags_ = Ref{Ptr{Cint}}()
api_outDimTags_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetBoundary, gmsh.lib), Cvoid,
(Ptr{Cint}, Csize_t, Ptr{Ptr{Cint}}, Ptr{Csize_t}, Cint, Cint, Cint, Ptr{Cint}),
api_dimTags_, api_dimTags_n_, api_outDimTags_, api_outDimTags_n_, combined, oriented, recursive, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
tmp_api_outDimTags_ = unsafe_wrap(Array, api_outDimTags_[], api_outDimTags_n_[], own = true)
outDimTags = [ (tmp_api_outDimTags_[i], tmp_api_outDimTags_[i+1]) for i in 1:2:length(tmp_api_outDimTags_) ]
return outDimTags
end
const get_boundary = getBoundary
"""
gmsh.model.getAdjacencies(dim, tag)
Get the upward and downward adjacencies of the model entity of dimension `dim`
and tag `tag`. The `upward` vector returns the adjacent entities of dimension
`dim` + 1; the `downward` vector returns the adjacent entities of dimension
`dim` - 1.
Return `upward`, `downward`.
"""
function getAdjacencies(dim, tag)
api_upward_ = Ref{Ptr{Cint}}()
api_upward_n_ = Ref{Csize_t}()
api_downward_ = Ref{Ptr{Cint}}()
api_downward_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetAdjacencies, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Ptr{Cint}}, Ptr{Csize_t}, Ptr{Ptr{Cint}}, Ptr{Csize_t}, Ptr{Cint}),
dim, tag, api_upward_, api_upward_n_, api_downward_, api_downward_n_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
upward = unsafe_wrap(Array, api_upward_[], api_upward_n_[], own = true)
downward = unsafe_wrap(Array, api_downward_[], api_downward_n_[], own = true)
return upward, downward
end
const get_adjacencies = getAdjacencies
"""
gmsh.model.getEntitiesInBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax, dim = -1)
Get the model entities in the bounding box defined by the two points (`xmin`,
`ymin`, `zmin`) and (`xmax`, `ymax`, `zmax`). If `dim` is >= 0, return only the
entities of the specified dimension (e.g. points if `dim` == 0).
Return `tags`.
"""
function getEntitiesInBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax, dim = -1)
api_tags_ = Ref{Ptr{Cint}}()
api_tags_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetEntitiesInBoundingBox, gmsh.lib), Cvoid,
(Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Ptr{Ptr{Cint}}, Ptr{Csize_t}, Cint, Ptr{Cint}),
xmin, ymin, zmin, xmax, ymax, zmax, api_tags_, api_tags_n_, dim, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
tmp_api_tags_ = unsafe_wrap(Array, api_tags_[], api_tags_n_[], own = true)
tags = [ (tmp_api_tags_[i], tmp_api_tags_[i+1]) for i in 1:2:length(tmp_api_tags_) ]
return tags
end
const get_entities_in_bounding_box = getEntitiesInBoundingBox
"""
gmsh.model.getBoundingBox(dim, tag)
Get the bounding box (`xmin`, `ymin`, `zmin`), (`xmax`, `ymax`, `zmax`) of the
model entity of dimension `dim` and tag `tag`. If `dim` and `tag` are negative,
get the bounding box of the whole model.
Return `xmin`, `ymin`, `zmin`, `xmax`, `ymax`, `zmax`.
"""
function getBoundingBox(dim, tag)
api_xmin_ = Ref{Cdouble}()
api_ymin_ = Ref{Cdouble}()
api_zmin_ = Ref{Cdouble}()
api_xmax_ = Ref{Cdouble}()
api_ymax_ = Ref{Cdouble}()
api_zmax_ = Ref{Cdouble}()
ierr = Ref{Cint}()
ccall((:gmshModelGetBoundingBox, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cint}),
dim, tag, api_xmin_, api_ymin_, api_zmin_, api_xmax_, api_ymax_, api_zmax_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return api_xmin_[], api_ymin_[], api_zmin_[], api_xmax_[], api_ymax_[], api_zmax_[]
end
const get_bounding_box = getBoundingBox
"""
gmsh.model.getDimension()
Return the geometrical dimension of the current model.
Return an integer value.
"""
function getDimension()
ierr = Ref{Cint}()
api_result_ = ccall((:gmshModelGetDimension, gmsh.lib), Cint,
(Ptr{Cint},),
ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return api_result_
end
const get_dimension = getDimension
"""
gmsh.model.addDiscreteEntity(dim, tag = -1, boundary = Cint[])
Add a discrete model entity (defined by a mesh) of dimension `dim` in the
current model. Return the tag of the new discrete entity, equal to `tag` if
`tag` is positive, or a new tag if `tag` < 0. `boundary` specifies the tags of
the entities on the boundary of the discrete entity, if any. Specifying
`boundary` allows Gmsh to construct the topology of the overall model.
Return an integer value.
"""
function addDiscreteEntity(dim, tag = -1, boundary = Cint[])
ierr = Ref{Cint}()
api_result_ = ccall((:gmshModelAddDiscreteEntity, gmsh.lib), Cint,
(Cint, Cint, Ptr{Cint}, Csize_t, Ptr{Cint}),
dim, tag, convert(Vector{Cint}, boundary), length(boundary), ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return api_result_
end
const add_discrete_entity = addDiscreteEntity
"""
gmsh.model.removeEntities(dimTags, recursive = false)
Remove the entities `dimTags` of the current model, provided that they are not
on the boundary of (or embedded in) higher-dimensional entities. If `recursive`
is true, remove all the entities on their boundaries, down to dimension 0.
"""
function removeEntities(dimTags, recursive = false)
api_dimTags_ = collect(Cint, Iterators.flatten(dimTags))
api_dimTags_n_ = length(api_dimTags_)
ierr = Ref{Cint}()
ccall((:gmshModelRemoveEntities, gmsh.lib), Cvoid,
(Ptr{Cint}, Csize_t, Cint, Ptr{Cint}),
api_dimTags_, api_dimTags_n_, recursive, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const remove_entities = removeEntities
"""
gmsh.model.removeEntityName(name)
Remove the entity name `name` from the current model.
"""
function removeEntityName(name)
ierr = Ref{Cint}()
ccall((:gmshModelRemoveEntityName, gmsh.lib), Cvoid,
(Ptr{Cchar}, Ptr{Cint}),
name, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return nothing
end
const remove_entity_name = removeEntityName
"""
gmsh.model.getType(dim, tag)
Get the type of the entity of dimension `dim` and tag `tag`.
Return `entityType`.
"""
function getType(dim, tag)
api_entityType_ = Ref{Ptr{Cchar}}()
ierr = Ref{Cint}()
ccall((:gmshModelGetType, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Ptr{Cchar}}, Ptr{Cint}),
dim, tag, api_entityType_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
entityType = unsafe_string(api_entityType_[])
return entityType
end
const get_type = getType
"""
gmsh.model.getParent(dim, tag)
In a partitioned model, get the parent of the entity of dimension `dim` and tag
`tag`, i.e. from which the entity is a part of, if any. `parentDim` and
`parentTag` are set to -1 if the entity has no parent.
Return `parentDim`, `parentTag`.
"""
function getParent(dim, tag)
api_parentDim_ = Ref{Cint}()
api_parentTag_ = Ref{Cint}()
ierr = Ref{Cint}()
ccall((:gmshModelGetParent, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}),
dim, tag, api_parentDim_, api_parentTag_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return api_parentDim_[], api_parentTag_[]
end
const get_parent = getParent
"""
gmsh.model.getNumberOfPartitions()
Return the number of partitions in the model.
Return an integer value.
"""
function getNumberOfPartitions()
ierr = Ref{Cint}()
api_result_ = ccall((:gmshModelGetNumberOfPartitions, gmsh.lib), Cint,
(Ptr{Cint},),
ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
return api_result_
end
const get_number_of_partitions = getNumberOfPartitions
"""
gmsh.model.getPartitions(dim, tag)
In a partitioned model, return the tags of the partition(s) to which the entity
belongs.
Return `partitions`.
"""
function getPartitions(dim, tag)
api_partitions_ = Ref{Ptr{Cint}}()
api_partitions_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetPartitions, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Ptr{Cint}}, Ptr{Csize_t}, Ptr{Cint}),
dim, tag, api_partitions_, api_partitions_n_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
partitions = unsafe_wrap(Array, api_partitions_[], api_partitions_n_[], own = true)
return partitions
end
const get_partitions = getPartitions
"""
gmsh.model.getValue(dim, tag, parametricCoord)
Evaluate the parametrization of the entity of dimension `dim` and tag `tag` at
the parametric coordinates `parametricCoord`. Only valid for `dim` equal to 0
(with empty `parametricCoord`), 1 (with `parametricCoord` containing parametric
coordinates on the curve) or 2 (with `parametricCoord` containing pairs of u, v
parametric coordinates on the surface, concatenated: [p1u, p1v, p2u, ...]).
Return triplets of x, y, z coordinates in `coord`, concatenated: [p1x, p1y, p1z,
p2x, ...].
Return `coord`.
"""
function getValue(dim, tag, parametricCoord)
api_coord_ = Ref{Ptr{Cdouble}}()
api_coord_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetValue, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Cdouble}, Csize_t, Ptr{Ptr{Cdouble}}, Ptr{Csize_t}, Ptr{Cint}),
dim, tag, convert(Vector{Cdouble}, parametricCoord), length(parametricCoord), api_coord_, api_coord_n_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
coord = unsafe_wrap(Array, api_coord_[], api_coord_n_[], own = true)
return coord
end
const get_value = getValue
"""
gmsh.model.getDerivative(dim, tag, parametricCoord)
Evaluate the derivative of the parametrization of the entity of dimension `dim`
and tag `tag` at the parametric coordinates `parametricCoord`. Only valid for
`dim` equal to 1 (with `parametricCoord` containing parametric coordinates on
the curve) or 2 (with `parametricCoord` containing pairs of u, v parametric
coordinates on the surface, concatenated: [p1u, p1v, p2u, ...]). For `dim` equal
to 1 return the x, y, z components of the derivative with respect to u [d1ux,
d1uy, d1uz, d2ux, ...]; for `dim` equal to 2 return the x, y, z components of
the derivative with respect to u and v: [d1ux, d1uy, d1uz, d1vx, d1vy, d1vz,
d2ux, ...].
Return `derivatives`.
"""
function getDerivative(dim, tag, parametricCoord)
api_derivatives_ = Ref{Ptr{Cdouble}}()
api_derivatives_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetDerivative, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Cdouble}, Csize_t, Ptr{Ptr{Cdouble}}, Ptr{Csize_t}, Ptr{Cint}),
dim, tag, convert(Vector{Cdouble}, parametricCoord), length(parametricCoord), api_derivatives_, api_derivatives_n_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
derivatives = unsafe_wrap(Array, api_derivatives_[], api_derivatives_n_[], own = true)
return derivatives
end
const get_derivative = getDerivative
"""
gmsh.model.getSecondDerivative(dim, tag, parametricCoord)
Evaluate the second derivative of the parametrization of the entity of dimension
`dim` and tag `tag` at the parametric coordinates `parametricCoord`. Only valid
for `dim` equal to 1 (with `parametricCoord` containing parametric coordinates
on the curve) or 2 (with `parametricCoord` containing pairs of u, v parametric
coordinates on the surface, concatenated: [p1u, p1v, p2u, ...]). For `dim` equal
to 1 return the x, y, z components of the second derivative with respect to u
[d1uux, d1uuy, d1uuz, d2uux, ...]; for `dim` equal to 2 return the x, y, z
components of the second derivative with respect to u and v, and the mixed
derivative with respect to u and v: [d1uux, d1uuy, d1uuz, d1vvx, d1vvy, d1vvz,
d1uvx, d1uvy, d1uvz, d2uux, ...].
Return `derivatives`.
"""
function getSecondDerivative(dim, tag, parametricCoord)
api_derivatives_ = Ref{Ptr{Cdouble}}()
api_derivatives_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetSecondDerivative, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Cdouble}, Csize_t, Ptr{Ptr{Cdouble}}, Ptr{Csize_t}, Ptr{Cint}),
dim, tag, convert(Vector{Cdouble}, parametricCoord), length(parametricCoord), api_derivatives_, api_derivatives_n_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
derivatives = unsafe_wrap(Array, api_derivatives_[], api_derivatives_n_[], own = true)
return derivatives
end
const get_second_derivative = getSecondDerivative
"""
gmsh.model.getCurvature(dim, tag, parametricCoord)
Evaluate the (maximum) curvature of the entity of dimension `dim` and tag `tag`
at the parametric coordinates `parametricCoord`. Only valid for `dim` equal to 1
(with `parametricCoord` containing parametric coordinates on the curve) or 2
(with `parametricCoord` containing pairs of u, v parametric coordinates on the
surface, concatenated: [p1u, p1v, p2u, ...]).
Return `curvatures`.
"""
function getCurvature(dim, tag, parametricCoord)
api_curvatures_ = Ref{Ptr{Cdouble}}()
api_curvatures_n_ = Ref{Csize_t}()
ierr = Ref{Cint}()
ccall((:gmshModelGetCurvature, gmsh.lib), Cvoid,
(Cint, Cint, Ptr{Cdouble}, Csize_t, Ptr{Ptr{Cdouble}}, Ptr{Csize_t}, Ptr{Cint}),
dim, tag, convert(Vector{Cdouble}, parametricCoord), length(parametricCoord), api_curvatures_, api_curvatures_n_, ierr)
ierr[] != 0 && error(gmsh.logger.getLastError())
curvatures = unsafe_wrap(Array, api_curvatures_[], api_curvatures_n_[], own = true)
return curvatures
end
const get_curvature = getCurvature
"""
gmsh.model.getPrincipalCurvatures(tag, parametricCoord)
Evaluate the principal curvatures of the surface with tag `tag` at the
parametric coordinates `parametricCoord`, as well as their respective
directions. `parametricCoord` are given by pair of u and v coordinates,
concatenated: [p1u, p1v, p2u, ...].
Return `curvatureMax`, `curvatureMin`, `directionMax`, `directionMin`.
"""
function getPrincipalCurvatures(tag, parametricCoord)
api_curvatureMax_ = Ref{Ptr{Cdouble}}()
api_curvatureMax_n_ = Ref{Csize_t}()
api_curvatureMin_ = Ref{Ptr{Cdouble}}()
api_curvatureMin_n_ = Ref{Csize_t}()
api_directionMax_ = Ref{Ptr{Cdouble}}()
api_directionMax_n_ = Ref{Csize_t}()
api_directionMin_ = Ref{Ptr{Cdouble}}()
api_directionMin_n_ = Ref{Csize_t}()