-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
OpenFOAM-5.0.patch
2580 lines (2432 loc) · 79 KB
/
OpenFOAM-5.0.patch
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
Allwmake | 5 +-
applications/Allwmake | 2 +
.../foamyMesh/conformalVoronoiMesh/Make/options | 1 +
.../generation/foamyMesh/foamyHexMesh/Make/options | 1 +
.../foamyMesh/foamyQuadMesh/Make/options | 1 +
.../mesh/generation/snappyHexMesh/Make/options | 1 -
.../mesh/manipulation/renumberMesh/Allwmake | 9 +-
.../mesh/manipulation/renumberMesh/Make/options | 1 -
.../postProcessing/graphics/PVReaders/Allwmake | 6 +
bin/foamMonitor | 11 +-
bin/paraFoam | 6 +
bin/tools/RunFunctions | 13 +-
etc/bashrc | 74 ++++++++---
etc/config.sh/bash_completion | 4 +-
etc/config.sh/mac/CGAL | 69 +++++++++++
etc/config.sh/mac/functions | 133 ++++++++++++++++++++
etc/config.sh/mac/metis | 44 +++++++
etc/config.sh/mac/paraview | 17 +++
etc/config.sh/mac/scotch | 47 +++++++
etc/config.sh/mpi | 2 +-
etc/config.sh/settings | 18 ++-
etc/cshrc | 2 +-
src/Allwmake | 2 +
src/OSspecific/POSIX/POSIX.C | 33 +++++
src/OSspecific/POSIX/clockTime/clockTime.H | 3 +
src/OSspecific/POSIX/fileStat.C | 2 +
src/OSspecific/POSIX/printStack.C | 54 +++++++-
src/OSspecific/POSIX/signals/sigFpe.C | 85 ++++++++++++-
src/OSspecific/POSIX/signals/sigFpe.H | 12 +-
src/OpenFOAM/Make/files | 6 +
src/OpenFOAM/db/IOstreams/IOstreams.H | 4 +
.../db/dynamicLibrary/dynamicCode/dynamicCode.C | 4 +
.../db/dynamicLibrary/dynamicCode/dynamicCode.H | 4 +
.../masterUncollatedFileOperation.C | 12 ++
src/OpenFOAM/primitives/Scalar/doubleFloat.H | 15 +++
src/OpenFOAM/primitives/ints/int/int.H | 9 ++
src/OpenFOAM/primitives/ints/long/long.C | 50 ++++++++
src/OpenFOAM/primitives/ints/long/long.H | 138 +++++++++++++++++++++
src/OpenFOAM/primitives/ints/long/longIO.C | 104 ++++++++++++++++
src/OpenFOAM/primitives/ints/ulong/ulong.C | 52 ++++++++
src/OpenFOAM/primitives/ints/ulong/ulong.H | 138 +++++++++++++++++++++
src/OpenFOAM/primitives/ints/ulong/ulongIO.C | 101 +++++++++++++++
src/fvAgglomerationMethods/Allwmake | 10 +-
.../MGridGenGamgAgglomeration/Make/options | 14 ++-
src/parallel/decompose/Allwmake | 5 +-
src/parallel/decompose/metisDecomp/Allwmake | 14 ++-
src/parallel/decompose/metisDecomp/Make/options | 1 -
src/parallel/decompose/ptscotchDecomp/Make/options | 11 +-
src/parallel/decompose/scotchDecomp/Make/options | 10 +-
src/renumber/SloanRenumber/Make/options | 14 ++-
.../porousSimpleFoam/straightDuctImplicit/Allrun | 7 +-
wmake/makefiles/files | 6 +-
wmake/makefiles/general | 4 +
wmake/rules/darwin64Clang/CGAL | 13 ++
wmake/rules/darwin64Clang/bison | 13 ++
wmake/rules/darwin64Clang/c | 23 ++++
wmake/rules/darwin64Clang/c++ | 35 ++++++
wmake/rules/darwin64Clang/c++Debug | 4 +
wmake/rules/darwin64Clang/c++Opt | 5 +
wmake/rules/darwin64Clang/c++Prof | 4 +
wmake/rules/darwin64Clang/cDebug | 4 +
wmake/rules/darwin64Clang/cOpt | 4 +
wmake/rules/darwin64Clang/cProf | 4 +
wmake/rules/darwin64Clang/flex | 5 +
wmake/rules/darwin64Clang/flex++ | 5 +
wmake/rules/darwin64Clang/general | 16 +++
wmake/rules/darwin64Clang/yacc | 13 ++
wmake/wmake | 5 +
68 files changed, 1480 insertions(+), 64 deletions(-)
diff --git a/Allwmake b/Allwmake
index 3f6a752..00810af 100755
--- a/Allwmake
+++ b/Allwmake
@@ -12,11 +12,13 @@ wmakeCheckPwd "$WM_PROJECT_DIR" || {
exit 1
}
+[ "$(uname -s)" = "Darwin" ] || {
[ -n "$FOAM_EXT_LIBBIN" ] || {
echo "Allwmake error: FOAM_EXT_LIBBIN not set"
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
}
+}
# Compile wmake support applications
(cd wmake/src && make)
@@ -26,7 +28,8 @@ if [ -d "$WM_THIRD_PARTY_DIR" ]
then
$WM_THIRD_PARTY_DIR/Allwmake
else
- echo "Allwmake: no ThirdParty directory found - skipping"
+ [ "$(uname -s)" = "Darwin" ] \
+ || echo "Allwmake: no ThirdParty directory found - skipping"
fi
# Compile OpenFOAM libraries and applications
diff --git a/applications/Allwmake b/applications/Allwmake
index 2b72583..8f96f6e 100755
--- a/applications/Allwmake
+++ b/applications/Allwmake
@@ -12,11 +12,13 @@ wmakeCheckPwd "$WM_PROJECT_DIR/applications" || {
exit 1
}
+[ "$(uname -s)" = "Darwin" ] || {
[ -n "$FOAM_EXT_LIBBIN" ] || {
echo "Allwmake error: FOAM_EXT_LIBBIN not set"
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
}
+}
wmake -all $targetType solvers
wmake -all $targetType utilities
diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/Make/options b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/Make/options
index 6276148..fc45a11 100644
--- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/Make/options
+++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/Make/options
@@ -5,6 +5,7 @@ CGAL_EXACT = /*-DCGAL_DONT_USE_LAZY_KERNEL*/
CGAL_INEXACT = -DCGAL_INEXACT
include $(GENERAL_RULES)/CGAL
+-include $(RULES)/CGAL
EXE_INC = \
${ROUNDING_MATH} \
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options b/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options
index ecf9cc2..5e067a7 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMesh/Make/options
@@ -5,6 +5,7 @@ CGAL_EXACT = /*-DCGAL_DONT_USE_LAZY_KERNEL*/
CGAL_INEXACT = -DCGAL_INEXACT
include $(GENERAL_RULES)/CGAL
+-include $(RULES)/CGAL
EXE_INC = \
${ROUNDING_MATH} \
diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options
index 37dda18..28ecb42 100644
--- a/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options
+++ b/applications/utilities/mesh/generation/foamyMesh/foamyQuadMesh/Make/options
@@ -2,6 +2,7 @@ EXE_DEBUG = -DFULLDEBUG -g -O0
EXE_NDEBUG = -DNDEBUG
include $(GENERAL_RULES)/CGAL
+-include $(RULES)/CGAL
EXE_INC = \
${ROUNDING_MATH} \
diff --git a/applications/utilities/mesh/generation/snappyHexMesh/Make/options b/applications/utilities/mesh/generation/snappyHexMesh/Make/options
index b50c639..0fa291c 100644
--- a/applications/utilities/mesh/generation/snappyHexMesh/Make/options
+++ b/applications/utilities/mesh/generation/snappyHexMesh/Make/options
@@ -1,5 +1,4 @@
EXE_INC = \
- /* -g -DFULLDEBUG -O0 */ \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/mesh/snappyHexMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Allwmake b/applications/utilities/mesh/manipulation/renumberMesh/Allwmake
index ee135cc..1d3f69f 100755
--- a/applications/utilities/mesh/manipulation/renumberMesh/Allwmake
+++ b/applications/utilities/mesh/manipulation/renumberMesh/Allwmake
@@ -4,22 +4,29 @@ cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for compilation (at least for error catching)
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
+_soExt=so
+[ "$(uname -s)" = "Darwin" ] && _soExt=dylib
+
export COMPILE_FLAGS=''
export LINK_FLAGS=''
-if [ -f "${FOAM_LIBBIN}/libSloanRenumber.so" ]
+if [ -f "${FOAM_LIBBIN}/libSloanRenumber.$_soExt" ]
then
echo "Found libSloanRenumber.so -- enabling Sloan renumbering support."
export LINK_FLAGS="${LINK_FLAGS} -lSloanRenumber"
fi
+[ -n "$ZOLTAN_ARCH_PATH" ] && {
if [ -f "${ZOLTAN_ARCH_PATH}/lib/libzoltan.a" -a -f "${FOAM_LIBBIN}/libzoltanRenumber.so" ]
then
echo "Found libzoltanRenumber.so -- enabling zoltan renumbering support."
export COMPILE_FLAGS="-DFOAM_USE_ZOLTAN"
export LINK_FLAGS="${LINK_FLAGS} -lzoltanRenumber -L${ZOLTAN_ARCH_PATH}/lib -lzoltan"
fi
+}
wmake $targetType
+unset _soExt
+
#------------------------------------------------------------------------------
diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Make/options b/applications/utilities/mesh/manipulation/renumberMesh/Make/options
index ef06510..720011d 100644
--- a/applications/utilities/mesh/manipulation/renumberMesh/Make/options
+++ b/applications/utilities/mesh/manipulation/renumberMesh/Make/options
@@ -1,5 +1,4 @@
EXE_INC = \
- /* -DFULLDEBUG -g -O0 */ \
${COMPILE_FLAGS} \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
diff --git a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake b/applications/utilities/postProcessing/graphics/PVReaders/Allwmake
index 12b4679..17f3fd8 100755
--- a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake
+++ b/applications/utilities/postProcessing/graphics/PVReaders/Allwmake
@@ -4,6 +4,12 @@ cd ${0%/*} || exit 1 # Run from this directory
# Parse arguments for library compilation
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
+if [ "$(uname -s)" = "Darwin" ]
+then
+ echo "Skipping PVReaders on macOS"
+ exit 0
+fi
+
case "$ParaView_VERSION" in
4* | 5*)
if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ]
diff --git a/bin/foamMonitor b/bin/foamMonitor
index df5aca2..81eff51 100755
--- a/bin/foamMonitor
+++ b/bin/foamMonitor
@@ -61,7 +61,12 @@ error() {
plotFileHeader() {
cat<<EOF
-set term x11 1 font "helvetica,17" linewidth 1.5 persist noraise
+if (strstrt(GPVAL_TERMINALS, 'wxt')) {
+ selected_terminal = 'wxt'
+} else {
+ selected_terminal = 'x11'
+}
+set term selected_terminal 1 font "helvetica,17" linewidth 1.5 persist noraise
$logscale
$yrange
set title "Data Monitoring"
@@ -90,6 +95,8 @@ refresh=10
logscale=""
yrange=""
command -v gnuplot >/dev/null 2>&1 || error "Gnuplot not installed"
+STAT="stat --format=%Y"
+[ "$(uname -s)" = "Darwin" ] && STAT="stat -f %m"
# parse options
while [ "$#" -gt 0 ]
@@ -178,7 +185,7 @@ pid=$!
while true
do
- mod_time=$(stat --format=%Y "$file")
+ mod_time=$($STAT "$file")
idle_ago=$(( $(date +%s) - idle ))
test "$mod_time" -gt "$idle_ago" || break
sleep "$refresh"
diff --git a/bin/paraFoam b/bin/paraFoam
index 2fcf6d7..52e1a34 100755
--- a/bin/paraFoam
+++ b/bin/paraFoam
@@ -75,6 +75,12 @@ extension=OpenFOAM
requirePV=1
+if [ "$(uname -s)" = "Darwin" ]
+then
+ extension=foam
+ requirePV=0
+fi
+
# Parse options
while [ "$#" -gt 0 ]
do
diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions
index ed101f9..ac6709e 100644
--- a/bin/tools/RunFunctions
+++ b/bin/tools/RunFunctions
@@ -28,6 +28,17 @@
# Miscellaneous functions for running tutorial cases
#------------------------------------------------------------------------------
+isSIPEnabled()
+{
+ $(which -s csrutil) && {
+ [ $(csrutil status | awk '{print $5}' | tr -d ".") = "enabled" ] \
+ && return 0
+ }
+ return 1
+}
+
+[ "$(uname -s)" = "Darwin" ] && isSIPEnabled && . $WM_PROJECT_DIR/etc/bashrc
+
isTest()
{
for i in "$@"; do
@@ -46,7 +57,7 @@ getNumberOfProcessors()
getApplication()
{
- sed -ne 's/^ *application\s*\([a-zA-Z]*\)\s*;.*$/\1/p' system/controlDict
+ foamDictionary -entry application -value system/controlDict
}
runApplication()
diff --git a/etc/bashrc b/etc/bashrc
index 65d0c2d..f1963ca 100644
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -52,6 +52,16 @@ export FOAM_INST_DIR=$HOME/$WM_PROJECT
# END OF (NORMAL) USER EDITABLE PART
################################################################################
+_foam_on_macos()
+{
+ if [ "$(uname -s)" = "Darwin" ]
+ then
+ return 0
+ else
+ return 1
+ fi
+}
+
# The default environment variables below can be overridden in a prefs.sh file
# located in ~/.OpenFOAM/$WM_PROJECT_VERSION, ~/.OpenFOAM,
# $FOAM_INST_DIR/site/$WM_PROJECT_VERSION or $FOAM_INST_DIR/site
@@ -62,7 +72,7 @@ export WM_COMPILER_TYPE=system
#- Compiler:
# WM_COMPILER = Gcc | Gcc48 ... Gcc62 | Clang | Icc
-export WM_COMPILER=Gcc
+export WM_COMPILER=Clang
unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH
#- Memory addressing:
@@ -115,7 +125,8 @@ export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION
# Location of third-party software
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
+_foam_on_macos \
+ || export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION
# Location of site-specific templates etc
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -135,8 +146,10 @@ export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
. $WM_PROJECT_DIR/etc/config.sh/functions
+_foam_on_macos && . $WM_PROJECT_DIR/etc/config.sh/mac/functions
+
# Add in preset user or site preferences:
-_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh`
+_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile prefs.sh)
# Evaluate command-line parameters and record settings for later
# these can be used to set/unset values, or specify alternative pref files
@@ -148,16 +161,25 @@ _foamEval $@
foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
#- Clean PATH
-cleaned=`$foamClean "$PATH" "$foamOldDirs"` && PATH="$cleaned"
+cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned"
-#- Clean LD_LIBRARY_PATH
-cleaned=`$foamClean "$LD_LIBRARY_PATH" "$foamOldDirs"` \
- && LD_LIBRARY_PATH="$cleaned"
+if _foam_on_macos
+then
+ #- Clean DYLD_LIBRARY_PATH on macOS
+ cleaned=$($foamClean "$DYLD_LIBRARY_PATH" "$foamOldDirs") \
+ && DYLD_LIBRARY_PATH="$cleaned"
+ export DYLD_LIBRARY_PATH
+else
+ #- Clean LD_LIBRARY_PATH
+ cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") \
+ && LD_LIBRARY_PATH="$cleaned"
+ export LD_LIBRARY_PATH
+fi
#- Clean MANPATH
-cleaned=`$foamClean "$MANPATH" "$foamOldDirs"` && MANPATH="$cleaned"
+cleaned=$($foamClean "$MANPATH" "$foamOldDirs") && MANPATH="$cleaned"
-export PATH LD_LIBRARY_PATH MANPATH
+export PATH MANPATH
# Source project setup files
@@ -169,13 +191,23 @@ _foamSource $WM_PROJECT_DIR/etc/config.sh/aliases
# Source user setup files for optional packages
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi`
-_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview`
-_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/ensight`
-_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools`
+if _foam_on_macos
+then
+ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mac/paraview`
+else
+ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview`
+ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/ensight`
+ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools`
+fi
if [ ! -z "$FOAMY_HEX_MESH" ]
then
- _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL`
+ if _foam_on_macos
+ then
+ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mac/CGAL`
+ else
+ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL`
+ fi
fi
@@ -184,13 +216,21 @@ fi
#- Clean PATH
cleaned=`$foamClean "$PATH"` && PATH="$cleaned"
-#- Clean LD_LIBRARY_PATH
-cleaned=`$foamClean "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleaned"
+if _foam_on_macos
+then
+ #- Clean DYLD_LIBRARY_PATH
+ cleaned=`$foamClean "$DYLD_LIBRARY_PATH"` && DYLD_LIBRARY_PATH="$cleaned"
+ export DYLD_LIBRARY_PATH
+else
+ #- Clean LD_LIBRARY_PATH
+ cleaned=`$foamClean "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleaned"
+ export LD_LIBRARY_PATH
+fi
#- Clean MANPATH (trailing ':' to find system pages)
cleaned=`$foamClean "$MANPATH"`: && MANPATH="$cleaned"
-export PATH LD_LIBRARY_PATH MANPATH
+export PATH MANPATH
#- Clean LD_PRELOAD
if [ -n "$LD_PRELOAD" ]
@@ -209,6 +249,8 @@ unset cleaned foamClean foamOldDirs
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
. $WM_PROJECT_DIR/etc/config.sh/functions
+_foam_on_macos && . $WM_PROJECT_DIR/etc/config.sh/mac/functions
+
# Source the bash completion file:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
. $WM_PROJECT_DIR/etc/config.sh/bash_completion
diff --git a/etc/config.sh/bash_completion b/etc/config.sh/bash_completion
index 34cbd31..7ae653c 100644
--- a/etc/config.sh/bash_completion
+++ b/etc/config.sh/bash_completion
@@ -6638,7 +6638,7 @@ _ptot_ ()
}
complete -o filenames -o nospace -F _ptot_ ptot
-_rm~all_ ()
+_rm_all_ ()
{
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"
@@ -6656,7 +6656,7 @@ _rm~all_ ()
esac
COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) )
}
-complete -o filenames -o nospace -F _rm~all_ rm~all
+complete -o filenames -o nospace -F _rm_all_ rm~all
_rmcore_ ()
{
diff --git a/etc/config.sh/mac/CGAL b/etc/config.sh/mac/CGAL
new file mode 100644
index 0000000..3e53043
--- /dev/null
+++ b/etc/config.sh/mac/CGAL
@@ -0,0 +1,69 @@
+# CGAL configuration for OS X
+
+if [ -n "$SOURCE_CGAL_VERSIONS_ONLY" ]
+then
+ . $WM_PROJECT_DIR/etc/config.sh/mac/functions
+ if [ "x$(_foamBrew)" = "xY" ]
+ then
+ _prefix=$(_foamBrewPrefix)
+ boost_version="boost-$(_foamGetPackageVersion boost)"
+ export BOOST_ARCH_PATH="$_prefix/opt/boost"
+ unset _prefix
+ elif [ "x$(_foamPort)" = "xY" ]
+ then
+ _prefix=$(_foamPortPrefix)
+ boost_version=$(_foamGetPackageVersion boost)
+ export BOOST_ARCH_PATH="$_prefix"
+ unset _prefix
+ else
+ boost_version=boost-unknown
+ export BOOST_ARCH_PATH=/usr/local
+ fi
+ unset boost_version
+ . $WM_PROJECT_DIR/etc/config.sh/mac/functions
+else
+ if [ "x$(_foamBrew)" = "xY" ]
+ then
+ _prefix=$(_foamBrewPrefix)
+
+ boost_version="boost-$(_foamGetPackageVersion boost)"
+ cgal_version="CGAL-$(_foamGetPackageVersion cgal)"
+
+ export BOOST_ARCH_PATH="$_prefix/opt/boost"
+ export CGAL_ARCH_PATH="$_prefix/opt/cgal"
+ export GMP_ARCH_PATH="$_prefix/opt/gmp"
+ export MPFR_ARCH_PATH="$_prefix/opt/mpfr"
+
+ unset _prefix
+ elif [ "x$(_foamPort)" = "xY" ]
+ then
+ _prefix=$(_foamPortPrefix)
+
+ boost_version=$(_foamGetPackageVersion boost)
+ cgal_version=$(_foamGetPackageVersion cgal)
+
+ export BOOST_ARCH_PATH="$_prefix"
+ export CGAL_ARCH_PATH="$_prefix"
+ export GMP_ARCH_PATH="$_prefix"
+ export MPFR_ARCH_PATH="$_prefix"
+
+ unset _prefix
+ else
+ boost_version=boost-unknown
+ cgal_version=CGAL-unknown
+
+ export BOOST_ARCH_PATH=/usr/local
+ export CGAL_ARCH_PATH=/usr/local
+ fi
+
+ if [ "$FOAM_VERBOSE" -a "$PS1" ]
+ then
+ echo "Using CGAL and boost" 1>&2
+ echo " $cgal_version at $CGAL_ARCH_PATH" 1>&2
+ echo " $boost_version at $BOOST_ARCH_PATH" 1>&2
+ fi
+ unset boost_version cgal_version
+fi
+
+
+# vim: set ft=sh:
diff --git a/etc/config.sh/mac/functions b/etc/config.sh/mac/functions
new file mode 100644
index 0000000..68c723a
--- /dev/null
+++ b/etc/config.sh/mac/functions
@@ -0,0 +1,133 @@
+# Additional functions for OS X
+
+if [ -z "$WM_BASH_FUNCTIONS_MAC" ]
+then
+ WM_BASH_FUNCTIONS_MAC=loaded
+
+ # Prefix to DYLD_LIBRARY_PATH
+ _foamAddLib ()
+ {
+ while [ $# -ge 1 ]
+ do
+ export DYLD_LIBRARY_PATH=$1:$DYLD_LIBRARY_PATH
+ shift
+ done
+ }
+
+ _foamBrew ()
+ {
+ if $(which -s brew)
+ then
+ echo Y
+ return 0
+ else
+ echo N
+ return 1
+ fi
+ }
+
+ _foamPort ()
+ {
+ if $(which -s port)
+ then
+ echo Y
+ return 0
+ else
+ echo N
+ return 1
+ fi
+ }
+
+ _foamPortPrefix ()
+ {
+ echo "$(dirname $(dirname $(which port)))"
+ }
+
+ _foamBrewPrefix ()
+ {
+ echo $(brew --prefix)
+ }
+
+ _foamGetPackageVersion ()
+ {
+ local version="?"
+ local ret=0
+ local pkg="$1"
+
+ if [ "x$(_foamBrew)" = "xY" ]
+ then
+ local prefix="$(_foamBrewPrefix)"
+ if [ -d "$prefix/opt/${pkg}64" -a "$WM_LABEL_SIZE" -eq 64 ]
+ then
+ version="$(basename $(readlink "$prefix/opt/${pkg}64"))"
+ elif [ -d "$prefix/opt/$pkg" ]
+ then
+ version="$(basename $(readlink "$prefix/opt/$pkg"))"
+ else
+ ret=1
+ fi
+ elif [ "x$(_foamPort)" = "xY" ]
+ then
+ version="0.0.x"
+ else
+ ret=1
+ fi
+ echo $version
+ return $ret
+ }
+
+ _foamGetPackageArchPath ()
+ {
+ local arch_path="/usr/local"
+ local ret=0
+ local pkg="$1"
+ if [ "x$(_foamBrew)" = "xY" ]
+ then
+ local prefix="$(_foamBrewPrefix)"
+ if [ -d "$prefix/opt/${pkg}64" -a "$WM_LABEL_SIZE" -eq 64 ]
+ then
+ arch_path="$prefix/opt/${pkg}64"
+ elif [ -d "$prefix/opt/$pkg" ]
+ then
+ arch_path="$prefix/opt/$pkg"
+ else
+ ret=1
+ fi
+ elif [ "x$(_foamPort)" = "xY" ]
+ then
+ arch_path="$(_foamPortPrefix)"
+ else
+ ret=1
+ fi
+ echo $arch_path
+ return $ret
+ }
+
+ _foam_increase_max_open_files ()
+ {
+ # Default value
+ local lim=4096
+
+ # Reset if parameter passed
+ [ -n "$1" ] && lim="$1"
+
+ # Silencing the errors
+ local current_limit=$(ulimit -n)
+ if [ "$current_limit" = "unlimited" ]
+ then
+ return 0
+ elif [ "$current_limit" -lt "$lim" ]
+ then
+ ulimit -n "$lim" > /dev/null 2>&1
+ return 0
+ fi
+ return 0
+ }
+else
+ unset WM_BASH_FUNCTIONS_MAC
+ unset _foamAddLib _foamBrew _foamPort _foamPortPrefix _foamBrewPrefix \
+ _foamGetPackageVersion _foamGetPackageArchPath \
+ _foam_increase_max_open_files
+fi
+
+# vim: set ft=sh:
diff --git a/etc/config.sh/mac/metis b/etc/config.sh/mac/metis
new file mode 100644
index 0000000..bb87346
--- /dev/null
+++ b/etc/config.sh/mac/metis
@@ -0,0 +1,44 @@
+#----------------------------------*-sh-*--------------------------------------
+# ========= |
+# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+# \\ / O peration |
+# \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
+# \\/ M anipulation |
+#------------------------------------------------------------------------------
+# License
+# This file is part of OpenFOAM.
+#
+# OpenFOAM is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
+#
+# File
+# etc/config.sh/metis
+#
+# Description
+# Setup file for metis include/libraries.
+# Sourced during wmake process only.
+#
+# Note
+# A csh version is not needed, since the values here are only sourced
+# during the wmake process
+#
+#------------------------------------------------------------------------------
+
+. $WM_PROJECT_DIR/etc/config.sh/mac/functions
+
+export METIS_VERSION=$(_foamGetPackageVersion metis)
+export METIS_ARCH_PATH=$(_foamGetPackageArchPath metis)
+
+. $WM_PROJECT_DIR/etc/config.sh/mac/functions
+
+#------------------------------------------------------------------------------
diff --git a/etc/config.sh/mac/paraview b/etc/config.sh/mac/paraview
new file mode 100644
index 0000000..da71f0b
--- /dev/null
+++ b/etc/config.sh/mac/paraview
@@ -0,0 +1,17 @@
+if [ -d /Applications/[Pp][Aa][Rr][Aa][Vv][Ii][Ee][Ww]*.app ];
+then
+ [ "$FOAM_VERBOSE" -a "$PS1" ] && echo Using /Applications/[Pp][Aa][Rr][Aa][Vv][Ii][Ee][Ww]*.app
+
+ paraview () {
+ local _paraviews=(/Applications/[Pp][Aa][Rr][Aa][Vv][Ii][Ee][Ww]*.app)
+ $_paraviews/Contents/MacOS/paraview "$@"
+ }
+
+ export -f paraview
+else
+ echo
+ echo "Please download binary Paraview release from"
+ echo "http://paraview.org and install it in /Applications"
+ echo "folder."
+ echo
+fi
diff --git a/etc/config.sh/mac/scotch b/etc/config.sh/mac/scotch
new file mode 100644
index 0000000..e62931c
--- /dev/null
+++ b/etc/config.sh/mac/scotch
@@ -0,0 +1,47 @@
+#----------------------------------*-sh-*--------------------------------------
+# ========= |
+# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+# \\ / O peration |
+# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
+# \\/ M anipulation |
+#------------------------------------------------------------------------------
+# License
+# This file is part of OpenFOAM.
+#
+# OpenFOAM is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
+#
+# File
+# etc/config.sh/scotch
+#
+# Description
+# Setup file for scotch include/libraries.
+# Sourced during wmake process only.
+#
+# Note
+# A csh version is not needed, since the values here are only sourced
+# during the wmake process
+#
+# If Scotch is to be entirely disabled, either rename this file or create
+# an empty one with the same name at a user or site location.
+#
+#------------------------------------------------------------------------------
+
+. $WM_PROJECT_DIR/etc/config.sh/mac/functions
+
+export SCOTCH_VERSION=$(_foamGetPackageVersion scotch)
+export SCOTCH_ARCH_PATH=$(_foamGetPackageArchPath scotch)
+
+. $WM_PROJECT_DIR/etc/config.sh/mac/functions
+
+#------------------------------------------------------------------------------
diff --git a/etc/config.sh/mpi b/etc/config.sh/mpi
index 856f669..1cc5988 100644
--- a/etc/config.sh/mpi
+++ b/etc/config.sh/mpi
@@ -47,7 +47,7 @@ SYSTEMOPENMPI)
# Bit of a hack: strip off 'lib' and hope this is the path to openmpi
# include files and libraries.
- export MPI_ARCH_PATH="${libDir%/*}"
+ _foam_on_macos || export MPI_ARCH_PATH="${libDir%/*}"
_foamAddLib $libDir
unset libDir
diff --git a/etc/config.sh/settings b/etc/config.sh/settings
index 64d675d..6c4304d 100644
--- a/etc/config.sh/settings
+++ b/etc/config.sh/settings
@@ -126,7 +126,12 @@ SunOS)
export WM_CXXFLAGS='-mabi=64 -fPIC -std=c++0x'
export WM_LDFLAGS='-mabi=64 -G0'
;;
-
+Darwin)
+ WM_ARCH=darwin64
+ export WM_COMPILER_ARCH=64
+ export WM_CC=clang
+ export WM_CXX=clang++
+ ;;
*) # An unsupported operating system
/bin/cat <<USAGE 1>&2
@@ -154,7 +159,7 @@ export FOAM_APPBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/bin
export FOAM_LIBBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib
# External (ThirdParty) libraries
-export FOAM_EXT_LIBBIN=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib
+_foam_on_macos || export FOAM_EXT_LIBBIN=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib
# Site-specific directory
siteDir="${WM_PROJECT_SITE:-$WM_PROJECT_INST_DIR/site}"
@@ -199,7 +204,12 @@ unset siteDir
_foamAddPath $FOAM_USER_APPBIN:$FOAM_SITE_APPBIN:$FOAM_APPBIN
# Make sure to pick up dummy versions of external libraries last
-_foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN:$FOAM_EXT_LIBBIN:$FOAM_LIBBIN/dummy
+if [ -n "$FOAM_EXT_LIBBIN" ]
+then
+ _foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN:$FOAM_EXT_LIBBIN:$FOAM_LIBBIN/dummy
+else
+ _foamAddLib $FOAM_USER_LIBBIN:$FOAM_SITE_LIBBIN:$FOAM_LIBBIN:$FOAM_LIBBIN/dummy
+fi
# Compiler settings
# ~~~~~~~~~~~~~~~~~
@@ -292,4 +302,6 @@ system)
;;
esac
+_foam_on_macos && _foam_increase_max_open_files 4096
+
#------------------------------------------------------------------------------
diff --git a/etc/cshrc b/etc/cshrc
index ecfc814..c270738 100644
--- a/etc/cshrc
+++ b/etc/cshrc
@@ -31,7 +31,7 @@
#------------------------------------------------------------------------------
setenv WM_PROJECT OpenFOAM
-setenv WM_PROJECT_VERSION 5.0
+setenv WM_PROJECT_VERSION 5.x
################################################################################
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
diff --git a/src/Allwmake b/src/Allwmake
index e7fb458..6c30041 100755
--- a/src/Allwmake
+++ b/src/Allwmake
@@ -12,11 +12,13 @@ wmakeCheckPwd "$WM_PROJECT_DIR/src" || {
exit 1
}
+[ "$(uname -s)" = "Darwin" ] || {
[ -n "$FOAM_EXT_LIBBIN" ] || {
echo "Allwmake error: FOAM_EXT_LIBBIN not set"
echo " Check the OpenFOAM entries in your dot-files and source them."
exit 1
}
+}
# Update OpenFOAM version strings if required
wmakePrintBuild -check || wrmo OpenFOAM/global/global.o 2>/dev/null
diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C
index deaa19d..090a453 100644
--- a/src/OSspecific/POSIX/POSIX.C
+++ b/src/OSspecific/POSIX/POSIX.C
@@ -55,7 +55,11 @@ Description
#include <sys/socket.h>
#include <netdb.h>
#include <dlfcn.h>
+#if defined(darwin64)
+#include <mach-o/dyld.h>
+#else
#include <link.h>
+#endif
#include <netinet/in.h>
@@ -626,9 +630,15 @@ double Foam::highResLastModified(const fileName& name, const bool followLink)
fileStat fileStatus(name, followLink);
if (fileStatus.isValid())
{
+#if defined(darwin64)
+ return
+ fileStatus.status().st_mtime
+ + 1e-9*fileStatus.status().st_atimespec.tv_nsec;
+#else
return
fileStatus.status().st_mtime
+ 1e-9*fileStatus.status().st_atim.tv_nsec;
+#endif
}
else
{
@@ -1204,6 +1214,20 @@ void* Foam::dlOpen(const fileName& lib, const bool check)
<< " : dlopen of " << lib << std::endl;
}
void* handle = ::dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
+#if defined(darwin64)
+ if (handle == nullptr && lib.ext() == "so")
+ {
+ fileName fallback_lib = lib.lessExt() + ".dylib";
+ if (check)
+ {
+ WarningIn("dlOpen(const fileName&, const bool)")
+ << "dlOpen: using fallback library name "
+ << fallback_lib
+ << endl;
+ }
+ handle = ::dlopen(fallback_lib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
+ }
+#endif
if (!handle && check)
{
@@ -1291,6 +1315,7 @@ bool Foam::dlSymFound(void* handle, const std::string& symbol)
}
+#if ! defined(darwin64)
static int collectLibsCallback
(
struct dl_phdr_info *info,
@@ -1303,12 +1328,20 @@ static int collectLibsCallback
ptr->append(info->dlpi_name);
return 0;
}
+#endif
Foam::fileNameList Foam::dlLoaded()
{
DynamicList<fileName> libs;
+#if defined(darwin64)
+ for(uint32_t cnt = 0; cnt < _dyld_image_count(); ++cnt)
+ {
+ libs.append(_dyld_get_image_name(cnt));
+ }
+#else
dl_iterate_phdr(collectLibsCallback, &libs);
+#endif
if (POSIX::debug)
{
std::cout
diff --git a/src/OSspecific/POSIX/clockTime/clockTime.H b/src/OSspecific/POSIX/clockTime/clockTime.H
index 8708ba9..65f046c 100644
--- a/src/OSspecific/POSIX/clockTime/clockTime.H
+++ b/src/OSspecific/POSIX/clockTime/clockTime.H
@@ -37,6 +37,9 @@ SourceFiles
#define clockTime_H
#include <sys/types.h>
+#if defined(darwin64)
+#include <sys/time.h>