Compare commits
535
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b555a7bf8 | ||
|
|
fb0cdbb9f7 | ||
|
|
a8090e318d | ||
|
|
0de295d6e1 | ||
|
|
4ba0c28a6a | ||
|
|
77d409b4c6 | ||
|
|
238a9da6d9 | ||
|
|
15be3d493c | ||
|
|
5896f590e7 | ||
|
|
cda68d779c | ||
|
|
d54d2668a2 | ||
|
|
1af666cb9a | ||
|
|
ad87b9cb5f | ||
|
|
1c037bf476 | ||
|
|
dd83719b58 | ||
|
|
cce2d98fce | ||
|
|
7d0c0199d8 | ||
|
|
629bb6a2a7 | ||
|
|
8a5c5523ee | ||
|
|
47e042245e | ||
|
|
2b27d4815f | ||
|
|
9bd2fd3cc3 | ||
|
|
6095d41779 | ||
|
|
217e644b29 | ||
|
|
c54f0ee11a | ||
|
|
4eed7c754e | ||
|
|
90bc29a976 | ||
|
|
96d516a1a8 | ||
|
|
56fcc5dcef | ||
|
|
9f5b282c7a | ||
|
|
5a34b0f236 | ||
|
|
4e25b1ba6b | ||
|
|
39add0f7a9 | ||
|
|
e26f72da36 | ||
|
|
cbe12d1419 | ||
|
|
d5aa18f762 | ||
|
|
918622a430 | ||
|
|
30a8a51e20 | ||
|
|
d9ae367705 | ||
|
|
b3a3ad3488 | ||
|
|
ceaabce20d | ||
|
|
49fe6fc429 | ||
|
|
1c1e8293e1 | ||
|
|
bcad115dda | ||
|
|
7c81683d1b | ||
|
|
144bc29496 | ||
|
|
b732c3ffe8 | ||
|
|
5736f3832b | ||
|
|
38e9c0951b | ||
|
|
148047f692 | ||
|
|
7d1b07f873 | ||
|
|
80449bbd15 | ||
|
|
abb466d2f7 | ||
|
|
79b609872a | ||
|
|
38c27dfe4c | ||
|
|
c1871afea4 | ||
|
|
a7a7807652 | ||
|
|
0ecfcb3633 | ||
|
|
a35b5e76b0 | ||
|
|
b5ca50d967 | ||
|
|
cbce58c685 | ||
|
|
912c7d24b6 | ||
|
|
5cdfd84635 | ||
|
|
7c9abd5303 | ||
|
|
bf4c7ea8c1 | ||
|
|
9beaa836b0 | ||
|
|
b5670b4daf | ||
|
|
6a3a7e4746 | ||
|
|
4fe30263e4 | ||
|
|
170c520493 | ||
|
|
aea91bf9dc | ||
|
|
fd44d57e91 | ||
|
|
8a4affef5a | ||
|
|
3f629314d2 | ||
|
|
c4c3b4edf9 | ||
|
|
89ed97c5e8 | ||
|
|
59fd822fb5 | ||
|
|
1f028cd9a8 | ||
|
|
1717231f32 | ||
|
|
e3201429c0 | ||
|
|
90c4ab6e17 | ||
|
|
d25e7a3877 | ||
|
|
a5f73604b1 | ||
|
|
5b5356495a | ||
|
|
9e7f733eac | ||
|
|
87504f2e6d | ||
|
|
7d15a638be | ||
|
|
b273b7669f | ||
|
|
d983b34924 | ||
|
|
865c343db7 | ||
|
|
db41b274c9 | ||
|
|
4610d4d689 | ||
|
|
45de8cdf93 | ||
|
|
f916711d36 | ||
|
|
28ee8d30fe | ||
|
|
47ab481aa2 | ||
|
|
a8b0b35c1d | ||
|
|
5b79224171 | ||
|
|
79204fd4a1 | ||
|
|
373a3a0099 | ||
|
|
e3ea03baa0 | ||
|
|
c1b6fe6506 | ||
|
|
f7dd1f59a7 | ||
|
|
8fbfec3829 | ||
|
|
757b1ed529 | ||
|
|
8c12c6d2af | ||
|
|
37e3151d6d | ||
|
|
af3294b361 | ||
|
|
185a339db3 | ||
|
|
714a6040f0 | ||
|
|
7fe1df7e00 | ||
|
|
43d577a4f1 | ||
|
|
9d44f3be75 | ||
|
|
99df066336 | ||
|
|
ce2462a126 | ||
|
|
9adc3c5d8b | ||
|
|
855fd34471 | ||
|
|
860c95c2de | ||
|
|
e3cac5edb3 | ||
|
|
fa3b23fc92 | ||
|
|
96e2fa95d8 | ||
|
|
b13d4d6631 | ||
|
|
3c7ee44fb7 | ||
|
|
eb28399c7c | ||
|
|
35b28b3552 | ||
|
|
aa4d4efc04 | ||
|
|
28f48489a6 | ||
|
|
76171e95a7 | ||
|
|
22670890ce | ||
|
|
be5541dba1 | ||
|
|
262f5fff23 | ||
|
|
90b65160c8 | ||
|
|
a37c8e3acb | ||
|
|
0adecf5596 | ||
|
|
0fa1275ccf | ||
|
|
8b44981fa2 | ||
|
|
66768c1dd8 | ||
|
|
02e57a881d | ||
|
|
956be1a755 | ||
|
|
e9fbd5057f | ||
|
|
a0b1307bc0 | ||
|
|
9ec30fb48a | ||
|
|
415033aef2 | ||
|
|
5ee7ab1fd1 | ||
|
|
864233213e | ||
|
|
e52ce5f060 | ||
|
|
c30924731f | ||
|
|
0056b04a43 | ||
|
|
92a11125c8 | ||
|
|
01bd1a1142 | ||
|
|
8bdc3b67bb | ||
|
|
0ddb7aba31 | ||
|
|
a4f7c68ac7 | ||
|
|
2033b9853c | ||
|
|
48935c4a8a | ||
|
|
61fc44f5ff | ||
|
|
ab203b26f9 | ||
|
|
336236eae8 | ||
|
|
1160bc272b | ||
|
|
4a38577e3f | ||
|
|
0ca7ff4533 | ||
|
|
b8e4945878 | ||
|
|
3440025266 | ||
|
|
7aba8e28ba | ||
|
|
c7aa393ba0 | ||
|
|
d9c60f710e | ||
|
|
71c4566944 | ||
|
|
422c163466 | ||
|
|
0230285d65 | ||
|
|
3fd54f4e91 | ||
|
|
27e681f9e7 | ||
|
|
a4aa7d70b9 | ||
|
|
d96152a08a | ||
|
|
4653df940c | ||
|
|
fdbb8e2757 | ||
|
|
c3a5798463 | ||
|
|
35254a3e02 | ||
|
|
4a45c70d12 | ||
|
|
fcbfba6fa3 | ||
|
|
d6c7698712 | ||
|
|
ba13719aa8 | ||
|
|
78ae46e9a2 | ||
|
|
f12fb5522a | ||
|
|
13abdfafe0 | ||
|
|
65a3108084 | ||
|
|
91b40c9b78 | ||
|
|
a3a73e9ab2 | ||
|
|
22b991d9f1 | ||
|
|
b17291ba3b | ||
|
|
f60c93dd19 | ||
|
|
e59534b921 | ||
|
|
a3d530f2f0 | ||
|
|
87494199c0 | ||
|
|
627a295eaa | ||
|
|
f8e4b83043 | ||
|
|
304c94f184 | ||
|
|
be6d3e57e7 | ||
|
|
86bbefca08 | ||
|
|
ae3443fd1d | ||
|
|
514d281475 | ||
|
|
5c0ae17a5b | ||
|
|
0140fed416 | ||
|
|
d07e541f5c | ||
|
|
ee335907f7 | ||
|
|
f5d2144e80 | ||
|
|
c9e112c192 | ||
|
|
59fbc05880 | ||
|
|
5f85120da4 | ||
|
|
f66a16257f | ||
|
|
baf06bdc93 | ||
|
|
b25c4e30ee | ||
|
|
9734af90ed | ||
|
|
5c66134872 | ||
|
|
ff95fdb3af | ||
|
|
0e209bbf05 | ||
|
|
8e1fd9c27d | ||
|
|
8d75a62e65 | ||
|
|
85e435be84 | ||
|
|
f7f7a46d8e | ||
|
|
ce09755c75 | ||
|
|
cdd5d74a7a | ||
|
|
672c331189 | ||
|
|
3e5ad8d18c | ||
|
|
57de5fa684 | ||
|
|
d41b97552c | ||
|
|
4db39d6d4b | ||
|
|
43804b7e29 | ||
|
|
05683c3cae | ||
|
|
a769ca1fcb | ||
|
|
43c7303e45 | ||
|
|
fe85793042 | ||
|
|
68067d2f25 | ||
|
|
1efe47c8d6 | ||
|
|
e3c68a5300 | ||
|
|
398ff215f3 | ||
|
|
b1c7fc6b26 | ||
|
|
055b807772 | ||
|
|
4779b9a385 | ||
|
|
245e7dc35c | ||
|
|
b49f91fa2f | ||
|
|
110bec1507 | ||
|
|
68635cc1a8 | ||
|
|
8bb929c2ff | ||
|
|
cf9d5bbb9c | ||
|
|
986a0ac0ca | ||
|
|
358cf496ee | ||
|
|
65dc31e51a | ||
|
|
7ab0206976 | ||
|
|
193e603ace | ||
|
|
ffd2938cea | ||
|
|
4161aac03e | ||
|
|
588ce586db | ||
|
|
12c8827cb2 | ||
|
|
26613eec97 | ||
|
|
8a5dbbe3fb | ||
|
|
b88787c1a1 | ||
|
|
8b2ed54835 | ||
|
|
ff76f26ce1 | ||
|
|
1354c29905 | ||
|
|
b3813ed053 | ||
|
|
d49dcc33f9 | ||
|
|
3aea84aa2c | ||
|
|
93fef9d8a4 | ||
|
|
a06e19ce7d | ||
|
|
4202daa1fa | ||
|
|
f46e7d93de | ||
|
|
cccb23b459 | ||
|
|
5d8e9c237a | ||
|
|
b78275e79e | ||
|
|
f2a7cb9b7a | ||
|
|
dcf0a01298 | ||
|
|
3966255076 | ||
|
|
b5a9fd3df4 | ||
|
|
1c58d6d3d1 | ||
|
|
b2acd235b2 | ||
|
|
b15d483611 | ||
|
|
e008f815ae | ||
|
|
8846587efb | ||
|
|
64a01150ee | ||
|
|
a8c34e351e | ||
|
|
a3d2036838 | ||
|
|
f36873a150 | ||
|
|
e617238cc5 | ||
|
|
47e62a55f9 | ||
|
|
89f62d04e1 | ||
|
|
83a72b343a | ||
|
|
686756d73f | ||
|
|
a3e7080fc1 | ||
|
|
ecfab8fe9f | ||
|
|
935be38e4f | ||
|
|
23a78751d5 | ||
|
|
953a883903 | ||
|
|
25e95ef38b | ||
|
|
901c4b425a | ||
|
|
00815df5d0 | ||
|
|
ea404352a6 | ||
|
|
1911fbc883 | ||
|
|
36106d6fe4 | ||
|
|
21de36604a | ||
|
|
eea5e91bb3 | ||
|
|
21c1d3a54e | ||
|
|
c0fed5b393 | ||
|
|
1420fc6b63 | ||
|
|
a453d97ab9 | ||
|
|
76d3a54a88 | ||
|
|
723a613236 | ||
|
|
9eca33b09d | ||
|
|
b89222762d | ||
|
|
fd4c6892a4 | ||
|
|
d6205812cf | ||
|
|
7de9f15d12 | ||
|
|
1f9f8bd5cb | ||
|
|
f09f969197 | ||
|
|
0857e8e22f | ||
|
|
7e2580f262 | ||
|
|
a3c51c8a70 | ||
|
|
05154bad34 | ||
|
|
8c8b52d572 | ||
|
|
718bece30c | ||
|
|
3ce24ea2ba | ||
|
|
69e4e13185 | ||
|
|
c80fdc6f74 | ||
|
|
62c0444cbf | ||
|
|
bada9b86f0 | ||
|
|
6594329638 | ||
|
|
1ae7ced2dc | ||
|
|
a5b1b2111d | ||
|
|
8ab890b7d7 | ||
|
|
9166d8fdcb | ||
|
|
a241e4a447 | ||
|
|
11aa88c5e0 | ||
|
|
79cc10d12b | ||
|
|
4d247cff97 | ||
|
|
81af422efb | ||
|
|
de0f5a1da4 | ||
|
|
ed10bed8c8 | ||
|
|
c794dae53b | ||
|
|
0e859e6122 | ||
|
|
e61fdb139e | ||
|
|
d02a90f9f2 | ||
|
|
9017b9700d | ||
|
|
3b4fc3b1df | ||
|
|
9a70f50e22 | ||
|
|
c4957f1907 | ||
|
|
ee3a46af24 | ||
|
|
aa8e466e42 | ||
|
|
c64d7858e8 | ||
|
|
ed655d51bc | ||
|
|
d9937c5b82 | ||
|
|
19e016e5d0 | ||
|
|
9863bc5bd6 | ||
|
|
f4fdd37735 | ||
|
|
563084ca0f | ||
|
|
015a0f2eae | ||
|
|
823eef1d9a | ||
|
|
6118beb9e0 | ||
|
|
ffc2f31b6f | ||
|
|
a7f7fc94ea | ||
|
|
46c73c8745 | ||
|
|
d000d212e5 | ||
|
|
742132da1b | ||
|
|
4745f7aa87 | ||
|
|
544cf9318b | ||
|
|
6885a99955 | ||
|
|
21b0b8bcf6 | ||
|
|
44b34f5e64 | ||
|
|
f106c03dd1 | ||
|
|
9d65c08c77 | ||
|
|
6cb689d6bd | ||
|
|
134ac98216 | ||
|
|
2609ef0306 | ||
|
|
3f4d31473e | ||
|
|
7014d7f6d2 | ||
|
|
86bb7d46e2 | ||
|
|
cce556551b | ||
|
|
a71509b8ce | ||
|
|
ac8ea6fe2d | ||
|
|
e26208c725 | ||
|
|
a8502b5b29 | ||
|
|
a6b8ca5654 | ||
|
|
771ae1fc3c | ||
|
|
4de0b3b1c6 | ||
|
|
aef28190b3 | ||
|
|
37402a0b4f | ||
|
|
16b9256edd | ||
|
|
4fb0372c83 | ||
|
|
e34090d634 | ||
|
|
a7b0edc290 | ||
|
|
81e5489f5e | ||
|
|
26841dd3e3 | ||
|
|
1ffc187de6 | ||
|
|
e1666702d4 | ||
|
|
6c3c25d439 | ||
|
|
13bd25ea34 | ||
|
|
e6f54f8b92 | ||
|
|
465e5e784e | ||
|
|
369e76bd18 | ||
|
|
e4af497922 | ||
|
|
34741d3d96 | ||
|
|
4bbfec3270 | ||
|
|
ace2a34e90 | ||
|
|
38189de216 | ||
|
|
26590a1bef | ||
|
|
88a5d0ad7d | ||
|
|
47eebe1841 | ||
|
|
e8268e0357 | ||
|
|
07dc63bfbf | ||
|
|
b3851cd284 | ||
|
|
8d9d3cba4c | ||
|
|
c826ed6f88 | ||
|
|
69c6a75d29 | ||
|
|
98e41c1de9 | ||
|
|
dede616db7 | ||
|
|
34842a5c71 | ||
|
|
90fd923c4f | ||
|
|
04bccfe0ba | ||
|
|
74a32f5cd6 | ||
|
|
8a56100051 | ||
|
|
9edca06544 | ||
|
|
ebbbf6d031 | ||
|
|
8a1636c3ee | ||
|
|
55ecd126ae | ||
|
|
ef5f65457e | ||
|
|
f238ed6f41 | ||
|
|
0c4d3e35e3 | ||
|
|
56b3d254a0 | ||
|
|
eb5a77e2e8 | ||
|
|
3059cf06c7 | ||
|
|
61f6c8e115 | ||
|
|
9159121ff7 | ||
|
|
80916f85a4 | ||
|
|
e37314ff51 | ||
|
|
4d47bb42f3 | ||
|
|
eba1824ebb | ||
|
|
9b4c527442 | ||
|
|
66258d17ba | ||
|
|
5359237ffd | ||
|
|
808a8b1a18 | ||
|
|
db6d9df56b | ||
|
|
55a6d1b25a | ||
|
|
e42c849e49 | ||
|
|
dbb119a4a9 | ||
|
|
2b4daad324 | ||
|
|
9f83408b2e | ||
|
|
fe59ea04a2 | ||
|
|
0e8461c26b | ||
|
|
2932862fe9 | ||
|
|
2ce61b5e70 | ||
|
|
935f060063 | ||
|
|
7c7e6fe9d3 | ||
|
|
d2358b36fb | ||
|
|
449df5ceea | ||
|
|
996bfd97bd | ||
|
|
d0bcf2f903 | ||
|
|
fbf26241d1 | ||
|
|
f5d0658223 | ||
|
|
c145a0c687 | ||
|
|
947cb04ea4 | ||
|
|
075c9caea4 | ||
|
|
05c4de2e23 | ||
|
|
77810e3741 | ||
|
|
15934bebb9 | ||
|
|
75b5eacbd8 | ||
|
|
a2daad497d | ||
|
|
a357c4fe42 | ||
|
|
47ce35a487 | ||
|
|
1726be86b9 | ||
|
|
a65ee60983 | ||
|
|
ce47a35740 | ||
|
|
e138f366fe | ||
|
|
8390b1b44e | ||
|
|
bbfb88b7ee | ||
|
|
c788c4787c | ||
|
|
1e642147ae | ||
|
|
06766e8d05 | ||
|
|
a209ed2e17 | ||
|
|
c7b7b1082f | ||
|
|
cc8b1ec9f1 | ||
|
|
5d586c5081 | ||
|
|
45f8586ac9 | ||
|
|
a4457ce492 | ||
|
|
ef6074c420 | ||
|
|
ec729707e9 | ||
|
|
c10f832d2c | ||
|
|
89bf320ee0 | ||
|
|
49ebade007 | ||
|
|
76650a0d1e | ||
|
|
bdf529b9fe | ||
|
|
a53acb7ce8 | ||
|
|
35bd5c84e9 | ||
|
|
ad21adbf57 | ||
|
|
ff5238ed5b | ||
|
|
6ae0a5bb89 | ||
|
|
8dedcb1ee3 | ||
|
|
417837e238 | ||
|
|
b7a0ae8f6a | ||
|
|
b9bf7a57c1 | ||
|
|
aada43250d | ||
|
|
3a1b7ebc51 | ||
|
|
8edc9eaab0 | ||
|
|
052b5e0cf2 | ||
|
|
6738a32c03 | ||
|
|
c2138c03e3 | ||
|
|
71ab478d05 | ||
|
|
9ccf38570a | ||
|
|
58bca5e33a | ||
|
|
d32c8eacaf | ||
|
|
3b1bbb1913 | ||
|
|
279395ee43 | ||
|
|
2dfada007d | ||
|
|
19f2eba010 | ||
|
|
b49a06424d | ||
|
|
fda714333c | ||
|
|
f9852a2333 | ||
|
|
1573c8afc6 | ||
|
|
0b8b7d748c | ||
|
|
53bc105b9b | ||
|
|
744d3e7d2c | ||
|
|
312e58d6fe | ||
|
|
876360aac9 | ||
|
|
1dda81269e | ||
|
|
e246398e89 | ||
|
|
228325f2fd | ||
|
|
1647ca9118 | ||
|
|
8fce03b0c4 | ||
|
|
ab97591270 | ||
|
|
aac9ac14e4 | ||
|
|
483dfa7b5c | ||
|
|
c4f6a00467 | ||
|
|
809af14ddf | ||
|
|
c04b596a7f | ||
|
|
c7f42bd83c | ||
|
|
e7fc38420d | ||
|
|
5295015a31 | ||
|
|
48750e304b |
+13
-1
@@ -128,6 +128,13 @@ examples/amgx/sol.gf
|
||||
examples/amgx/mesh.*
|
||||
examples/amgx/sol.*
|
||||
|
||||
examples/caliper/ex1
|
||||
examples/caliper/ex1p
|
||||
examples/caliper/refined.mesh
|
||||
examples/caliper/sol.gf
|
||||
examples/caliper/mesh.*
|
||||
examples/caliper/sol.*
|
||||
|
||||
examples/ginkgo/ex1
|
||||
examples/ginkgo/refined.mesh
|
||||
examples/ginkgo/sol.gf
|
||||
@@ -276,6 +283,10 @@ miniapps/nurbs/mode_*
|
||||
miniapps/nurbs/Example1*
|
||||
miniapps/nurbs/sin-fit.mesh
|
||||
miniapps/nurbs/CurveInt
|
||||
miniapps/nurbs/nurbs_naca_cmesh
|
||||
miniapps/nurbs/naca-cmesh.mesh
|
||||
miniapps/nurbs/glvis_naca-cmesh.mesh
|
||||
miniapps/nurbs/Naca_cmesh
|
||||
|
||||
miniapps/performance/ex1
|
||||
miniapps/performance/ex1p
|
||||
@@ -300,7 +311,7 @@ miniapps/tools/convert-dc
|
||||
miniapps/tools/lor-transfer
|
||||
miniapps/tools/plor-transfer
|
||||
miniapps/tools/get-values
|
||||
miniapps/tools/check-tmop-metric
|
||||
miniapps/tools/tmop-check-metric
|
||||
miniapps/tools/tmop-metric-magnitude
|
||||
miniapps/tools/nodal-transfer
|
||||
miniapps/tools/ParaView
|
||||
@@ -331,6 +342,7 @@ miniapps/toys/mondrian.mesh
|
||||
miniapps/solvers/block-solvers
|
||||
miniapps/solvers/lor_solvers
|
||||
miniapps/solvers/plor_solvers
|
||||
miniapps/solvers/lor_elast
|
||||
miniapps/solvers/ParaView
|
||||
miniapps/solvers/mesh.*
|
||||
miniapps/solvers/sol.*
|
||||
|
||||
@@ -15,11 +15,40 @@ Discretization improvements
|
||||
---------------------------
|
||||
- Introduced support for higher order non conformal Nedelec elements on
|
||||
simplices in ParMesh.
|
||||
- Introduced support for internal boundary elements in nonconformal adapted
|
||||
meshes.
|
||||
|
||||
- Added functionality for construction of cut-surface and cut-volume
|
||||
IntegrationRules through a moment-fitting approach. The cut is specified by
|
||||
the zero level set of a Coefficient. See fem/intrules_cut.hpp and Example 38.
|
||||
|
||||
GPU support
|
||||
----------------------------
|
||||
- Added support for full assembly on simplices.
|
||||
- Added functionality for BilinearFormIntegrators to use kernels that work for both
|
||||
tensor and unstructured elements.
|
||||
- Added partial assembly for linear elasticity. Does not use sum factorization for now.
|
||||
|
||||
New and updated examples and miniapps
|
||||
-------------------------------------
|
||||
- Added miniapp to demonstrate new elasticity integrator and unstructured element GPU support,
|
||||
and a block diagonal preconditioner using low order refinement. Allows comparison with
|
||||
currently existing legacy mode integrator. See miniapps/solvers/lor_elast.
|
||||
|
||||
Miscellaneous
|
||||
-------------
|
||||
- Added support for single and double precision, with corresponding hypre build.
|
||||
Generalized the floating point type from `double` to `real_t`.
|
||||
|
||||
- The ReadCubit Genesis mesh importer has been rewritten to improve readability.
|
||||
|
||||
- Updated the Doxygen documentation style, which now requires Doxygen version
|
||||
1.9.8 or later. See the doc/ directory.
|
||||
|
||||
- Improved thread safety for global variables in the library, for example
|
||||
IntegrationRules IntRules, RefinedIntRules, GeometryRefiner
|
||||
GlobGeometryRefiner, and FiniteElement::dof2quad_array.
|
||||
|
||||
|
||||
Version 4.6, released on September 27, 2023
|
||||
===========================================
|
||||
@@ -87,6 +116,8 @@ Linear and nonlinear solvers
|
||||
|
||||
- Added HIP support to the PETSc and SUNDIALS interfaces.
|
||||
|
||||
- Efficient GPU-accelerated LOR assembly now supports surface meshes.
|
||||
|
||||
New and updated examples and miniapps
|
||||
-------------------------------------
|
||||
- Added a new H(div) solver miniapp demonstrating the use of a matrix-free
|
||||
|
||||
+23
-6
@@ -139,10 +139,9 @@ if (MFEM_USE_CUDA)
|
||||
set(CMAKE_CUDA_HOST_LINK_LAUNCHER ${CMAKE_CXX_COMPILER})
|
||||
endif()
|
||||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} ${CUDA_FLAGS}")
|
||||
find_package(CUDAToolkit REQUIRED)
|
||||
set(CUSPARSE_FOUND TRUE)
|
||||
set(CUSPARSE_LIBRARIES "cusparse")
|
||||
set(CUBLAS_FOUND TRUE)
|
||||
set(CUBLAS_LIBRARIES "cublas")
|
||||
get_target_property(CUSPARSE_LIBRARIES CUDA::cusparse LOCATION)
|
||||
endif()
|
||||
|
||||
if (XSDK_ENABLE_C)
|
||||
@@ -531,7 +530,7 @@ find_package(Threads REQUIRED)
|
||||
set(MFEM_TPLS OPENMP HYPRE LAPACK BLAS SuperLUDist STRUMPACK METIS SuiteSparse
|
||||
SUNDIALS PETSC SLEPC MUMPS AXOM FMS CONDUIT Ginkgo GNUTLS GSLIB
|
||||
NETCDF MPFR PUMI HIOP POSIXCLOCKS MFEMBacktrace ZLIB OCCA CEED RAJA UMPIRE
|
||||
ADIOS2 CUBLAS CUSPARSE MKL_CPARDISO MKL_PARDISO AMGX CALIPER CODIPACK
|
||||
ADIOS2 CUSPARSE MKL_CPARDISO MKL_PARDISO AMGX CALIPER CODIPACK
|
||||
BENCHMARK PARELAG MPI_CXX HIP HIPSPARSE MOONOLITH BLITZ ALGOIM ENZYME)
|
||||
|
||||
# Add all *_FOUND libraries in the variable TPL_LIBRARIES.
|
||||
@@ -641,16 +640,34 @@ if (NOT ("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}"))
|
||||
foreach(Header mfem.hpp mfem-performance.hpp)
|
||||
message(STATUS
|
||||
"Writing substitute header --> \"${Header}\"")
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/${Header}"
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/${Header}.tmp"
|
||||
"// Auto-generated file.
|
||||
#define MFEM_CONFIG_FILE \"${PROJECT_BINARY_DIR}/config/_config.hpp\"
|
||||
#include \"${PROJECT_SOURCE_DIR}/${Header}\"
|
||||
")
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_BINARY_DIR}/${Header}.tmp"
|
||||
"${PROJECT_BINARY_DIR}/${Header}"
|
||||
)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E remove
|
||||
"${PROJECT_BINARY_DIR}/${Header}.tmp"
|
||||
)
|
||||
|
||||
# This version will be installed in the top include directory:
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/InstallHeaders/${Header}"
|
||||
file(WRITE "${PROJECT_BINARY_DIR}/InstallHeaders/${Header}.tmp"
|
||||
"// Auto-generated file.
|
||||
#include \"mfem/${Header}\"
|
||||
")
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${PROJECT_BINARY_DIR}/InstallHeaders/${Header}.tmp"
|
||||
"${PROJECT_BINARY_DIR}/InstallHeaders/${Header}"
|
||||
)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E remove
|
||||
"${PROJECT_BINARY_DIR}/InstallHeaders/${Header}.tmp"
|
||||
)
|
||||
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -359,6 +359,8 @@ Before you can start, you need a GitHub account, here are a few suggestions:
|
||||
conflicted files in the commit message.
|
||||
- All significant new features and changes should be documented in CHANGELOG.
|
||||
- New examples and miniapps should have documentation on the MFEM webpage.
|
||||
- The general floating-point type `real_t` should be used, rather than
|
||||
`float` or `double`, except in special cases where only one is possible.
|
||||
|
||||
|
||||
### Pull Requests
|
||||
|
||||
@@ -659,8 +659,7 @@ The specific libraries and their options are:
|
||||
requires the PT-Scotch and Scalapack libraries as well as ParMETIS, which
|
||||
includes METIS 5 in its distribution. Starting with STRUMPACK v2.2.0, ParMETIS
|
||||
and PT-Scotch are optional dependencies.
|
||||
The support for STRUMPACK was added in MFEM v3.3.2 and it requires STRUMPACK
|
||||
2.0.0 or later.
|
||||
The support for STRUMPACK was added in MFEM v3.3.2.
|
||||
URL: http://portal.nersc.gov/project/sparse/strumpack
|
||||
Options: STRUMPACK_OPT, STRUMPACK_LIB.
|
||||
Versions: STRUMPACK >= 3.0.0.
|
||||
@@ -797,7 +796,7 @@ The specific libraries and their options are:
|
||||
URL: https://github.com/CEED/libCEED
|
||||
https://ceed.exascaleproject.org/libceed
|
||||
Options: CEED_DIR, CEED_OPT, CEED_LIB.
|
||||
Versions: libCEED >= 0.10.
|
||||
Versions: libCEED >= 0.12.
|
||||
|
||||
- RAJA (optional), used when MFEM_USE_RAJA = YES.
|
||||
Beginning with MFEM v4.5.1, only RAJA v2022.10.3+ is supported.
|
||||
|
||||
@@ -63,6 +63,8 @@ set(MFEM_USE_ALGOIM @MFEM_USE_ALGOIM@)
|
||||
set(MFEM_USE_BENCHMARK @MFEM_USE_BENCHMARK@)
|
||||
set(MFEM_USE_PARELAG @MFEM_USE_PARELAG@)
|
||||
set(MFEM_USE_ENZYME @MFEM_USE_ENZYME@)
|
||||
set(MFEM_USE_DOUBLE @MFEM_USE_DOUBLE@)
|
||||
set(MFEM_USE_SINGLE @MFEM_USE_SINGLE@)
|
||||
|
||||
set(MFEM_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
|
||||
set(MFEM_CXX_FLAGS "@CMAKE_CXX_FLAGS@")
|
||||
|
||||
@@ -201,4 +201,10 @@
|
||||
// Enable Enzyme for AD
|
||||
#cmakedefine MFEM_USE_ENZYME
|
||||
|
||||
// Use double-precision floating point type
|
||||
#cmakedefine MFEM_USE_DOUBLE
|
||||
|
||||
// Use single-precision floating point type
|
||||
#cmakedefine MFEM_USE_SINGLE
|
||||
|
||||
#endif // MFEM_CONFIG_HEADER
|
||||
|
||||
@@ -14,9 +14,13 @@
|
||||
# - HYPRE_LIBRARIES
|
||||
# - HYPRE_INCLUDE_DIRS
|
||||
# - HYPRE_VERSION
|
||||
# - HYPRE_USING_CUDA (internal)
|
||||
# - HYPRE_USING_HIP (internal)
|
||||
|
||||
if (HYPRE_FOUND)
|
||||
if (HYPRE_USING_CUDA)
|
||||
find_package(CUDAToolkit REQUIRED)
|
||||
endif()
|
||||
if (HYPRE_USING_HIP)
|
||||
find_package(rocsparse REQUIRED)
|
||||
find_package(rocrand REQUIRED)
|
||||
@@ -27,6 +31,20 @@ endif()
|
||||
include(MfemCmakeUtilities)
|
||||
mfem_find_package(HYPRE HYPRE HYPRE_DIR "include" "HYPRE.h" "lib" "HYPRE"
|
||||
"Paths to headers required by HYPRE." "Libraries required by HYPRE."
|
||||
CHECK_BUILD HYPRE_USING_CUDA FALSE
|
||||
"
|
||||
#undef HYPRE_USING_CUDA
|
||||
#include <HYPRE_config.h>
|
||||
|
||||
#ifndef HYPRE_USING_CUDA
|
||||
#error HYPRE is built without CUDA.
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
CHECK_BUILD HYPRE_USING_HIP FALSE
|
||||
"
|
||||
#undef HYPRE_USING_HIP
|
||||
@@ -57,6 +75,16 @@ if (HYPRE_FOUND AND (NOT HYPRE_VERSION))
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (HYPRE_FOUND AND HYPRE_USING_CUDA)
|
||||
find_package(CUDAToolkit REQUIRED)
|
||||
get_target_property(CUSPARSE_LIBRARIES CUDA::cusparse LOCATION)
|
||||
get_target_property(CURAND_LIBRARIES CUDA::curand LOCATION)
|
||||
list(APPEND HYPRE_LIBRARIES ${CUSPARSE_LIBRARIES} ${CURAND_LIBRARIES})
|
||||
set(HYPRE_LIBRARIES ${HYPRE_LIBRARIES} CACHE STRING
|
||||
"HYPRE libraries + dependencies." FORCE)
|
||||
message(STATUS "Updated HYPRE_LIBRARIES: ${HYPRE_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
if (HYPRE_FOUND AND HYPRE_USING_HIP)
|
||||
find_package(rocsparse REQUIRED)
|
||||
find_package(rocrand REQUIRED)
|
||||
|
||||
@@ -201,4 +201,10 @@
|
||||
// Enable the Enzyme LLVM plugin
|
||||
// #define MFEM_USE_ENZYME
|
||||
|
||||
// Use double-precision floating point type
|
||||
// #define MFEM_USE_DOUBLE
|
||||
|
||||
// Use single-precision floating point type
|
||||
// #define MFEM_USE_SINGLE
|
||||
|
||||
#endif // MFEM_CONFIG_HEADER
|
||||
|
||||
@@ -64,6 +64,8 @@ MFEM_USE_CODIPACK = @MFEM_USE_CODIPACK@
|
||||
MFEM_USE_BENCHMARK = @MFEM_USE_BENCHMARK@
|
||||
MFEM_USE_PARELAG = @MFEM_USE_PARELAG@
|
||||
MFEM_USE_ENZYME = @MFEM_USE_ENZYME@
|
||||
MFEM_USE_DOUBLE = @MFEM_USE_DOUBLE@
|
||||
MFEM_USE_SINGLE = @MFEM_USE_SINGLE@
|
||||
|
||||
# Compiler, compile options, and link options
|
||||
MFEM_CXX = @MFEM_CXX@
|
||||
|
||||
@@ -66,6 +66,8 @@ option(MFEM_USE_CODIPACK "Enable automatic differentiation (AD) using CoDiPack"
|
||||
option(MFEM_USE_BENCHMARK "Enable Google Benchmark" OFF)
|
||||
option(MFEM_USE_PARELAG "Enable ParELAG" OFF)
|
||||
option(MFEM_USE_ENZYME "Enable Enzyme" OFF)
|
||||
option(MFEM_USE_DOUBLE "Double precision" ON)
|
||||
option(MFEM_USE_SINGLE "Single precision" OFF)
|
||||
|
||||
# Optional overrides for autodetected MPIEXEC and MPIEXEC_NUMPROC_FLAG
|
||||
# set(MFEM_MPIEXEC "mpirun" CACHE STRING "Command for running MPI tests")
|
||||
@@ -106,12 +108,7 @@ set(HYPRE_DIR "${MFEM_DIR}/../hypre/src/hypre" CACHE PATH
|
||||
# If hypre was compiled to depend on BLAS and LAPACK:
|
||||
# set(HYPRE_REQUIRED_PACKAGES "BLAS" "LAPACK" CACHE STRING
|
||||
# "Packages that HYPRE depends on.")
|
||||
if (MFEM_USE_CUDA)
|
||||
# This is only necessary when hypre is built with cuda:
|
||||
set(HYPRE_REQUIRED_LIBRARIES "-lcusparse" "-lcurand" CACHE STRING
|
||||
"Libraries that HYPRE depends on.")
|
||||
endif()
|
||||
# HIP dependency for HYPRE is handled in FindHYPRE.cmake.
|
||||
# CUDA and HIP dependencies for HYPRE are handled in FindHYPRE.cmake.
|
||||
|
||||
set(METIS_DIR "${MFEM_DIR}/../metis-4.0" CACHE PATH "Path to the METIS library.")
|
||||
|
||||
@@ -157,7 +154,8 @@ set(STRUMPACK_DIR "${MFEM_DIR}/../STRUMPACK-build" CACHE PATH
|
||||
# STRUMPACK may also depend on "OpenMP", depending on how it was compiled.
|
||||
# Starting with v2.2.0 of STRUMPACK, ParMETIS and Scotch are optional.
|
||||
set(STRUMPACK_REQUIRED_PACKAGES "MPI" "MPI_Fortran" "ParMETIS" "METIS"
|
||||
"ScaLAPACK" "Scotch/ptscotch/ptscotcherr/scotch/scotcherr" CACHE STRING
|
||||
"Scotch/ptscotch/ptscotcherr/scotch/scotcherr"
|
||||
"ScaLAPACK" "LAPACK" "BLAS" CACHE STRING
|
||||
"Additional packages required by STRUMPACK.")
|
||||
# If the MPI package does not find all required Fortran libraries:
|
||||
# set(STRUMPACK_REQUIRED_LIBRARIES "gfortran" "mpi_mpifh" CACHE STRING
|
||||
|
||||
@@ -167,6 +167,8 @@ MFEM_USE_CODIPACK = NO
|
||||
MFEM_USE_BENCHMARK = NO
|
||||
MFEM_USE_PARELAG = NO
|
||||
MFEM_USE_ENZYME = NO
|
||||
MFEM_USE_DOUBLE = YES
|
||||
MFEM_USE_SINGLE = NO
|
||||
|
||||
# MPI library compile and link flags
|
||||
# These settings are used only when building MFEM with MPI + HIP
|
||||
|
||||
+3
-2
@@ -38,14 +38,14 @@ all: header config-mk
|
||||
MPI = $(MFEM_USE_MPI:NO=)
|
||||
GHV_CXX ?= $(MFEM_CXX)
|
||||
GHV = get_hypre_version
|
||||
GHV_FLAGS = $(subst @MFEM_DIR@,$(if $(MFEM_DIR),$(MFEM_DIR),..),$(HYPRE_OPT))
|
||||
GHV_FLAGS = $(MFEM_CXXFLAGS) $(subst @MFEM_DIR@,$(if $(MFEM_DIR),$(MFEM_DIR),..),$(HYPRE_OPT))
|
||||
SMX = $(if $(MFEM_USE_PUMI:NO=),MFEM_USE_SIMMETRIX)
|
||||
SMX_PATH = $(PUMI_DIR)/include/gmi_sim.h
|
||||
SMX_FILE = $(subst @MFEM_DIR@,$(if $(MFEM_DIR),$(MFEM_DIR),..),$(SMX_PATH))
|
||||
MUMPS = $(MFEM_USE_MUMPS:NO=)
|
||||
GMV_CXX ?= $(MFEM_CXX)
|
||||
GMV = get_mumps_version
|
||||
GMV_FLAGS = $(subst @MFEM_DIR@,$(if $(MFEM_DIR),$(MFEM_DIR),..),$(MUMPS_OPT))
|
||||
GMV_FLAGS = $(MFEM_CXXFLAGS) $(subst @MFEM_DIR@,$(if $(MFEM_DIR),$(MFEM_DIR),..),$(MUMPS_OPT))
|
||||
|
||||
$(GHV): $(SRC)$(GHV).cpp
|
||||
$(call mfem-info, Determining HYPRE version ...)
|
||||
@@ -110,3 +110,4 @@ config-mk:
|
||||
|
||||
clean:
|
||||
rm -f $(CONFIG_HPP) $(CONFIG_MK) sample-runs-build.log
|
||||
rm -f $(GHV) $(GHV).out $(GMV) $(GMV).out
|
||||
|
||||
@@ -315,7 +315,7 @@ function extract_sample_runs()
|
||||
sruns=`grep -v "^//.* mpirun .* ${app}" "${src}" |
|
||||
grep "^//.* ${app}" |
|
||||
sed -e "s/.* ${app}/${vg_app}/g"`
|
||||
runs="${sruns}${pruns}"
|
||||
runs="${sruns}"$'\n'"${pruns}"
|
||||
if [ "$skip_gen_meshes" == "yes" ]; then
|
||||
runs=`printf "%s" "$runs" | grep -v ".* -m .*\.gen"`
|
||||
fi
|
||||
|
||||
+703
-299
File diff suppressed because it is too large
Load Diff
@@ -112,6 +112,7 @@ namespace mfem {
|
||||
* - <a class="el" href="ex36p_8cpp_source.html">Example 36p</a>: parallel Proximal Galerkin FEM for the obstacle problem
|
||||
* - <a class="el" href="ex37_8cpp_source.html">Example 37</a>: Topology optimization
|
||||
* - <a class="el" href="ex37p_8cpp_source.html">Example 37p</a>: parallel topology optimization
|
||||
* - <a class="el" href="ex38_8cpp_source.html">Example 38</a>: cut-surface and cut-volume integration
|
||||
*
|
||||
* <H4>AmgX Examples</H4>
|
||||
* - Variants of Examples
|
||||
@@ -215,6 +216,7 @@ namespace mfem {
|
||||
* - <a class="el" href="generate__random__field_8cpp_source.html">SPDE Solvers</a>: SPDE solver random field generation
|
||||
* - <a class="el" href="pdiffusion_8cpp_source.html">DPG Diffusion example</a>: DPG formulation for the diffusion problem
|
||||
* - <a class="el" href="pmaxwell_8cpp_source.html">DPG Maxwell example</a>: DPG formulation for the indefinite Maxwell problem
|
||||
* - <a class="el" href="lor__elast_8cpp_source.html">LOR Elasticity</a>: solve linear elasticity with LOR preconditioning on GPUs
|
||||
*
|
||||
* See also the <a class="el" href="https://mfem.org/examples/">examples documentation</a> online.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ If not already available, Doxygen can be downloaded from
|
||||
|
||||
http://www.doxygen.org
|
||||
|
||||
We recommend using version 1.8 or later.
|
||||
We recommend using version 1.9.8 or later.
|
||||
|
||||
To build the documentation, simply type "make" in the doc/ directory. This will
|
||||
create the file CodeDocumentation.html, which can be viewed in any web browser.
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
html {
|
||||
--content-maxwidth: auto;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,78 @@
|
||||
<!-- HTML header for doxygen 1.9.6-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="$langISO">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen $doxygenversion"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
|
||||
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<!--BEGIN DISABLE_INDEX-->
|
||||
<!--BEGIN FULL_SIDEBAR-->
|
||||
<script type="text/javascript">var page_layout=1;</script>
|
||||
<!--END FULL_SIDEBAR-->
|
||||
<!--END DISABLE_INDEX-->
|
||||
<script type="text/javascript" src="$relpath^jquery.js"></script>
|
||||
<script type="text/javascript" src="$relpath^dynsections.js"></script>
|
||||
$treeview
|
||||
$search
|
||||
$mathjax
|
||||
$darkmode
|
||||
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
||||
$extrastylesheet
|
||||
<script type="text/javascript" src="$relpath^doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<!--BEGIN DISABLE_INDEX-->
|
||||
<!--BEGIN FULL_SIDEBAR-->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<!--END FULL_SIDEBAR-->
|
||||
<!--END DISABLE_INDEX-->
|
||||
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
|
||||
<!--BEGIN TITLEAREA-->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<!--BEGIN PROJECT_LOGO-->
|
||||
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td>
|
||||
<!--END PROJECT_LOGO-->
|
||||
<!--BEGIN PROJECT_NAME-->
|
||||
<td id="projectalign">
|
||||
<div id="projectname">$projectname<!--BEGIN PROJECT_NUMBER--><span id="projectnumber"> $projectnumber</span><!--END PROJECT_NUMBER-->
|
||||
</div>
|
||||
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
|
||||
</td>
|
||||
<!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME-->
|
||||
<!--BEGIN PROJECT_BRIEF-->
|
||||
<td>
|
||||
<div id="projectbrief">$projectbrief</div>
|
||||
</td>
|
||||
<!--END PROJECT_BRIEF-->
|
||||
<!--END !PROJECT_NAME-->
|
||||
<!--BEGIN DISABLE_INDEX-->
|
||||
<!--BEGIN SEARCHENGINE-->
|
||||
<!--BEGIN !FULL_SIDEBAR-->
|
||||
<td>$searchbox</td>
|
||||
<!--END !FULL_SIDEBAR-->
|
||||
<!--END SEARCHENGINE-->
|
||||
<!--END DISABLE_INDEX-->
|
||||
</tr>
|
||||
<!--BEGIN SEARCHENGINE-->
|
||||
<!--BEGIN FULL_SIDEBAR-->
|
||||
<tr><td colspan="2">$searchbox</td></tr>
|
||||
<!--END FULL_SIDEBAR-->
|
||||
<!--END SEARCHENGINE-->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--END TITLEAREA-->
|
||||
<!-- end header part -->
|
||||
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
|
||||
Doxygen Awesome
|
||||
https://github.com/jothepro/doxygen-awesome-css
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 - 2023 jothepro
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
class DoxygenAwesomeDarkModeToggle extends HTMLElement {
|
||||
// SVG icons from https://fonts.google.com/icons
|
||||
// Licensed under the Apache 2.0 license:
|
||||
// https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
static lightModeIcon = `<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#FCBF00"><rect fill="none" height="24" width="24"/><circle cx="12" cy="12" opacity=".3" r="3"/><path d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"/></svg>`
|
||||
static darkModeIcon = `<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#FE9700"><rect fill="none" height="24" width="24"/><path d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27 C17.45,17.19,14.93,19,12,19c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z" opacity=".3"/><path d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"/></svg>`
|
||||
static title = "Toggle Light/Dark Mode"
|
||||
|
||||
static prefersLightModeInDarkModeKey = "prefers-light-mode-in-dark-mode"
|
||||
static prefersDarkModeInLightModeKey = "prefers-dark-mode-in-light-mode"
|
||||
|
||||
static _staticConstructor = function() {
|
||||
DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.userPreference)
|
||||
// Update the color scheme when the browsers preference changes
|
||||
// without user interaction on the website.
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
||||
DoxygenAwesomeDarkModeToggle.onSystemPreferenceChanged()
|
||||
})
|
||||
// Update the color scheme when the tab is made visible again.
|
||||
// It is possible that the appearance was changed in another tab
|
||||
// while this tab was in the background.
|
||||
document.addEventListener("visibilitychange", visibilityState => {
|
||||
if (document.visibilityState === 'visible') {
|
||||
DoxygenAwesomeDarkModeToggle.onSystemPreferenceChanged()
|
||||
}
|
||||
});
|
||||
}()
|
||||
|
||||
static init() {
|
||||
$(function() {
|
||||
$(document).ready(function() {
|
||||
const toggleButton = document.createElement('doxygen-awesome-dark-mode-toggle')
|
||||
toggleButton.title = DoxygenAwesomeDarkModeToggle.title
|
||||
toggleButton.updateIcon()
|
||||
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
|
||||
toggleButton.updateIcon()
|
||||
})
|
||||
document.addEventListener("visibilitychange", visibilityState => {
|
||||
if (document.visibilityState === 'visible') {
|
||||
toggleButton.updateIcon()
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function(){
|
||||
document.getElementById("MSearchBox").parentNode.appendChild(toggleButton)
|
||||
})
|
||||
$(window).resize(function(){
|
||||
document.getElementById("MSearchBox").parentNode.appendChild(toggleButton)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.onclick=this.toggleDarkMode
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns `true` for dark-mode, `false` for light-mode system preference
|
||||
*/
|
||||
static get systemPreference() {
|
||||
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns `true` for dark-mode, `false` for light-mode user preference
|
||||
*/
|
||||
static get userPreference() {
|
||||
return (!DoxygenAwesomeDarkModeToggle.systemPreference && localStorage.getItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey)) ||
|
||||
(DoxygenAwesomeDarkModeToggle.systemPreference && !localStorage.getItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey))
|
||||
}
|
||||
|
||||
static set userPreference(userPreference) {
|
||||
DoxygenAwesomeDarkModeToggle.darkModeEnabled = userPreference
|
||||
if(!userPreference) {
|
||||
if(DoxygenAwesomeDarkModeToggle.systemPreference) {
|
||||
localStorage.setItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey, true)
|
||||
} else {
|
||||
localStorage.removeItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey)
|
||||
}
|
||||
} else {
|
||||
if(!DoxygenAwesomeDarkModeToggle.systemPreference) {
|
||||
localStorage.setItem(DoxygenAwesomeDarkModeToggle.prefersDarkModeInLightModeKey, true)
|
||||
} else {
|
||||
localStorage.removeItem(DoxygenAwesomeDarkModeToggle.prefersLightModeInDarkModeKey)
|
||||
}
|
||||
}
|
||||
DoxygenAwesomeDarkModeToggle.onUserPreferenceChanged()
|
||||
}
|
||||
|
||||
static enableDarkMode(enable) {
|
||||
if(enable) {
|
||||
DoxygenAwesomeDarkModeToggle.darkModeEnabled = true
|
||||
document.documentElement.classList.add("dark-mode")
|
||||
document.documentElement.classList.remove("light-mode")
|
||||
} else {
|
||||
DoxygenAwesomeDarkModeToggle.darkModeEnabled = false
|
||||
document.documentElement.classList.remove("dark-mode")
|
||||
document.documentElement.classList.add("light-mode")
|
||||
}
|
||||
}
|
||||
|
||||
static onSystemPreferenceChanged() {
|
||||
DoxygenAwesomeDarkModeToggle.darkModeEnabled = DoxygenAwesomeDarkModeToggle.userPreference
|
||||
DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.darkModeEnabled)
|
||||
}
|
||||
|
||||
static onUserPreferenceChanged() {
|
||||
DoxygenAwesomeDarkModeToggle.enableDarkMode(DoxygenAwesomeDarkModeToggle.darkModeEnabled)
|
||||
}
|
||||
|
||||
toggleDarkMode() {
|
||||
DoxygenAwesomeDarkModeToggle.userPreference = !DoxygenAwesomeDarkModeToggle.userPreference
|
||||
this.updateIcon()
|
||||
}
|
||||
|
||||
updateIcon() {
|
||||
if(DoxygenAwesomeDarkModeToggle.darkModeEnabled) {
|
||||
this.innerHTML = DoxygenAwesomeDarkModeToggle.darkModeIcon
|
||||
} else {
|
||||
this.innerHTML = DoxygenAwesomeDarkModeToggle.lightModeIcon
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define("doxygen-awesome-dark-mode-toggle", DoxygenAwesomeDarkModeToggle);
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 17 KiB |
+1
-1
@@ -16,7 +16,7 @@ DOXYGEN_CONF = CodeDocumentation.conf
|
||||
# doxygen uses: graphviz, latex
|
||||
html: $(DOXYGEN_CONF)
|
||||
@# Generate the html documentation
|
||||
@( cat $(DOXYGEN_CONF) ; echo "$(MFEM_DOXYGEN_FLAGS)" ) | doxygen -
|
||||
@( cat $(DOXYGEN_CONF) ; printf "$(MFEM_DOXYGEN_FLAGS)\n" ) | doxygen -
|
||||
@echo "<meta http-equiv=\"REFRESH\" content=\"0;URL=CodeDocumentation/html/index.html\">" > CodeDocumentation.html
|
||||
@cat warnings.log 1>&2
|
||||
@# Generate the log of undocumented methods
|
||||
|
||||
@@ -45,6 +45,12 @@ list(APPEND ALL_EXE_SRCS
|
||||
ex37.cpp
|
||||
)
|
||||
|
||||
if(MFEM_USE_LAPACK)
|
||||
list(APPEND ALL_EXE_SRCS
|
||||
ex38.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (MFEM_USE_MPI)
|
||||
list(APPEND ALL_EXE_SRCS
|
||||
ex0p.cpp
|
||||
|
||||
+34
-30
@@ -62,7 +62,7 @@ protected:
|
||||
|
||||
BilinearForm M, S;
|
||||
NonlinearForm H;
|
||||
double viscosity;
|
||||
real_t viscosity;
|
||||
HyperelasticModel *model;
|
||||
|
||||
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
|
||||
@@ -84,16 +84,16 @@ protected:
|
||||
|
||||
public:
|
||||
HyperelasticOperator(FiniteElementSpace &f, Array<int> &ess_bdr,
|
||||
double visc, double mu, double K);
|
||||
real_t visc, real_t mu, real_t K);
|
||||
|
||||
/// Compute the right-hand side of the ODE system.
|
||||
virtual void Mult(const Vector &vx, Vector &dvx_dt) const;
|
||||
/** Solve the Backward-Euler equation: k = f(x + dt*k, t), for the unknown k.
|
||||
This is the only requirement for high-order SDIRK implicit integration.*/
|
||||
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
|
||||
|
||||
double ElasticEnergy(const Vector &x) const;
|
||||
double KineticEnergy(const Vector &v) const;
|
||||
real_t ElasticEnergy(const Vector &x) const;
|
||||
real_t KineticEnergy(const Vector &v) const;
|
||||
void GetElasticEnergyDensity(const GridFunction &x, GridFunction &w) const;
|
||||
|
||||
virtual ~HyperelasticOperator();
|
||||
@@ -109,7 +109,7 @@ private:
|
||||
BilinearForm *M, *S;
|
||||
NonlinearForm *H;
|
||||
mutable SparseMatrix *Jacobian;
|
||||
double dt;
|
||||
real_t dt;
|
||||
const Vector *v, *x;
|
||||
mutable Vector w, z;
|
||||
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
ReducedSystemOperator(BilinearForm *M_, BilinearForm *S_, NonlinearForm *H_);
|
||||
|
||||
/// Set current dt, v, x values - needed to compute action and Jacobian.
|
||||
void SetParameters(double dt_, const Vector *v_, const Vector *x_);
|
||||
void SetParameters(real_t dt_, const Vector *v_, const Vector *x_);
|
||||
|
||||
/// Compute y = H(x + dt (v + dt k)) + M k + S (v + dt k).
|
||||
virtual void Mult(const Vector &k, Vector &y) const;
|
||||
@@ -141,7 +141,7 @@ private:
|
||||
public:
|
||||
ElasticEnergyCoefficient(HyperelasticModel &m, const GridFunction &x_)
|
||||
: model(m), x(x_) { }
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual ~ElasticEnergyCoefficient() { }
|
||||
};
|
||||
|
||||
@@ -161,11 +161,11 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 2;
|
||||
int order = 2;
|
||||
int ode_solver_type = 3;
|
||||
double t_final = 300.0;
|
||||
double dt = 3.0;
|
||||
double visc = 1e-2;
|
||||
double mu = 0.25;
|
||||
double K = 5.0;
|
||||
real_t t_final = 300.0;
|
||||
real_t dt = 3.0;
|
||||
real_t visc = 1e-2;
|
||||
real_t mu = 0.25;
|
||||
real_t K = 5.0;
|
||||
bool visualization = true;
|
||||
int vis_steps = 1;
|
||||
|
||||
@@ -205,6 +205,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
args.PrintOptions(cout);
|
||||
|
||||
#ifdef MFEM_USE_SINGLE
|
||||
MFEM_ABORT("This example is not supported in single precision.");
|
||||
#endif
|
||||
|
||||
// 2. Read the mesh from the given mesh file. We can handle triangular,
|
||||
// quadrilateral, tetrahedral and hexahedral meshes with the same code.
|
||||
Mesh *mesh = new Mesh(mesh_file, 1, 1);
|
||||
@@ -309,13 +313,13 @@ int main(int argc, char *argv[])
|
||||
<< " Press space (in the GLVis window) to resume it.\n";
|
||||
}
|
||||
|
||||
double ee0 = oper.ElasticEnergy(x.GetTrueVector());
|
||||
double ke0 = oper.KineticEnergy(v.GetTrueVector());
|
||||
real_t ee0 = oper.ElasticEnergy(x.GetTrueVector());
|
||||
real_t ke0 = oper.KineticEnergy(v.GetTrueVector());
|
||||
cout << "initial elastic energy (EE) = " << ee0 << endl;
|
||||
cout << "initial kinetic energy (KE) = " << ke0 << endl;
|
||||
cout << "initial total energy (TE) = " << (ee0 + ke0) << endl;
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
oper.SetTime(t);
|
||||
ode_solver->Init(oper);
|
||||
|
||||
@@ -324,7 +328,7 @@ int main(int argc, char *argv[])
|
||||
bool last_step = false;
|
||||
for (int ti = 1; !last_step; ti++)
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
|
||||
ode_solver->Step(vx, t, dt_real);
|
||||
|
||||
@@ -332,8 +336,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (last_step || (ti % vis_steps) == 0)
|
||||
{
|
||||
double ee = oper.ElasticEnergy(x.GetTrueVector());
|
||||
double ke = oper.KineticEnergy(v.GetTrueVector());
|
||||
real_t ee = oper.ElasticEnergy(x.GetTrueVector());
|
||||
real_t ke = oper.KineticEnergy(v.GetTrueVector());
|
||||
|
||||
cout << "step " << ti << ", t = " << t << ", EE = " << ee << ", KE = "
|
||||
<< ke << ", ΔTE = " << (ee+ke)-(ee0+ke0) << endl;
|
||||
@@ -419,7 +423,7 @@ ReducedSystemOperator::ReducedSystemOperator(
|
||||
dt(0.0), v(NULL), x(NULL), w(height), z(height)
|
||||
{ }
|
||||
|
||||
void ReducedSystemOperator::SetParameters(double dt_, const Vector *v_,
|
||||
void ReducedSystemOperator::SetParameters(real_t dt_, const Vector *v_,
|
||||
const Vector *x_)
|
||||
{
|
||||
dt = dt_; v = v_; x = x_;
|
||||
@@ -453,16 +457,16 @@ ReducedSystemOperator::~ReducedSystemOperator()
|
||||
|
||||
|
||||
HyperelasticOperator::HyperelasticOperator(FiniteElementSpace &f,
|
||||
Array<int> &ess_bdr, double visc,
|
||||
double mu, double K)
|
||||
: TimeDependentOperator(2*f.GetTrueVSize(), 0.0), fespace(f),
|
||||
Array<int> &ess_bdr, real_t visc,
|
||||
real_t mu, real_t K)
|
||||
: TimeDependentOperator(2*f.GetTrueVSize(), (real_t) 0.0), fespace(f),
|
||||
M(&fespace), S(&fespace), H(&fespace),
|
||||
viscosity(visc), z(height/2)
|
||||
{
|
||||
const double rel_tol = 1e-8;
|
||||
const real_t rel_tol = 1e-8;
|
||||
const int skip_zero_entries = 0;
|
||||
|
||||
const double ref_density = 1.0; // density in the reference configuration
|
||||
const real_t ref_density = 1.0; // density in the reference configuration
|
||||
ConstantCoefficient rho0(ref_density);
|
||||
M.AddDomainIntegrator(new VectorMassIntegrator(rho0));
|
||||
M.Assemble(skip_zero_entries);
|
||||
@@ -533,7 +537,7 @@ void HyperelasticOperator::Mult(const Vector &vx, Vector &dvx_dt) const
|
||||
dx_dt = v;
|
||||
}
|
||||
|
||||
void HyperelasticOperator::ImplicitSolve(const double dt,
|
||||
void HyperelasticOperator::ImplicitSolve(const real_t dt,
|
||||
const Vector &vx, Vector &dvx_dt)
|
||||
{
|
||||
int sc = height/2;
|
||||
@@ -555,12 +559,12 @@ void HyperelasticOperator::ImplicitSolve(const double dt,
|
||||
add(v, dt, dv_dt, dx_dt);
|
||||
}
|
||||
|
||||
double HyperelasticOperator::ElasticEnergy(const Vector &x) const
|
||||
real_t HyperelasticOperator::ElasticEnergy(const Vector &x) const
|
||||
{
|
||||
return H.GetEnergy(x);
|
||||
}
|
||||
|
||||
double HyperelasticOperator::KineticEnergy(const Vector &v) const
|
||||
real_t HyperelasticOperator::KineticEnergy(const Vector &v) const
|
||||
{
|
||||
return 0.5*M.InnerProduct(v, v);
|
||||
}
|
||||
@@ -581,7 +585,7 @@ HyperelasticOperator::~HyperelasticOperator()
|
||||
}
|
||||
|
||||
|
||||
double ElasticEnergyCoefficient::Eval(ElementTransformation &T,
|
||||
real_t ElasticEnergyCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
model.SetTransformation(T);
|
||||
@@ -601,7 +605,7 @@ void InitialDeformation(const Vector &x, Vector &y)
|
||||
void InitialVelocity(const Vector &x, Vector &v)
|
||||
{
|
||||
const int dim = x.Size();
|
||||
const double s = 0.1/64.;
|
||||
const real_t s = 0.1/64.;
|
||||
|
||||
v = 0.0;
|
||||
v(dim-1) = s*x(0)*x(0)*(8.0-x(0));
|
||||
|
||||
+38
-34
@@ -63,7 +63,7 @@ protected:
|
||||
|
||||
ParBilinearForm M, S;
|
||||
ParNonlinearForm H;
|
||||
double viscosity;
|
||||
real_t viscosity;
|
||||
HyperelasticModel *model;
|
||||
|
||||
HypreParMatrix *Mmat; // Mass matrix from ParallelAssemble()
|
||||
@@ -86,16 +86,16 @@ protected:
|
||||
|
||||
public:
|
||||
HyperelasticOperator(ParFiniteElementSpace &f, Array<int> &ess_bdr,
|
||||
double visc, double mu, double K);
|
||||
real_t visc, real_t mu, real_t K);
|
||||
|
||||
/// Compute the right-hand side of the ODE system.
|
||||
virtual void Mult(const Vector &vx, Vector &dvx_dt) const;
|
||||
/** Solve the Backward-Euler equation: k = f(x + dt*k, t), for the unknown k.
|
||||
This is the only requirement for high-order SDIRK implicit integration.*/
|
||||
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
|
||||
|
||||
double ElasticEnergy(const ParGridFunction &x) const;
|
||||
double KineticEnergy(const ParGridFunction &v) const;
|
||||
real_t ElasticEnergy(const ParGridFunction &x) const;
|
||||
real_t KineticEnergy(const ParGridFunction &v) const;
|
||||
void GetElasticEnergyDensity(const ParGridFunction &x,
|
||||
ParGridFunction &w) const;
|
||||
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
ParBilinearForm *M, *S;
|
||||
ParNonlinearForm *H;
|
||||
mutable HypreParMatrix *Jacobian;
|
||||
double dt;
|
||||
real_t dt;
|
||||
const Vector *v, *x;
|
||||
mutable Vector w, z;
|
||||
const Array<int> &ess_tdof_list;
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
ParNonlinearForm *H_, const Array<int> &ess_tdof_list);
|
||||
|
||||
/// Set current dt, v, x values - needed to compute action and Jacobian.
|
||||
void SetParameters(double dt_, const Vector *v_, const Vector *x_);
|
||||
void SetParameters(real_t dt_, const Vector *v_, const Vector *x_);
|
||||
|
||||
/// Compute y = H(x + dt (v + dt k)) + M k + S (v + dt k).
|
||||
virtual void Mult(const Vector &k, Vector &y) const;
|
||||
@@ -146,7 +146,7 @@ private:
|
||||
public:
|
||||
ElasticEnergyCoefficient(HyperelasticModel &m, const ParGridFunction &x_)
|
||||
: model(m), x(x_) { }
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual ~ElasticEnergyCoefficient() { }
|
||||
};
|
||||
|
||||
@@ -173,11 +173,11 @@ int main(int argc, char *argv[])
|
||||
int par_ref_levels = 0;
|
||||
int order = 2;
|
||||
int ode_solver_type = 3;
|
||||
double t_final = 300.0;
|
||||
double dt = 3.0;
|
||||
double visc = 1e-2;
|
||||
double mu = 0.25;
|
||||
double K = 5.0;
|
||||
real_t t_final = 300.0;
|
||||
real_t dt = 3.0;
|
||||
real_t visc = 1e-2;
|
||||
real_t mu = 0.25;
|
||||
real_t K = 5.0;
|
||||
bool adaptive_lin_rtol = true;
|
||||
bool visualization = true;
|
||||
int vis_steps = 1;
|
||||
@@ -229,6 +229,10 @@ int main(int argc, char *argv[])
|
||||
args.PrintOptions(cout);
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_SINGLE
|
||||
MFEM_ABORT("This example is not supported in single precision.");
|
||||
#endif
|
||||
|
||||
// 3. Read the serial mesh from the given mesh file on all processors. We can
|
||||
// handle triangular, quadrilateral, tetrahedral and hexahedral meshes
|
||||
// with the same code.
|
||||
@@ -358,8 +362,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
double ee0 = oper.ElasticEnergy(x_gf);
|
||||
double ke0 = oper.KineticEnergy(v_gf);
|
||||
real_t ee0 = oper.ElasticEnergy(x_gf);
|
||||
real_t ke0 = oper.KineticEnergy(v_gf);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "initial elastic energy (EE) = " << ee0 << endl;
|
||||
@@ -367,7 +371,7 @@ int main(int argc, char *argv[])
|
||||
cout << "initial total energy (TE) = " << (ee0 + ke0) << endl;
|
||||
}
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
oper.SetTime(t);
|
||||
ode_solver->Init(oper);
|
||||
|
||||
@@ -376,7 +380,7 @@ int main(int argc, char *argv[])
|
||||
bool last_step = false;
|
||||
for (int ti = 1; !last_step; ti++)
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
|
||||
ode_solver->Step(vx, t, dt_real);
|
||||
|
||||
@@ -386,8 +390,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
v_gf.SetFromTrueVector(); x_gf.SetFromTrueVector();
|
||||
|
||||
double ee = oper.ElasticEnergy(x_gf);
|
||||
double ke = oper.KineticEnergy(v_gf);
|
||||
real_t ee = oper.ElasticEnergy(x_gf);
|
||||
real_t ke = oper.KineticEnergy(v_gf);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -485,7 +489,7 @@ ReducedSystemOperator::ReducedSystemOperator(
|
||||
ess_tdof_list(ess_tdof_list_)
|
||||
{ }
|
||||
|
||||
void ReducedSystemOperator::SetParameters(double dt_, const Vector *v_,
|
||||
void ReducedSystemOperator::SetParameters(real_t dt_, const Vector *v_,
|
||||
const Vector *x_)
|
||||
{
|
||||
dt = dt_; v = v_; x = x_;
|
||||
@@ -523,17 +527,17 @@ ReducedSystemOperator::~ReducedSystemOperator()
|
||||
|
||||
|
||||
HyperelasticOperator::HyperelasticOperator(ParFiniteElementSpace &f,
|
||||
Array<int> &ess_bdr, double visc,
|
||||
double mu, double K)
|
||||
: TimeDependentOperator(2*f.TrueVSize(), 0.0), fespace(f),
|
||||
Array<int> &ess_bdr, real_t visc,
|
||||
real_t mu, real_t K)
|
||||
: TimeDependentOperator(2*f.TrueVSize(), (real_t) 0.0), fespace(f),
|
||||
M(&fespace), S(&fespace), H(&fespace),
|
||||
viscosity(visc), M_solver(f.GetComm()), newton_solver(f.GetComm()),
|
||||
z(height/2)
|
||||
{
|
||||
const double rel_tol = 1e-8;
|
||||
const real_t rel_tol = 1e-8;
|
||||
const int skip_zero_entries = 0;
|
||||
|
||||
const double ref_density = 1.0; // density in the reference configuration
|
||||
const real_t ref_density = 1.0; // density in the reference configuration
|
||||
ConstantCoefficient rho0(ref_density);
|
||||
M.AddDomainIntegrator(new VectorMassIntegrator(rho0));
|
||||
M.Assemble(skip_zero_entries);
|
||||
@@ -607,7 +611,7 @@ void HyperelasticOperator::Mult(const Vector &vx, Vector &dvx_dt) const
|
||||
dx_dt = v;
|
||||
}
|
||||
|
||||
void HyperelasticOperator::ImplicitSolve(const double dt,
|
||||
void HyperelasticOperator::ImplicitSolve(const real_t dt,
|
||||
const Vector &vx, Vector &dvx_dt)
|
||||
{
|
||||
int sc = height/2;
|
||||
@@ -629,17 +633,17 @@ void HyperelasticOperator::ImplicitSolve(const double dt,
|
||||
add(v, dt, dv_dt, dx_dt);
|
||||
}
|
||||
|
||||
double HyperelasticOperator::ElasticEnergy(const ParGridFunction &x) const
|
||||
real_t HyperelasticOperator::ElasticEnergy(const ParGridFunction &x) const
|
||||
{
|
||||
return H.GetEnergy(x);
|
||||
}
|
||||
|
||||
double HyperelasticOperator::KineticEnergy(const ParGridFunction &v) const
|
||||
real_t HyperelasticOperator::KineticEnergy(const ParGridFunction &v) const
|
||||
{
|
||||
double loc_energy = 0.5*M.InnerProduct(v, v);
|
||||
double energy;
|
||||
MPI_Allreduce(&loc_energy, &energy, 1, MPI_DOUBLE, MPI_SUM,
|
||||
fespace.GetComm());
|
||||
real_t loc_energy = 0.5*M.InnerProduct(v, v);
|
||||
real_t energy;
|
||||
MPI_Allreduce(&loc_energy, &energy, 1, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_SUM, fespace.GetComm());
|
||||
return energy;
|
||||
}
|
||||
|
||||
@@ -660,7 +664,7 @@ HyperelasticOperator::~HyperelasticOperator()
|
||||
}
|
||||
|
||||
|
||||
double ElasticEnergyCoefficient::Eval(ElementTransformation &T,
|
||||
real_t ElasticEnergyCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
model.SetTransformation(T);
|
||||
@@ -680,7 +684,7 @@ void InitialDeformation(const Vector &x, Vector &y)
|
||||
void InitialVelocity(const Vector &x, Vector &v)
|
||||
{
|
||||
const int dim = x.Size();
|
||||
const double s = 0.1/64.;
|
||||
const real_t s = 0.1/64.;
|
||||
|
||||
v = 0.0;
|
||||
v(dim-1) = s*x(0)*x(0)*(8.0-x(0));
|
||||
|
||||
+5
-4
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
|
||||
m->AddDomainIntegrator(new MassIntegrator(one));
|
||||
m->Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m->Finalize();
|
||||
|
||||
HypreParMatrix *A = a->ParallelAssemble();
|
||||
@@ -262,12 +262,13 @@ int main(int argc, char *argv[])
|
||||
#ifdef MFEM_USE_STRUMPACK
|
||||
if (sp_solver)
|
||||
{
|
||||
STRUMPACKSolver * strumpack = new STRUMPACKSolver(argc, argv, MPI_COMM_WORLD);
|
||||
STRUMPACKSolver * strumpack = new STRUMPACKSolver(MPI_COMM_WORLD, argc, argv);
|
||||
strumpack->SetPrintFactorStatistics(true);
|
||||
strumpack->SetPrintSolveStatistics(false);
|
||||
strumpack->SetKrylovSolver(strumpack::KrylovSolver::DIRECT);
|
||||
strumpack->SetReorderingStrategy(strumpack::ReorderingStrategy::METIS);
|
||||
strumpack->DisableMatching();
|
||||
strumpack->SetMatching(strumpack::MatchingJob::NONE);
|
||||
strumpack->SetCompression(strumpack::CompressionType::NONE);
|
||||
strumpack->SetOperator(*Arow);
|
||||
strumpack->SetFromCommandLine();
|
||||
precond = strumpack;
|
||||
@@ -299,7 +300,7 @@ int main(int argc, char *argv[])
|
||||
// 9. Compute the eigenmodes and extract the array of eigenvalues. Define a
|
||||
// parallel grid function to represent each of the eigenmodes returned by
|
||||
// the solver.
|
||||
Array<double> eigenvalues;
|
||||
Array<real_t> eigenvalues;
|
||||
lobpcg->Solve();
|
||||
lobpcg->GetEigenvalues(eigenvalues);
|
||||
ParGridFunction x(fespace);
|
||||
|
||||
+2
-2
@@ -206,7 +206,7 @@ int main(int argc, char *argv[])
|
||||
m->AddDomainIntegrator(new VectorMassIntegrator());
|
||||
m->Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m->Finalize();
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -247,7 +247,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Compute the eigenmodes and extract the array of eigenvalues. Define a
|
||||
// parallel grid function to represent each of the eigenmodes returned by
|
||||
// the solver.
|
||||
Array<double> eigenvalues;
|
||||
Array<real_t> eigenvalues;
|
||||
lobpcg->Solve();
|
||||
lobpcg->GetEigenvalues(eigenvalues);
|
||||
ParGridFunction x(fespace);
|
||||
|
||||
+2
-2
@@ -170,7 +170,7 @@ int main(int argc, char *argv[])
|
||||
m->AddDomainIntegrator(new VectorFEMassIntegrator(one));
|
||||
m->Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m->EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m->Finalize();
|
||||
|
||||
HypreParMatrix *A = a->ParallelAssemble();
|
||||
@@ -198,7 +198,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Compute the eigenmodes and extract the array of eigenvalues. Define a
|
||||
// parallel grid function to represent each of the eigenmodes returned by
|
||||
// the solver.
|
||||
Array<double> eigenvalues;
|
||||
Array<real_t> eigenvalues;
|
||||
ame->Solve();
|
||||
ame->GetEigenvalues(eigenvalues);
|
||||
ParGridFunction x(fespace);
|
||||
|
||||
+3
-3
@@ -43,9 +43,9 @@ int main(int argc, char *argv[])
|
||||
const char *mesh_file = "../data/star.mesh";
|
||||
int ref_levels = -1;
|
||||
int order = 1;
|
||||
double sigma = -1.0;
|
||||
double kappa = -1.0;
|
||||
double eta = 0.0;
|
||||
real_t sigma = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
real_t eta = 0.0;
|
||||
bool visualization = 1;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
|
||||
+4
-4
@@ -44,7 +44,7 @@ public:
|
||||
pmesh(m),
|
||||
pgf(f) {}
|
||||
|
||||
void MonitorSolution(int i, double norm, const Vector &x, bool final)
|
||||
void MonitorSolution(int i, real_t norm, const Vector &x, bool final)
|
||||
{
|
||||
char vishost[] = "localhost";
|
||||
int visport = 19916;
|
||||
@@ -81,9 +81,9 @@ int main(int argc, char *argv[])
|
||||
int ser_ref_levels = -1;
|
||||
int par_ref_levels = 2;
|
||||
int order = 1;
|
||||
double sigma = -1.0;
|
||||
double kappa = -1.0;
|
||||
double eta = 0.0;
|
||||
real_t sigma = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
real_t eta = 0.0;
|
||||
bool visualization = 1;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
|
||||
+30
-30
@@ -63,8 +63,8 @@ int problem;
|
||||
int nfeatures;
|
||||
|
||||
// Prescribed time-dependent boundary and right-hand side functions.
|
||||
double bdr_func(const Vector &pt, double t);
|
||||
double rhs_func(const Vector &pt, double t);
|
||||
real_t bdr_func(const Vector &pt, real_t t);
|
||||
real_t rhs_func(const Vector &pt, real_t t);
|
||||
|
||||
// Update the finite element space, interpolate the solution and perform
|
||||
// parallel load balancing.
|
||||
@@ -79,9 +79,9 @@ int main(int argc, char *argv[])
|
||||
nfeatures = 1;
|
||||
const char *mesh_file = "../data/star-hilbert.mesh";
|
||||
int order = 2;
|
||||
double t_final = 1.0;
|
||||
double max_elem_error = 5.0e-3;
|
||||
double hysteresis = 0.15; // derefinement safety coefficient
|
||||
real_t t_final = 1.0;
|
||||
real_t max_elem_error = 5.0e-3;
|
||||
real_t hysteresis = 0.15; // derefinement safety coefficient
|
||||
int ref_levels = 0;
|
||||
int nc_limit = 3; // maximum level of hanging nodes
|
||||
bool visualization = true;
|
||||
@@ -247,7 +247,7 @@ int main(int argc, char *argv[])
|
||||
// refine the mesh as many times as necessary. Then we derefine any
|
||||
// elements which have very small errors.
|
||||
x = 0.0;
|
||||
for (double time = 0.0; time < t_final + 1e-10; time += 0.01)
|
||||
for (real_t time = 0.0; time < t_final + 1e-10; time += 0.01)
|
||||
{
|
||||
cout << "\nTime " << time << "\n\nRefinement:" << endl;
|
||||
|
||||
@@ -366,47 +366,47 @@ void UpdateProblem(Mesh &mesh, FiniteElementSpace &fespace,
|
||||
}
|
||||
|
||||
|
||||
const double alpha = 0.02;
|
||||
const real_t alpha = 0.02;
|
||||
|
||||
// Spherical front with a Gaussian cross section and radius t
|
||||
double front(double x, double y, double z, double t, int)
|
||||
real_t front(real_t x, real_t y, real_t z, real_t t, int)
|
||||
{
|
||||
double r = sqrt(x*x + y*y + z*z);
|
||||
real_t r = sqrt(x*x + y*y + z*z);
|
||||
return exp(-0.5*pow((r - t)/alpha, 2));
|
||||
}
|
||||
|
||||
double front_laplace(double x, double y, double z, double t, int dim)
|
||||
real_t front_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
|
||||
{
|
||||
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
|
||||
double r = sqrt(x2 + y2 + z2);
|
||||
double a2 = alpha*alpha, a4 = a2*a2;
|
||||
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
|
||||
real_t r = sqrt(x2 + y2 + z2);
|
||||
real_t a2 = alpha*alpha, a4 = a2*a2;
|
||||
return -exp(-0.5*pow((r - t)/alpha, 2)) / a4 *
|
||||
(-2*t*(x2 + y2 + z2 - (dim-1)*a2/2)/r + x2 + y2 + z2 + t2 - dim*a2);
|
||||
}
|
||||
|
||||
// Smooth spherical step function with radius t
|
||||
double ball(double x, double y, double z, double t, int)
|
||||
real_t ball(real_t x, real_t y, real_t z, real_t t, int)
|
||||
{
|
||||
double r = sqrt(x*x + y*y + z*z);
|
||||
real_t r = sqrt(x*x + y*y + z*z);
|
||||
return -atan(2*(r - t)/alpha);
|
||||
}
|
||||
|
||||
double ball_laplace(double x, double y, double z, double t, int dim)
|
||||
real_t ball_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
|
||||
{
|
||||
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
|
||||
double r = sqrt(x2 + y2 + z2);
|
||||
double a2 = alpha*alpha;
|
||||
double den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
|
||||
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
|
||||
real_t r = sqrt(x2 + y2 + z2);
|
||||
real_t a2 = alpha*alpha;
|
||||
real_t den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
|
||||
return (dim == 2) ? 2*alpha*(a2 + t2 - 4*x2 - 4*y2)/r/den
|
||||
/* */ : 4*alpha*(a2 + t2 - 4*r*t)/r/den;
|
||||
}
|
||||
|
||||
// Composes several features into one function
|
||||
template<typename F0, typename F1>
|
||||
double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
real_t composite_func(const Vector &pt, real_t t, F0 f0, F1 f1)
|
||||
{
|
||||
int dim = pt.Size();
|
||||
double x = pt(0), y = pt(1), z = 0.0;
|
||||
real_t x = pt(0), y = pt(1), z = 0.0;
|
||||
if (dim == 3) { z = pt(2); }
|
||||
|
||||
if (problem == 0)
|
||||
@@ -417,11 +417,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
else
|
||||
{
|
||||
double sum = 0.0;
|
||||
real_t sum = 0.0;
|
||||
for (int i = 0; i < nfeatures; i++)
|
||||
{
|
||||
double x0 = 0.5*cos(2*M_PI * i / nfeatures);
|
||||
double y0 = 0.5*sin(2*M_PI * i / nfeatures);
|
||||
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures);
|
||||
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures);
|
||||
sum += f0(x - x0, y - y0, z, t, dim);
|
||||
}
|
||||
return sum;
|
||||
@@ -429,11 +429,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
else
|
||||
{
|
||||
double sum = 0.0;
|
||||
real_t sum = 0.0;
|
||||
for (int i = 0; i < nfeatures; i++)
|
||||
{
|
||||
double x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
|
||||
double y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
|
||||
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
|
||||
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
|
||||
sum += f1(x - x0, y - y0, z, 0.25, dim);
|
||||
}
|
||||
return sum;
|
||||
@@ -441,13 +441,13 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
|
||||
// Exact solution, used for the Dirichlet BC.
|
||||
double bdr_func(const Vector &pt, double t)
|
||||
real_t bdr_func(const Vector &pt, real_t t)
|
||||
{
|
||||
return composite_func(pt, t, front, ball);
|
||||
}
|
||||
|
||||
// Laplace of the exact solution, used for the right hand side.
|
||||
double rhs_func(const Vector &pt, double t)
|
||||
real_t rhs_func(const Vector &pt, real_t t)
|
||||
{
|
||||
return composite_func(pt, t, front_laplace, ball_laplace);
|
||||
}
|
||||
|
||||
+30
-30
@@ -68,8 +68,8 @@ int problem;
|
||||
int nfeatures;
|
||||
|
||||
// Prescribed time-dependent boundary and right-hand side functions.
|
||||
double bdr_func(const Vector &pt, double t);
|
||||
double rhs_func(const Vector &pt, double t);
|
||||
real_t bdr_func(const Vector &pt, real_t t);
|
||||
real_t rhs_func(const Vector &pt, real_t t);
|
||||
|
||||
// Update the finite element space, interpolate the solution and perform
|
||||
// parallel load balancing.
|
||||
@@ -91,9 +91,9 @@ int main(int argc, char *argv[])
|
||||
nfeatures = 1;
|
||||
const char *mesh_file = "../data/star-hilbert.mesh";
|
||||
int order = 2;
|
||||
double t_final = 1.0;
|
||||
double max_elem_error = 1.0e-4;
|
||||
double hysteresis = 0.25; // derefinement safety coefficient
|
||||
real_t t_final = 1.0;
|
||||
real_t max_elem_error = 1.0e-4;
|
||||
real_t hysteresis = 0.25; // derefinement safety coefficient
|
||||
int ref_levels = 0;
|
||||
int nc_limit = 3; // maximum level of hanging nodes
|
||||
bool visualization = true;
|
||||
@@ -282,7 +282,7 @@ int main(int argc, char *argv[])
|
||||
// solve the problem on the current mesh, visualize the solution and
|
||||
// refine the mesh as many times as necessary. Then we derefine any
|
||||
// elements which have very small errors.
|
||||
for (double time = 0.0; time < t_final + 1e-10; time += 0.01)
|
||||
for (real_t time = 0.0; time < t_final + 1e-10; time += 0.01)
|
||||
{
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -427,47 +427,47 @@ void UpdateAndRebalance(ParMesh &pmesh, ParFiniteElementSpace &fespace,
|
||||
}
|
||||
|
||||
|
||||
const double alpha = 0.02;
|
||||
const real_t alpha = 0.02;
|
||||
|
||||
// Spherical front with a Gaussian cross section and radius t
|
||||
double front(double x, double y, double z, double t, int)
|
||||
real_t front(real_t x, real_t y, real_t z, real_t t, int)
|
||||
{
|
||||
double r = sqrt(x*x + y*y + z*z);
|
||||
real_t r = sqrt(x*x + y*y + z*z);
|
||||
return exp(-0.5*pow((r - t)/alpha, 2));
|
||||
}
|
||||
|
||||
double front_laplace(double x, double y, double z, double t, int dim)
|
||||
real_t front_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
|
||||
{
|
||||
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
|
||||
double r = sqrt(x2 + y2 + z2);
|
||||
double a2 = alpha*alpha, a4 = a2*a2;
|
||||
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = t*t;
|
||||
real_t r = sqrt(x2 + y2 + z2);
|
||||
real_t a2 = alpha*alpha, a4 = a2*a2;
|
||||
return -exp(-0.5*pow((r - t)/alpha, 2)) / a4 *
|
||||
(-2*t*(x2 + y2 + z2 - (dim-1)*a2/2)/r + x2 + y2 + z2 + t2 - dim*a2);
|
||||
}
|
||||
|
||||
// Smooth spherical step function with radius t
|
||||
double ball(double x, double y, double z, double t, int)
|
||||
real_t ball(real_t x, real_t y, real_t z, real_t t, int)
|
||||
{
|
||||
double r = sqrt(x*x + y*y + z*z);
|
||||
real_t r = sqrt(x*x + y*y + z*z);
|
||||
return -atan(2*(r - t)/alpha);
|
||||
}
|
||||
|
||||
double ball_laplace(double x, double y, double z, double t, int dim)
|
||||
real_t ball_laplace(real_t x, real_t y, real_t z, real_t t, int dim)
|
||||
{
|
||||
double x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
|
||||
double r = sqrt(x2 + y2 + z2);
|
||||
double a2 = alpha*alpha;
|
||||
double den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
|
||||
real_t x2 = x*x, y2 = y*y, z2 = z*z, t2 = 4*t*t;
|
||||
real_t r = sqrt(x2 + y2 + z2);
|
||||
real_t a2 = alpha*alpha;
|
||||
real_t den = pow(-a2 - 4*(x2 + y2 + z2 - 2*r*t) - t2, 2.0);
|
||||
return (dim == 2) ? 2*alpha*(a2 + t2 - 4*x2 - 4*y2)/r/den
|
||||
/* */ : 4*alpha*(a2 + t2 - 4*r*t)/r/den;
|
||||
}
|
||||
|
||||
// Composes several features into one function
|
||||
template<typename F0, typename F1>
|
||||
double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
real_t composite_func(const Vector &pt, real_t t, F0 f0, F1 f1)
|
||||
{
|
||||
int dim = pt.Size();
|
||||
double x = pt(0), y = pt(1), z = 0.0;
|
||||
real_t x = pt(0), y = pt(1), z = 0.0;
|
||||
if (dim == 3) { z = pt(2); }
|
||||
|
||||
if (problem == 0)
|
||||
@@ -478,11 +478,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
else
|
||||
{
|
||||
double sum = 0.0;
|
||||
real_t sum = 0.0;
|
||||
for (int i = 0; i < nfeatures; i++)
|
||||
{
|
||||
double x0 = 0.5*cos(2*M_PI * i / nfeatures);
|
||||
double y0 = 0.5*sin(2*M_PI * i / nfeatures);
|
||||
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures);
|
||||
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures);
|
||||
sum += f0(x - x0, y - y0, z, t, dim);
|
||||
}
|
||||
return sum;
|
||||
@@ -490,11 +490,11 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
else
|
||||
{
|
||||
double sum = 0.0;
|
||||
real_t sum = 0.0;
|
||||
for (int i = 0; i < nfeatures; i++)
|
||||
{
|
||||
double x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
|
||||
double y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
|
||||
real_t x0 = 0.5*cos(2*M_PI * i / nfeatures + M_PI*t);
|
||||
real_t y0 = 0.5*sin(2*M_PI * i / nfeatures + M_PI*t);
|
||||
sum += f1(x - x0, y - y0, z, 0.25, dim);
|
||||
}
|
||||
return sum;
|
||||
@@ -502,13 +502,13 @@ double composite_func(const Vector &pt, double t, F0 f0, F1 f1)
|
||||
}
|
||||
|
||||
// Exact solution, used for the Dirichlet BC.
|
||||
double bdr_func(const Vector &pt, double t)
|
||||
real_t bdr_func(const Vector &pt, real_t t)
|
||||
{
|
||||
return composite_func(pt, t, front, ball);
|
||||
}
|
||||
|
||||
// Laplace of the exact solution, used for the right hand side.
|
||||
double rhs_func(const Vector &pt, double t)
|
||||
real_t rhs_func(const Vector &pt, real_t t)
|
||||
{
|
||||
return composite_func(pt, t, front_laplace, ball_laplace);
|
||||
}
|
||||
|
||||
+17
-17
@@ -60,7 +60,7 @@ protected:
|
||||
|
||||
SparseMatrix Mmat, Kmat;
|
||||
SparseMatrix *T; // T = M + dt K
|
||||
double current_dt;
|
||||
real_t current_dt;
|
||||
|
||||
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
|
||||
DSmoother M_prec; // Preconditioner for the mass matrix M
|
||||
@@ -68,18 +68,18 @@ protected:
|
||||
CGSolver T_solver; // Implicit solver for T = M + dt K
|
||||
DSmoother T_prec; // Preconditioner for the implicit solver
|
||||
|
||||
double alpha, kappa;
|
||||
real_t alpha, kappa;
|
||||
|
||||
mutable Vector z; // auxiliary vector
|
||||
|
||||
public:
|
||||
ConductionOperator(FiniteElementSpace &f, double alpha, double kappa,
|
||||
ConductionOperator(FiniteElementSpace &f, real_t alpha, real_t kappa,
|
||||
const Vector &u);
|
||||
|
||||
virtual void Mult(const Vector &u, Vector &du_dt) const;
|
||||
/** Solve the Backward-Euler equation: k = f(u + dt*k, t), for the unknown k.
|
||||
This is the only requirement for high-order SDIRK implicit integration.*/
|
||||
virtual void ImplicitSolve(const double dt, const Vector &u, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &u, Vector &k);
|
||||
|
||||
/// Update the diffusion BilinearForm K using the given true-dof vector `u`.
|
||||
void SetParameters(const Vector &u);
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
virtual ~ConductionOperator();
|
||||
};
|
||||
|
||||
double InitialTemperature(const Vector &x);
|
||||
real_t InitialTemperature(const Vector &x);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -96,10 +96,10 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 2;
|
||||
int order = 2;
|
||||
int ode_solver_type = 3;
|
||||
double t_final = 0.5;
|
||||
double dt = 1.0e-2;
|
||||
double alpha = 1.0e-2;
|
||||
double kappa = 0.5;
|
||||
real_t t_final = 0.5;
|
||||
real_t dt = 1.0e-2;
|
||||
real_t alpha = 1.0e-2;
|
||||
real_t kappa = 0.5;
|
||||
bool visualization = true;
|
||||
bool visit = false;
|
||||
int vis_steps = 5;
|
||||
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
|
||||
// 8. Perform time-integration (looping over the time iterations, ti, with a
|
||||
// time-step dt).
|
||||
ode_solver->Init(oper);
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
|
||||
bool last_step = false;
|
||||
for (int ti = 1; !last_step; ti++)
|
||||
@@ -293,12 +293,12 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConductionOperator::ConductionOperator(FiniteElementSpace &f, double al,
|
||||
double kap, const Vector &u)
|
||||
: TimeDependentOperator(f.GetTrueVSize(), 0.0), fespace(f), M(NULL), K(NULL),
|
||||
T(NULL), current_dt(0.0), z(height)
|
||||
ConductionOperator::ConductionOperator(FiniteElementSpace &f, real_t al,
|
||||
real_t kap, const Vector &u)
|
||||
: TimeDependentOperator(f.GetTrueVSize(), (real_t) 0.0), fespace(f),
|
||||
M(NULL), K(NULL), T(NULL), current_dt(0.0), z(height)
|
||||
{
|
||||
const double rel_tol = 1e-8;
|
||||
const real_t rel_tol = 1e-8;
|
||||
|
||||
M = new BilinearForm(&fespace);
|
||||
M->AddDomainIntegrator(new MassIntegrator());
|
||||
@@ -336,7 +336,7 @@ void ConductionOperator::Mult(const Vector &u, Vector &du_dt) const
|
||||
M_solver.Mult(z, du_dt);
|
||||
}
|
||||
|
||||
void ConductionOperator::ImplicitSolve(const double dt,
|
||||
void ConductionOperator::ImplicitSolve(const real_t dt,
|
||||
const Vector &u, Vector &du_dt)
|
||||
{
|
||||
// Solve the equation:
|
||||
@@ -382,7 +382,7 @@ ConductionOperator::~ConductionOperator()
|
||||
delete K;
|
||||
}
|
||||
|
||||
double InitialTemperature(const Vector &x)
|
||||
real_t InitialTemperature(const Vector &x)
|
||||
{
|
||||
if (x.Norml2() < 0.5)
|
||||
{
|
||||
|
||||
+17
-17
@@ -62,7 +62,7 @@ protected:
|
||||
HypreParMatrix Mmat;
|
||||
HypreParMatrix Kmat;
|
||||
HypreParMatrix *T; // T = M + dt K
|
||||
double current_dt;
|
||||
real_t current_dt;
|
||||
|
||||
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
|
||||
HypreSmoother M_prec; // Preconditioner for the mass matrix M
|
||||
@@ -70,18 +70,18 @@ protected:
|
||||
CGSolver T_solver; // Implicit solver for T = M + dt K
|
||||
HypreSmoother T_prec; // Preconditioner for the implicit solver
|
||||
|
||||
double alpha, kappa;
|
||||
real_t alpha, kappa;
|
||||
|
||||
mutable Vector z; // auxiliary vector
|
||||
|
||||
public:
|
||||
ConductionOperator(ParFiniteElementSpace &f, double alpha, double kappa,
|
||||
ConductionOperator(ParFiniteElementSpace &f, real_t alpha, real_t kappa,
|
||||
const Vector &u);
|
||||
|
||||
virtual void Mult(const Vector &u, Vector &du_dt) const;
|
||||
/** Solve the Backward-Euler equation: k = f(u + dt*k, t), for the unknown k.
|
||||
This is the only requirement for high-order SDIRK implicit integration.*/
|
||||
virtual void ImplicitSolve(const double dt, const Vector &u, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &u, Vector &k);
|
||||
|
||||
/// Update the diffusion BilinearForm K using the given true-dof vector `u`.
|
||||
void SetParameters(const Vector &u);
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
virtual ~ConductionOperator();
|
||||
};
|
||||
|
||||
double InitialTemperature(const Vector &x);
|
||||
real_t InitialTemperature(const Vector &x);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -105,10 +105,10 @@ int main(int argc, char *argv[])
|
||||
int par_ref_levels = 1;
|
||||
int order = 2;
|
||||
int ode_solver_type = 3;
|
||||
double t_final = 0.5;
|
||||
double dt = 1.0e-2;
|
||||
double alpha = 1.0e-2;
|
||||
double kappa = 0.5;
|
||||
real_t t_final = 0.5;
|
||||
real_t dt = 1.0e-2;
|
||||
real_t alpha = 1.0e-2;
|
||||
real_t kappa = 0.5;
|
||||
bool visualization = true;
|
||||
bool visit = false;
|
||||
int vis_steps = 5;
|
||||
@@ -313,7 +313,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Perform time-integration (looping over the time iterations, ti, with a
|
||||
// time-step dt).
|
||||
ode_solver->Init(oper);
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
|
||||
bool last_step = false;
|
||||
for (int ti = 1; !last_step; ti++)
|
||||
@@ -382,13 +382,13 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
ConductionOperator::ConductionOperator(ParFiniteElementSpace &f, double al,
|
||||
double kap, const Vector &u)
|
||||
: TimeDependentOperator(f.GetTrueVSize(), 0.0), fespace(f), M(NULL), K(NULL),
|
||||
T(NULL), current_dt(0.0),
|
||||
ConductionOperator::ConductionOperator(ParFiniteElementSpace &f, real_t al,
|
||||
real_t kap, const Vector &u)
|
||||
: TimeDependentOperator(f.GetTrueVSize(), (real_t) 0.0), fespace(f),
|
||||
M(NULL), K(NULL), T(NULL), current_dt(0.0),
|
||||
M_solver(f.GetComm()), T_solver(f.GetComm()), z(height)
|
||||
{
|
||||
const double rel_tol = 1e-8;
|
||||
const real_t rel_tol = 1e-8;
|
||||
|
||||
M = new ParBilinearForm(&fespace);
|
||||
M->AddDomainIntegrator(new MassIntegrator());
|
||||
@@ -427,7 +427,7 @@ void ConductionOperator::Mult(const Vector &u, Vector &du_dt) const
|
||||
M_solver.Mult(z, du_dt);
|
||||
}
|
||||
|
||||
void ConductionOperator::ImplicitSolve(const double dt,
|
||||
void ConductionOperator::ImplicitSolve(const real_t dt,
|
||||
const Vector &u, Vector &du_dt)
|
||||
{
|
||||
// Solve the equation:
|
||||
@@ -473,7 +473,7 @@ ConductionOperator::~ConductionOperator()
|
||||
delete K;
|
||||
}
|
||||
|
||||
double InitialTemperature(const Vector &x)
|
||||
real_t InitialTemperature(const Vector &x)
|
||||
{
|
||||
if (x.Norml2() < 0.5)
|
||||
{
|
||||
|
||||
+8
-8
@@ -69,7 +69,7 @@ public:
|
||||
void SetDisplacement(GridFunction &u_) { u = &u_; }
|
||||
void SetComponent(int i, int j) { si = i; sj = j; }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
// Simple GLVis visualization manager.
|
||||
@@ -104,8 +104,8 @@ int main(int argc, char *argv[])
|
||||
const char *mesh_file = "../data/beam-tri.mesh";
|
||||
int ref_levels = -1;
|
||||
int order = 1;
|
||||
double alpha = -1.0;
|
||||
double kappa = -1.0;
|
||||
real_t alpha = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
bool visualization = 1;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
@@ -245,7 +245,7 @@ int main(int argc, char *argv[])
|
||||
// solve the system Ax=b with PCG for the symmetric formulation, or GMRES
|
||||
// for the non-symmetric.
|
||||
GSSmoother M(A);
|
||||
const double rtol = 1e-6;
|
||||
const real_t rtol = 1e-6;
|
||||
if (alpha == -1.0)
|
||||
{
|
||||
PCG(A, M, B, X, 3, 5000, rtol*rtol, 0.0);
|
||||
@@ -337,17 +337,17 @@ void InitDisplacement(const Vector &x, Vector &u)
|
||||
}
|
||||
|
||||
|
||||
double StressCoefficient::Eval(ElementTransformation &T,
|
||||
real_t StressCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "displacement field is not set");
|
||||
|
||||
double L = lambda.Eval(T, ip);
|
||||
double M = mu.Eval(T, ip);
|
||||
real_t L = lambda.Eval(T, ip);
|
||||
real_t M = mu.Eval(T, ip);
|
||||
u->GetVectorGradient(T, grad);
|
||||
if (si == sj)
|
||||
{
|
||||
double div_u = grad.Trace();
|
||||
real_t div_u = grad.Trace();
|
||||
return L*div_u + 2*M*grad(si,si);
|
||||
}
|
||||
else
|
||||
|
||||
+8
-8
@@ -69,7 +69,7 @@ public:
|
||||
void SetDisplacement(GridFunction &u_) { u = &u_; }
|
||||
void SetComponent(int i, int j) { si = i; sj = j; }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
// Simple GLVis visualization manager.
|
||||
@@ -108,8 +108,8 @@ int main(int argc, char *argv[])
|
||||
int ser_ref_levels = -1;
|
||||
int par_ref_levels = 1;
|
||||
int order = 1;
|
||||
double alpha = -1.0;
|
||||
double kappa = -1.0;
|
||||
real_t alpha = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
bool amg_elast = false;
|
||||
bool visualization = 1;
|
||||
|
||||
@@ -268,7 +268,7 @@ int main(int argc, char *argv[])
|
||||
// 11. Define a simple symmetric Gauss-Seidel preconditioner and use it to
|
||||
// solve the system Ax=b with PCG for the symmetric formulation, or GMRES
|
||||
// for the non-symmetric.
|
||||
const double rtol = 1e-6;
|
||||
const real_t rtol = 1e-6;
|
||||
HypreBoomerAMG amg(A);
|
||||
if (amg_elast)
|
||||
{
|
||||
@@ -376,17 +376,17 @@ void InitDisplacement(const Vector &x, Vector &u)
|
||||
}
|
||||
|
||||
|
||||
double StressCoefficient::Eval(ElementTransformation &T,
|
||||
real_t StressCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "displacement field is not set");
|
||||
|
||||
double L = lambda.Eval(T, ip);
|
||||
double M = mu.Eval(T, ip);
|
||||
real_t L = lambda.Eval(T, ip);
|
||||
real_t M = mu.Eval(T, ip);
|
||||
u->GetVectorGradient(T, grad);
|
||||
if (si == sj)
|
||||
{
|
||||
double div_u = grad.Trace();
|
||||
real_t div_u = grad.Trace();
|
||||
return L*div_u + 2*M*grad(si,si);
|
||||
}
|
||||
else
|
||||
|
||||
+10
-10
@@ -52,11 +52,11 @@ int problem;
|
||||
|
||||
// Equation constant parameters.
|
||||
const int num_equation = 4;
|
||||
const double specific_heat_ratio = 1.4;
|
||||
const double gas_constant = 1.0;
|
||||
const real_t specific_heat_ratio = 1.4;
|
||||
const real_t gas_constant = 1.0;
|
||||
|
||||
// Maximum characteristic speed (updated by integrators)
|
||||
double max_char_speed;
|
||||
real_t max_char_speed;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -66,9 +66,9 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 1;
|
||||
int order = 3;
|
||||
int ode_solver_type = 4;
|
||||
double t_final = 2.0;
|
||||
double dt = -0.01;
|
||||
double cfl = 0.3;
|
||||
real_t t_final = 2.0;
|
||||
real_t dt = -0.01;
|
||||
real_t cfl = 0.3;
|
||||
bool visualization = true;
|
||||
int vis_steps = 50;
|
||||
|
||||
@@ -228,7 +228,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Determine the minimum element size.
|
||||
double hmin = 0.0;
|
||||
real_t hmin = 0.0;
|
||||
if (cfl > 0)
|
||||
{
|
||||
hmin = mesh.GetElementSize(0, 1);
|
||||
@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
|
||||
tic_toc.Clear();
|
||||
tic_toc.Start();
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
euler.SetTime(t);
|
||||
ode_solver->Init(euler);
|
||||
|
||||
@@ -260,7 +260,7 @@ int main(int argc, char *argv[])
|
||||
bool done = false;
|
||||
for (int ti = 0; !done; )
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
|
||||
ode_solver->Step(sol, t, dt_real);
|
||||
if (cfl > 0)
|
||||
@@ -298,7 +298,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Compute the L2 solution error summed for all components.
|
||||
if (t_final == 2.0)
|
||||
{
|
||||
const double error = sol.ComputeLpError(2, u0);
|
||||
const real_t error = sol.ComputeLpError(2, u0);
|
||||
cout << "Solution error: " << error << endl;
|
||||
}
|
||||
|
||||
|
||||
+50
-50
@@ -9,11 +9,11 @@ using namespace mfem;
|
||||
extern int problem;
|
||||
|
||||
// Maximum characteristic speed (updated by integrators)
|
||||
extern double max_char_speed;
|
||||
extern real_t max_char_speed;
|
||||
|
||||
extern const int num_equation;
|
||||
extern const double specific_heat_ratio;
|
||||
extern const double gas_constant;
|
||||
extern const real_t specific_heat_ratio;
|
||||
extern const real_t gas_constant;
|
||||
|
||||
// Time-dependent operator for the right-hand side of the ODE representing the
|
||||
// DG weak form.
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
|
||||
public:
|
||||
RiemannSolver();
|
||||
double Eval(const Vector &state1, const Vector &state2,
|
||||
real_t Eval(const Vector &state1, const Vector &state2,
|
||||
const Vector &nor, Vector &flux);
|
||||
};
|
||||
|
||||
@@ -149,13 +149,13 @@ void FE_Evolution::Mult(const Vector &x, Vector &y) const
|
||||
bool StateIsPhysical(const Vector &state, const int dim);
|
||||
|
||||
// Pressure (EOS) computation
|
||||
inline double ComputePressure(const Vector &state, int dim)
|
||||
inline real_t ComputePressure(const Vector &state, int dim)
|
||||
{
|
||||
const double den = state(0);
|
||||
const real_t den = state(0);
|
||||
const Vector den_vel(state.GetData() + 1, dim);
|
||||
const double den_energy = state(1 + dim);
|
||||
const real_t den_energy = state(1 + dim);
|
||||
|
||||
double den_vel2 = 0;
|
||||
real_t den_vel2 = 0;
|
||||
for (int d = 0; d < dim; d++) { den_vel2 += den_vel(d) * den_vel(d); }
|
||||
den_vel2 /= den;
|
||||
|
||||
@@ -165,13 +165,13 @@ inline double ComputePressure(const Vector &state, int dim)
|
||||
// Compute the vector flux F(u)
|
||||
void ComputeFlux(const Vector &state, int dim, DenseMatrix &flux)
|
||||
{
|
||||
const double den = state(0);
|
||||
const real_t den = state(0);
|
||||
const Vector den_vel(state.GetData() + 1, dim);
|
||||
const double den_energy = state(1 + dim);
|
||||
const real_t den_energy = state(1 + dim);
|
||||
|
||||
MFEM_ASSERT(StateIsPhysical(state, dim), "");
|
||||
|
||||
const double pres = ComputePressure(state, dim);
|
||||
const real_t pres = ComputePressure(state, dim);
|
||||
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
@@ -183,7 +183,7 @@ void ComputeFlux(const Vector &state, int dim, DenseMatrix &flux)
|
||||
flux(1+d, d) += pres;
|
||||
}
|
||||
|
||||
const double H = (den_energy + pres) / den;
|
||||
const real_t H = (den_energy + pres) / den;
|
||||
for (int d = 0; d < dim; d++)
|
||||
{
|
||||
flux(1+dim, d) = den_vel(d) * H;
|
||||
@@ -196,15 +196,15 @@ void ComputeFluxDotN(const Vector &state, const Vector &nor,
|
||||
{
|
||||
// NOTE: nor in general is not a unit normal
|
||||
const int dim = nor.Size();
|
||||
const double den = state(0);
|
||||
const real_t den = state(0);
|
||||
const Vector den_vel(state.GetData() + 1, dim);
|
||||
const double den_energy = state(1 + dim);
|
||||
const real_t den_energy = state(1 + dim);
|
||||
|
||||
MFEM_ASSERT(StateIsPhysical(state, dim), "");
|
||||
|
||||
const double pres = ComputePressure(state, dim);
|
||||
const real_t pres = ComputePressure(state, dim);
|
||||
|
||||
double den_velN = 0;
|
||||
real_t den_velN = 0;
|
||||
for (int d = 0; d < dim; d++) { den_velN += den_vel(d) * nor(d); }
|
||||
|
||||
fluxN(0) = den_velN;
|
||||
@@ -213,23 +213,23 @@ void ComputeFluxDotN(const Vector &state, const Vector &nor,
|
||||
fluxN(1+d) = den_velN * den_vel(d) / den + pres * nor(d);
|
||||
}
|
||||
|
||||
const double H = (den_energy + pres) / den;
|
||||
const real_t H = (den_energy + pres) / den;
|
||||
fluxN(1 + dim) = den_velN * H;
|
||||
}
|
||||
|
||||
// Compute the maximum characteristic speed.
|
||||
inline double ComputeMaxCharSpeed(const Vector &state, const int dim)
|
||||
inline real_t ComputeMaxCharSpeed(const Vector &state, const int dim)
|
||||
{
|
||||
const double den = state(0);
|
||||
const real_t den = state(0);
|
||||
const Vector den_vel(state.GetData() + 1, dim);
|
||||
|
||||
double den_vel2 = 0;
|
||||
real_t den_vel2 = 0;
|
||||
for (int d = 0; d < dim; d++) { den_vel2 += den_vel(d) * den_vel(d); }
|
||||
den_vel2 /= den;
|
||||
|
||||
const double pres = ComputePressure(state, dim);
|
||||
const double sound = sqrt(specific_heat_ratio * pres / den);
|
||||
const double vel = sqrt(den_vel2 / den);
|
||||
const real_t pres = ComputePressure(state, dim);
|
||||
const real_t sound = sqrt(specific_heat_ratio * pres / den);
|
||||
const real_t vel = sqrt(den_vel2 / den);
|
||||
|
||||
return vel + sound;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ void FE_Evolution::GetFlux(const DenseMatrix &x_, DenseTensor &flux_) const
|
||||
}
|
||||
|
||||
// Update max char speed
|
||||
const double mcs = ComputeMaxCharSpeed(state, flux_dim);
|
||||
const real_t mcs = ComputeMaxCharSpeed(state, flux_dim);
|
||||
if (mcs > max_char_speed) { max_char_speed = mcs; }
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ RiemannSolver::RiemannSolver() :
|
||||
flux1(num_equation),
|
||||
flux2(num_equation) { }
|
||||
|
||||
double RiemannSolver::Eval(const Vector &state1, const Vector &state2,
|
||||
real_t RiemannSolver::Eval(const Vector &state1, const Vector &state2,
|
||||
const Vector &nor, Vector &flux)
|
||||
{
|
||||
// NOTE: nor in general is not a unit normal
|
||||
@@ -273,15 +273,15 @@ double RiemannSolver::Eval(const Vector &state1, const Vector &state2,
|
||||
MFEM_ASSERT(StateIsPhysical(state1, dim), "");
|
||||
MFEM_ASSERT(StateIsPhysical(state2, dim), "");
|
||||
|
||||
const double maxE1 = ComputeMaxCharSpeed(state1, dim);
|
||||
const double maxE2 = ComputeMaxCharSpeed(state2, dim);
|
||||
const real_t maxE1 = ComputeMaxCharSpeed(state1, dim);
|
||||
const real_t maxE2 = ComputeMaxCharSpeed(state2, dim);
|
||||
|
||||
const double maxE = max(maxE1, maxE2);
|
||||
const real_t maxE = max(maxE1, maxE2);
|
||||
|
||||
ComputeFluxDotN(state1, nor, flux1);
|
||||
ComputeFluxDotN(state2, nor, flux2);
|
||||
|
||||
double normag = 0;
|
||||
real_t normag = 0;
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
normag += nor(i) * nor(i);
|
||||
@@ -359,7 +359,7 @@ void FaceIntegrator::AssembleFaceVector(const FiniteElement &el1,
|
||||
|
||||
// Get the normal vector and the flux on the face
|
||||
CalcOrtho(Tr.Jacobian(), nor);
|
||||
const double mcs = rsolver.Eval(funval1, funval2, nor, fluxN);
|
||||
const real_t mcs = rsolver.Eval(funval1, funval2, nor, fluxN);
|
||||
|
||||
// Update max char speed
|
||||
if (mcs > max_char_speed) { max_char_speed = mcs; }
|
||||
@@ -382,9 +382,9 @@ void FaceIntegrator::AssembleFaceVector(const FiniteElement &el1,
|
||||
// Check that the state is physical - enabled in debug mode
|
||||
bool StateIsPhysical(const Vector &state, const int dim)
|
||||
{
|
||||
const double den = state(0);
|
||||
const real_t den = state(0);
|
||||
const Vector den_vel(state.GetData() + 1, dim);
|
||||
const double den_energy = state(1 + dim);
|
||||
const real_t den_energy = state(1 + dim);
|
||||
|
||||
if (den < 0)
|
||||
{
|
||||
@@ -407,11 +407,11 @@ bool StateIsPhysical(const Vector &state, const int dim)
|
||||
return false;
|
||||
}
|
||||
|
||||
double den_vel2 = 0;
|
||||
real_t den_vel2 = 0;
|
||||
for (int i = 0; i < dim; i++) { den_vel2 += den_vel(i) * den_vel(i); }
|
||||
den_vel2 /= den;
|
||||
|
||||
const double pres = (specific_heat_ratio - 1.0) * (den_energy - 0.5 * den_vel2);
|
||||
const real_t pres = (specific_heat_ratio - 1.0) * (den_energy - 0.5 * den_vel2);
|
||||
|
||||
if (pres <= 0)
|
||||
{
|
||||
@@ -431,7 +431,7 @@ void InitialCondition(const Vector &x, Vector &y)
|
||||
{
|
||||
MFEM_ASSERT(x.Size() == 2, "");
|
||||
|
||||
double radius = 0, Minf = 0, beta = 0;
|
||||
real_t radius = 0, Minf = 0, beta = 0;
|
||||
if (problem == 1)
|
||||
{
|
||||
// "Fast vortex"
|
||||
@@ -452,36 +452,36 @@ void InitialCondition(const Vector &x, Vector &y)
|
||||
"Options are: 1 - fast vortex, 2 - slow vortex");
|
||||
}
|
||||
|
||||
const double xc = 0.0, yc = 0.0;
|
||||
const real_t xc = 0.0, yc = 0.0;
|
||||
|
||||
// Nice units
|
||||
const double vel_inf = 1.;
|
||||
const double den_inf = 1.;
|
||||
const real_t vel_inf = 1.;
|
||||
const real_t den_inf = 1.;
|
||||
|
||||
// Derive remainder of background state from this and Minf
|
||||
const double pres_inf = (den_inf / specific_heat_ratio) * (vel_inf / Minf) *
|
||||
const real_t pres_inf = (den_inf / specific_heat_ratio) * (vel_inf / Minf) *
|
||||
(vel_inf / Minf);
|
||||
const double temp_inf = pres_inf / (den_inf * gas_constant);
|
||||
const real_t temp_inf = pres_inf / (den_inf * gas_constant);
|
||||
|
||||
double r2rad = 0.0;
|
||||
real_t r2rad = 0.0;
|
||||
r2rad += (x(0) - xc) * (x(0) - xc);
|
||||
r2rad += (x(1) - yc) * (x(1) - yc);
|
||||
r2rad /= (radius * radius);
|
||||
|
||||
const double shrinv1 = 1.0 / (specific_heat_ratio - 1.);
|
||||
const real_t shrinv1 = 1.0 / (specific_heat_ratio - 1.);
|
||||
|
||||
const double velX = vel_inf * (1 - beta * (x(1) - yc) / radius * exp(
|
||||
const real_t velX = vel_inf * (1 - beta * (x(1) - yc) / radius * exp(
|
||||
-0.5 * r2rad));
|
||||
const double velY = vel_inf * beta * (x(0) - xc) / radius * exp(-0.5 * r2rad);
|
||||
const double vel2 = velX * velX + velY * velY;
|
||||
const real_t velY = vel_inf * beta * (x(0) - xc) / radius * exp(-0.5 * r2rad);
|
||||
const real_t vel2 = velX * velX + velY * velY;
|
||||
|
||||
const double specific_heat = gas_constant * specific_heat_ratio * shrinv1;
|
||||
const double temp = temp_inf - 0.5 * (vel_inf * beta) *
|
||||
const real_t specific_heat = gas_constant * specific_heat_ratio * shrinv1;
|
||||
const real_t temp = temp_inf - 0.5 * (vel_inf * beta) *
|
||||
(vel_inf * beta) / specific_heat * exp(-r2rad);
|
||||
|
||||
const double den = den_inf * pow(temp/temp_inf, shrinv1);
|
||||
const double pres = den * gas_constant * temp;
|
||||
const double energy = shrinv1 * pres / den + 0.5 * vel2;
|
||||
const real_t den = den_inf * pow(temp/temp_inf, shrinv1);
|
||||
const real_t pres = den * gas_constant * temp;
|
||||
const real_t energy = shrinv1 * pres / den + 0.5 * vel2;
|
||||
|
||||
y(0) = den;
|
||||
y(1) = den * velX;
|
||||
|
||||
+19
-18
@@ -52,11 +52,11 @@ int problem;
|
||||
|
||||
// Equation constant parameters.
|
||||
const int num_equation = 4;
|
||||
const double specific_heat_ratio = 1.4;
|
||||
const double gas_constant = 1.0;
|
||||
const real_t specific_heat_ratio = 1.4;
|
||||
const real_t gas_constant = 1.0;
|
||||
|
||||
// Maximum characteristic speed (updated by integrators)
|
||||
double max_char_speed;
|
||||
real_t max_char_speed;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -71,9 +71,9 @@ int main(int argc, char *argv[])
|
||||
int par_ref_levels = 1;
|
||||
int order = 3;
|
||||
int ode_solver_type = 4;
|
||||
double t_final = 2.0;
|
||||
double dt = -0.01;
|
||||
double cfl = 0.3;
|
||||
real_t t_final = 2.0;
|
||||
real_t dt = -0.01;
|
||||
real_t cfl = 0.3;
|
||||
bool visualization = true;
|
||||
int vis_steps = 50;
|
||||
|
||||
@@ -270,23 +270,24 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Determine the minimum element size.
|
||||
double hmin;
|
||||
real_t hmin;
|
||||
if (cfl > 0)
|
||||
{
|
||||
double my_hmin = pmesh.GetElementSize(0, 1);
|
||||
real_t my_hmin = pmesh.GetElementSize(0, 1);
|
||||
for (int i = 1; i < pmesh.GetNE(); i++)
|
||||
{
|
||||
my_hmin = min(pmesh.GetElementSize(i, 1), my_hmin);
|
||||
}
|
||||
// Reduce to find the global minimum element size
|
||||
MPI_Allreduce(&my_hmin, &hmin, 1, MPI_DOUBLE, MPI_MIN, pmesh.GetComm());
|
||||
MPI_Allreduce(&my_hmin, &hmin, 1, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_MIN, pmesh.GetComm());
|
||||
}
|
||||
|
||||
// Start the timer.
|
||||
tic_toc.Clear();
|
||||
tic_toc.Start();
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
euler.SetTime(t);
|
||||
ode_solver->Init(euler);
|
||||
|
||||
@@ -299,9 +300,9 @@ int main(int argc, char *argv[])
|
||||
A.Mult(sol, z);
|
||||
// Reduce to find the global maximum wave speed
|
||||
{
|
||||
double all_max_char_speed;
|
||||
MPI_Allreduce(&max_char_speed, &all_max_char_speed,
|
||||
1, MPI_DOUBLE, MPI_MAX, pmesh.GetComm());
|
||||
real_t all_max_char_speed;
|
||||
MPI_Allreduce(&max_char_speed, &all_max_char_speed, 1,
|
||||
MPITypeMap<real_t>::mpi_type, MPI_MAX, pmesh.GetComm());
|
||||
max_char_speed = all_max_char_speed;
|
||||
}
|
||||
dt = cfl * hmin / max_char_speed / (2*order+1);
|
||||
@@ -311,16 +312,16 @@ int main(int argc, char *argv[])
|
||||
bool done = false;
|
||||
for (int ti = 0; !done; )
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
|
||||
ode_solver->Step(sol, t, dt_real);
|
||||
if (cfl > 0)
|
||||
{
|
||||
// Reduce to find the global maximum wave speed
|
||||
{
|
||||
double all_max_char_speed;
|
||||
MPI_Allreduce(&max_char_speed, &all_max_char_speed,
|
||||
1, MPI_DOUBLE, MPI_MAX, pmesh.GetComm());
|
||||
real_t all_max_char_speed;
|
||||
MPI_Allreduce(&max_char_speed, &all_max_char_speed, 1,
|
||||
MPITypeMap<real_t>::mpi_type, MPI_MAX, pmesh.GetComm());
|
||||
max_char_speed = all_max_char_speed;
|
||||
}
|
||||
dt = cfl * hmin / max_char_speed / (2*order+1);
|
||||
@@ -366,7 +367,7 @@ int main(int argc, char *argv[])
|
||||
// 12. Compute the L2 solution error summed for all components.
|
||||
if (t_final == 2.0)
|
||||
{
|
||||
const double error = sol.ComputeLpError(2, u0);
|
||||
const real_t error = sol.ComputeLpError(2, u0);
|
||||
if (Mpi::Root())
|
||||
{
|
||||
cout << "Solution error: " << error << endl;
|
||||
|
||||
+10
-10
@@ -48,15 +48,15 @@ public:
|
||||
print_level = print_lvl;
|
||||
}
|
||||
|
||||
virtual void MonitorResidual(int it, double norm, const Vector &r, bool final);
|
||||
virtual void MonitorResidual(int it, real_t norm, const Vector &r, bool final);
|
||||
|
||||
private:
|
||||
const std::string prefix;
|
||||
int print_level;
|
||||
mutable double norm0;
|
||||
mutable real_t norm0;
|
||||
};
|
||||
|
||||
void GeneralResidualMonitor::MonitorResidual(int it, double norm,
|
||||
void GeneralResidualMonitor::MonitorResidual(int it, real_t norm,
|
||||
const Vector &r, bool final)
|
||||
{
|
||||
if (print_level == 1 || (print_level == 3 && (final || it == 0)))
|
||||
@@ -103,7 +103,7 @@ protected:
|
||||
BlockOperator *jacobian;
|
||||
|
||||
// Scaling factor for the pressure mass matrix in the block preconditioner
|
||||
double gamma;
|
||||
real_t gamma;
|
||||
|
||||
// Objects for the block preconditioner application
|
||||
SparseMatrix *pressure_mass;
|
||||
@@ -157,7 +157,7 @@ protected:
|
||||
|
||||
public:
|
||||
RubberOperator(Array<FiniteElementSpace *> &fes, Array<Array<int> *>&ess_bdr,
|
||||
Array<int> &block_trueOffsets, double rel_tol, double abs_tol,
|
||||
Array<int> &block_trueOffsets, real_t rel_tol, real_t abs_tol,
|
||||
int iter, Coefficient &mu);
|
||||
|
||||
// Required to use the native newton solver
|
||||
@@ -187,10 +187,10 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 0;
|
||||
int order = 2;
|
||||
bool visualization = true;
|
||||
double newton_rel_tol = 1e-4;
|
||||
double newton_abs_tol = 1e-6;
|
||||
real_t newton_rel_tol = 1e-4;
|
||||
real_t newton_abs_tol = 1e-6;
|
||||
int newton_iter = 500;
|
||||
double mu = 1.0;
|
||||
real_t mu = 1.0;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&mesh_file, "-m", "--mesh",
|
||||
@@ -449,8 +449,8 @@ JacobianPreconditioner::~JacobianPreconditioner()
|
||||
RubberOperator::RubberOperator(Array<FiniteElementSpace *> &fes,
|
||||
Array<Array<int> *> &ess_bdr,
|
||||
Array<int> &offsets,
|
||||
double rel_tol,
|
||||
double abs_tol,
|
||||
real_t rel_tol,
|
||||
real_t abs_tol,
|
||||
int iter,
|
||||
Coefficient &c_mu)
|
||||
: Operator(fes[0]->GetTrueVSize() + fes[1]->GetTrueVSize()),
|
||||
|
||||
+10
-10
@@ -62,15 +62,15 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void MonitorResidual(int it, double norm, const Vector &r, bool final);
|
||||
virtual void MonitorResidual(int it, real_t norm, const Vector &r, bool final);
|
||||
|
||||
private:
|
||||
const std::string prefix;
|
||||
int print_level;
|
||||
mutable double norm0;
|
||||
mutable real_t norm0;
|
||||
};
|
||||
|
||||
void GeneralResidualMonitor::MonitorResidual(int it, double norm,
|
||||
void GeneralResidualMonitor::MonitorResidual(int it, real_t norm,
|
||||
const Vector &r, bool final)
|
||||
{
|
||||
if (print_level == 1 || (print_level == 3 && (final || it == 0)))
|
||||
@@ -117,7 +117,7 @@ protected:
|
||||
BlockOperator *jacobian;
|
||||
|
||||
// Scaling factor for the pressure mass matrix in the block preconditioner
|
||||
double gamma;
|
||||
real_t gamma;
|
||||
|
||||
// Objects for the block preconditioner application
|
||||
Operator *pressure_mass;
|
||||
@@ -171,7 +171,7 @@ protected:
|
||||
|
||||
public:
|
||||
RubberOperator(Array<ParFiniteElementSpace *> &fes, Array<Array<int> *>&ess_bdr,
|
||||
Array<int> &block_trueOffsets, double rel_tol, double abs_tol,
|
||||
Array<int> &block_trueOffsets, real_t rel_tol, real_t abs_tol,
|
||||
int iter, Coefficient &mu);
|
||||
|
||||
// Required to use the native newton solver
|
||||
@@ -214,10 +214,10 @@ int main(int argc, char *argv[])
|
||||
int par_ref_levels = 0;
|
||||
int order = 2;
|
||||
bool visualization = true;
|
||||
double newton_rel_tol = 1e-4;
|
||||
double newton_abs_tol = 1e-6;
|
||||
real_t newton_rel_tol = 1e-4;
|
||||
real_t newton_abs_tol = 1e-6;
|
||||
int newton_iter = 500;
|
||||
double mu = 1.0;
|
||||
real_t mu = 1.0;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&mesh_file, "-m", "--mesh",
|
||||
@@ -524,8 +524,8 @@ JacobianPreconditioner::~JacobianPreconditioner()
|
||||
RubberOperator::RubberOperator(Array<ParFiniteElementSpace *> &fes,
|
||||
Array<Array<int> *> &ess_bdr,
|
||||
Array<int> &trueOffsets,
|
||||
double rel_tol,
|
||||
double abs_tol,
|
||||
real_t rel_tol,
|
||||
real_t abs_tol,
|
||||
int iter,
|
||||
Coefficient &c_mu)
|
||||
: Operator(fes[0]->TrueVSize() + fes[1]->TrueVSize()),
|
||||
|
||||
+10
-10
@@ -69,11 +69,11 @@ using namespace mfem;
|
||||
|
||||
// Constants used in the Hamiltonian
|
||||
static int prob_ = 0;
|
||||
static double m_ = 1.0;
|
||||
static double k_ = 1.0;
|
||||
static real_t m_ = 1.0;
|
||||
static real_t k_ = 1.0;
|
||||
|
||||
// Hamiltonian functional, see below for implementation
|
||||
double hamiltonian(double q, double p, double t);
|
||||
real_t hamiltonian(real_t q, real_t p, real_t t);
|
||||
|
||||
class GradT : public Operator
|
||||
{
|
||||
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
|
||||
// 1. Parse command-line options.
|
||||
int order = 1;
|
||||
int nsteps = 100;
|
||||
double dt = 0.1;
|
||||
real_t dt = 0.1;
|
||||
bool visualization = true;
|
||||
bool gnuplot = false;
|
||||
|
||||
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
|
||||
siaSolver.Init(P,F);
|
||||
|
||||
// 3. Set the initial conditions
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
Vector q(1), p(1);
|
||||
Vector e(nsteps+1);
|
||||
q(0) = 0.0;
|
||||
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
|
||||
Vector x1(3); x1 = 0.0;
|
||||
|
||||
// 6. Perform time-stepping
|
||||
double e_mean = 0.0;
|
||||
real_t e_mean = 0.0;
|
||||
|
||||
for (int i = 0; i < nsteps; i++)
|
||||
{
|
||||
@@ -210,13 +210,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 7. Compute and display mean and standard deviation of the energy
|
||||
e_mean /= (nsteps + 1);
|
||||
double e_var = 0.0;
|
||||
real_t e_var = 0.0;
|
||||
for (int i=0; i<=nsteps; i++)
|
||||
{
|
||||
e_var += pow(e[i] - e_mean, 2);
|
||||
}
|
||||
e_var /= (nsteps + 1);
|
||||
double e_sd = sqrt(e_var);
|
||||
real_t e_sd = sqrt(e_var);
|
||||
cout << endl << "Mean and standard deviation of the energy" << endl;
|
||||
cout << e_mean << "\t" << e_sd << endl;
|
||||
|
||||
@@ -256,9 +256,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
double hamiltonian(double q, double p, double t)
|
||||
real_t hamiltonian(real_t q, real_t p, real_t t)
|
||||
{
|
||||
double h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
|
||||
real_t h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
|
||||
switch (prob_)
|
||||
{
|
||||
case 1:
|
||||
|
||||
+16
-15
@@ -74,11 +74,11 @@ using namespace mfem;
|
||||
|
||||
// Constants used in the Hamiltonian
|
||||
static int prob_ = 0;
|
||||
static double m_ = 1.0;
|
||||
static double k_ = 1.0;
|
||||
static real_t m_ = 1.0;
|
||||
static real_t k_ = 1.0;
|
||||
|
||||
// Hamiltonian functional, see below for implementation
|
||||
double hamiltonian(double q, double p, double t);
|
||||
real_t hamiltonian(real_t q, real_t p, real_t t);
|
||||
|
||||
class GradT : public Operator
|
||||
{
|
||||
@@ -106,7 +106,7 @@ int main(int argc, char *argv[])
|
||||
// 2. Parse command-line options.
|
||||
int order = 1;
|
||||
int nsteps = 100;
|
||||
double dt = 0.1;
|
||||
real_t dt = 0.1;
|
||||
bool visualization = true;
|
||||
bool gnuplot = false;
|
||||
|
||||
@@ -154,11 +154,11 @@ int main(int argc, char *argv[])
|
||||
siaSolver.Init(P,F);
|
||||
|
||||
// 4. Set the initial conditions
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
Vector q(1), p(1);
|
||||
Vector e(nsteps+1);
|
||||
q(0) = sin(2.0*M_PI*(double)myid/num_procs);
|
||||
p(0) = cos(2.0*M_PI*(double)myid/num_procs);
|
||||
q(0) = sin(2.0*M_PI*(real_t)myid/num_procs);
|
||||
p(0) = cos(2.0*M_PI*(real_t)myid/num_procs);
|
||||
|
||||
// 5. Prepare GnuPlot output file if needed
|
||||
ostringstream oss;
|
||||
@@ -181,7 +181,7 @@ int main(int argc, char *argv[])
|
||||
Vector x1(3); x1 = 0.0;
|
||||
|
||||
// 7. Perform time-stepping
|
||||
double e_mean = 0.0;
|
||||
real_t e_mean = 0.0;
|
||||
|
||||
for (int i = 0; i < nsteps; i++)
|
||||
{
|
||||
@@ -238,20 +238,21 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 8. Compute and display mean and standard deviation of the energy
|
||||
e_mean /= (nsteps + 1);
|
||||
double e_var = 0.0;
|
||||
real_t e_var = 0.0;
|
||||
for (int i = 0; i <= nsteps; i++)
|
||||
{
|
||||
e_var += pow(e[i] - e_mean, 2);
|
||||
}
|
||||
e_var /= (nsteps + 1);
|
||||
double e_sd = sqrt(e_var);
|
||||
real_t e_sd = sqrt(e_var);
|
||||
|
||||
double e_loc_stats[2];
|
||||
double *e_stats = (myid == 0) ? new double[2 * num_procs] : (double*)NULL;
|
||||
real_t e_loc_stats[2];
|
||||
real_t *e_stats = (myid == 0) ? new real_t[2 * num_procs] : (real_t*)NULL;
|
||||
|
||||
e_loc_stats[0] = e_mean;
|
||||
e_loc_stats[1] = e_sd;
|
||||
MPI_Gather(e_loc_stats, 2, MPI_DOUBLE, e_stats, 2, MPI_DOUBLE, 0, comm);
|
||||
MPI_Gather(e_loc_stats, 2, MPITypeMap<real_t>::mpi_type, e_stats, 2,
|
||||
MPITypeMap<real_t>::mpi_type, 0, comm);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -324,9 +325,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
double hamiltonian(double q, double p, double t)
|
||||
real_t hamiltonian(real_t q, real_t p, real_t t)
|
||||
{
|
||||
double h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
|
||||
real_t h = 1.0 - 0.5 / m_ + 0.5 * p * p / m_;
|
||||
switch (prob_)
|
||||
{
|
||||
case 1:
|
||||
|
||||
+18
-18
@@ -57,13 +57,13 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
static double mu_ = 1.0;
|
||||
static double epsilon_ = 1.0;
|
||||
static double sigma_ = 20.0;
|
||||
static double omega_ = 10.0;
|
||||
static real_t mu_ = 1.0;
|
||||
static real_t epsilon_ = 1.0;
|
||||
static real_t sigma_ = 20.0;
|
||||
static real_t omega_ = 10.0;
|
||||
|
||||
double u0_real_exact(const Vector &);
|
||||
double u0_imag_exact(const Vector &);
|
||||
real_t u0_real_exact(const Vector &);
|
||||
real_t u0_imag_exact(const Vector &);
|
||||
|
||||
void u1_real_exact(const Vector &, Vector &);
|
||||
void u1_imag_exact(const Vector &, Vector &);
|
||||
@@ -80,8 +80,8 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 0;
|
||||
int order = 1;
|
||||
int prob = 0;
|
||||
double freq = -1.0;
|
||||
double a_coef = 0.0;
|
||||
real_t freq = -1.0;
|
||||
real_t a_coef = 0.0;
|
||||
bool visualization = 1;
|
||||
bool herm_conv = true;
|
||||
bool exact_sol = true;
|
||||
@@ -412,7 +412,7 @@ int main(int argc, char *argv[])
|
||||
break; // This should be unreachable
|
||||
}
|
||||
}
|
||||
double s = (prob != 1) ? 1.0 : -1.0;
|
||||
real_t s = (prob != 1) ? 1.0 : -1.0;
|
||||
pc_i = new ScaledOperator(pc_r,
|
||||
(conv == ComplexOperator::HERMITIAN) ?
|
||||
s:-s);
|
||||
@@ -436,8 +436,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (exact_sol)
|
||||
{
|
||||
double err_r = -1.0;
|
||||
double err_i = -1.0;
|
||||
real_t err_r = -1.0;
|
||||
real_t err_i = -1.0;
|
||||
|
||||
switch (prob)
|
||||
{
|
||||
@@ -524,7 +524,7 @@ int main(int argc, char *argv[])
|
||||
int i = 0;
|
||||
while (sol_sock)
|
||||
{
|
||||
double t = (double)(i % num_frames) / num_frames;
|
||||
real_t t = (real_t)(i % num_frames) / num_frames;
|
||||
ostringstream oss;
|
||||
oss << "Harmonic Solution (t = " << t << " T)";
|
||||
|
||||
@@ -555,21 +555,21 @@ bool check_for_inline_mesh(const char * mesh_file)
|
||||
return s0 == "inline-";
|
||||
}
|
||||
|
||||
complex<double> u0_exact(const Vector &x)
|
||||
complex<real_t> u0_exact(const Vector &x)
|
||||
{
|
||||
int dim = x.Size();
|
||||
complex<double> i(0.0, 1.0);
|
||||
complex<double> alpha = (epsilon_ * omega_ - i * sigma_);
|
||||
complex<double> kappa = std::sqrt(mu_ * omega_* alpha);
|
||||
complex<real_t> i(0.0, 1.0);
|
||||
complex<real_t> alpha = (epsilon_ * omega_ - i * sigma_);
|
||||
complex<real_t> kappa = std::sqrt(mu_ * omega_* alpha);
|
||||
return std::exp(-i * kappa * x[dim - 1]);
|
||||
}
|
||||
|
||||
double u0_real_exact(const Vector &x)
|
||||
real_t u0_real_exact(const Vector &x)
|
||||
{
|
||||
return u0_exact(x).real();
|
||||
}
|
||||
|
||||
double u0_imag_exact(const Vector &x)
|
||||
real_t u0_imag_exact(const Vector &x)
|
||||
{
|
||||
return u0_exact(x).imag();
|
||||
}
|
||||
|
||||
+17
-17
@@ -57,13 +57,13 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
static double mu_ = 1.0;
|
||||
static double epsilon_ = 1.0;
|
||||
static double sigma_ = 20.0;
|
||||
static double omega_ = 10.0;
|
||||
static real_t mu_ = 1.0;
|
||||
static real_t epsilon_ = 1.0;
|
||||
static real_t sigma_ = 20.0;
|
||||
static real_t omega_ = 10.0;
|
||||
|
||||
double u0_real_exact(const Vector &);
|
||||
double u0_imag_exact(const Vector &);
|
||||
real_t u0_real_exact(const Vector &);
|
||||
real_t u0_imag_exact(const Vector &);
|
||||
|
||||
void u1_real_exact(const Vector &, Vector &);
|
||||
void u1_imag_exact(const Vector &, Vector &);
|
||||
@@ -87,8 +87,8 @@ int main(int argc, char *argv[])
|
||||
int par_ref_levels = 1;
|
||||
int order = 1;
|
||||
int prob = 0;
|
||||
double freq = -1.0;
|
||||
double a_coef = 0.0;
|
||||
real_t freq = -1.0;
|
||||
real_t a_coef = 0.0;
|
||||
bool visualization = 1;
|
||||
bool herm_conv = true;
|
||||
bool exact_sol = true;
|
||||
@@ -475,8 +475,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (exact_sol)
|
||||
{
|
||||
double err_r = -1.0;
|
||||
double err_i = -1.0;
|
||||
real_t err_r = -1.0;
|
||||
real_t err_i = -1.0;
|
||||
|
||||
switch (prob)
|
||||
{
|
||||
@@ -576,7 +576,7 @@ int main(int argc, char *argv[])
|
||||
int i = 0;
|
||||
while (sol_sock)
|
||||
{
|
||||
double t = (double)(i % num_frames) / num_frames;
|
||||
real_t t = (real_t)(i % num_frames) / num_frames;
|
||||
ostringstream oss;
|
||||
oss << "Harmonic Solution (t = " << t << " T)";
|
||||
|
||||
@@ -608,21 +608,21 @@ bool check_for_inline_mesh(const char * mesh_file)
|
||||
return s0 == "inline-";
|
||||
}
|
||||
|
||||
complex<double> u0_exact(const Vector &x)
|
||||
complex<real_t> u0_exact(const Vector &x)
|
||||
{
|
||||
int dim = x.Size();
|
||||
complex<double> i(0.0, 1.0);
|
||||
complex<double> alpha = (epsilon_ * omega_ - i * sigma_);
|
||||
complex<double> kappa = std::sqrt(mu_ * omega_* alpha);
|
||||
complex<real_t> i(0.0, 1.0);
|
||||
complex<real_t> alpha = (epsilon_ * omega_ - i * sigma_);
|
||||
complex<real_t> kappa = std::sqrt(mu_ * omega_* alpha);
|
||||
return std::exp(-i * kappa * x[dim - 1]);
|
||||
}
|
||||
|
||||
double u0_real_exact(const Vector &x)
|
||||
real_t u0_real_exact(const Vector &x)
|
||||
{
|
||||
return u0_exact(x).real();
|
||||
}
|
||||
|
||||
double u0_imag_exact(const Vector &x)
|
||||
real_t u0_imag_exact(const Vector &x)
|
||||
{
|
||||
return u0_exact(x).imag();
|
||||
}
|
||||
|
||||
+19
-21
@@ -26,13 +26,12 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
/** After spatial discretization, the conduction model can be written as:
|
||||
/** After spatial discretization, the wave model can be written as:
|
||||
*
|
||||
* d^2u/dt^2 = M^{-1}(-Ku)
|
||||
*
|
||||
* where u is the vector representing the temperature, M is the mass matrix,
|
||||
* and K is the diffusion operator with diffusivity depending on u:
|
||||
* (\kappa + \alpha u).
|
||||
* where u is the vector representing the temperature, M is the mass,
|
||||
* and K is the stiffness matrix.
|
||||
*
|
||||
* Class WaveOperator represents the right-hand side of the above ODE.
|
||||
*/
|
||||
@@ -47,7 +46,7 @@ protected:
|
||||
|
||||
SparseMatrix Mmat, Kmat, Kmat0;
|
||||
SparseMatrix *T; // T = M + dt K
|
||||
double current_dt;
|
||||
real_t current_dt;
|
||||
|
||||
CGSolver M_solver; // Krylov solver for inverting the mass matrix M
|
||||
DSmoother M_prec; // Preconditioner for the mass matrix M
|
||||
@@ -59,7 +58,7 @@ protected:
|
||||
mutable Vector z; // auxiliary vector
|
||||
|
||||
public:
|
||||
WaveOperator(FiniteElementSpace &f, Array<int> &ess_bdr,double speed);
|
||||
WaveOperator(FiniteElementSpace &f, Array<int> &ess_bdr, real_t speed);
|
||||
|
||||
using SecondOrderTimeDependentOperator::Mult;
|
||||
virtual void Mult(const Vector &u, const Vector &du_dt,
|
||||
@@ -69,7 +68,7 @@ public:
|
||||
d2udt2 = f(u + fac0*d2udt2,dudt + fac1*d2udt2, t),
|
||||
for the unknown d2udt2. */
|
||||
using SecondOrderTimeDependentOperator::ImplicitSolve;
|
||||
virtual void ImplicitSolve(const double fac0, const double fac1,
|
||||
virtual void ImplicitSolve(const real_t fac0, const real_t fac1,
|
||||
const Vector &u, const Vector &dudt, Vector &d2udt2);
|
||||
|
||||
///
|
||||
@@ -80,12 +79,11 @@ public:
|
||||
|
||||
|
||||
WaveOperator::WaveOperator(FiniteElementSpace &f,
|
||||
Array<int> &ess_bdr, double speed)
|
||||
: SecondOrderTimeDependentOperator(f.GetTrueVSize(), 0.0), fespace(f), M(NULL),
|
||||
K(NULL),
|
||||
T(NULL), current_dt(0.0), z(height)
|
||||
Array<int> &ess_bdr, real_t speed)
|
||||
: SecondOrderTimeDependentOperator(f.GetTrueVSize(), (real_t) 0.0),
|
||||
fespace(f), M(NULL), K(NULL), T(NULL), current_dt(0.0), z(height)
|
||||
{
|
||||
const double rel_tol = 1e-8;
|
||||
const real_t rel_tol = 1e-8;
|
||||
|
||||
fespace.GetEssentialTrueDofs(ess_bdr, ess_tdof_list);
|
||||
|
||||
@@ -133,7 +131,7 @@ void WaveOperator::Mult(const Vector &u, const Vector &du_dt,
|
||||
M_solver.Mult(z, d2udt2);
|
||||
}
|
||||
|
||||
void WaveOperator::ImplicitSolve(const double fac0, const double fac1,
|
||||
void WaveOperator::ImplicitSolve(const real_t fac0, const real_t fac1,
|
||||
const Vector &u, const Vector &dudt, Vector &d2udt2)
|
||||
{
|
||||
// Solve the equation:
|
||||
@@ -168,12 +166,12 @@ WaveOperator::~WaveOperator()
|
||||
delete c2;
|
||||
}
|
||||
|
||||
double InitialSolution(const Vector &x)
|
||||
real_t InitialSolution(const Vector &x)
|
||||
{
|
||||
return exp(-x.Norml2()*x.Norml2()*30);
|
||||
}
|
||||
|
||||
double InitialRate(const Vector &x)
|
||||
real_t InitialRate(const Vector &x)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
@@ -187,9 +185,9 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 2;
|
||||
int order = 2;
|
||||
int ode_solver_type = 10;
|
||||
double t_final = 0.5;
|
||||
double dt = 1.0e-2;
|
||||
double speed = 1.0;
|
||||
real_t t_final = 0.5;
|
||||
real_t dt = 1.0e-2;
|
||||
real_t speed = 1.0;
|
||||
bool visualization = true;
|
||||
bool visit = true;
|
||||
bool dirichlet = true;
|
||||
@@ -301,7 +299,7 @@ int main(int argc, char *argv[])
|
||||
Vector dudt;
|
||||
dudt_gf.GetTrueDofs(dudt);
|
||||
|
||||
// 7. Initialize the conduction operator and the visualization.
|
||||
// 7. Initialize the wave operator and the visualization.
|
||||
Array<int> ess_bdr;
|
||||
if (mesh->bdr_attributes.Size())
|
||||
{
|
||||
@@ -356,7 +354,7 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
sout.precision(precision);
|
||||
sout << "solution\n" << *mesh << dudt_gf;
|
||||
sout << "solution\n" << *mesh << u_gf;
|
||||
sout << "pause\n";
|
||||
sout << flush;
|
||||
cout << "GLVis visualization paused."
|
||||
@@ -367,7 +365,7 @@ int main(int argc, char *argv[])
|
||||
// 8. Perform time-integration (looping over the time iterations, ti, with a
|
||||
// time-step dt).
|
||||
ode_solver->Init(oper);
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
|
||||
bool last_step = false;
|
||||
for (int ti = 1; !last_step; ti++)
|
||||
|
||||
+14
-14
@@ -44,14 +44,14 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
double p_exact(const Vector &x);
|
||||
real_t p_exact(const Vector &x);
|
||||
void gradp_exact(const Vector &, Vector &);
|
||||
double div_gradp_exact(const Vector &x);
|
||||
real_t div_gradp_exact(const Vector &x);
|
||||
void v_exact(const Vector &x, Vector &v);
|
||||
void curlv_exact(const Vector &x, Vector &cv);
|
||||
|
||||
int dim;
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -304,9 +304,9 @@ int main(int argc, char *argv[])
|
||||
// 12. Compute and print the L_2 norm of the error.
|
||||
if (prob == 0)
|
||||
{
|
||||
double errSol = x.ComputeL2Error(gradp_coef);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
|
||||
double errProj = exact_proj.ComputeL2Error(gradp_coef);
|
||||
real_t errSol = x.ComputeL2Error(gradp_coef);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
|
||||
real_t errProj = exact_proj.ComputeL2Error(gradp_coef);
|
||||
|
||||
cout << "\n Solution of (E_h,v) = (grad p_h,v) for E_h and v in H(curl): "
|
||||
"|| E_h - grad p ||_{L_2} = " << errSol << '\n' << endl;
|
||||
@@ -317,9 +317,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (prob == 1)
|
||||
{
|
||||
double errSol = x.ComputeL2Error(curlv_coef);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
|
||||
double errProj = exact_proj.ComputeL2Error(curlv_coef);
|
||||
real_t errSol = x.ComputeL2Error(curlv_coef);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
|
||||
real_t errProj = exact_proj.ComputeL2Error(curlv_coef);
|
||||
|
||||
cout << "\n Solution of (E_h,w) = (curl v_h,w) for E_h and w in H(div): "
|
||||
"|| E_h - curl v ||_{L_2} = " << errSol << '\n' << endl;
|
||||
@@ -337,9 +337,9 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double errSol = x.ComputeL2Error(divgradp_coef, irs);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
|
||||
double errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errSol = x.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
|
||||
|
||||
cout << "\n Solution of (f_h,q) = (div v_h,q) for f_h and q in L_2: "
|
||||
"|| f_h - div v ||_{L_2} = " << errSol << '\n' << endl;
|
||||
@@ -376,7 +376,7 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double p_exact(const Vector &x)
|
||||
real_t p_exact(const Vector &x)
|
||||
{
|
||||
if (dim == 3)
|
||||
{
|
||||
@@ -406,7 +406,7 @@ void gradp_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
}
|
||||
|
||||
double div_gradp_exact(const Vector &x)
|
||||
real_t div_gradp_exact(const Vector &x)
|
||||
{
|
||||
if (dim == 3)
|
||||
{
|
||||
|
||||
+14
-14
@@ -44,14 +44,14 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
double p_exact(const Vector &x);
|
||||
real_t p_exact(const Vector &x);
|
||||
void gradp_exact(const Vector &, Vector &);
|
||||
double div_gradp_exact(const Vector &x);
|
||||
real_t div_gradp_exact(const Vector &x);
|
||||
void v_exact(const Vector &x, Vector &v);
|
||||
void curlv_exact(const Vector &x, Vector &cv);
|
||||
|
||||
int dim;
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -352,9 +352,9 @@ int main(int argc, char *argv[])
|
||||
// 14. Compute and print the L_2 norm of the error.
|
||||
if (prob == 0)
|
||||
{
|
||||
double errSol = x.ComputeL2Error(gradp_coef);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
|
||||
double errProj = exact_proj.ComputeL2Error(gradp_coef);
|
||||
real_t errSol = x.ComputeL2Error(gradp_coef);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(gradp_coef);
|
||||
real_t errProj = exact_proj.ComputeL2Error(gradp_coef);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -368,9 +368,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if (prob == 1)
|
||||
{
|
||||
double errSol = x.ComputeL2Error(curlv_coef);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
|
||||
double errProj = exact_proj.ComputeL2Error(curlv_coef);
|
||||
real_t errSol = x.ComputeL2Error(curlv_coef);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(curlv_coef);
|
||||
real_t errProj = exact_proj.ComputeL2Error(curlv_coef);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -391,9 +391,9 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double errSol = x.ComputeL2Error(divgradp_coef, irs);
|
||||
double errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
|
||||
double errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errSol = x.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errInterp = discreteInterpolant.ComputeL2Error(divgradp_coef, irs);
|
||||
real_t errProj = exact_proj.ComputeL2Error(divgradp_coef, irs);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -441,7 +441,7 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double p_exact(const Vector &x)
|
||||
real_t p_exact(const Vector &x)
|
||||
{
|
||||
if (dim == 3)
|
||||
{
|
||||
@@ -471,7 +471,7 @@ void gradp_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
}
|
||||
|
||||
double div_gradp_exact(const Vector &x)
|
||||
real_t div_gradp_exact(const Vector &x)
|
||||
{
|
||||
if (dim == 3)
|
||||
{
|
||||
|
||||
+101
-101
@@ -53,13 +53,13 @@ private:
|
||||
int dim;
|
||||
|
||||
// Length of the PML Region in each direction
|
||||
Array2D<double> length;
|
||||
Array2D<real_t> length;
|
||||
|
||||
// Computational Domain Boundary
|
||||
Array2D<double> comp_dom_bdr;
|
||||
Array2D<real_t> comp_dom_bdr;
|
||||
|
||||
// Domain Boundary
|
||||
Array2D<double> dom_bdr;
|
||||
Array2D<real_t> dom_bdr;
|
||||
|
||||
// Integer Array identifying elements in the PML
|
||||
// 0: in the PML, 1: not in the PML
|
||||
@@ -70,13 +70,13 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
PML(Mesh *mesh_,Array2D<double> length_);
|
||||
PML(Mesh *mesh_,Array2D<real_t> length_);
|
||||
|
||||
// Return Computational Domain Boundary
|
||||
Array2D<double> GetCompDomainBdr() {return comp_dom_bdr;}
|
||||
Array2D<real_t> GetCompDomainBdr() {return comp_dom_bdr;}
|
||||
|
||||
// Return Domain Boundary
|
||||
Array2D<double> GetDomainBdr() {return dom_bdr;}
|
||||
Array2D<real_t> GetDomainBdr() {return dom_bdr;}
|
||||
|
||||
// Return Markers list for elements
|
||||
Array<int> * GetMarkedPMLElements() {return &elems;}
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
void SetAttributes(Mesh *mesh_);
|
||||
|
||||
// PML complex stretching function
|
||||
void StretchFunction(const Vector &x, vector<complex<double>> &dxs);
|
||||
void StretchFunction(const Vector &x, vector<complex<real_t>> &dxs);
|
||||
};
|
||||
|
||||
// Class for returning the PML coefficients of the bilinear form
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
virtual void Eval(Vector &K, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
double x[3];
|
||||
real_t x[3];
|
||||
Vector transip(x, 3);
|
||||
T.Transform(ip, transip);
|
||||
K.SetSize(vdim);
|
||||
@@ -114,7 +114,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void maxwell_solution(const Vector &x, vector<complex<double>> &Eval);
|
||||
void maxwell_solution(const Vector &x, vector<complex<real_t>> &Eval);
|
||||
|
||||
void E_bdr_data_Re(const Vector &x, Vector &E);
|
||||
void E_bdr_data_Im(const Vector &x, Vector &E);
|
||||
@@ -134,12 +134,12 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector &D);
|
||||
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector &D);
|
||||
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector &D);
|
||||
|
||||
Array2D<double> comp_domain_bdr;
|
||||
Array2D<double> domain_bdr;
|
||||
Array2D<real_t> comp_domain_bdr;
|
||||
Array2D<real_t> domain_bdr;
|
||||
|
||||
double mu = 1.0;
|
||||
double epsilon = 1.0;
|
||||
double omega;
|
||||
real_t mu = 1.0;
|
||||
real_t epsilon = 1.0;
|
||||
real_t omega;
|
||||
int dim;
|
||||
bool exact_known = false;
|
||||
|
||||
@@ -160,7 +160,7 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
int ref_levels = 3;
|
||||
int iprob = 4;
|
||||
double freq = 5.0;
|
||||
real_t freq = 5.0;
|
||||
bool herm_conv = true;
|
||||
bool umf_solver = false;
|
||||
bool visualization = 1;
|
||||
@@ -244,7 +244,7 @@ int main(int argc, char *argv[])
|
||||
omega = 2.0 * M_PI * freq;
|
||||
|
||||
// Setup PML length
|
||||
Array2D<double> length(dim, 2); length = 0.0;
|
||||
Array2D<real_t> length(dim, 2); length = 0.0;
|
||||
|
||||
// 4. Setup the Cartesian PML region.
|
||||
switch (prob)
|
||||
@@ -470,7 +470,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
std::unique_ptr<Operator> pc_r;
|
||||
std::unique_ptr<Operator> pc_i;
|
||||
double s = (conv == ComplexOperator::HERMITIAN) ? -1.0 : 1.0;
|
||||
real_t s = (conv == ComplexOperator::HERMITIAN) ? -1.0 : 1.0;
|
||||
if (pa)
|
||||
{
|
||||
// Jacobi Smoother
|
||||
@@ -519,14 +519,14 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
|
||||
real_t L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
double L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
real_t L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
|
||||
ComplexGridFunction x_gf0(fespace);
|
||||
x_gf0 = 0.0;
|
||||
double norm_E_Re, norm_E_Im;
|
||||
real_t norm_E_Re, norm_E_Im;
|
||||
norm_E_Re = x_gf0.real().ComputeL2Error(E_ex_Re, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
norm_E_Im = x_gf0.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
@@ -593,7 +593,7 @@ int main(int argc, char *argv[])
|
||||
int i = 0;
|
||||
while (sol_sock)
|
||||
{
|
||||
double t = (double)(i % num_frames) / num_frames;
|
||||
real_t t = (real_t)(i % num_frames) / num_frames;
|
||||
ostringstream oss;
|
||||
oss << "Harmonic Solution (t = " << t << " T)";
|
||||
|
||||
@@ -617,20 +617,20 @@ int main(int argc, char *argv[])
|
||||
void source(const Vector &x, Vector &f)
|
||||
{
|
||||
Vector center(dim);
|
||||
double r = 0.0;
|
||||
real_t r = 0.0;
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
center(i) = 0.5 * (comp_domain_bdr(i, 0) + comp_domain_bdr(i, 1));
|
||||
r += pow(x[i] - center[i], 2.);
|
||||
}
|
||||
double n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
|
||||
double coeff = pow(n, 2) / M_PI;
|
||||
double alpha = -pow(n, 2) * r;
|
||||
real_t n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
|
||||
real_t coeff = pow(n, 2) / M_PI;
|
||||
real_t alpha = -pow(n, 2) * r;
|
||||
f = 0.0;
|
||||
f[0] = coeff * exp(alpha);
|
||||
}
|
||||
|
||||
void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
void maxwell_solution(const Vector &x, vector<complex<real_t>> &E)
|
||||
{
|
||||
// Initialize
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -638,8 +638,8 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
E[i] = 0.0;
|
||||
}
|
||||
|
||||
complex<double> zi = complex<double>(0., 1.);
|
||||
double k = omega * sqrt(epsilon * mu);
|
||||
complex<real_t> zi = complex<real_t>(0., 1.);
|
||||
real_t k = omega * sqrt(epsilon * mu);
|
||||
switch (prob)
|
||||
{
|
||||
case disc:
|
||||
@@ -654,58 +654,58 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
double x0 = x(0) + shift(0);
|
||||
double x1 = x(1) + shift(1);
|
||||
double r = sqrt(x0 * x0 + x1 * x1);
|
||||
double beta = k * r;
|
||||
real_t x0 = x(0) + shift(0);
|
||||
real_t x1 = x(1) + shift(1);
|
||||
real_t r = sqrt(x0 * x0 + x1 * x1);
|
||||
real_t beta = k * r;
|
||||
|
||||
// Bessel functions
|
||||
complex<double> Ho, Ho_r, Ho_rr;
|
||||
Ho = jn(0, beta) + zi * yn(0, beta);
|
||||
Ho_r = -k * (jn(1, beta) + zi * yn(1, beta));
|
||||
Ho_rr = -k * k * (1.0 / beta *
|
||||
(jn(1, beta) + zi * yn(1, beta)) -
|
||||
(jn(2, beta) + zi * yn(2, beta)));
|
||||
complex<real_t> Ho, Ho_r, Ho_rr;
|
||||
Ho = jn(0, beta) + (complex<double>) zi * yn(0, beta);
|
||||
Ho_r = -k * complex<real_t>(jn(1, beta) + (complex<double>) zi * yn(1, beta));
|
||||
Ho_rr = -k * k * (real_t(1) / beta *
|
||||
complex<real_t>(jn(1, beta) + (complex<double>) zi * yn(1, beta)) -
|
||||
complex<real_t>(jn(2, beta) + (complex<double>) zi * yn(2, beta)));
|
||||
|
||||
// First derivatives
|
||||
double r_x = x0 / r;
|
||||
double r_y = x1 / r;
|
||||
double r_xy = -(r_x / r) * r_y;
|
||||
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
real_t r_x = x0 / r;
|
||||
real_t r_y = x1 / r;
|
||||
real_t r_xy = -(r_x / r) * r_y;
|
||||
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
|
||||
complex<double> val, val_xx, val_xy;
|
||||
val = 0.25 * zi * Ho;
|
||||
val_xx = 0.25 * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
|
||||
val_xy = 0.25 * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
|
||||
complex<real_t> val, val_xx, val_xy;
|
||||
val = real_t(0.25) * zi * Ho;
|
||||
val_xx = real_t(0.25) * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
|
||||
val_xy = real_t(0.25) * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
|
||||
E[0] = zi / k * (k * k * val + val_xx);
|
||||
E[1] = zi / k * val_xy;
|
||||
}
|
||||
else if (dim == 3)
|
||||
{
|
||||
double x0 = x(0) + shift(0);
|
||||
double x1 = x(1) + shift(1);
|
||||
double x2 = x(2) + shift(2);
|
||||
double r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
||||
real_t x0 = x(0) + shift(0);
|
||||
real_t x1 = x(1) + shift(1);
|
||||
real_t x2 = x(2) + shift(2);
|
||||
real_t r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
||||
|
||||
double r_x = x0 / r;
|
||||
double r_y = x1 / r;
|
||||
double r_z = x2 / r;
|
||||
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
double r_yx = -(r_y / r) * r_x;
|
||||
double r_zx = -(r_z / r) * r_x;
|
||||
real_t r_x = x0 / r;
|
||||
real_t r_y = x1 / r;
|
||||
real_t r_z = x2 / r;
|
||||
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
real_t r_yx = -(r_y / r) * r_x;
|
||||
real_t r_zx = -(r_z / r) * r_x;
|
||||
|
||||
complex<double> val, val_r, val_rr;
|
||||
complex<real_t> val, val_r, val_rr;
|
||||
val = exp(zi * k * r) / r;
|
||||
val_r = val / r * (zi * k * r - 1.0);
|
||||
val_r = val / r * (zi * k * r - real_t(1));
|
||||
val_rr = val / (r * r) * (-k * k * r * r
|
||||
- 2.0 * zi * k * r + 2.0);
|
||||
- real_t(2) * zi * k * r + real_t(2));
|
||||
|
||||
complex<double> val_xx, val_yx, val_zx;
|
||||
complex<real_t> val_xx, val_yx, val_zx;
|
||||
val_xx = val_rr * r_x * r_x + val_r * r_xx;
|
||||
val_yx = val_rr * r_x * r_y + val_r * r_yx;
|
||||
val_zx = val_rr * r_x * r_z + val_r * r_zx;
|
||||
|
||||
complex<double> alpha = zi * k / 4.0 / M_PI / k / k;
|
||||
complex<real_t> alpha = zi * k / real_t(4) / (real_t) M_PI / k / k;
|
||||
E[0] = alpha * (k * k * val + val_xx);
|
||||
E[1] = alpha * val_yx;
|
||||
E[2] = alpha * val_zx;
|
||||
@@ -717,12 +717,12 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
// T_10 mode
|
||||
if (dim == 3)
|
||||
{
|
||||
double k10 = sqrt(k * k - M_PI * M_PI);
|
||||
E[1] = -zi * k / M_PI * sin(M_PI*x(2))*exp(zi * k10 * x(0));
|
||||
real_t k10 = sqrt(k * k - M_PI * M_PI);
|
||||
E[1] = -zi * k / (real_t) M_PI * sin((real_t) M_PI*x(2))*exp(zi * k10 * x(0));
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
E[1] = -zi * k / M_PI * exp(zi * k * x(0));
|
||||
E[1] = -zi * k / (real_t) M_PI * exp(zi * k * x(0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -733,7 +733,7 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
|
||||
void E_exact_Re(const Vector &x, Vector &E)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -743,7 +743,7 @@ void E_exact_Re(const Vector &x, Vector &E)
|
||||
|
||||
void E_exact_Im(const Vector &x, Vector &E)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -768,7 +768,7 @@ void E_bdr_data_Re(const Vector &x, Vector &E)
|
||||
}
|
||||
if (!in_pml)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -795,7 +795,7 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
|
||||
}
|
||||
if (!in_pml)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -806,8 +806,8 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
|
||||
|
||||
void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det(1.0, 0.0);
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det(1.0, 0.0);
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -817,14 +817,14 @@ void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector &D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (det / pow(dxs[i], 2)).real();
|
||||
D(i) = (det / pow(dxs[i], real_t(2))).real();
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -834,14 +834,14 @@ void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector &D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (det / pow(dxs[i], 2)).imag();
|
||||
D(i) = (det / pow(dxs[i], real_t(2))).imag();
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -851,14 +851,14 @@ void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector &D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = abs(det / pow(dxs[i], 2));
|
||||
D(i) = abs(det / pow(dxs[i], real_t(2)));
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det(1.0, 0.0);
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det(1.0, 0.0);
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -869,21 +869,21 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector &D)
|
||||
// in the 2D case the coefficient is scalar 1/det(J)
|
||||
if (dim == 2)
|
||||
{
|
||||
D = (1.0 / det).real();
|
||||
D = (real_t(1) / det).real();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (pow(dxs[i], 2) / det).real();
|
||||
D(i) = (pow(dxs[i], real_t(2)) / det).real();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -893,21 +893,21 @@ void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector &D)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
D = (1.0 / det).imag();
|
||||
D = (real_t(1) / det).imag();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (pow(dxs[i], 2) / det).imag();
|
||||
D(i) = (pow(dxs[i], real_t(2)) / det).imag();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector &D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -917,18 +917,18 @@ void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector &D)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
D = abs(1.0 / det);
|
||||
D = abs(real_t(1) / det);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = abs(pow(dxs[i], 2) / det);
|
||||
D(i) = abs(pow(dxs[i], real_t(2)) / det);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PML::PML(Mesh *mesh_, Array2D<double> length_)
|
||||
PML::PML(Mesh *mesh_, Array2D<real_t> length_)
|
||||
: mesh(mesh_), length(length_)
|
||||
{
|
||||
dim = mesh->Dimension();
|
||||
@@ -979,7 +979,7 @@ void PML::SetAttributes(Mesh *mesh_)
|
||||
for (int iv = 0; iv < nrvert; ++iv)
|
||||
{
|
||||
int vert_idx = vertices[iv];
|
||||
double *coords = mesh_->GetVertex(vert_idx);
|
||||
real_t *coords = mesh_->GetVertex(vert_idx);
|
||||
for (int comp = 0; comp < dim; ++comp)
|
||||
{
|
||||
if (coords[comp] > comp_dom_bdr(comp, 1) ||
|
||||
@@ -1000,14 +1000,14 @@ void PML::SetAttributes(Mesh *mesh_)
|
||||
}
|
||||
|
||||
void PML::StretchFunction(const Vector &x,
|
||||
vector<complex<double>> &dxs)
|
||||
vector<complex<real_t>> &dxs)
|
||||
{
|
||||
complex<double> zi = complex<double>(0., 1.);
|
||||
complex<real_t> zi = complex<real_t>(0., 1.);
|
||||
|
||||
double n = 2.0;
|
||||
double c = 5.0;
|
||||
double coeff;
|
||||
double k = omega * sqrt(epsilon * mu);
|
||||
real_t n = 2.0;
|
||||
real_t c = 5.0;
|
||||
real_t coeff;
|
||||
real_t k = omega * sqrt(epsilon * mu);
|
||||
|
||||
// Stretch in each direction independently
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -1016,14 +1016,14 @@ void PML::StretchFunction(const Vector &x,
|
||||
if (x(i) >= comp_domain_bdr(i, 1))
|
||||
{
|
||||
coeff = n * c / k / pow(length(i, 1), n);
|
||||
dxs[i] = 1.0 + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 1), n - 1.0));
|
||||
dxs[i] = real_t(1) + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 1), n - real_t(1)));
|
||||
}
|
||||
if (x(i) <= comp_domain_bdr(i, 0))
|
||||
{
|
||||
coeff = n * c / k / pow(length(i, 0), n);
|
||||
dxs[i] = 1.0 + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 0), n - 1.0));
|
||||
dxs[i] = real_t(1) + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 0), n - real_t(1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+129
-104
@@ -52,13 +52,13 @@ private:
|
||||
int dim;
|
||||
|
||||
// Length of the PML Region in each direction
|
||||
Array2D<double> length;
|
||||
Array2D<real_t> length;
|
||||
|
||||
// Computational Domain Boundary
|
||||
Array2D<double> comp_dom_bdr;
|
||||
Array2D<real_t> comp_dom_bdr;
|
||||
|
||||
// Domain Boundary
|
||||
Array2D<double> dom_bdr;
|
||||
Array2D<real_t> dom_bdr;
|
||||
|
||||
// Integer Array identifying elements in the PML
|
||||
// 0: in the PML, 1: not in the PML
|
||||
@@ -69,13 +69,13 @@ private:
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
PML(Mesh *mesh_,Array2D<double> length_);
|
||||
PML(Mesh *mesh_,Array2D<real_t> length_);
|
||||
|
||||
// Return Computational Domain Boundary
|
||||
Array2D<double> GetCompDomainBdr() {return comp_dom_bdr;}
|
||||
Array2D<real_t> GetCompDomainBdr() {return comp_dom_bdr;}
|
||||
|
||||
// Return Domain Boundary
|
||||
Array2D<double> GetDomainBdr() {return dom_bdr;}
|
||||
Array2D<real_t> GetDomainBdr() {return dom_bdr;}
|
||||
|
||||
// Return Markers list for elements
|
||||
Array<int> * GetMarkedPMLElements() {return &elems;}
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
void SetAttributes(ParMesh *pmesh);
|
||||
|
||||
// PML complex stretching function
|
||||
void StretchFunction(const Vector &x, vector<complex<double>> &dxs);
|
||||
void StretchFunction(const Vector &x, vector<complex<real_t>> &dxs);
|
||||
};
|
||||
|
||||
// Class for returning the PML coefficients of the bilinear form
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
virtual void Eval(Vector &K, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
double x[3];
|
||||
real_t x[3];
|
||||
Vector transip(x, 3);
|
||||
T.Transform(ip, transip);
|
||||
K.SetSize(vdim);
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void maxwell_solution(const Vector &x, vector<complex<double>> &Eval);
|
||||
void maxwell_solution(const Vector &x, vector<complex<real_t>> &Eval);
|
||||
|
||||
void E_bdr_data_Re(const Vector &x, Vector &E);
|
||||
void E_bdr_data_Im(const Vector &x, Vector &E);
|
||||
@@ -133,12 +133,12 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector & D);
|
||||
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector & D);
|
||||
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector & D);
|
||||
|
||||
Array2D<double> comp_domain_bdr;
|
||||
Array2D<double> domain_bdr;
|
||||
Array2D<real_t> comp_domain_bdr;
|
||||
Array2D<real_t> domain_bdr;
|
||||
|
||||
double mu = 1.0;
|
||||
double epsilon = 1.0;
|
||||
double omega;
|
||||
real_t mu = 1.0;
|
||||
real_t epsilon = 1.0;
|
||||
real_t omega;
|
||||
int dim;
|
||||
bool exact_known = false;
|
||||
|
||||
@@ -166,10 +166,11 @@ int main(int argc, char *argv[])
|
||||
int ref_levels = 1;
|
||||
int par_ref_levels = 2;
|
||||
int iprob = 4;
|
||||
double freq = 5.0;
|
||||
real_t freq = 5.0;
|
||||
bool herm_conv = true;
|
||||
bool slu_solver = false;
|
||||
bool mumps_solver = false;
|
||||
bool strumpack_solver = false;
|
||||
bool visualization = 1;
|
||||
bool pa = false;
|
||||
const char *device_config = "cpu";
|
||||
@@ -200,6 +201,11 @@ int main(int argc, char *argv[])
|
||||
#ifdef MFEM_USE_MUMPS
|
||||
args.AddOption(&mumps_solver, "-mumps", "--mumps-solver", "-no-mumps",
|
||||
"--no-mumps-solver", "Use the MUMPS Solver.");
|
||||
#endif
|
||||
#ifdef MFEM_USE_STRUMPACK
|
||||
args.AddOption(&strumpack_solver, "-strumpack", "--strumpack-solver",
|
||||
"-no-strumpack", "--no-strumpack-solver",
|
||||
"Use the STRUMPACK Solver.");
|
||||
#endif
|
||||
args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
|
||||
"--no-visualization",
|
||||
@@ -209,13 +215,14 @@ int main(int argc, char *argv[])
|
||||
args.AddOption(&device_config, "-d", "--device",
|
||||
"Device configuration string, see Device::Configure().");
|
||||
args.Parse();
|
||||
if (slu_solver && mumps_solver)
|
||||
if (slu_solver + mumps_solver + strumpack_solver > 1)
|
||||
{
|
||||
if (myid == 0)
|
||||
cout << "WARNING: Both SuperLU and MUMPS have been selected,"
|
||||
<< " please choose either one." << endl
|
||||
cout << "WARNING: More than one of SuperLU, MUMPS, and STRUMPACK have"
|
||||
<< " been selected, please choose only one." << endl
|
||||
<< " Defaulting to SuperLU." << endl;
|
||||
mumps_solver = false;
|
||||
strumpack_solver = false;
|
||||
}
|
||||
|
||||
if (iprob > 4) { iprob = 4; }
|
||||
@@ -271,7 +278,7 @@ int main(int argc, char *argv[])
|
||||
omega = 2.0 * M_PI * freq;
|
||||
|
||||
// Setup PML length
|
||||
Array2D<double> length(dim, 2); length = 0.0;
|
||||
Array2D<real_t> length(dim, 2); length = 0.0;
|
||||
|
||||
// 5. Setup the Cartesian PML region.
|
||||
switch (prob)
|
||||
@@ -474,6 +481,24 @@ int main(int argc, char *argv[])
|
||||
delete A;
|
||||
}
|
||||
#endif
|
||||
#ifdef MFEM_USE_STRUMPACK
|
||||
if (!pa && strumpack_solver)
|
||||
{
|
||||
HypreParMatrix *A = Ah.As<ComplexHypreParMatrix>()->GetSystemMatrix();
|
||||
STRUMPACKRowLocMatrix SA(*A);
|
||||
STRUMPACKSolver strumpack(MPI_COMM_WORLD, argc, argv);
|
||||
strumpack.SetPrintFactorStatistics(false);
|
||||
strumpack.SetPrintSolveStatistics(false);
|
||||
strumpack.SetKrylovSolver(strumpack::KrylovSolver::DIRECT);
|
||||
strumpack.SetReorderingStrategy(strumpack::ReorderingStrategy::METIS);
|
||||
strumpack.SetMatching(strumpack::MatchingJob::NONE);
|
||||
strumpack.SetCompression(strumpack::CompressionType::NONE);
|
||||
strumpack.SetFromCommandLine();
|
||||
strumpack.SetOperator(SA);
|
||||
strumpack.Mult(B, X);
|
||||
delete A;
|
||||
}
|
||||
#endif
|
||||
#ifdef MFEM_USE_MUMPS
|
||||
if (!pa && mumps_solver)
|
||||
{
|
||||
@@ -493,7 +518,7 @@ int main(int argc, char *argv[])
|
||||
//
|
||||
// In PML: 1/mu (abs(1/det(J) J^T J) Curl E, Curl F)
|
||||
// + omega^2 * epsilon (abs(det(J) * (J^T J)^-1) * E, F)
|
||||
if (pa || (!slu_solver && !mumps_solver))
|
||||
if (pa || (!slu_solver && !mumps_solver && !strumpack_solver))
|
||||
{
|
||||
ConstantCoefficient absomeg(pow(omega, 2) * epsilon);
|
||||
RestrictedCoefficient restr_absomeg(absomeg,attr);
|
||||
@@ -574,14 +599,14 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
|
||||
real_t L2Error_Re = x.real().ComputeL2Error(E_ex_Re, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
double L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
real_t L2Error_Im = x.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
|
||||
ParComplexGridFunction x_gf0(fespace);
|
||||
x_gf0 = 0.0;
|
||||
double norm_E_Re, norm_E_Im;
|
||||
real_t norm_E_Re, norm_E_Im;
|
||||
norm_E_Re = x_gf0.real().ComputeL2Error(E_ex_Re, irs,
|
||||
pml->GetMarkedPMLElements());
|
||||
norm_E_Im = x_gf0.imag().ComputeL2Error(E_ex_Im, irs,
|
||||
@@ -669,7 +694,7 @@ int main(int argc, char *argv[])
|
||||
int i = 0;
|
||||
while (sol_sock)
|
||||
{
|
||||
double t = (double)(i % num_frames) / num_frames;
|
||||
real_t t = (real_t)(i % num_frames) / num_frames;
|
||||
ostringstream oss;
|
||||
oss << "Harmonic Solution (t = " << t << " T)";
|
||||
|
||||
@@ -693,20 +718,20 @@ int main(int argc, char *argv[])
|
||||
void source(const Vector &x, Vector &f)
|
||||
{
|
||||
Vector center(dim);
|
||||
double r = 0.0;
|
||||
real_t r = 0.0;
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
center(i) = 0.5 * (comp_domain_bdr(i, 0) + comp_domain_bdr(i, 1));
|
||||
r += pow(x[i] - center[i], 2.);
|
||||
}
|
||||
double n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
|
||||
double coeff = pow(n, 2) / M_PI;
|
||||
double alpha = -pow(n, 2) * r;
|
||||
real_t n = 5.0 * omega * sqrt(epsilon * mu) / M_PI;
|
||||
real_t coeff = pow(n, 2) / M_PI;
|
||||
real_t alpha = -pow(n, 2) * r;
|
||||
f = 0.0;
|
||||
f[0] = coeff * exp(alpha);
|
||||
}
|
||||
|
||||
void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
void maxwell_solution(const Vector &x, vector<complex<real_t>> &E)
|
||||
{
|
||||
// Initialize
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -714,8 +739,8 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
E[i] = 0.0;
|
||||
}
|
||||
|
||||
complex<double> zi = complex<double>(0., 1.);
|
||||
double k = omega * sqrt(epsilon * mu);
|
||||
complex<real_t> zi = complex<real_t>(0., 1.);
|
||||
real_t k = omega * sqrt(epsilon * mu);
|
||||
switch (prob)
|
||||
{
|
||||
case disc:
|
||||
@@ -730,58 +755,58 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
double x0 = x(0) + shift(0);
|
||||
double x1 = x(1) + shift(1);
|
||||
double r = sqrt(x0 * x0 + x1 * x1);
|
||||
double beta = k * r;
|
||||
real_t x0 = x(0) + shift(0);
|
||||
real_t x1 = x(1) + shift(1);
|
||||
real_t r = sqrt(x0 * x0 + x1 * x1);
|
||||
real_t beta = k * r;
|
||||
|
||||
// Bessel functions
|
||||
complex<double> Ho, Ho_r, Ho_rr;
|
||||
Ho = jn(0, beta) + zi * yn(0, beta);
|
||||
Ho_r = -k * (jn(1, beta) + zi * yn(1, beta));
|
||||
Ho_rr = -k * k * (1.0 / beta *
|
||||
(jn(1, beta) + zi * yn(1, beta)) -
|
||||
(jn(2, beta) + zi * yn(2, beta)));
|
||||
complex<real_t> Ho, Ho_r, Ho_rr;
|
||||
Ho = jn(0, beta) + (complex<double>) zi * yn(0, beta);
|
||||
Ho_r = -k * complex<real_t>(jn(1, beta) + (complex<double>) zi * yn(1, beta));
|
||||
Ho_rr = -k * k * complex<real_t>(1.0 / beta *
|
||||
(jn(1, beta) + (complex<double>) zi * yn(1, beta)) -
|
||||
(jn(2, beta) + (complex<double>) zi * yn(2, beta)));
|
||||
|
||||
// First derivatives
|
||||
double r_x = x0 / r;
|
||||
double r_y = x1 / r;
|
||||
double r_xy = -(r_x / r) * r_y;
|
||||
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
real_t r_x = x0 / r;
|
||||
real_t r_y = x1 / r;
|
||||
real_t r_xy = -(r_x / r) * r_y;
|
||||
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
|
||||
complex<double> val, val_xx, val_xy;
|
||||
val = 0.25 * zi * Ho;
|
||||
val_xx = 0.25 * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
|
||||
val_xy = 0.25 * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
|
||||
complex<real_t> val, val_xx, val_xy;
|
||||
val = real_t(0.25) * zi * Ho;
|
||||
val_xx = real_t(0.25) * zi * (r_xx * Ho_r + r_x * r_x * Ho_rr);
|
||||
val_xy = real_t(0.25) * zi * (r_xy * Ho_r + r_x * r_y * Ho_rr);
|
||||
E[0] = zi / k * (k * k * val + val_xx);
|
||||
E[1] = zi / k * val_xy;
|
||||
}
|
||||
else if (dim == 3)
|
||||
{
|
||||
double x0 = x(0) + shift(0);
|
||||
double x1 = x(1) + shift(1);
|
||||
double x2 = x(2) + shift(2);
|
||||
double r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
||||
real_t x0 = x(0) + shift(0);
|
||||
real_t x1 = x(1) + shift(1);
|
||||
real_t x2 = x(2) + shift(2);
|
||||
real_t r = sqrt(x0 * x0 + x1 * x1 + x2 * x2);
|
||||
|
||||
double r_x = x0 / r;
|
||||
double r_y = x1 / r;
|
||||
double r_z = x2 / r;
|
||||
double r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
double r_yx = -(r_y / r) * r_x;
|
||||
double r_zx = -(r_z / r) * r_x;
|
||||
real_t r_x = x0 / r;
|
||||
real_t r_y = x1 / r;
|
||||
real_t r_z = x2 / r;
|
||||
real_t r_xx = (1.0 / r) * (1.0 - r_x * r_x);
|
||||
real_t r_yx = -(r_y / r) * r_x;
|
||||
real_t r_zx = -(r_z / r) * r_x;
|
||||
|
||||
complex<double> val, val_r, val_rr;
|
||||
complex<real_t> val, val_r, val_rr;
|
||||
val = exp(zi * k * r) / r;
|
||||
val_r = val / r * (zi * k * r - 1.0);
|
||||
val_r = val / r * (zi * k * r - real_t(1));
|
||||
val_rr = val / (r * r) * (-k * k * r * r
|
||||
- 2.0 * zi * k * r + 2.0);
|
||||
- real_t(2) * zi * k * r + real_t(2));
|
||||
|
||||
complex<double> val_xx, val_yx, val_zx;
|
||||
complex<real_t> val_xx, val_yx, val_zx;
|
||||
val_xx = val_rr * r_x * r_x + val_r * r_xx;
|
||||
val_yx = val_rr * r_x * r_y + val_r * r_yx;
|
||||
val_zx = val_rr * r_x * r_z + val_r * r_zx;
|
||||
|
||||
complex<double> alpha = zi * k / 4.0 / M_PI / k / k;
|
||||
complex<real_t> alpha = zi * k / real_t(4) / (real_t) M_PI / k / k;
|
||||
E[0] = alpha * (k * k * val + val_xx);
|
||||
E[1] = alpha * val_yx;
|
||||
E[2] = alpha * val_zx;
|
||||
@@ -793,12 +818,12 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
// T_10 mode
|
||||
if (dim == 3)
|
||||
{
|
||||
double k10 = sqrt(k * k - M_PI * M_PI);
|
||||
E[1] = -zi * k / M_PI * sin(M_PI*x(2))*exp(zi * k10 * x(0));
|
||||
real_t k10 = sqrt(k * k - M_PI * M_PI);
|
||||
E[1] = -zi * k / (real_t) M_PI * sin((real_t) M_PI*x(2))*exp(zi * k10 * x(0));
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
E[1] = -zi * k / M_PI * exp(zi * k * x(0));
|
||||
E[1] = -zi * k / (real_t) M_PI * exp(zi * k * x(0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -809,7 +834,7 @@ void maxwell_solution(const Vector &x, vector<complex<double>> &E)
|
||||
|
||||
void E_exact_Re(const Vector &x, Vector &E)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -819,7 +844,7 @@ void E_exact_Re(const Vector &x, Vector &E)
|
||||
|
||||
void E_exact_Im(const Vector &x, Vector &E)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -844,7 +869,7 @@ void E_bdr_data_Re(const Vector &x, Vector &E)
|
||||
}
|
||||
if (!in_pml)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -871,7 +896,7 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
|
||||
}
|
||||
if (!in_pml)
|
||||
{
|
||||
vector<complex<double>> Eval(E.Size());
|
||||
vector<complex<real_t>> Eval(E.Size());
|
||||
maxwell_solution(x, Eval);
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
@@ -882,8 +907,8 @@ void E_bdr_data_Im(const Vector &x, Vector &E)
|
||||
|
||||
void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det(1.0, 0.0);
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det(1.0, 0.0);
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -893,14 +918,14 @@ void detJ_JT_J_inv_Re(const Vector &x, PML * pml, Vector & D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (det / pow(dxs[i], 2)).real();
|
||||
D(i) = (det / pow(dxs[i], real_t(2))).real();
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -910,14 +935,14 @@ void detJ_JT_J_inv_Im(const Vector &x, PML * pml, Vector & D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (det / pow(dxs[i], 2)).imag();
|
||||
D(i) = (det / pow(dxs[i], real_t(2))).imag();
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -927,14 +952,14 @@ void detJ_JT_J_inv_abs(const Vector &x, PML * pml, Vector & D)
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = abs(det / pow(dxs[i], 2));
|
||||
D(i) = abs(det / pow(dxs[i], real_t(2)));
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det(1.0, 0.0);
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det(1.0, 0.0);
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -945,21 +970,21 @@ void detJ_inv_JT_J_Re(const Vector &x, PML * pml, Vector & D)
|
||||
// in the 2D case the coefficient is scalar 1/det(J)
|
||||
if (dim == 2)
|
||||
{
|
||||
D = (1.0 / det).real();
|
||||
D = (real_t(1) / det).real();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (pow(dxs[i], 2) / det).real();
|
||||
D(i) = (pow(dxs[i], real_t(2)) / det).real();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -969,21 +994,21 @@ void detJ_inv_JT_J_Im(const Vector &x, PML * pml, Vector & D)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
D = (1.0 / det).imag();
|
||||
D = (real_t(1) / det).imag();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = (pow(dxs[i], 2) / det).imag();
|
||||
D(i) = (pow(dxs[i], real_t(2)) / det).imag();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector & D)
|
||||
{
|
||||
vector<complex<double>> dxs(dim);
|
||||
complex<double> det = 1.0;
|
||||
vector<complex<real_t>> dxs(dim);
|
||||
complex<real_t> det = 1.0;
|
||||
pml->StretchFunction(x, dxs);
|
||||
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -993,18 +1018,18 @@ void detJ_inv_JT_J_abs(const Vector &x, PML * pml, Vector & D)
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
D = abs(1.0 / det);
|
||||
D = abs(real_t(1) / det);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < dim; ++i)
|
||||
{
|
||||
D(i) = abs(pow(dxs[i], 2) / det);
|
||||
D(i) = abs(pow(dxs[i], real_t(2)) / det);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PML::PML(Mesh *mesh_, Array2D<double> length_)
|
||||
PML::PML(Mesh *mesh_, Array2D<real_t> length_)
|
||||
: mesh(mesh_), length(length_)
|
||||
{
|
||||
dim = mesh->Dimension();
|
||||
@@ -1056,7 +1081,7 @@ void PML::SetAttributes(ParMesh *pmesh)
|
||||
for (int iv = 0; iv < nrvert; ++iv)
|
||||
{
|
||||
int vert_idx = vertices[iv];
|
||||
double *coords = pmesh->GetVertex(vert_idx);
|
||||
real_t *coords = pmesh->GetVertex(vert_idx);
|
||||
for (int comp = 0; comp < dim; ++comp)
|
||||
{
|
||||
if (coords[comp] > comp_dom_bdr(comp, 1) ||
|
||||
@@ -1077,14 +1102,14 @@ void PML::SetAttributes(ParMesh *pmesh)
|
||||
}
|
||||
|
||||
void PML::StretchFunction(const Vector &x,
|
||||
vector<complex<double>> &dxs)
|
||||
vector<complex<real_t>> &dxs)
|
||||
{
|
||||
complex<double> zi = complex<double>(0., 1.);
|
||||
complex<real_t> zi = complex<real_t>(0., 1.);
|
||||
|
||||
double n = 2.0;
|
||||
double c = 5.0;
|
||||
double coeff;
|
||||
double k = omega * sqrt(epsilon * mu);
|
||||
real_t n = 2.0;
|
||||
real_t c = 5.0;
|
||||
real_t coeff;
|
||||
real_t k = omega * sqrt(epsilon * mu);
|
||||
|
||||
// Stretch in each direction independently
|
||||
for (int i = 0; i < dim; ++i)
|
||||
@@ -1093,14 +1118,14 @@ void PML::StretchFunction(const Vector &x,
|
||||
if (x(i) >= comp_domain_bdr(i, 1))
|
||||
{
|
||||
coeff = n * c / k / pow(length(i, 1), n);
|
||||
dxs[i] = 1.0 + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 1), n - 1.0));
|
||||
dxs[i] = real_t(1) + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 1), n - real_t(1)));
|
||||
}
|
||||
if (x(i) <= comp_domain_bdr(i, 0))
|
||||
{
|
||||
coeff = n * c / k / pow(length(i, 0), n);
|
||||
dxs[i] = 1.0 + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 0), n - 1.0));
|
||||
dxs[i] = real_t(1) + zi * coeff *
|
||||
abs(pow(x(i) - comp_domain_bdr(i, 0), n - real_t(1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+32
-32
@@ -63,7 +63,7 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
static double a_ = 0.2;
|
||||
static real_t a_ = 0.2;
|
||||
|
||||
// Normal to hole with boundary attribute 4
|
||||
void n4Vec(const Vector &x, Vector &n) { n = x; n[0] -= 0.5; n /= -n.Norml2(); }
|
||||
@@ -73,25 +73,25 @@ Mesh * GenerateSerialMesh(int ref);
|
||||
// Compute the average value of alpha*n.Grad(sol) + beta*sol over the boundary
|
||||
// attributes marked in bdr_marker. Also computes the L2 norm of
|
||||
// alpha*n.Grad(sol) + beta*sol - gamma over the same boundary.
|
||||
double IntegrateBC(const GridFunction &sol, const Array<int> &bdr_marker,
|
||||
double alpha, double beta, double gamma,
|
||||
double &error);
|
||||
real_t IntegrateBC(const GridFunction &sol, const Array<int> &bdr_marker,
|
||||
real_t alpha, real_t beta, real_t gamma,
|
||||
real_t &error);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// 1. Parse command-line options.
|
||||
int ser_ref_levels = 2;
|
||||
int order = 1;
|
||||
double sigma = -1.0;
|
||||
double kappa = -1.0;
|
||||
real_t sigma = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
bool h1 = true;
|
||||
bool visualization = true;
|
||||
|
||||
double mat_val = 1.0;
|
||||
double dbc_val = 0.0;
|
||||
double nbc_val = 1.0;
|
||||
double rbc_a_val = 1.0; // du/dn + a * u = b
|
||||
double rbc_b_val = 1.0;
|
||||
real_t mat_val = 1.0;
|
||||
real_t dbc_val = 0.0;
|
||||
real_t nbc_val = 1.0;
|
||||
real_t rbc_a_val = 1.0; // du/dn + a * u = b
|
||||
real_t rbc_b_val = 1.0;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&h1, "-h1", "--continuous", "-dg", "--discontinuous",
|
||||
@@ -302,7 +302,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate the solution on the Dirichlet boundary and compare to the
|
||||
// expected value.
|
||||
double error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
|
||||
real_t error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
|
||||
|
||||
bool hom_dbc = (dbc_val == 0.0);
|
||||
error /= hom_dbc ? 1.0 : fabs(dbc_val);
|
||||
@@ -314,7 +314,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate n.Grad(u) on the inhomogeneous Neumann boundary and compare
|
||||
// to the expected value.
|
||||
double error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
|
||||
real_t error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
|
||||
|
||||
bool hom_nbc = (nbc_val == 0.0);
|
||||
error /= hom_nbc ? 1.0 : fabs(nbc_val);
|
||||
@@ -330,7 +330,7 @@ int main(int argc, char *argv[])
|
||||
nbc0_bdr = 0;
|
||||
nbc0_bdr[3] = 1;
|
||||
|
||||
double error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
|
||||
real_t error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
|
||||
|
||||
bool hom_nbc = true;
|
||||
mfem::out << "Average of n.Grad(u) on Gamma_nbc0:\t"
|
||||
@@ -341,8 +341,8 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate n.Grad(u) + a * u on the Robin boundary and compare to the
|
||||
// expected value.
|
||||
double error;
|
||||
double avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val, error);
|
||||
real_t error;
|
||||
real_t avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val, error);
|
||||
|
||||
bool hom_rbc = (rbc_b_val == 0.0);
|
||||
error /= hom_rbc ? 1.0 : fabs(rbc_b_val);
|
||||
@@ -383,22 +383,22 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
void quad_trans(double u, double v, double &x, double &y, bool log = false)
|
||||
void quad_trans(real_t u, real_t v, real_t &x, real_t &y, bool log = false)
|
||||
{
|
||||
double a = a_; // Radius of disc
|
||||
real_t a = a_; // Radius of disc
|
||||
|
||||
double d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
|
||||
real_t d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
|
||||
|
||||
double v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
|
||||
real_t v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
|
||||
((4.0 - 3 * M_SQRT2) * a +
|
||||
(8.0 * (M_SQRT2 - 1.0) * a - 2.0) * v) / d;
|
||||
|
||||
double r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
|
||||
real_t r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
|
||||
2.0 * (1.0 + M_SQRT2 *
|
||||
(1.0 + 2.0 * (2.0 * a - M_SQRT2 - 1.0) * a)) * v * v
|
||||
) / d;
|
||||
|
||||
double t = asin(v / r) * u / v;
|
||||
real_t t = asin(v / r) * u / v;
|
||||
if (log)
|
||||
{
|
||||
mfem::out << "u, v, r, v0, t "
|
||||
@@ -411,7 +411,7 @@ void quad_trans(double u, double v, double &x, double &y, bool log = false)
|
||||
|
||||
void trans(const Vector &u, Vector &x)
|
||||
{
|
||||
double tol = 1e-4;
|
||||
real_t tol = 1e-4;
|
||||
|
||||
if (u[1] > 0.5 - tol || u[1] < -0.5 + tol)
|
||||
{
|
||||
@@ -542,8 +542,8 @@ Mesh * GenerateSerialMesh(int ref)
|
||||
vi[0] = o + 3; vi[1] = o + 4; mesh->AddBdrSegment(vi, 3 + i);
|
||||
}
|
||||
|
||||
double d[2];
|
||||
double a = a_ / M_SQRT2;
|
||||
real_t d[2];
|
||||
real_t a = a_ / M_SQRT2;
|
||||
|
||||
d[0] = -1.0; d[1] = -0.5; mesh->AddVertex(d);
|
||||
d[0] = -1.0; d[1] = 0.0; mesh->AddVertex(d);
|
||||
@@ -636,12 +636,12 @@ Mesh * GenerateSerialMesh(int ref)
|
||||
return mesh;
|
||||
}
|
||||
|
||||
double IntegrateBC(const GridFunction &x, const Array<int> &bdr,
|
||||
double alpha, double beta, double gamma,
|
||||
double &error)
|
||||
real_t IntegrateBC(const GridFunction &x, const Array<int> &bdr,
|
||||
real_t alpha, real_t beta, real_t gamma,
|
||||
real_t &error)
|
||||
{
|
||||
double nrm = 0.0;
|
||||
double avg = 0.0;
|
||||
real_t nrm = 0.0;
|
||||
real_t avg = 0.0;
|
||||
error = 0.0;
|
||||
|
||||
const bool a_is_zero = alpha == 0.0;
|
||||
@@ -683,8 +683,8 @@ double IntegrateBC(const GridFunction &x, const Array<int> &bdr,
|
||||
IntegrationPoint eip;
|
||||
FTr->Loc1.Transform(ip, eip);
|
||||
FTr->Face->SetIntPoint(&ip);
|
||||
double face_weight = FTr->Face->Weight();
|
||||
double val = 0.0;
|
||||
real_t face_weight = FTr->Face->Weight();
|
||||
real_t val = 0.0;
|
||||
if (!a_is_zero)
|
||||
{
|
||||
FTr->Elem1->SetIntPoint(&eip);
|
||||
|
||||
+38
-37
@@ -63,7 +63,7 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
static double a_ = 0.2;
|
||||
static real_t a_ = 0.2;
|
||||
|
||||
// Normal to hole with boundary attribute 4
|
||||
void n4Vec(const Vector &x, Vector &n) { n = x; n[0] -= 0.5; n /= -n.Norml2(); }
|
||||
@@ -73,9 +73,9 @@ Mesh * GenerateSerialMesh(int ref);
|
||||
// Compute the average value of alpha*n.Grad(sol) + beta*sol over the boundary
|
||||
// attributes marked in bdr_marker. Also computes the L2 norm of
|
||||
// alpha*n.Grad(sol) + beta*sol - gamma over the same boundary.
|
||||
double IntegrateBC(const ParGridFunction &sol, const Array<int> &bdr_marker,
|
||||
double alpha, double beta, double gamma,
|
||||
double &error);
|
||||
real_t IntegrateBC(const ParGridFunction &sol, const Array<int> &bdr_marker,
|
||||
real_t alpha, real_t beta, real_t gamma,
|
||||
real_t &error);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -88,16 +88,16 @@ int main(int argc, char *argv[])
|
||||
int ser_ref_levels = 2;
|
||||
int par_ref_levels = 1;
|
||||
int order = 1;
|
||||
double sigma = -1.0;
|
||||
double kappa = -1.0;
|
||||
real_t sigma = -1.0;
|
||||
real_t kappa = -1.0;
|
||||
bool h1 = true;
|
||||
bool visualization = true;
|
||||
|
||||
double mat_val = 1.0;
|
||||
double dbc_val = 0.0;
|
||||
double nbc_val = 1.0;
|
||||
double rbc_a_val = 1.0; // du/dn + a * u = b
|
||||
double rbc_b_val = 1.0;
|
||||
real_t mat_val = 1.0;
|
||||
real_t dbc_val = 0.0;
|
||||
real_t nbc_val = 1.0;
|
||||
real_t rbc_a_val = 1.0; // du/dn + a * u = b
|
||||
real_t rbc_b_val = 1.0;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&h1, "-h1", "--continuous", "-dg", "--discontinuous",
|
||||
@@ -322,7 +322,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate the solution on the Dirichlet boundary and compare to the
|
||||
// expected value.
|
||||
double error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
|
||||
real_t error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
|
||||
|
||||
bool hom_dbc = (dbc_val == 0.0);
|
||||
error /= hom_dbc ? 1.0 : fabs(dbc_val);
|
||||
@@ -334,7 +334,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate n.Grad(u) on the inhomogeneous Neumann boundary and compare
|
||||
// to the expected value.
|
||||
double error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
|
||||
real_t error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
|
||||
|
||||
bool hom_nbc = (nbc_val == 0.0);
|
||||
error /= hom_nbc ? 1.0 : fabs(nbc_val);
|
||||
@@ -350,7 +350,7 @@ int main(int argc, char *argv[])
|
||||
nbc0_bdr = 0;
|
||||
nbc0_bdr[3] = 1;
|
||||
|
||||
double error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
|
||||
real_t error, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, error);
|
||||
|
||||
bool hom_nbc = true;
|
||||
mfem::out << "Average of n.Grad(u) on Gamma_nbc0:\t"
|
||||
@@ -361,7 +361,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate n.Grad(u) + a * u on the Robin boundary and compare to the
|
||||
// expected value.
|
||||
double error, avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val,
|
||||
real_t error, avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val,
|
||||
error);
|
||||
|
||||
bool hom_rbc = (rbc_b_val == 0.0);
|
||||
@@ -409,22 +409,22 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
void quad_trans(double u, double v, double &x, double &y, bool log = false)
|
||||
void quad_trans(real_t u, real_t v, real_t &x, real_t &y, bool log = false)
|
||||
{
|
||||
double a = a_; // Radius of disc
|
||||
real_t a = a_; // Radius of disc
|
||||
|
||||
double d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
|
||||
real_t d = 4.0 * a * (M_SQRT2 - 2.0 * a) * (1.0 - 2.0 * v);
|
||||
|
||||
double v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
|
||||
real_t v0 = (1.0 + M_SQRT2) * (M_SQRT2 * a - 2.0 * v) *
|
||||
((4.0 - 3 * M_SQRT2) * a +
|
||||
(8.0 * (M_SQRT2 - 1.0) * a - 2.0) * v) / d;
|
||||
|
||||
double r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
|
||||
real_t r = 2.0 * ((M_SQRT2 - 1.0) * a * a * (1.0 - 4.0 *v) +
|
||||
2.0 * (1.0 + M_SQRT2 *
|
||||
(1.0 + 2.0 * (2.0 * a - M_SQRT2 - 1.0) * a)) * v * v
|
||||
) / d;
|
||||
|
||||
double t = asin(v / r) * u / v;
|
||||
real_t t = asin(v / r) * u / v;
|
||||
if (log)
|
||||
{
|
||||
mfem::out << "u, v, r, v0, t "
|
||||
@@ -437,7 +437,7 @@ void quad_trans(double u, double v, double &x, double &y, bool log = false)
|
||||
|
||||
void trans(const Vector &u, Vector &x)
|
||||
{
|
||||
double tol = 1e-4;
|
||||
real_t tol = 1e-4;
|
||||
|
||||
if (u[1] > 0.5 - tol || u[1] < -0.5 + tol)
|
||||
{
|
||||
@@ -568,8 +568,8 @@ Mesh * GenerateSerialMesh(int ref)
|
||||
vi[0] = o + 3; vi[1] = o + 4; mesh->AddBdrSegment(vi, 3 + i);
|
||||
}
|
||||
|
||||
double d[2];
|
||||
double a = a_ / M_SQRT2;
|
||||
real_t d[2];
|
||||
real_t a = a_ / M_SQRT2;
|
||||
|
||||
d[0] = -1.0; d[1] = -0.5; mesh->AddVertex(d);
|
||||
d[0] = -1.0; d[1] = 0.0; mesh->AddVertex(d);
|
||||
@@ -662,14 +662,14 @@ Mesh * GenerateSerialMesh(int ref)
|
||||
return mesh;
|
||||
}
|
||||
|
||||
double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
|
||||
double alpha, double beta, double gamma,
|
||||
double &glb_err)
|
||||
real_t IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
|
||||
real_t alpha, real_t beta, real_t gamma,
|
||||
real_t &glb_err)
|
||||
{
|
||||
double loc_vals[3];
|
||||
double &nrm = loc_vals[0];
|
||||
double &avg = loc_vals[1];
|
||||
double &error = loc_vals[2];
|
||||
real_t loc_vals[3];
|
||||
real_t &nrm = loc_vals[0];
|
||||
real_t &avg = loc_vals[1];
|
||||
real_t &error = loc_vals[2];
|
||||
|
||||
nrm = 0.0;
|
||||
avg = 0.0;
|
||||
@@ -714,8 +714,8 @@ double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
|
||||
IntegrationPoint eip;
|
||||
FTr->Loc1.Transform(ip, eip);
|
||||
FTr->Face->SetIntPoint(&ip);
|
||||
double face_weight = FTr->Face->Weight();
|
||||
double val = 0.0;
|
||||
real_t face_weight = FTr->Face->Weight();
|
||||
real_t val = 0.0;
|
||||
if (!a_is_zero)
|
||||
{
|
||||
FTr->Elem1->SetIntPoint(&eip);
|
||||
@@ -741,11 +741,12 @@ double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
|
||||
}
|
||||
}
|
||||
|
||||
double glb_vals[3];
|
||||
MPI_Allreduce(loc_vals, glb_vals, 3, MPI_DOUBLE, MPI_SUM, fes.GetComm());
|
||||
real_t glb_vals[3];
|
||||
MPI_Allreduce(loc_vals, glb_vals, 3, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_SUM, fes.GetComm());
|
||||
|
||||
double glb_nrm = glb_vals[0];
|
||||
double glb_avg = glb_vals[1];
|
||||
real_t glb_nrm = glb_vals[0];
|
||||
real_t glb_avg = glb_vals[1];
|
||||
glb_err = glb_vals[2];
|
||||
|
||||
// Normalize by the length of the boundary
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ using namespace mfem;
|
||||
// Return a mesh with a single element with vertices (0, 0), (1, 0), (1, 1),
|
||||
// (offset, 1) to demonstrate boundary conditions on a surface that is not
|
||||
// axis-aligned.
|
||||
Mesh * build_trapezoid_mesh(double offset)
|
||||
Mesh * build_trapezoid_mesh(real_t offset)
|
||||
{
|
||||
MFEM_VERIFY(offset < 0.9, "offset is too large!");
|
||||
|
||||
@@ -45,7 +45,7 @@ Mesh * build_trapezoid_mesh(double offset)
|
||||
Mesh * mesh = new Mesh(dimension, nvt, 1, nbe);
|
||||
|
||||
// vertices
|
||||
double vc[dimension];
|
||||
real_t vc[dimension];
|
||||
vc[0] = 0.0; vc[1] = 0.0;
|
||||
mesh->AddVertex(vc);
|
||||
vc[0] = 1.0; vc[1] = 0.0;
|
||||
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
||||
// 1. Parse command-line options.
|
||||
int order = 1;
|
||||
bool visualization = 1;
|
||||
double offset = 0.3;
|
||||
real_t offset = 0.3;
|
||||
bool visit = false;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
|
||||
+4
-4
@@ -38,7 +38,7 @@ using namespace mfem;
|
||||
// Return a mesh with a single element with vertices (0, 0), (1, 0), (1, 1),
|
||||
// (offset, 1) to demonstrate boundary conditions on a surface that is not
|
||||
// axis-aligned.
|
||||
Mesh * build_trapezoid_mesh(double offset)
|
||||
Mesh * build_trapezoid_mesh(real_t offset)
|
||||
{
|
||||
MFEM_VERIFY(offset < 0.9, "offset is too large!");
|
||||
|
||||
@@ -48,7 +48,7 @@ Mesh * build_trapezoid_mesh(double offset)
|
||||
Mesh * mesh = new Mesh(dimension, nvt, 1, nbe);
|
||||
|
||||
// vertices
|
||||
double vc[dimension];
|
||||
real_t vc[dimension];
|
||||
vc[0] = 0.0; vc[1] = 0.0;
|
||||
mesh->AddVertex(vc);
|
||||
vc[0] = 1.0; vc[1] = 0.0;
|
||||
@@ -97,9 +97,9 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
bool visualization = 1;
|
||||
bool reorder_space = false;
|
||||
double offset = 0.3;
|
||||
real_t offset = 0.3;
|
||||
bool visit = false;
|
||||
double penalty = 0.0;
|
||||
real_t penalty = 0.0;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&order, "-o", "--order",
|
||||
|
||||
+6
-6
@@ -34,7 +34,7 @@ void trans(const Vector &x, Vector &r);
|
||||
|
||||
void sigmaFunc(const Vector &x, DenseMatrix &s);
|
||||
|
||||
double uExact(const Vector &x)
|
||||
real_t uExact(const Vector &x)
|
||||
{
|
||||
return (0.25 * (2.0 + x[0]) - x[2]) * (x[2] + 0.25 * (2.0 + x[0]));
|
||||
}
|
||||
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 13. Compute error in the solution and its flux
|
||||
FunctionCoefficient uCoef(uExact);
|
||||
double error = x.ComputeL2Error(uCoef);
|
||||
real_t error = x.ComputeL2Error(uCoef);
|
||||
|
||||
cout << "|u - u_h|_2 = " << error << endl;
|
||||
|
||||
@@ -176,7 +176,7 @@ int main(int argc, char *argv[])
|
||||
x.ComputeFlux(*integ, flux); flux *= -1.0;
|
||||
|
||||
VectorFunctionCoefficient fluxCoef(3, fluxExact);
|
||||
double flux_err = flux.ComputeL2Error(fluxCoef);
|
||||
real_t flux_err = flux.ComputeL2Error(fluxCoef);
|
||||
|
||||
cout << "|f - f_h|_2 = " << flux_err << endl;
|
||||
|
||||
@@ -304,8 +304,8 @@ void trans(const Vector &x, Vector &r)
|
||||
{
|
||||
r.SetSize(3);
|
||||
|
||||
double tol = 1e-6;
|
||||
double theta = 0.0;
|
||||
real_t tol = 1e-6;
|
||||
real_t theta = 0.0;
|
||||
if (fabs(x[1] + 1.0) < tol)
|
||||
{
|
||||
theta = 0.25 * M_PI * (x[0] - 2.0);
|
||||
@@ -337,7 +337,7 @@ void trans(const Vector &x, Vector &r)
|
||||
void sigmaFunc(const Vector &x, DenseMatrix &s)
|
||||
{
|
||||
s.SetSize(3);
|
||||
double a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
|
||||
real_t a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
|
||||
s(0,0) = 0.5 + x[0] * x[0] * (8.0 / a - 0.5);
|
||||
s(0,1) = x[0] * x[1] * (8.0 / a - 0.5);
|
||||
s(0,2) = 0.0;
|
||||
|
||||
+6
-6
@@ -34,7 +34,7 @@ void trans(const Vector &x, Vector &r);
|
||||
|
||||
void sigmaFunc(const Vector &x, DenseMatrix &s);
|
||||
|
||||
double uExact(const Vector &x)
|
||||
real_t uExact(const Vector &x)
|
||||
{
|
||||
return (0.25 * (2.0 + x[0]) - x[2]) * (x[2] + 0.25 * (2.0 + x[0]));
|
||||
}
|
||||
@@ -201,7 +201,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 15. Compute error in the solution and its flux
|
||||
FunctionCoefficient uCoef(uExact);
|
||||
double error = x.ComputeL2Error(uCoef);
|
||||
real_t error = x.ComputeL2Error(uCoef);
|
||||
|
||||
if (myid == 0) { cout << "|u - u_h|_2 = " << error << endl; }
|
||||
|
||||
@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
|
||||
x.ComputeFlux(*integ, flux); flux *= -1.0;
|
||||
|
||||
VectorFunctionCoefficient fluxCoef(3, fluxExact);
|
||||
double flux_err = flux.ComputeL2Error(fluxCoef);
|
||||
real_t flux_err = flux.ComputeL2Error(fluxCoef);
|
||||
|
||||
if (myid == 0) { cout << "|f - f_h|_2 = " << flux_err << endl; }
|
||||
|
||||
@@ -349,8 +349,8 @@ void trans(const Vector &x, Vector &r)
|
||||
{
|
||||
r.SetSize(3);
|
||||
|
||||
double tol = 1e-6;
|
||||
double theta = 0.0;
|
||||
real_t tol = 1e-6;
|
||||
real_t theta = 0.0;
|
||||
if (fabs(x[1] + 1.0) < tol)
|
||||
{
|
||||
theta = 0.25 * M_PI * (x[0] - 2.0);
|
||||
@@ -382,7 +382,7 @@ void trans(const Vector &x, Vector &r)
|
||||
void sigmaFunc(const Vector &x, DenseMatrix &s)
|
||||
{
|
||||
s.SetSize(3);
|
||||
double a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
|
||||
real_t a = 17.0 - 2.0 * x[0] * (1.0 + x[0]);
|
||||
s(0,0) = 0.5 + x[0] * x[0] * (8.0 / a - 0.5);
|
||||
s(0,1) = x[0] * x[1] * (8.0 / a - 0.5);
|
||||
s(0,2) = 0.0;
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ using namespace mfem;
|
||||
// Exact solution, E, and r.h.s., f. See below for implementation.
|
||||
void E_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
int dim;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
+14
-14
@@ -42,9 +42,9 @@ using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
// Piecewise-affine function which is sometimes mesh-conforming
|
||||
double affine_function(const Vector &p)
|
||||
real_t affine_function(const Vector &p)
|
||||
{
|
||||
double x = p(0), y = p(1);
|
||||
real_t x = p(0), y = p(1);
|
||||
if (x < 0.0)
|
||||
{
|
||||
return 1.0 + x + y;
|
||||
@@ -56,7 +56,7 @@ double affine_function(const Vector &p)
|
||||
}
|
||||
|
||||
// Piecewise-constant function which is never mesh-conforming
|
||||
double jump_function(const Vector &p)
|
||||
real_t jump_function(const Vector &p)
|
||||
{
|
||||
if (p.Normlp(2.0) > 0.4 && p.Normlp(2.0) < 0.6)
|
||||
{
|
||||
@@ -70,17 +70,17 @@ double jump_function(const Vector &p)
|
||||
|
||||
// Singular function derived from the Laplacian of the "steep wavefront" problem
|
||||
// in [2].
|
||||
double singular_function(const Vector &p)
|
||||
real_t singular_function(const Vector &p)
|
||||
{
|
||||
double x = p(0), y = p(1);
|
||||
double alpha = 1000.0;
|
||||
double xc = 0.75, yc = 0.5;
|
||||
double r0 = 0.7;
|
||||
double r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
|
||||
double num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
|
||||
double denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
|
||||
real_t x = p(0), y = p(1);
|
||||
real_t alpha = 1000.0;
|
||||
real_t xc = 0.75, yc = 0.5;
|
||||
real_t r0 = 0.7;
|
||||
real_t r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
|
||||
real_t num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
|
||||
real_t denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
|
||||
- 2 * pow(alpha,2) * r0 * r + 1.0 ),2);
|
||||
denom = max(denom,1e-8);
|
||||
denom = std::max(denom, (real_t) 1.0e-8);
|
||||
return num / denom;
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
int nc_limit = 1;
|
||||
int max_elems = 100*1000;
|
||||
double double_max_elems = double(max_elems);
|
||||
real_t double_max_elems = real_t(max_elems);
|
||||
bool visualization = true;
|
||||
double osc_threshold = 1e-3;
|
||||
real_t osc_threshold = 1e-3;
|
||||
int enriched_order = 5;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
|
||||
+15
-15
@@ -42,9 +42,9 @@ using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
// Piecewise-affine function which is sometimes mesh-conforming
|
||||
double affine_function(const Vector &p)
|
||||
real_t affine_function(const Vector &p)
|
||||
{
|
||||
double x = p(0), y = p(1);
|
||||
real_t x = p(0), y = p(1);
|
||||
if (x < 0.0)
|
||||
{
|
||||
return 1.0 + x + y;
|
||||
@@ -56,7 +56,7 @@ double affine_function(const Vector &p)
|
||||
}
|
||||
|
||||
// Piecewise-constant function which is never mesh-conforming
|
||||
double jump_function(const Vector &p)
|
||||
real_t jump_function(const Vector &p)
|
||||
{
|
||||
if (p.Normlp(2.0) > 0.4 && p.Normlp(2.0) < 0.6)
|
||||
{
|
||||
@@ -70,17 +70,17 @@ double jump_function(const Vector &p)
|
||||
|
||||
// Singular function derived from the Laplacian of the "steep wavefront" problem
|
||||
// in [2].
|
||||
double singular_function(const Vector &p)
|
||||
real_t singular_function(const Vector &p)
|
||||
{
|
||||
double x = p(0), y = p(1);
|
||||
double alpha = 1000.0;
|
||||
double xc = 0.75, yc = 0.5;
|
||||
double r0 = 0.7;
|
||||
double r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
|
||||
double num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
|
||||
double denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
|
||||
real_t x = p(0), y = p(1);
|
||||
real_t alpha = 1000.0;
|
||||
real_t xc = 0.75, yc = 0.5;
|
||||
real_t r0 = 0.7;
|
||||
real_t r = sqrt(pow(x - xc,2.0) + pow(y - yc,2.0));
|
||||
real_t num = - ( alpha - pow(alpha,3) * (pow(r,2) - pow(r0,2)) );
|
||||
real_t denom = pow(r * ( pow(alpha,2) * pow(r0,2) + pow(alpha,2) * pow(r,2) \
|
||||
- 2 * pow(alpha,2) * r0 * r + 1.0 ),2);
|
||||
denom = max(denom,1e-8);
|
||||
denom = std::max(denom, (real_t) 1.0e-8);
|
||||
return num / denom;
|
||||
}
|
||||
|
||||
@@ -97,10 +97,10 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
int nc_limit = 1;
|
||||
int max_elems = 1e5;
|
||||
double double_max_elems = double(max_elems);
|
||||
real_t double_max_elems = real_t(max_elems);
|
||||
bool visualization = true;
|
||||
bool nc_simplices = true;
|
||||
double osc_threshold = 1e-3;
|
||||
real_t osc_threshold = 1e-3;
|
||||
int enriched_order = 5;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
@@ -199,7 +199,7 @@ int main(int argc, char *argv[])
|
||||
coeffrefiner.PreprocessMesh(pmesh);
|
||||
|
||||
int globalNE = pmesh.GetGlobalNE();
|
||||
double osc = coeffrefiner.GetOsc();
|
||||
real_t osc = coeffrefiner.GetOsc();
|
||||
if (myid == 0)
|
||||
{
|
||||
mfem::out << "\n";
|
||||
|
||||
+28
-28
@@ -39,7 +39,7 @@ using namespace mfem;
|
||||
void E_exact(const Vector &, Vector &);
|
||||
void CurlE_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
int dim;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -177,7 +177,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 13. Compute and print the H(Curl) norm of the error.
|
||||
{
|
||||
double error = sol.ComputeHCurlError(&E, &CurlE);
|
||||
real_t error = sol.ComputeHCurlError(&E, &CurlE);
|
||||
cout << "\n|| E_h - E ||_{H(Curl)} = " << error << '\n' << endl;
|
||||
}
|
||||
|
||||
@@ -376,8 +376,8 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
{
|
||||
if (dim == 1)
|
||||
{
|
||||
double c4 = cos(kappa * x(0) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * x(0) + 0.9 * M_PI);
|
||||
real_t c4 = cos(kappa * x(0) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * x(0) + 0.9 * M_PI);
|
||||
|
||||
dE(0) = 0.0;
|
||||
dE(1) = -1.3 * c9;
|
||||
@@ -386,9 +386,9 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
|
||||
dE(0) = 1.3 * c9;
|
||||
dE(1) = -1.3 * c9;
|
||||
@@ -397,13 +397,13 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
}
|
||||
else
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double sk = sin(kappa * x(2));
|
||||
double ck = cos(kappa * x(2));
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t sk = sin(kappa * x(2));
|
||||
real_t ck = cos(kappa * x(2));
|
||||
|
||||
dE(0) = 1.2 * s4 * sk + 1.3 * M_SQRT1_2 * c9 * ck;
|
||||
dE(1) = -1.1 * s0 * sk - 1.3 * M_SQRT1_2 * c9 * ck;
|
||||
@@ -416,9 +416,9 @@ void f_exact(const Vector &x, Vector &f)
|
||||
{
|
||||
if (dim == 1)
|
||||
{
|
||||
double s0 = sin(kappa * x(0) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * x(0) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * x(0) + 0.9 * M_PI);
|
||||
real_t s0 = sin(kappa * x(0) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * x(0) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * x(0) + 0.9 * M_PI);
|
||||
|
||||
f(0) = 2.2 * s0 + 1.2 * M_SQRT1_2 * s4;
|
||||
f(1) = 1.2 * (2.0 + kappa * kappa) * s4 +
|
||||
@@ -427,9 +427,9 @@ void f_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
|
||||
f(0) = 0.55 * (4.0 + kappa * kappa) * s0 +
|
||||
0.6 * (M_SQRT2 - kappa * kappa) * s4;
|
||||
@@ -440,14 +440,14 @@ void f_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
else
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double sk = sin(kappa * x(2));
|
||||
double ck = cos(kappa * x(2));
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t sk = sin(kappa * x(2));
|
||||
real_t ck = cos(kappa * x(2));
|
||||
|
||||
f(0) = 0.55 * (4.0 + 3.0 * kappa * kappa) * s0 * ck +
|
||||
0.6 * (M_SQRT2 - kappa * kappa) * s4 * ck -
|
||||
|
||||
+28
-28
@@ -39,7 +39,7 @@ using namespace mfem;
|
||||
void E_exact(const Vector &, Vector &);
|
||||
void CurlE_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
int dim;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -224,7 +224,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 14. Compute and print the H(Curl) norm of the error.
|
||||
{
|
||||
double error = sol.ComputeHCurlError(&E, &CurlE);
|
||||
real_t error = sol.ComputeHCurlError(&E, &CurlE);
|
||||
if (Mpi::Root())
|
||||
{
|
||||
cout << "\n|| E_h - E ||_{H(Curl)} = " << error << '\n' << endl;
|
||||
@@ -442,8 +442,8 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
{
|
||||
if (dim == 1)
|
||||
{
|
||||
double c4 = cos(kappa * x(0) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * x(0) + 0.9 * M_PI);
|
||||
real_t c4 = cos(kappa * x(0) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * x(0) + 0.9 * M_PI);
|
||||
|
||||
dE(0) = 0.0;
|
||||
dE(1) = -1.3 * c9;
|
||||
@@ -452,9 +452,9 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
|
||||
dE(0) = 1.3 * c9;
|
||||
dE(1) = -1.3 * c9;
|
||||
@@ -463,13 +463,13 @@ void CurlE_exact(const Vector &x, Vector &dE)
|
||||
}
|
||||
else
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double sk = sin(kappa * x(2));
|
||||
double ck = cos(kappa * x(2));
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t sk = sin(kappa * x(2));
|
||||
real_t ck = cos(kappa * x(2));
|
||||
|
||||
dE(0) = 1.2 * s4 * sk + 1.3 * M_SQRT1_2 * c9 * ck;
|
||||
dE(1) = -1.1 * s0 * sk - 1.3 * M_SQRT1_2 * c9 * ck;
|
||||
@@ -482,9 +482,9 @@ void f_exact(const Vector &x, Vector &f)
|
||||
{
|
||||
if (dim == 1)
|
||||
{
|
||||
double s0 = sin(kappa * x(0) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * x(0) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * x(0) + 0.9 * M_PI);
|
||||
real_t s0 = sin(kappa * x(0) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * x(0) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * x(0) + 0.9 * M_PI);
|
||||
|
||||
f(0) = 2.2 * s0 + 1.2 * M_SQRT1_2 * s4;
|
||||
f(1) = 1.2 * (2.0 + kappa * kappa) * s4 +
|
||||
@@ -493,9 +493,9 @@ void f_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
else if (dim == 2)
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
|
||||
f(0) = 0.55 * (4.0 + kappa * kappa) * s0 +
|
||||
0.6 * (M_SQRT2 - kappa * kappa) * s4;
|
||||
@@ -506,14 +506,14 @@ void f_exact(const Vector &x, Vector &f)
|
||||
}
|
||||
else
|
||||
{
|
||||
double s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
double s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
double s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
double sk = sin(kappa * x(2));
|
||||
double ck = cos(kappa * x(2));
|
||||
real_t s0 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t c0 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.0 * M_PI);
|
||||
real_t s4 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t c4 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.4 * M_PI);
|
||||
real_t s9 = sin(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t c9 = cos(kappa * M_SQRT1_2 * (x(0) + x(1)) + 0.9 * M_PI);
|
||||
real_t sk = sin(kappa * x(2));
|
||||
real_t ck = cos(kappa * x(2));
|
||||
|
||||
f(0) = 0.55 * (4.0 + 3.0 * kappa * kappa) * s0 * ck +
|
||||
0.6 * (M_SQRT2 - kappa * kappa) * s4 * ck -
|
||||
|
||||
+18
-18
@@ -35,8 +35,8 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
double GetVectorMax(int vdim, const ParGridFunction &x);
|
||||
double GetScalarMax(const ParGridFunction &x);
|
||||
real_t GetVectorMax(int vdim, const ParGridFunction &x);
|
||||
real_t GetScalarMax(const ParGridFunction &x);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -140,7 +140,7 @@ int main(int argc, char *argv[])
|
||||
// extract the corresponding parallel matrices A and M.
|
||||
HypreParMatrix *A = NULL;
|
||||
HypreParMatrix *M = NULL;
|
||||
double shift = 0.0;
|
||||
real_t shift = 0.0;
|
||||
{
|
||||
DenseMatrix epsilonMat(3);
|
||||
epsilonMat(0,0) = 2.0; epsilonMat(1,1) = 2.0; epsilonMat(2,2) = 2.0;
|
||||
@@ -178,7 +178,7 @@ int main(int argc, char *argv[])
|
||||
m.AddDomainIntegrator(new VectorFEMassIntegrator(epsilon));
|
||||
m.Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m.Finalize();
|
||||
|
||||
A = a.ParallelAssemble();
|
||||
@@ -204,7 +204,7 @@ int main(int argc, char *argv[])
|
||||
// 9. Compute the eigenmodes and extract the array of eigenvalues. Define
|
||||
// parallel grid functions to represent each of the eigenmodes returned by
|
||||
// the solver and their derivatives.
|
||||
Array<double> eigenvalues;
|
||||
Array<real_t> eigenvalues;
|
||||
ame->Solve();
|
||||
ame->GetEigenvalues(eigenvalues);
|
||||
ParGridFunction x(&fespace_nd);
|
||||
@@ -308,10 +308,10 @@ int main(int argc, char *argv[])
|
||||
yComp.ProjectCoefficient(yCoef);
|
||||
zComp.ProjectCoefficient(zCoef);
|
||||
|
||||
double max_x = GetScalarMax(xComp);
|
||||
double max_y = GetScalarMax(yComp);
|
||||
double max_z = GetScalarMax(zComp);
|
||||
double max_r = std::max(max_x, std::max(max_y, max_z));
|
||||
real_t max_x = GetScalarMax(xComp);
|
||||
real_t max_y = GetScalarMax(yComp);
|
||||
real_t max_z = GetScalarMax(zComp);
|
||||
real_t max_r = std::max(max_x, std::max(max_y, max_z));
|
||||
|
||||
ostringstream x_cmd;
|
||||
x_cmd << " window_title 'Eigenmode " << i+1 << '/' << nev
|
||||
@@ -368,7 +368,7 @@ int main(int argc, char *argv[])
|
||||
dyComp.ProjectCoefficient(dyCoef);
|
||||
dzComp.ProjectCoefficient(dzCoef);
|
||||
|
||||
double min_d = max_r / (bbMax[0] - bbMin[0]);
|
||||
real_t min_d = max_r / (bbMax[0] - bbMin[0]);
|
||||
|
||||
max_y = GetScalarMax(dyComp);
|
||||
max_z = GetScalarMax(dzComp);
|
||||
@@ -480,9 +480,9 @@ int main(int argc, char *argv[])
|
||||
xyComp.ProjectCoefficient(xyCoef);
|
||||
zComp.ProjectCoefficient(zCoef);
|
||||
|
||||
double max_v = GetVectorMax(2, xyComp);
|
||||
double max_s = GetScalarMax(zComp);
|
||||
double max_r = std::max(max_v, max_s);
|
||||
real_t max_v = GetVectorMax(2, xyComp);
|
||||
real_t max_s = GetScalarMax(zComp);
|
||||
real_t max_r = std::max(max_v, max_s);
|
||||
|
||||
ostringstream xy_cmd;
|
||||
xy_cmd << " window_title 'Eigenmode " << i+1 << '/' << nev
|
||||
@@ -523,7 +523,7 @@ int main(int argc, char *argv[])
|
||||
dxyComp.ProjectCoefficient(dxyCoef);
|
||||
dzComp.ProjectCoefficient(dzCoef);
|
||||
|
||||
double min_d = max_r / std::min(bbMax[0] - bbMin[0],
|
||||
real_t min_d = max_r / std::min(bbMax[0] - bbMin[0],
|
||||
bbMax[1] - bbMin[1]);
|
||||
|
||||
max_v = GetVectorMax(2, dxyComp);
|
||||
@@ -649,17 +649,17 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double GetVectorMax(int vdim, const ParGridFunction &x)
|
||||
real_t GetVectorMax(int vdim, const ParGridFunction &x)
|
||||
{
|
||||
Vector zeroVec(vdim); zeroVec = 0.0;
|
||||
VectorConstantCoefficient zero(zeroVec);
|
||||
double nrm = x.ComputeMaxError(zero);
|
||||
real_t nrm = x.ComputeMaxError(zero);
|
||||
return nrm;
|
||||
}
|
||||
|
||||
double GetScalarMax(const ParGridFunction &x)
|
||||
real_t GetScalarMax(const ParGridFunction &x)
|
||||
{
|
||||
ConstantCoefficient zero(0.0);
|
||||
double nrm = x.ComputeMaxError(zero);
|
||||
real_t nrm = x.ComputeMaxError(zero);
|
||||
return nrm;
|
||||
}
|
||||
|
||||
+11
-7
@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
|
||||
const char *mesh_file = "../data/star.mesh";
|
||||
int order = 1;
|
||||
int num_refs = 3;
|
||||
double alpha = 0.5;
|
||||
real_t alpha = 0.5;
|
||||
bool visualization = true;
|
||||
bool verification = false;
|
||||
|
||||
@@ -118,13 +118,17 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
args.PrintOptions(cout);
|
||||
|
||||
Array<double> coeffs, poles;
|
||||
#ifdef MFEM_USE_SINGLE
|
||||
MFEM_ABORT("This example is not supported in single precision.");
|
||||
#endif
|
||||
|
||||
Array<real_t> coeffs, poles;
|
||||
int progress_steps = 1;
|
||||
|
||||
// 2. Compute the rational expansion coefficients that define the
|
||||
// integer-order PDEs.
|
||||
const int power_of_laplace = (int)floor(alpha);
|
||||
double exponent_to_approximate = alpha - power_of_laplace;
|
||||
real_t exponent_to_approximate = alpha - power_of_laplace;
|
||||
bool integer_order = false;
|
||||
// Check if alpha is an integer or not.
|
||||
if (abs(exponent_to_approximate) > 1e-12)
|
||||
@@ -135,7 +139,7 @@ int main(int argc, char *argv[])
|
||||
ComputePartialFractionApproximation(exponent_to_approximate, coeffs,
|
||||
poles);
|
||||
|
||||
// If the example is build without LAPACK, the exponent_to_approximate
|
||||
// If the example is built without LAPACK, the exponent_to_approximate
|
||||
// might be modified by the function call above.
|
||||
alpha = exponent_to_approximate + power_of_laplace;
|
||||
}
|
||||
@@ -173,7 +177,7 @@ int main(int argc, char *argv[])
|
||||
// 7. Define diffusion coefficient, load, and solution GridFunction.
|
||||
auto func = [&alpha](const Vector &x)
|
||||
{
|
||||
double val = 1.0;
|
||||
real_t val = 1.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
val *= sin(M_PI*x(i));
|
||||
@@ -364,7 +368,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
auto solution = [] (const Vector &x)
|
||||
{
|
||||
double val = 1.0;
|
||||
real_t val = 1.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
val *= sin(M_PI*x(i));
|
||||
@@ -372,7 +376,7 @@ int main(int argc, char *argv[])
|
||||
return val;
|
||||
};
|
||||
FunctionCoefficient sol(solution);
|
||||
double l2_error = u.ComputeL2Error(sol);
|
||||
real_t l2_error = u.ComputeL2Error(sol);
|
||||
|
||||
string analytic_solution,expected_mesh;
|
||||
switch (dim)
|
||||
|
||||
+28
-28
@@ -50,8 +50,8 @@ using namespace mfem;
|
||||
|
||||
See pg. A1501 of Nakatsukasa et al. [1]. */
|
||||
void RationalApproximation_AAA(const Vector &val, const Vector &pt,
|
||||
Array<double> &z, Array<double> &f, Vector &w,
|
||||
double tol, int max_order)
|
||||
Array<real_t> &z, Array<real_t> &f, Vector &w,
|
||||
real_t tol, int max_order)
|
||||
{
|
||||
|
||||
// number of sample points
|
||||
@@ -67,11 +67,11 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
|
||||
DenseMatrix C, Ctemp, A, Am;
|
||||
// auxiliary arrays and vectors
|
||||
Vector f_vec;
|
||||
Array<double> c_i;
|
||||
Array<real_t> c_i;
|
||||
|
||||
// mean of the value vector
|
||||
Vector R(val.Size());
|
||||
double mean_val = val.Sum()/size;
|
||||
real_t mean_val = val.Sum()/size;
|
||||
|
||||
for (int i = 0; i<R.Size(); i++) { R(i) = mean_val; }
|
||||
|
||||
@@ -79,10 +79,10 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
|
||||
{
|
||||
// select next support point
|
||||
int idx = 0;
|
||||
double tmp_max = 0;
|
||||
real_t tmp_max = 0;
|
||||
for (int j = 0; j < size; j++)
|
||||
{
|
||||
double tmp = abs(val(j)-R(j));
|
||||
real_t tmp = abs(val(j)-R(j));
|
||||
if (tmp > tmp_max)
|
||||
{
|
||||
tmp_max = tmp;
|
||||
@@ -98,7 +98,7 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
|
||||
J.DeleteFirst(idx);
|
||||
|
||||
// next column in Cauchy matrix
|
||||
Array<double> C_tmp(size);
|
||||
Array<real_t> C_tmp(size);
|
||||
for (int j = 0; j < size; j++)
|
||||
{
|
||||
C_tmp[j] = 1.0/(pt(j)-pt(idx));
|
||||
@@ -173,7 +173,7 @@ void RationalApproximation_AAA(const Vector &val, const Vector &pt,
|
||||
|
||||
See pg. A1501 of Nakatsukasa et al. [1]. */
|
||||
void ComputePolesAndZeros(const Vector &z, const Vector &f, const Vector &w,
|
||||
Array<double> & poles, Array<double> & zeros, double &scale)
|
||||
Array<real_t> & poles, Array<real_t> & zeros, real_t &scale)
|
||||
{
|
||||
// Initialization
|
||||
poles.SetSize(0);
|
||||
@@ -242,8 +242,8 @@ void ComputePolesAndZeros(const Vector &z, const Vector &f, const Vector &w,
|
||||
@param[in] zeros Array of zeros
|
||||
@param[in] scale Scaling constant
|
||||
@param[out] coeffs Coefficients c_i */
|
||||
void PartialFractionExpansion(double scale, Array<double> & poles,
|
||||
Array<double> & zeros, Array<double> & coeffs)
|
||||
void PartialFractionExpansion(real_t scale, Array<real_t> & poles,
|
||||
Array<real_t> & zeros, Array<real_t> & coeffs)
|
||||
{
|
||||
int psize = poles.Size();
|
||||
int zsize = zeros.Size();
|
||||
@@ -259,13 +259,13 @@ void PartialFractionExpansion(double scale, Array<double> & poles,
|
||||
|
||||
for (int i=0; i<psize; i++)
|
||||
{
|
||||
double tmp_numer=1.0;
|
||||
real_t tmp_numer=1.0;
|
||||
for (int j=0; j<zsize; j++)
|
||||
{
|
||||
tmp_numer *= poles[i]-zeros[j];
|
||||
}
|
||||
|
||||
double tmp_denom=1.0;
|
||||
real_t tmp_denom=1.0;
|
||||
for (int k=0; k<psize; k++)
|
||||
{
|
||||
if (k != i) { tmp_denom *= poles[i]-poles[k]; }
|
||||
@@ -292,10 +292,10 @@ void PartialFractionExpansion(double scale, Array<double> & poles,
|
||||
@a alpha != 0.99, then @a alpha = 0.5 is used by default.
|
||||
|
||||
See pg. A1501 of Nakatsukasa et al. [1]. */
|
||||
void ComputePartialFractionApproximation(double & alpha,
|
||||
Array<double> & coeffs, Array<double> & poles,
|
||||
double lmax = 1000.,
|
||||
double tol=1e-10, int npoints = 1000,
|
||||
void ComputePartialFractionApproximation(real_t & alpha,
|
||||
Array<real_t> & coeffs, Array<real_t> & poles,
|
||||
real_t lmax = 1000.,
|
||||
real_t tol=1e-10, int npoints = 1000,
|
||||
int max_order = 100)
|
||||
{
|
||||
MFEM_VERIFY(alpha < 1., "alpha must be less than 1");
|
||||
@@ -320,26 +320,26 @@ void ComputePartialFractionApproximation(double & alpha,
|
||||
<< "\nThe default is alpha = 0.5.\n" << string(80, '=') << "\n"
|
||||
<< endl;
|
||||
}
|
||||
const double eps = std::numeric_limits<double>::epsilon();
|
||||
const real_t eps = std::numeric_limits<real_t>::epsilon();
|
||||
|
||||
if (abs(alpha - 0.33) < eps)
|
||||
{
|
||||
coeffs = Array<double> ({1.821898e+03, 9.101221e+01, 2.650611e+01,
|
||||
coeffs = Array<real_t> ({1.821898e+03, 9.101221e+01, 2.650611e+01,
|
||||
1.174937e+01, 6.140444e+00, 3.441713e+00,
|
||||
1.985735e+00, 1.162634e+00, 6.891560e-01,
|
||||
4.111574e-01, 2.298736e-01});
|
||||
poles = Array<double> ({-4.155583e+04, -2.956285e+03, -8.331715e+02,
|
||||
poles = Array<real_t> ({-4.155583e+04, -2.956285e+03, -8.331715e+02,
|
||||
-3.139332e+02, -1.303448e+02, -5.563385e+01,
|
||||
-2.356255e+01, -9.595516e+00, -3.552160e+00,
|
||||
-1.032136e+00, -1.241480e-01});
|
||||
}
|
||||
else if (abs(alpha - 0.99) < eps)
|
||||
{
|
||||
coeffs = Array<double>({2.919591e-02, 1.419750e-02, 1.065798e-02,
|
||||
coeffs = Array<real_t>({2.919591e-02, 1.419750e-02, 1.065798e-02,
|
||||
9.395094e-03, 8.915329e-03, 8.822991e-03,
|
||||
9.058247e-03, 9.814521e-03, 1.180396e-02,
|
||||
1.834554e-02, 9.840482e-01});
|
||||
poles = Array<double> ({-1.069683e+04, -1.769370e+03, -5.718374e+02,
|
||||
poles = Array<real_t> ({-1.069683e+04, -1.769370e+03, -5.718374e+02,
|
||||
-2.242095e+02, -9.419132e+01, -4.031012e+01,
|
||||
-1.701525e+01, -6.810088e+00, -2.382810e+00,
|
||||
-5.700059e-01, -1.384324e-03});
|
||||
@@ -350,11 +350,11 @@ void ComputePartialFractionApproximation(double & alpha,
|
||||
{
|
||||
alpha = 0.5;
|
||||
}
|
||||
coeffs = Array<double>({2.290262e+02, 2.641819e+01, 1.005566e+01,
|
||||
coeffs = Array<real_t>({2.290262e+02, 2.641819e+01, 1.005566e+01,
|
||||
5.390411e+00, 3.340725e+00, 2.211205e+00,
|
||||
1.508883e+00, 1.049474e+00, 7.462709e-01,
|
||||
5.482686e-01, 4.232510e-01, 3.578967e-01});
|
||||
poles = Array<double>({-3.168211e+04, -3.236077e+03, -9.868287e+02,
|
||||
poles = Array<real_t>({-3.168211e+04, -3.236077e+03, -9.868287e+02,
|
||||
-3.945597e+02, -1.738889e+02, -7.925178e+01,
|
||||
-3.624992e+01, -1.629196e+01, -6.982956e+00,
|
||||
-2.679984e+00, -7.782607e-01, -7.649166e-02});
|
||||
@@ -372,15 +372,15 @@ void ComputePartialFractionApproximation(double & alpha,
|
||||
|
||||
Vector x(npoints);
|
||||
Vector val(npoints);
|
||||
double dx = lmax / (double)(npoints-1);
|
||||
real_t dx = lmax / (real_t)(npoints-1);
|
||||
for (int i = 0; i<npoints; i++)
|
||||
{
|
||||
x(i) = dx * (double)i;
|
||||
x(i) = dx * (real_t)i;
|
||||
val(i) = pow(x(i),1.-alpha);
|
||||
}
|
||||
|
||||
// Apply triple-A algorithm to f(x) = x^{1-a}
|
||||
Array<double> z, f;
|
||||
Array<real_t> z, f;
|
||||
Vector w;
|
||||
RationalApproximation_AAA(val,x,z,f,w,tol,max_order);
|
||||
|
||||
@@ -389,8 +389,8 @@ void ComputePartialFractionApproximation(double & alpha,
|
||||
vecf.SetDataAndSize(f.GetData(), f.Size());
|
||||
|
||||
// Compute poles and zeros for RA of f(x) = x^{1-a}
|
||||
double scale;
|
||||
Array<double> zeros;
|
||||
real_t scale;
|
||||
Array<real_t> zeros;
|
||||
ComputePolesAndZeros(vecz, vecf, w, poles, zeros, scale);
|
||||
|
||||
// Remove the zero at x=0, thus, delivering a RA for f(x) = x^{-a}
|
||||
|
||||
+10
-6
@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
|
||||
const char *mesh_file = "../data/star.mesh";
|
||||
int order = 1;
|
||||
int num_refs = 3;
|
||||
double alpha = 0.5;
|
||||
real_t alpha = 0.5;
|
||||
bool visualization = true;
|
||||
bool verification = false;
|
||||
|
||||
@@ -127,13 +127,17 @@ int main(int argc, char *argv[])
|
||||
args.PrintOptions(cout);
|
||||
}
|
||||
|
||||
Array<double> coeffs, poles;
|
||||
#ifdef MFEM_USE_SINGLE
|
||||
MFEM_ABORT("This example is not supported in single precision.");
|
||||
#endif
|
||||
|
||||
Array<real_t> coeffs, poles;
|
||||
int progress_steps = 1;
|
||||
|
||||
// 2. Compute the rational expansion coefficients that define the
|
||||
// integer-order PDEs.
|
||||
const int power_of_laplace = floor(alpha);
|
||||
double exponent_to_approximate = alpha - power_of_laplace;
|
||||
real_t exponent_to_approximate = alpha - power_of_laplace;
|
||||
bool integer_order = false;
|
||||
// Check if alpha is an integer or not.
|
||||
if (abs(exponent_to_approximate) > 1e-12)
|
||||
@@ -193,7 +197,7 @@ int main(int argc, char *argv[])
|
||||
// 7. Define diffusion coefficient, load, and solution GridFunction.
|
||||
auto func = [&alpha](const Vector &x)
|
||||
{
|
||||
double val = 1.0;
|
||||
real_t val = 1.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
val *= sin(M_PI*x(i));
|
||||
@@ -398,7 +402,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
auto solution = [] (const Vector &x)
|
||||
{
|
||||
double val = 1.0;
|
||||
real_t val = 1.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
val *= sin(M_PI*x(i));
|
||||
@@ -406,7 +410,7 @@ int main(int argc, char *argv[])
|
||||
return val;
|
||||
};
|
||||
FunctionCoefficient sol(solution);
|
||||
double l2_error = u.ComputeL2Error(sol);
|
||||
real_t l2_error = u.ComputeL2Error(sol);
|
||||
|
||||
if (Mpi::Root())
|
||||
{
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
|
||||
Array<int> jn_zero_attr;
|
||||
int ref_levels = 1;
|
||||
int order = 1;
|
||||
double delta_const = 1e-6;
|
||||
real_t delta_const = 1e-6;
|
||||
bool mixed = true;
|
||||
bool static_cond = false;
|
||||
const char *device_config = "cpu";
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
|
||||
int ser_ref_levels = 1;
|
||||
int par_ref_levels = 1;
|
||||
int order = 1;
|
||||
double delta_const = 1e-6;
|
||||
real_t delta_const = 1e-6;
|
||||
bool mixed = true;
|
||||
bool static_cond = false;
|
||||
bool pa = false;
|
||||
|
||||
+9
-9
@@ -55,9 +55,9 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
static double mu_ = 1.0;
|
||||
static double epsilon_ = 1.0;
|
||||
static double sigma_ = 2.0;
|
||||
static real_t mu_ = 1.0;
|
||||
static real_t epsilon_ = 1.0;
|
||||
static real_t sigma_ = 2.0;
|
||||
|
||||
void SetPortBC(int prob, int dim, int mode, ParGridFunction &port_bc);
|
||||
|
||||
@@ -77,9 +77,9 @@ int main(int argc, char *argv[])
|
||||
Array<int> port_bc_attr;
|
||||
int prob = 0;
|
||||
int mode = 1;
|
||||
double freq = -1.0;
|
||||
double omega = 2.0 * M_PI;
|
||||
double a_coef = 0.0;
|
||||
real_t freq = -1.0;
|
||||
real_t omega = 2.0 * M_PI;
|
||||
real_t a_coef = 0.0;
|
||||
bool herm_conv = true;
|
||||
bool slu_solver = false;
|
||||
bool visualization = 1;
|
||||
@@ -587,7 +587,7 @@ int main(int argc, char *argv[])
|
||||
int i = 0;
|
||||
while (sol_sock)
|
||||
{
|
||||
double t = (double)(i % num_frames) / num_frames;
|
||||
real_t t = (real_t)(i % num_frames) / num_frames;
|
||||
ostringstream oss;
|
||||
oss << "Harmonic Solution (t = " << t << " T)";
|
||||
|
||||
@@ -637,7 +637,7 @@ void ScalarWaveGuide(int mode, ParGridFunction &x)
|
||||
m.AddDomainIntegrator(new MassIntegrator);
|
||||
m.Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m.Finalize();
|
||||
|
||||
HypreParMatrix *A = a.ParallelAssemble();
|
||||
@@ -694,7 +694,7 @@ void VectorWaveGuide(int mode, ParGridFunction &x)
|
||||
m.AddDomainIntegrator(new VectorFEMassIntegrator);
|
||||
m.Assemble();
|
||||
// shift the eigenvalue corresponding to eliminated dofs to a large value
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<double>::min());
|
||||
m.EliminateEssentialBCDiag(ess_bdr, numeric_limits<real_t>::min());
|
||||
m.Finalize();
|
||||
|
||||
HypreParMatrix *A = a.ParallelAssemble();
|
||||
|
||||
+45
-45
@@ -37,8 +37,8 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
double spherical_obstacle(const Vector &pt);
|
||||
double exact_solution_obstacle(const Vector &pt);
|
||||
real_t spherical_obstacle(const Vector &pt);
|
||||
real_t exact_solution_obstacle(const Vector &pt);
|
||||
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad);
|
||||
|
||||
class LogarithmGridFunctionCoefficient : public Coefficient
|
||||
@@ -46,14 +46,14 @@ class LogarithmGridFunctionCoefficient : public Coefficient
|
||||
protected:
|
||||
GridFunction *u; // grid function
|
||||
Coefficient *obstacle;
|
||||
double min_val;
|
||||
real_t min_val;
|
||||
|
||||
public:
|
||||
LogarithmGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
|
||||
double min_val_=-36)
|
||||
real_t min_val_=-36)
|
||||
: u(&u_), obstacle(&obst_), min_val(min_val_) { }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
class ExponentialGridFunctionCoefficient : public Coefficient
|
||||
@@ -61,15 +61,15 @@ class ExponentialGridFunctionCoefficient : public Coefficient
|
||||
protected:
|
||||
GridFunction *u;
|
||||
Coefficient *obstacle;
|
||||
double min_val;
|
||||
double max_val;
|
||||
real_t min_val;
|
||||
real_t max_val;
|
||||
|
||||
public:
|
||||
ExponentialGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
|
||||
double min_val_=0.0, double max_val_=1e6)
|
||||
real_t min_val_=0.0, real_t max_val_=1e6)
|
||||
: u(&u_), obstacle(&obst_), min_val(min_val_), max_val(max_val_) { }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -78,8 +78,8 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
int max_it = 10;
|
||||
int ref_levels = 3;
|
||||
double alpha = 1.0;
|
||||
double tol = 1e-5;
|
||||
real_t alpha = 1.0;
|
||||
real_t tol = 1e-5;
|
||||
bool visualization = true;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
@@ -124,7 +124,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 3C. Rescale the domain to a unit circle (radius = 1).
|
||||
GridFunction *nodes = mesh.GetNodes();
|
||||
double scale = 2*sqrt(2);
|
||||
real_t scale = 2*sqrt(2);
|
||||
*nodes /= scale;
|
||||
|
||||
// 4. Define the necessary finite element spaces on the mesh.
|
||||
@@ -159,8 +159,8 @@ int main(int argc, char *argv[])
|
||||
// 6. Define an initial guess for the solution.
|
||||
auto IC_func = [](const Vector &x)
|
||||
{
|
||||
double r0 = 1.0;
|
||||
double rr = 0.0;
|
||||
real_t r0 = 1.0;
|
||||
real_t rr = 0.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
rr += x(i)*x(i);
|
||||
@@ -211,7 +211,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Iterate
|
||||
int k;
|
||||
int total_iterations = 0;
|
||||
double increment_u = 0.1;
|
||||
real_t increment_u = 0.1;
|
||||
for (k = 0; k < max_it; k++)
|
||||
{
|
||||
GridFunction u_tmp(&H1fes);
|
||||
@@ -300,10 +300,10 @@ int main(int argc, char *argv[])
|
||||
delta_psi_gf.MakeRef(&L2fes, x.GetBlock(1), 0);
|
||||
|
||||
u_tmp -= u_gf;
|
||||
double Newton_update_size = u_tmp.ComputeL2Error(zero);
|
||||
real_t Newton_update_size = u_tmp.ComputeL2Error(zero);
|
||||
u_tmp = u_gf;
|
||||
|
||||
double gamma = 1.0;
|
||||
real_t gamma = 1.0;
|
||||
delta_psi_gf *= gamma;
|
||||
psi_gf += delta_psi_gf;
|
||||
|
||||
@@ -337,7 +337,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
mfem::out << "H1-error (|| u - uₕᵏ||) = " << H1_error << endl;
|
||||
|
||||
}
|
||||
@@ -362,13 +362,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
{
|
||||
double L2_error = u_gf.ComputeL2Error(exact_coef);
|
||||
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
real_t L2_error = u_gf.ComputeL2Error(exact_coef);
|
||||
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
|
||||
ExponentialGridFunctionCoefficient u_alt_cf(psi_gf,obstacle);
|
||||
GridFunction u_alt_gf(&L2fes);
|
||||
u_alt_gf.ProjectCoefficient(u_alt_cf);
|
||||
double L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
|
||||
real_t L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
|
||||
|
||||
mfem::out << "\n Final L2-error (|| u - uₕ||) = " << L2_error <<
|
||||
endl;
|
||||
@@ -380,35 +380,35 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
real_t LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "grid function is not set");
|
||||
|
||||
double val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
|
||||
real_t val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
|
||||
return max(min_val, log(val));
|
||||
}
|
||||
|
||||
double ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
real_t ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "grid function is not set");
|
||||
|
||||
double val = u->GetValue(T, ip);
|
||||
real_t val = u->GetValue(T, ip);
|
||||
return min(max_val, max(min_val, exp(val) + obstacle->Eval(T, ip)));
|
||||
}
|
||||
|
||||
double spherical_obstacle(const Vector &pt)
|
||||
real_t spherical_obstacle(const Vector &pt)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double beta = 0.9;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t beta = 0.9;
|
||||
|
||||
double b = r0*beta;
|
||||
double tmp = sqrt(r0*r0 - b*b);
|
||||
double B = tmp + b*b/tmp;
|
||||
double C = -b/tmp;
|
||||
real_t b = r0*beta;
|
||||
real_t tmp = sqrt(r0*r0 - b*b);
|
||||
real_t B = tmp + b*b/tmp;
|
||||
real_t C = -b/tmp;
|
||||
|
||||
if (r > b)
|
||||
{
|
||||
@@ -420,13 +420,13 @@ double spherical_obstacle(const Vector &pt)
|
||||
}
|
||||
}
|
||||
|
||||
double exact_solution_obstacle(const Vector &pt)
|
||||
real_t exact_solution_obstacle(const Vector &pt)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double a = 0.348982574111686;
|
||||
double A = -0.340129705945858;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t a = 0.348982574111686;
|
||||
real_t A = -0.340129705945858;
|
||||
|
||||
if (r > a)
|
||||
{
|
||||
@@ -440,11 +440,11 @@ double exact_solution_obstacle(const Vector &pt)
|
||||
|
||||
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double a = 0.348982574111686;
|
||||
double A = -0.340129705945858;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t a = 0.348982574111686;
|
||||
real_t A = -0.340129705945858;
|
||||
|
||||
if (r > a)
|
||||
{
|
||||
|
||||
+45
-45
@@ -37,8 +37,8 @@
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
double spherical_obstacle(const Vector &pt);
|
||||
double exact_solution_obstacle(const Vector &pt);
|
||||
real_t spherical_obstacle(const Vector &pt);
|
||||
real_t exact_solution_obstacle(const Vector &pt);
|
||||
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad);
|
||||
|
||||
class LogarithmGridFunctionCoefficient : public Coefficient
|
||||
@@ -46,14 +46,14 @@ class LogarithmGridFunctionCoefficient : public Coefficient
|
||||
protected:
|
||||
GridFunction *u; // grid function
|
||||
Coefficient *obstacle;
|
||||
double min_val;
|
||||
real_t min_val;
|
||||
|
||||
public:
|
||||
LogarithmGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
|
||||
double min_val_=-36)
|
||||
real_t min_val_=-36)
|
||||
: u(&u_), obstacle(&obst_), min_val(min_val_) { }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
class ExponentialGridFunctionCoefficient : public Coefficient
|
||||
@@ -61,15 +61,15 @@ class ExponentialGridFunctionCoefficient : public Coefficient
|
||||
protected:
|
||||
GridFunction *u;
|
||||
Coefficient *obstacle;
|
||||
double min_val;
|
||||
double max_val;
|
||||
real_t min_val;
|
||||
real_t max_val;
|
||||
|
||||
public:
|
||||
ExponentialGridFunctionCoefficient(GridFunction &u_, Coefficient &obst_,
|
||||
double min_val_=0.0, double max_val_=1e6)
|
||||
real_t min_val_=0.0, real_t max_val_=1e6)
|
||||
: u(&u_), obstacle(&obst_), min_val(min_val_), max_val(max_val_) { }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip);
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -84,8 +84,8 @@ int main(int argc, char *argv[])
|
||||
int order = 1;
|
||||
int max_it = 10;
|
||||
int ref_levels = 3;
|
||||
double alpha = 1.0;
|
||||
double tol = 1e-5;
|
||||
real_t alpha = 1.0;
|
||||
real_t tol = 1e-5;
|
||||
bool visualization = true;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 3C. Rescale the domain to a unit circle (radius = 1).
|
||||
GridFunction *nodes = mesh.GetNodes();
|
||||
double scale = 2*sqrt(2);
|
||||
real_t scale = 2*sqrt(2);
|
||||
*nodes /= scale;
|
||||
|
||||
ParMesh pmesh(MPI_COMM_WORLD, mesh);
|
||||
@@ -192,8 +192,8 @@ int main(int argc, char *argv[])
|
||||
// 6. Define an initial guess for the solution.
|
||||
auto IC_func = [](const Vector &x)
|
||||
{
|
||||
double r0 = 1.0;
|
||||
double rr = 0.0;
|
||||
real_t r0 = 1.0;
|
||||
real_t rr = 0.0;
|
||||
for (int i=0; i<x.Size(); i++)
|
||||
{
|
||||
rr += x(i)*x(i);
|
||||
@@ -243,7 +243,7 @@ int main(int argc, char *argv[])
|
||||
// 10. Iterate
|
||||
int k;
|
||||
int total_iterations = 0;
|
||||
double increment_u = 0.1;
|
||||
real_t increment_u = 0.1;
|
||||
for (k = 0; k < max_it; k++)
|
||||
{
|
||||
ParGridFunction u_tmp(&H1fes);
|
||||
@@ -346,10 +346,10 @@ int main(int argc, char *argv[])
|
||||
delta_psi_gf.SetFromTrueDofs(tx.GetBlock(1));
|
||||
|
||||
u_tmp -= u_gf;
|
||||
double Newton_update_size = u_tmp.ComputeL2Error(zero);
|
||||
real_t Newton_update_size = u_tmp.ComputeL2Error(zero);
|
||||
u_tmp = u_gf;
|
||||
|
||||
double gamma = 1.0;
|
||||
real_t gamma = 1.0;
|
||||
delta_psi_gf *= gamma;
|
||||
psi_gf += delta_psi_gf;
|
||||
|
||||
@@ -391,7 +391,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
if (myid == 0)
|
||||
{
|
||||
mfem::out << "H1-error (|| u - uₕᵏ||) = " << H1_error << endl;
|
||||
@@ -423,13 +423,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
{
|
||||
double L2_error = u_gf.ComputeL2Error(exact_coef);
|
||||
double H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
real_t L2_error = u_gf.ComputeL2Error(exact_coef);
|
||||
real_t H1_error = u_gf.ComputeH1Error(&exact_coef,&exact_grad_coef);
|
||||
|
||||
ExponentialGridFunctionCoefficient u_alt_cf(psi_gf,obstacle);
|
||||
ParGridFunction u_alt_gf(&L2fes);
|
||||
u_alt_gf.ProjectCoefficient(u_alt_cf);
|
||||
double L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
|
||||
real_t L2_error_alt = u_alt_gf.ComputeL2Error(exact_coef);
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -444,35 +444,35 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
real_t LogarithmGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "grid function is not set");
|
||||
|
||||
double val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
|
||||
real_t val = u->GetValue(T, ip) - obstacle->Eval(T, ip);
|
||||
return max(min_val, log(val));
|
||||
}
|
||||
|
||||
double ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
real_t ExponentialGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
MFEM_ASSERT(u != NULL, "grid function is not set");
|
||||
|
||||
double val = u->GetValue(T, ip);
|
||||
real_t val = u->GetValue(T, ip);
|
||||
return min(max_val, max(min_val, exp(val) + obstacle->Eval(T, ip)));
|
||||
}
|
||||
|
||||
double spherical_obstacle(const Vector &pt)
|
||||
real_t spherical_obstacle(const Vector &pt)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double beta = 0.9;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t beta = 0.9;
|
||||
|
||||
double b = r0*beta;
|
||||
double tmp = sqrt(r0*r0 - b*b);
|
||||
double B = tmp + b*b/tmp;
|
||||
double C = -b/tmp;
|
||||
real_t b = r0*beta;
|
||||
real_t tmp = sqrt(r0*r0 - b*b);
|
||||
real_t B = tmp + b*b/tmp;
|
||||
real_t C = -b/tmp;
|
||||
|
||||
if (r > b)
|
||||
{
|
||||
@@ -484,13 +484,13 @@ double spherical_obstacle(const Vector &pt)
|
||||
}
|
||||
}
|
||||
|
||||
double exact_solution_obstacle(const Vector &pt)
|
||||
real_t exact_solution_obstacle(const Vector &pt)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double a = 0.348982574111686;
|
||||
double A = -0.340129705945858;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t a = 0.348982574111686;
|
||||
real_t A = -0.340129705945858;
|
||||
|
||||
if (r > a)
|
||||
{
|
||||
@@ -504,11 +504,11 @@ double exact_solution_obstacle(const Vector &pt)
|
||||
|
||||
void exact_solution_gradient_obstacle(const Vector &pt, Vector &grad)
|
||||
{
|
||||
double x = pt(0), y = pt(1);
|
||||
double r = sqrt(x*x + y*y);
|
||||
double r0 = 0.5;
|
||||
double a = 0.348982574111686;
|
||||
double A = -0.340129705945858;
|
||||
real_t x = pt(0), y = pt(1);
|
||||
real_t r = sqrt(x*x + y*y);
|
||||
real_t r0 = 0.5;
|
||||
real_t a = 0.348982574111686;
|
||||
real_t A = -0.340129705945858;
|
||||
|
||||
if (r > a)
|
||||
{
|
||||
|
||||
+24
-24
@@ -67,9 +67,9 @@ using namespace mfem;
|
||||
* @param target_volume θ vol(Ω)
|
||||
* @param tol Newton iteration tolerance
|
||||
* @param max_its Newton maximum iteration number
|
||||
* @return double Final volume, ∫_Ω sigmoid(ψ)
|
||||
* @return real_t Final volume, ∫_Ω sigmoid(ψ)
|
||||
*/
|
||||
double proj(GridFunction &psi, double target_volume, double tol=1e-12,
|
||||
real_t proj(GridFunction &psi, real_t target_volume, real_t tol=1e-12,
|
||||
int max_its=10)
|
||||
{
|
||||
MappedGridFunctionCoefficient sigmoid_psi(&psi, sigmoid);
|
||||
@@ -84,12 +84,12 @@ double proj(GridFunction &psi, double target_volume, double tol=1e-12,
|
||||
for (int k=0; k<max_its; k++) // Newton iteration
|
||||
{
|
||||
int_sigmoid_psi.Assemble(); // Recompute f(c) with updated ψ
|
||||
const double f = int_sigmoid_psi.Sum() - target_volume;
|
||||
const real_t f = int_sigmoid_psi.Sum() - target_volume;
|
||||
|
||||
int_der_sigmoid_psi.Assemble(); // Recompute df(c) with updated ψ
|
||||
const double df = int_der_sigmoid_psi.Sum();
|
||||
const real_t df = int_der_sigmoid_psi.Sum();
|
||||
|
||||
const double dc = -f/df;
|
||||
const real_t dc = -f/df;
|
||||
psi += dc;
|
||||
if (abs(dc) < tol) { done = true; break; }
|
||||
}
|
||||
@@ -179,15 +179,15 @@ int main(int argc, char *argv[])
|
||||
// 1. Parse command-line options.
|
||||
int ref_levels = 5;
|
||||
int order = 2;
|
||||
double alpha = 1.0;
|
||||
double epsilon = 0.01;
|
||||
double vol_fraction = 0.5;
|
||||
real_t alpha = 1.0;
|
||||
real_t epsilon = 0.01;
|
||||
real_t vol_fraction = 0.5;
|
||||
int max_it = 1e3;
|
||||
double itol = 1e-1;
|
||||
double ntol = 1e-4;
|
||||
double rho_min = 1e-6;
|
||||
double lambda = 1.0;
|
||||
double mu = 1.0;
|
||||
real_t itol = 1e-1;
|
||||
real_t ntol = 1e-4;
|
||||
real_t rho_min = 1e-6;
|
||||
real_t lambda = 1.0;
|
||||
real_t mu = 1.0;
|
||||
bool glvis_visualization = true;
|
||||
bool paraview_output = false;
|
||||
|
||||
@@ -239,8 +239,8 @@ int main(int argc, char *argv[])
|
||||
Array<int> vertices;
|
||||
be->GetVertices(vertices);
|
||||
|
||||
double * coords1 = mesh.GetVertex(vertices[0]);
|
||||
double * coords2 = mesh.GetVertex(vertices[1]);
|
||||
real_t * coords1 = mesh.GetVertex(vertices[0]);
|
||||
real_t * coords2 = mesh.GetVertex(vertices[1]);
|
||||
|
||||
Vector center(2);
|
||||
center(0) = 0.5*(coords1[0] + coords2[0]);
|
||||
@@ -312,7 +312,7 @@ int main(int argc, char *argv[])
|
||||
ElasticitySolver->SetupFEM();
|
||||
Vector center(2); center(0) = 2.9; center(1) = 0.5;
|
||||
Vector force(2); force(0) = 0.0; force(1) = -1.0;
|
||||
double r = 0.05;
|
||||
real_t r = 0.05;
|
||||
VolumeForceCoefficient vforce_cf(r,center,force);
|
||||
ElasticitySolver->SetRHSCoefficient(&vforce_cf);
|
||||
ElasticitySolver->SetEssentialBoundary(ess_bdr);
|
||||
@@ -353,8 +353,8 @@ int main(int argc, char *argv[])
|
||||
LinearForm vol_form(&control_fes);
|
||||
vol_form.AddDomainIntegrator(new DomainLFIntegrator(one));
|
||||
vol_form.Assemble();
|
||||
double domain_volume = vol_form(onegf);
|
||||
const double target_volume = domain_volume * vol_fraction;
|
||||
real_t domain_volume = vol_form(onegf);
|
||||
const real_t target_volume = domain_volume * vol_fraction;
|
||||
|
||||
// 10. Connect to GLVis. Prepare for VisIt output.
|
||||
char vishost[] = "localhost";
|
||||
@@ -385,7 +385,7 @@ int main(int argc, char *argv[])
|
||||
// 11. Iterate:
|
||||
for (int k = 1; k <= max_it; k++)
|
||||
{
|
||||
if (k > 1) { alpha *= ((double) k) / ((double) k-1); }
|
||||
if (k > 1) { alpha *= ((real_t) k) / ((real_t) k-1); }
|
||||
|
||||
mfem::out << "\nStep = " << k << std::endl;
|
||||
|
||||
@@ -422,14 +422,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Step 5 - Update design variable ψ ← proj(ψ - αG)
|
||||
psi.Add(-alpha, grad);
|
||||
const double material_volume = proj(psi, target_volume);
|
||||
const real_t material_volume = proj(psi, target_volume);
|
||||
|
||||
// Compute ||ρ - ρ_old|| in control fes.
|
||||
double norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
|
||||
double norm_reduced_gradient = norm_increment/alpha;
|
||||
real_t norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
|
||||
real_t norm_reduced_gradient = norm_increment/alpha;
|
||||
psi_old = psi;
|
||||
|
||||
double compliance = (*(ElasticitySolver->GetLinearForm()))(u);
|
||||
real_t compliance = (*(ElasticitySolver->GetLinearForm()))(u);
|
||||
mfem::out << "norm of the reduced gradient = " << norm_reduced_gradient <<
|
||||
std::endl;
|
||||
mfem::out << "norm of the increment = " << norm_increment << endl;
|
||||
@@ -449,7 +449,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
rho_gf.ProjectCoefficient(rho);
|
||||
paraview_dc.SetCycle(k);
|
||||
paraview_dc.SetTime((double)k);
|
||||
paraview_dc.SetTime((real_t)k);
|
||||
paraview_dc.Save();
|
||||
}
|
||||
|
||||
|
||||
+40
-40
@@ -9,15 +9,15 @@ namespace mfem
|
||||
{
|
||||
|
||||
/// @brief Inverse sigmoid function
|
||||
double inv_sigmoid(double x)
|
||||
real_t inv_sigmoid(real_t x)
|
||||
{
|
||||
double tol = 1e-12;
|
||||
x = std::min(std::max(tol,x),1.0-tol);
|
||||
real_t tol = 1e-12;
|
||||
x = std::min(std::max(tol,x), real_t(1.0)-tol);
|
||||
return std::log(x/(1.0-x));
|
||||
}
|
||||
|
||||
/// @brief Sigmoid function
|
||||
double sigmoid(double x)
|
||||
real_t sigmoid(real_t x)
|
||||
{
|
||||
if (x >= 0)
|
||||
{
|
||||
@@ -30,9 +30,9 @@ double sigmoid(double x)
|
||||
}
|
||||
|
||||
/// @brief Derivative of sigmoid function
|
||||
double der_sigmoid(double x)
|
||||
real_t der_sigmoid(real_t x)
|
||||
{
|
||||
double tmp = sigmoid(-x);
|
||||
real_t tmp = sigmoid(-x);
|
||||
return tmp - std::pow(tmp,2);
|
||||
}
|
||||
|
||||
@@ -40,24 +40,24 @@ double der_sigmoid(double x)
|
||||
class MappedGridFunctionCoefficient : public GridFunctionCoefficient
|
||||
{
|
||||
protected:
|
||||
std::function<double(const double)> fun; // f:R → R
|
||||
std::function<real_t(const real_t)> fun; // f:R → R
|
||||
public:
|
||||
MappedGridFunctionCoefficient()
|
||||
:GridFunctionCoefficient(),
|
||||
fun([](double x) {return x;}) {}
|
||||
fun([](real_t x) {return x;}) {}
|
||||
MappedGridFunctionCoefficient(const GridFunction *gf,
|
||||
std::function<double(const double)> fun_,
|
||||
std::function<real_t(const real_t)> fun_,
|
||||
int comp=1)
|
||||
:GridFunctionCoefficient(gf, comp),
|
||||
fun(fun_) {}
|
||||
|
||||
|
||||
virtual double Eval(ElementTransformation &T,
|
||||
virtual real_t Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
return fun(GridFunctionCoefficient::Eval(T, ip));
|
||||
}
|
||||
void SetFunction(std::function<double(const double)> fun_) { fun = fun_; }
|
||||
void SetFunction(std::function<real_t(const real_t)> fun_) { fun = fun_; }
|
||||
};
|
||||
|
||||
|
||||
@@ -67,30 +67,30 @@ class DiffMappedGridFunctionCoefficient : public GridFunctionCoefficient
|
||||
protected:
|
||||
const GridFunction *OtherGridF;
|
||||
GridFunctionCoefficient OtherGridF_cf;
|
||||
std::function<double(const double)> fun; // f:R → R
|
||||
std::function<real_t(const real_t)> fun; // f:R → R
|
||||
public:
|
||||
DiffMappedGridFunctionCoefficient()
|
||||
:GridFunctionCoefficient(),
|
||||
OtherGridF(nullptr),
|
||||
OtherGridF_cf(),
|
||||
fun([](double x) {return x;}) {}
|
||||
fun([](real_t x) {return x;}) {}
|
||||
DiffMappedGridFunctionCoefficient(const GridFunction *gf,
|
||||
const GridFunction *other_gf,
|
||||
std::function<double(const double)> fun_,
|
||||
std::function<real_t(const real_t)> fun_,
|
||||
int comp=1)
|
||||
:GridFunctionCoefficient(gf, comp),
|
||||
OtherGridF(other_gf),
|
||||
OtherGridF_cf(OtherGridF),
|
||||
fun(fun_) {}
|
||||
|
||||
virtual double Eval(ElementTransformation &T,
|
||||
virtual real_t Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
const double value1 = fun(GridFunctionCoefficient::Eval(T, ip));
|
||||
const double value2 = fun(OtherGridF_cf.Eval(T, ip));
|
||||
const real_t value1 = fun(GridFunctionCoefficient::Eval(T, ip));
|
||||
const real_t value2 = fun(OtherGridF_cf.Eval(T, ip));
|
||||
return value1 - value2;
|
||||
}
|
||||
void SetFunction(std::function<double(const double)> fun_) { fun = fun_; }
|
||||
void SetFunction(std::function<real_t(const real_t)> fun_) { fun = fun_; }
|
||||
};
|
||||
|
||||
/// @brief Solid isotropic material penalization (SIMP) coefficient
|
||||
@@ -98,20 +98,20 @@ class SIMPInterpolationCoefficient : public Coefficient
|
||||
{
|
||||
protected:
|
||||
GridFunction *rho_filter;
|
||||
double min_val;
|
||||
double max_val;
|
||||
double exponent;
|
||||
real_t min_val;
|
||||
real_t max_val;
|
||||
real_t exponent;
|
||||
|
||||
public:
|
||||
SIMPInterpolationCoefficient(GridFunction *rho_filter_, double min_val_= 1e-6,
|
||||
double max_val_ = 1.0, double exponent_ = 3)
|
||||
SIMPInterpolationCoefficient(GridFunction *rho_filter_, real_t min_val_= 1e-6,
|
||||
real_t max_val_ = 1.0, real_t exponent_ = 3)
|
||||
: rho_filter(rho_filter_), min_val(min_val_), max_val(max_val_),
|
||||
exponent(exponent_) { }
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)
|
||||
{
|
||||
double val = rho_filter->GetValue(T, ip);
|
||||
double coeff = min_val + pow(val,exponent)*(max_val-min_val);
|
||||
real_t val = rho_filter->GetValue(T, ip);
|
||||
real_t coeff = min_val + pow(val,exponent)*(max_val-min_val);
|
||||
return coeff;
|
||||
}
|
||||
};
|
||||
@@ -126,13 +126,13 @@ protected:
|
||||
GridFunction *u = nullptr; // displacement
|
||||
GridFunction *rho_filter = nullptr; // filter density
|
||||
DenseMatrix grad; // auxiliary matrix, used in Eval
|
||||
double exponent;
|
||||
double rho_min;
|
||||
real_t exponent;
|
||||
real_t rho_min;
|
||||
|
||||
public:
|
||||
StrainEnergyDensityCoefficient(Coefficient *lambda_, Coefficient *mu_,
|
||||
GridFunction * u_, GridFunction * rho_filter_, double rho_min_=1e-6,
|
||||
double exponent_ = 3.0)
|
||||
GridFunction * u_, GridFunction * rho_filter_, real_t rho_min_=1e-6,
|
||||
real_t exponent_ = 3.0)
|
||||
: lambda(lambda_), mu(mu_), u(u_), rho_filter(rho_filter_),
|
||||
exponent(exponent_), rho_min(rho_min_)
|
||||
{
|
||||
@@ -142,13 +142,13 @@ public:
|
||||
MFEM_ASSERT(rho_filter, "density field is not set");
|
||||
}
|
||||
|
||||
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
|
||||
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)
|
||||
{
|
||||
double L = lambda->Eval(T, ip);
|
||||
double M = mu->Eval(T, ip);
|
||||
real_t L = lambda->Eval(T, ip);
|
||||
real_t M = mu->Eval(T, ip);
|
||||
u->GetVectorGradient(T, grad);
|
||||
double div_u = grad.Trace();
|
||||
double density = L*div_u*div_u;
|
||||
real_t div_u = grad.Trace();
|
||||
real_t density = L*div_u*div_u;
|
||||
int dim = T.GetSpaceDim();
|
||||
for (int i=0; i<dim; i++)
|
||||
{
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
density += M*grad(i,j)*(grad(i,j)+grad(j,i));
|
||||
}
|
||||
}
|
||||
double val = rho_filter->GetValue(T,ip);
|
||||
real_t val = rho_filter->GetValue(T,ip);
|
||||
|
||||
return -exponent * pow(val, exponent-1.0) * (1-rho_min) * density;
|
||||
}
|
||||
@@ -167,11 +167,11 @@ public:
|
||||
class VolumeForceCoefficient : public VectorCoefficient
|
||||
{
|
||||
private:
|
||||
double r;
|
||||
real_t r;
|
||||
Vector center;
|
||||
Vector force;
|
||||
public:
|
||||
VolumeForceCoefficient(double r_,Vector & center_, Vector & force_) :
|
||||
VolumeForceCoefficient(real_t r_,Vector & center_, Vector & force_) :
|
||||
VectorCoefficient(center_.Size()), r(r_), center(center_), force(force_) { }
|
||||
|
||||
using VectorCoefficient::Eval;
|
||||
@@ -186,7 +186,7 @@ public:
|
||||
xx[i]=xx[i]-center[i];
|
||||
}
|
||||
|
||||
double cr=xx.Norml2();
|
||||
real_t cr=xx.Norml2();
|
||||
V.SetSize(T.GetDimension());
|
||||
if (cr <= r)
|
||||
{
|
||||
@@ -198,7 +198,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void Set(double r_,Vector & center_, Vector & force_)
|
||||
void Set(real_t r_,Vector & center_, Vector & force_)
|
||||
{
|
||||
r=r_;
|
||||
center = center_;
|
||||
|
||||
+33
-30
@@ -66,9 +66,9 @@ using namespace mfem;
|
||||
* @param target_volume θ vol(Ω)
|
||||
* @param tol Newton iteration tolerance
|
||||
* @param max_its Newton maximum iteration number
|
||||
* @return double Final volume, ∫_Ω sigmoid(ψ)
|
||||
* @return real_t Final volume, ∫_Ω sigmoid(ψ)
|
||||
*/
|
||||
double proj(ParGridFunction &psi, double target_volume, double tol=1e-12,
|
||||
real_t proj(ParGridFunction &psi, real_t target_volume, real_t tol=1e-12,
|
||||
int max_its=10)
|
||||
{
|
||||
MappedGridFunctionCoefficient sigmoid_psi(&psi, sigmoid);
|
||||
@@ -83,15 +83,17 @@ double proj(ParGridFunction &psi, double target_volume, double tol=1e-12,
|
||||
for (int k=0; k<max_its; k++) // Newton iteration
|
||||
{
|
||||
int_sigmoid_psi.Assemble(); // Recompute f(c) with updated ψ
|
||||
double f = int_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &f, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
|
||||
real_t f = int_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &f, 1, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_SUM, MPI_COMM_WORLD);
|
||||
f -= target_volume;
|
||||
|
||||
int_der_sigmoid_psi.Assemble(); // Recompute df(c) with updated ψ
|
||||
double df = int_der_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &df, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
|
||||
real_t df = int_der_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &df, 1, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_SUM, MPI_COMM_WORLD);
|
||||
|
||||
const double dc = -f/df;
|
||||
const real_t dc = -f/df;
|
||||
psi += dc;
|
||||
if (abs(dc) < tol) { done = true; break; }
|
||||
}
|
||||
@@ -101,9 +103,9 @@ double proj(ParGridFunction &psi, double target_volume, double tol=1e-12,
|
||||
"Result may not be accurate.");
|
||||
}
|
||||
int_sigmoid_psi.Assemble();
|
||||
double material_volume = int_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &material_volume, 1, MPI_DOUBLE, MPI_SUM,
|
||||
MPI_COMM_WORLD);
|
||||
real_t material_volume = int_sigmoid_psi.Sum();
|
||||
MPI_Allreduce(MPI_IN_PLACE, &material_volume, 1,
|
||||
MPITypeMap<real_t>::mpi_type, MPI_SUM, MPI_COMM_WORLD);
|
||||
return material_volume;
|
||||
}
|
||||
|
||||
@@ -190,15 +192,15 @@ int main(int argc, char *argv[])
|
||||
// 1. Parse command-line options.
|
||||
int ref_levels = 5;
|
||||
int order = 2;
|
||||
double alpha = 1.0;
|
||||
double epsilon = 0.01;
|
||||
double vol_fraction = 0.5;
|
||||
real_t alpha = 1.0;
|
||||
real_t epsilon = 0.01;
|
||||
real_t vol_fraction = 0.5;
|
||||
int max_it = 1e3;
|
||||
double itol = 1e-1;
|
||||
double ntol = 1e-4;
|
||||
double rho_min = 1e-6;
|
||||
double lambda = 1.0;
|
||||
double mu = 1.0;
|
||||
real_t itol = 1e-1;
|
||||
real_t ntol = 1e-4;
|
||||
real_t rho_min = 1e-6;
|
||||
real_t lambda = 1.0;
|
||||
real_t mu = 1.0;
|
||||
bool glvis_visualization = true;
|
||||
bool paraview_output = false;
|
||||
|
||||
@@ -258,8 +260,8 @@ int main(int argc, char *argv[])
|
||||
Array<int> vertices;
|
||||
be->GetVertices(vertices);
|
||||
|
||||
double * coords1 = mesh.GetVertex(vertices[0]);
|
||||
double * coords2 = mesh.GetVertex(vertices[1]);
|
||||
real_t * coords1 = mesh.GetVertex(vertices[0]);
|
||||
real_t * coords2 = mesh.GetVertex(vertices[1]);
|
||||
|
||||
Vector center(2);
|
||||
center(0) = 0.5*(coords1[0] + coords2[0]);
|
||||
@@ -337,7 +339,7 @@ int main(int argc, char *argv[])
|
||||
ElasticitySolver->SetupFEM();
|
||||
Vector center(2); center(0) = 2.9; center(1) = 0.5;
|
||||
Vector force(2); force(0) = 0.0; force(1) = -1.0;
|
||||
double r = 0.05;
|
||||
real_t r = 0.05;
|
||||
VolumeForceCoefficient vforce_cf(r,center,force);
|
||||
ElasticitySolver->SetRHSCoefficient(&vforce_cf);
|
||||
ElasticitySolver->SetEssentialBoundary(ess_bdr);
|
||||
@@ -378,8 +380,8 @@ int main(int argc, char *argv[])
|
||||
ParLinearForm vol_form(&control_fes);
|
||||
vol_form.AddDomainIntegrator(new DomainLFIntegrator(one));
|
||||
vol_form.Assemble();
|
||||
double domain_volume = vol_form(onegf);
|
||||
const double target_volume = domain_volume * vol_fraction;
|
||||
real_t domain_volume = vol_form(onegf);
|
||||
const real_t target_volume = domain_volume * vol_fraction;
|
||||
|
||||
// 10. Connect to GLVis. Prepare for VisIt output.
|
||||
char vishost[] = "localhost";
|
||||
@@ -410,7 +412,7 @@ int main(int argc, char *argv[])
|
||||
// 11. Iterate:
|
||||
for (int k = 1; k <= max_it; k++)
|
||||
{
|
||||
if (k > 1) { alpha *= ((double) k) / ((double) k-1); }
|
||||
if (k > 1) { alpha *= ((real_t) k) / ((real_t) k-1); }
|
||||
|
||||
if (myid == 0)
|
||||
{
|
||||
@@ -450,15 +452,16 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Step 5 - Update design variable ψ ← proj(ψ - αG)
|
||||
psi.Add(-alpha, grad);
|
||||
const double material_volume = proj(psi, target_volume);
|
||||
const real_t material_volume = proj(psi, target_volume);
|
||||
|
||||
// Compute ||ρ - ρ_old|| in control fes.
|
||||
double norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
|
||||
double norm_reduced_gradient = norm_increment/alpha;
|
||||
real_t norm_increment = zerogf.ComputeL1Error(succ_diff_rho);
|
||||
real_t norm_reduced_gradient = norm_increment/alpha;
|
||||
psi_old = psi;
|
||||
|
||||
double compliance = (*(ElasticitySolver->GetLinearForm()))(u);
|
||||
MPI_Allreduce(MPI_IN_PLACE,&compliance,1,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD);
|
||||
real_t compliance = (*(ElasticitySolver->GetLinearForm()))(u);
|
||||
MPI_Allreduce(MPI_IN_PLACE, &compliance, 1, MPITypeMap<real_t>::mpi_type,
|
||||
MPI_SUM, MPI_COMM_WORLD);
|
||||
if (myid == 0)
|
||||
{
|
||||
mfem::out << "norm of the reduced gradient = " << norm_reduced_gradient << endl;
|
||||
@@ -480,7 +483,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
rho_gf.ProjectCoefficient(rho);
|
||||
paraview_dc.SetCycle(k);
|
||||
paraview_dc.SetTime((double)k);
|
||||
paraview_dc.SetTime((real_t)k);
|
||||
paraview_dc.Save();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,696 @@
|
||||
// MFEM Example 38
|
||||
//
|
||||
// Compile with: make ex38
|
||||
//
|
||||
// Sample runs:
|
||||
// (since all sample runs require LAPACK, the * symbol is used to exclude them
|
||||
// from the automatically generated internal MFEM tests).
|
||||
// * ex38
|
||||
// * ex38 -i volumetric1d
|
||||
// * ex38 -i surface2d
|
||||
// * ex38 -i surface2d -o 4 -r 5
|
||||
// * ex38 -i volumetric2d
|
||||
// * ex38 -i volumetric2d -o 4 -r 5
|
||||
// * ex38 -i surface3d
|
||||
// * ex38 -i surface3d -o 4 -r 5
|
||||
// * ex38 -i volumetric3d
|
||||
// * ex38 -i volumetric3d -o 4 -r 5
|
||||
//
|
||||
// Description: This example code demonstrates the use of MFEM to integrate
|
||||
// functions over implicit interfaces and subdomains bounded by
|
||||
// implicit interfaces.
|
||||
//
|
||||
// The quadrature rules are constructed by means of moment-fitting.
|
||||
// The interface is given by the zero isoline of a level-set
|
||||
// function ϕ and the subdomain is given as the domain where ϕ>0
|
||||
// holds. The algorithm for construction of the quadrature rules
|
||||
// was introduced by Mueller, Kummer and Oberlack [1].
|
||||
//
|
||||
// This example also showcases how to set up integrators using the
|
||||
// integration rules on implicit surfaces and subdomains.
|
||||
//
|
||||
// [1] Mueller, B., Kummer, F. and Oberlack, M. (2013) Highly accurate surface
|
||||
// and volume integration on implicit domains by means of moment-fitting.
|
||||
// Int. J. Numer. Meth. Engr. (96) 512-528. DOI:10.1002/nme.4569
|
||||
|
||||
#include "mfem.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
/// @brief Integration rule the example should demonstrate
|
||||
enum class IntegrationType { Volumetric1D, Surface2D, Volumetric2D,
|
||||
Surface3D, Volumetric3D
|
||||
};
|
||||
IntegrationType itype;
|
||||
|
||||
/// @brief Level-set function defining the implicit interface
|
||||
real_t lvlset(const Vector& X)
|
||||
{
|
||||
switch (itype)
|
||||
{
|
||||
case IntegrationType::Volumetric1D:
|
||||
return .55 - X(0);
|
||||
case IntegrationType::Surface2D:
|
||||
return 1. - (pow(X(0), 2.) + pow(X(1), 2.));
|
||||
case IntegrationType::Volumetric2D:
|
||||
return 1. - (pow(X(0) / 1.5, 2.) + pow(X(1) / .75, 2.));
|
||||
case IntegrationType::Surface3D:
|
||||
return 1. - (pow(X(0), 2.) + pow(X(1), 2.) + pow(X(2), 2.));
|
||||
case IntegrationType::Volumetric3D:
|
||||
return 1. - (pow(X(0) / 1.5, 2.) + pow(X(1) / .75, 2.) + pow(X(2) / .5, 2.));
|
||||
default:
|
||||
return 1.;
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Function that should be integrated
|
||||
real_t integrand(const Vector& X)
|
||||
{
|
||||
switch (itype)
|
||||
{
|
||||
case IntegrationType::Volumetric1D:
|
||||
return 1.;
|
||||
case IntegrationType::Surface2D:
|
||||
return 3. * pow(X(0), 2.) - pow(X(1), 2.);
|
||||
case IntegrationType::Volumetric2D:
|
||||
return 1.;
|
||||
case IntegrationType::Surface3D:
|
||||
return 4. - 3. * pow(X(0), 2.) + 2. * pow(X(1), 2.) - pow(X(2), 2.);
|
||||
case IntegrationType::Volumetric3D:
|
||||
return 1.;
|
||||
default:
|
||||
return 0.;
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Analytic surface integral
|
||||
real_t Surface()
|
||||
{
|
||||
switch (itype)
|
||||
{
|
||||
case IntegrationType::Volumetric1D:
|
||||
return 1.;
|
||||
case IntegrationType::Surface2D:
|
||||
return 2. * M_PI;
|
||||
case IntegrationType::Volumetric2D:
|
||||
return 7.26633616541076;
|
||||
case IntegrationType::Surface3D:
|
||||
return 40. / 3. * M_PI;
|
||||
case IntegrationType::Volumetric3D:
|
||||
return 9.90182151329315;
|
||||
default:
|
||||
return 0.;
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Analytic volume integral over subdomain with positive level-set
|
||||
real_t Volume()
|
||||
{
|
||||
switch (itype)
|
||||
{
|
||||
case IntegrationType::Volumetric1D:
|
||||
return .55;
|
||||
case IntegrationType::Surface2D:
|
||||
return NAN;
|
||||
case IntegrationType::Volumetric2D:
|
||||
return 9. / 8. * M_PI;
|
||||
case IntegrationType::Surface3D:
|
||||
return NAN;
|
||||
case IntegrationType::Volumetric3D:
|
||||
return 3. / 4. * M_PI;
|
||||
default:
|
||||
return 0.;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_LAPACK
|
||||
/**
|
||||
@brief Class for surface IntegrationRule
|
||||
|
||||
This class demonstrates how IntegrationRules computed as CutIntegrationRules
|
||||
can be saved to reduce the impact by computing them from scratch each time.
|
||||
*/
|
||||
class SIntegrationRule : public IntegrationRule
|
||||
{
|
||||
protected:
|
||||
/// @brief Space Dimension of the IntegrationRule
|
||||
int dim;
|
||||
/// @brief Column-wise matrix of the quadtrature weights
|
||||
DenseMatrix Weights;
|
||||
/// @brief Column-wise matrix of the transformation weights of the normal
|
||||
DenseMatrix SurfaceWeights;
|
||||
|
||||
public:
|
||||
/**
|
||||
@brief Constructor of SIntegrationRule
|
||||
|
||||
The surface integrationRules are computed and saved in the constructor.
|
||||
|
||||
@param [in] Order Order of the IntegrationRule
|
||||
@param [in] LvlSet Level-set defining the implicit interface
|
||||
@param [in] lsOrder Polynomial degree for approx of level-set function
|
||||
@param [in] mesh Pointer to the mesh that is used
|
||||
*/
|
||||
SIntegrationRule(int Order, Coefficient& LvlSet, int lsOrder, Mesh* mesh)
|
||||
{
|
||||
dim = mesh->Dimension();
|
||||
|
||||
IsoparametricTransformation Tr;
|
||||
MomentFittingIntRules MFIRs(Order, LvlSet, lsOrder);
|
||||
mesh->GetElementTransformation(0, &Tr);
|
||||
IntegrationRule ir;
|
||||
MFIRs.GetSurfaceIntegrationRule(Tr, ir);
|
||||
if (dim >1)
|
||||
{
|
||||
Weights.SetSize(ir.GetNPoints(), mesh->GetNE());
|
||||
}
|
||||
else
|
||||
{
|
||||
Weights.SetSize(2, mesh->GetNE());
|
||||
}
|
||||
SurfaceWeights.SetSize(ir.GetNPoints(), mesh->GetNE());
|
||||
Vector w;
|
||||
MFIRs.GetSurfaceWeights(Tr, ir, w);
|
||||
SurfaceWeights.SetCol(0, w);
|
||||
SetSize(ir.GetNPoints());
|
||||
|
||||
for (int ip = 0; ip < GetNPoints(); ip++)
|
||||
{
|
||||
IntPoint(ip).index = ip;
|
||||
IntegrationPoint &intp = IntPoint(ip);
|
||||
intp.x = ir.IntPoint(ip).x;
|
||||
intp.y = ir.IntPoint(ip).y;
|
||||
intp.z = ir.IntPoint(ip).z;
|
||||
if (dim > 1)
|
||||
{
|
||||
Weights(ip, 0) = ir.IntPoint(ip).weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
Weights(0, 0) = ir.IntPoint(ip).x;
|
||||
Weights(1, 0) = ir.IntPoint(ip).weight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int elem = 1; elem < mesh->GetNE(); elem++)
|
||||
{
|
||||
mesh->GetElementTransformation(elem, &Tr);
|
||||
MFIRs.GetSurfaceIntegrationRule(Tr, ir);
|
||||
Vector w;
|
||||
MFIRs.GetSurfaceWeights(Tr, ir, w);
|
||||
SurfaceWeights.SetCol(elem, w);
|
||||
|
||||
for (int ip = 0; ip < GetNPoints(); ip++)
|
||||
{
|
||||
if (dim > 1)
|
||||
{
|
||||
Weights(ip, elem) = ir.IntPoint(ip).weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
Weights(0, elem) = ir.IntPoint(ip).x;
|
||||
Weights(1, elem) = ir.IntPoint(ip).weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Set the weights for the given element and multiply them with the
|
||||
transformation of the interface
|
||||
*/
|
||||
void SetElementinclSurfaceWeight(int Element)
|
||||
{
|
||||
if (dim == 1)
|
||||
{
|
||||
IntegrationPoint &intp = IntPoint(0);
|
||||
intp.x = Weights(0, Element);
|
||||
intp.weight = Weights(1, Element);
|
||||
cout << intp.x << " " << Element << endl;
|
||||
}
|
||||
else
|
||||
for (int ip = 0; ip < GetNPoints(); ip++)
|
||||
{
|
||||
IntegrationPoint &intp = IntPoint(ip);
|
||||
intp.weight = Weights(ip, Element) * SurfaceWeights(ip, Element);
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Set the weights for the given element
|
||||
void SetElement(int Element)
|
||||
{
|
||||
if (dim == 1)
|
||||
{
|
||||
IntegrationPoint &intp = IntPoint(0);
|
||||
intp.x = Weights(0, Element);
|
||||
intp.weight = Weights(1, Element);
|
||||
}
|
||||
else
|
||||
for (int ip = 0; ip < GetNPoints(); ip++)
|
||||
{
|
||||
IntegrationPoint &intp = IntPoint(ip);
|
||||
intp.weight = Weights(ip, Element);
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Destructor of SIntegrationRule
|
||||
~SIntegrationRule() {}
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Class for volume IntegrationRule
|
||||
|
||||
This class demonstrates how IntegrationRules computed as CutIntegrationRules
|
||||
can be saved to reduce the impact by computing them from scratch each time.
|
||||
*/
|
||||
class CIntegrationRule : public IntegrationRule
|
||||
{
|
||||
protected:
|
||||
/// @brief Space Dimension of the IntegrationRule
|
||||
int dim;
|
||||
/// @brief Column-wise matrix of the quadtrature weights
|
||||
DenseMatrix Weights;
|
||||
|
||||
public:
|
||||
/**
|
||||
@brief Constructor of CIntegrationRule
|
||||
|
||||
The volume integrationRules are computed and saved in the constructor.
|
||||
|
||||
@param [in] Order Order of the IntegrationRule
|
||||
@param [in] LvlSet Level-set defining the implicit interface
|
||||
@param [in] lsOrder Polynomial degree for approx of level-set function
|
||||
@param [in] mesh Pointer to the mesh that is used
|
||||
*/
|
||||
CIntegrationRule(int Order, Coefficient& LvlSet, int lsOrder, Mesh* mesh)
|
||||
{
|
||||
dim = mesh->Dimension();
|
||||
|
||||
IsoparametricTransformation Tr;
|
||||
MomentFittingIntRules MFIRs(Order, LvlSet, lsOrder);
|
||||
mesh->GetElementTransformation(0, &Tr);
|
||||
IntegrationRule ir;
|
||||
MFIRs.GetVolumeIntegrationRule(Tr, ir);
|
||||
if (dim > 1)
|
||||
{
|
||||
Weights.SetSize(ir.GetNPoints(), mesh->GetNE());
|
||||
}
|
||||
else
|
||||
{
|
||||
Weights.SetSize(2 * ir.GetNPoints(), mesh->GetNE());
|
||||
}
|
||||
|
||||
SetSize(ir.GetNPoints());
|
||||
for (int ip = 0; ip < GetNPoints(); ip++)
|
||||
{
|
||||
IntPoint(ip).index = ip;
|
||||
IntegrationPoint &intp = IntPoint(ip);
|
||||
intp.x = ir.IntPoint(ip).x;
|
||||
intp.y = ir.IntPoint(ip).y;
|
||||
intp.z = ir.IntPoint(ip).z;
|
||||
if (dim > 1)
|
||||
{
|
||||
Weights(ip, 0) = ir.IntPoint(ip).weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
Weights(2 * ip, 0) = ir.IntPoint(ip).x;
|
||||
Weights(2 * ip + 1, 0) = ir.IntPoint(ip).weight;
|
||||
}
|
||||
}
|
||||
|
||||
for (int elem = 1; elem < mesh->GetNE(); elem++)
|
||||
{
|
||||
mesh->GetElementTransformation(elem, &Tr);
|
||||
MFIRs.GetVolumeIntegrationRule(Tr, ir);
|
||||
|
||||
for (int ip = 0; ip < GetNPoints(); ip++)
|
||||
{
|
||||
if (dim > 1)
|
||||
{
|
||||
Weights(ip, elem) = ir.IntPoint(ip).weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
Weights(2 * ip, elem) = ir.IntPoint(ip).x;
|
||||
Weights(2 * ip + 1, elem) = ir.IntPoint(ip).weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Set the weights for the given element
|
||||
void SetElement(int Element)
|
||||
{
|
||||
if (dim == 1)
|
||||
for (int ip = 0; ip < GetNPoints(); ip++)
|
||||
{
|
||||
IntegrationPoint &intp = IntPoint(ip);
|
||||
intp.x = Weights(2 * ip, Element);
|
||||
intp.weight = Weights(2 * ip + 1, Element);
|
||||
}
|
||||
else
|
||||
for (int ip = 0; ip < GetNPoints(); ip++)
|
||||
{
|
||||
IntegrationPoint &intp = IntPoint(ip);
|
||||
intp.weight = Weights(ip, Element);
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Destructor of CIntegrationRule
|
||||
~CIntegrationRule() {}
|
||||
};
|
||||
/**
|
||||
@brief Class for surface linearform integrator
|
||||
|
||||
Integrator to demonstrate the use of the surface integration rule on an
|
||||
implicit surface defined by a level-set.
|
||||
*/
|
||||
class SurfaceLFIntegrator : public LinearFormIntegrator
|
||||
{
|
||||
protected:
|
||||
/// @brief vector to evaluate the basis functions
|
||||
Vector shape;
|
||||
|
||||
/// @brief surface integration rule
|
||||
SIntegrationRule* SIntRule;
|
||||
|
||||
/// @brief coefficient representing the level-set defining the interface
|
||||
Coefficient &LevelSet;
|
||||
|
||||
/// @brief coefficient representing the integrand
|
||||
Coefficient &Q;
|
||||
|
||||
public:
|
||||
/**
|
||||
@brief Constructor for the surface linear form integrator
|
||||
|
||||
Constructor for the surface linear form integrator to demonstrate the use
|
||||
of the surface integration rule by means of moment-fitting.
|
||||
|
||||
@param [in] q coefficient representing the inegrand
|
||||
@param [in] levelset level-set defining the implicit interfac
|
||||
@param [in] ir surface integrtion rule to be used
|
||||
*/
|
||||
SurfaceLFIntegrator(Coefficient &q, Coefficient &levelset,
|
||||
SIntegrationRule* ir)
|
||||
: LinearFormIntegrator(), SIntRule(ir), LevelSet(levelset), Q(q) { }
|
||||
|
||||
/**
|
||||
@brief Assembly of the element vector
|
||||
|
||||
Assemble the element vector of for the right hand side on the element given
|
||||
by the FiniteElement and ElementTransformation.
|
||||
|
||||
@param [in] el finite Element the vector belongs to
|
||||
@param [in] Tr transformation of finite element
|
||||
@param [out] elvect vector containing the
|
||||
*/
|
||||
virtual void AssembleRHSElementVect(const FiniteElement &el,
|
||||
ElementTransformation &Tr,
|
||||
Vector &elvect) override
|
||||
{
|
||||
int dof = el.GetDof();
|
||||
shape.SetSize(dof);
|
||||
elvect.SetSize(dof);
|
||||
elvect = 0.;
|
||||
|
||||
// Update the surface integration rule for the current element
|
||||
SIntRule->SetElementinclSurfaceWeight(Tr.ElementNo);
|
||||
|
||||
for (int ip = 0; ip < SIntRule->GetNPoints(); ip++)
|
||||
{
|
||||
Tr.SetIntPoint((&(SIntRule->IntPoint(ip))));
|
||||
real_t val = Tr.Weight() * Q.Eval(Tr, SIntRule->IntPoint(ip));
|
||||
el.CalcShape(SIntRule->IntPoint(ip), shape);
|
||||
add(elvect, SIntRule->IntPoint(ip).weight * val, shape, elvect);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@brief Class for subdomain linearform integrator
|
||||
|
||||
Integrator to demonstrate the use of the subdomain integration rule within
|
||||
an area defined by an implicit surface defined by a level-set.
|
||||
*/
|
||||
class SubdomainLFIntegrator : public LinearFormIntegrator
|
||||
{
|
||||
protected:
|
||||
/// @brief vector to evaluate the basis functions
|
||||
Vector shape;
|
||||
|
||||
/// @brief surface integration rule
|
||||
CIntegrationRule* CIntRule;
|
||||
|
||||
/// @brief coefficient representing the level-set defining the interface
|
||||
Coefficient &LevelSet;
|
||||
|
||||
/// @brief coefficient representing the integrand
|
||||
Coefficient &Q;
|
||||
|
||||
public:
|
||||
/**
|
||||
@brief Constructor for the volumetric subdomain linear form integrator
|
||||
|
||||
Constructor for the subdomain linear form integrator to demonstrate the use
|
||||
of the volumetric subdomain integration rule by means of moment-fitting.
|
||||
|
||||
@param [in] q coefficient representing the inegrand
|
||||
@param [in] levelset level-set defining the implicit interfac
|
||||
@param [in] ir subdomain integrtion rule to be used
|
||||
*/
|
||||
SubdomainLFIntegrator(Coefficient &q, Coefficient &levelset,
|
||||
CIntegrationRule* ir)
|
||||
: LinearFormIntegrator(), CIntRule(ir), LevelSet(levelset), Q(q) { }
|
||||
|
||||
/**
|
||||
@brief Assembly of the element vector
|
||||
|
||||
Assemble the element vector of for the right hand side on the element given
|
||||
by the FiniteElement and ElementTransformation.
|
||||
|
||||
@param [in] el finite Element the vector belongs to
|
||||
@param [in] Tr transformation of finite element
|
||||
@param [out] elvect vector containing the
|
||||
*/
|
||||
virtual void AssembleRHSElementVect(const FiniteElement &el,
|
||||
ElementTransformation &Tr,
|
||||
Vector &elvect) override
|
||||
{
|
||||
int dof = el.GetDof();
|
||||
shape.SetSize(dof);
|
||||
elvect.SetSize(dof);
|
||||
elvect = 0.;
|
||||
|
||||
// Update the subdomain integration rule
|
||||
CIntRule->SetElement(Tr.ElementNo);
|
||||
|
||||
for (int ip = 0; ip < CIntRule->GetNPoints(); ip++)
|
||||
{
|
||||
Tr.SetIntPoint((&(CIntRule->IntPoint(ip))));
|
||||
real_t val = Tr.Weight()
|
||||
* Q.Eval(Tr, CIntRule->IntPoint(ip));
|
||||
el.CalcPhysShape(Tr, shape);
|
||||
add(elvect, CIntRule->IntPoint(ip).weight * val, shape, elvect);
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif // MFEM_USE_LAPACK
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifndef MFEM_USE_LAPACK
|
||||
cout << "MFEM must be built with LAPACK for this example." << endl;
|
||||
return EXIT_FAILURE;
|
||||
#else
|
||||
// 1. Parse he command-line options.
|
||||
int ref_levels = 3;
|
||||
int order = 2;
|
||||
const char *inttype = "surface2d";
|
||||
bool visualization = true;
|
||||
itype = IntegrationType::Surface2D;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&order, "-o", "--order", "Order of quadrature rule");
|
||||
args.AddOption(&ref_levels, "-r", "--refine", "Number of meh refinements");
|
||||
args.AddOption(&inttype, "-i", "--integrationtype",
|
||||
"IntegrationType to demonstrate");
|
||||
args.AddOption(&visualization, "-vis", "--visualization", "-no-vis",
|
||||
"--no-visualization",
|
||||
"Enable or disable GLVis visualization.");
|
||||
args.ParseCheck();
|
||||
|
||||
if (strcmp(inttype, "volumetric1d") == 0
|
||||
|| strcmp(inttype, "Volumetric1D") == 0)
|
||||
{
|
||||
itype = IntegrationType::Volumetric1D;
|
||||
}
|
||||
else if (strcmp(inttype, "surface2d") == 0
|
||||
|| strcmp(inttype, "Surface2D") == 0)
|
||||
{
|
||||
itype = IntegrationType::Surface2D;
|
||||
}
|
||||
else if (strcmp(inttype, "volumetric2d") == 0
|
||||
|| strcmp(inttype, "Volumetric2D") == 0)
|
||||
{
|
||||
itype = IntegrationType::Volumetric2D;
|
||||
}
|
||||
else if (strcmp(inttype, "surface3d") == 0
|
||||
|| strcmp(inttype, "Surface3d") == 0)
|
||||
{
|
||||
itype = IntegrationType::Surface3D;
|
||||
}
|
||||
else if (strcmp(inttype, "volumetric3d") == 0
|
||||
|| strcmp(inttype, "Volumetric3d") == 0)
|
||||
{
|
||||
itype = IntegrationType::Volumetric3D;
|
||||
}
|
||||
|
||||
// 2. Construct and refine the mesh.
|
||||
Mesh *mesh;
|
||||
if (itype == IntegrationType::Volumetric1D)
|
||||
{
|
||||
mesh = new Mesh("../data/inline-segment.mesh");
|
||||
}
|
||||
if (itype == IntegrationType::Surface2D
|
||||
|| itype == IntegrationType::Volumetric2D)
|
||||
{
|
||||
mesh = new Mesh(2, 4, 1, 0, 2);
|
||||
mesh->AddVertex(-1.6,-1.6);
|
||||
mesh->AddVertex(1.6,-1.6);
|
||||
mesh->AddVertex(1.6,1.6);
|
||||
mesh->AddVertex(-1.6,1.6);
|
||||
mesh->AddQuad(0,1,2,3);
|
||||
mesh->FinalizeQuadMesh(1, 0, 1);
|
||||
}
|
||||
else if (itype == IntegrationType::Surface3D
|
||||
|| itype == IntegrationType::Volumetric3D)
|
||||
{
|
||||
mesh = new Mesh(3, 8, 1, 0, 3);
|
||||
mesh->AddVertex(-1.6,-1.6,-1.6);
|
||||
mesh->AddVertex(1.6,-1.6,-1.6);
|
||||
mesh->AddVertex(1.6,1.6,-1.6);
|
||||
mesh->AddVertex(-1.6,1.6,-1.6);
|
||||
mesh->AddVertex(-1.6,-1.6,1.6);
|
||||
mesh->AddVertex(1.6,-1.6,1.6);
|
||||
mesh->AddVertex(1.6,1.6,1.6);
|
||||
mesh->AddVertex(-1.6,1.6,1.6);
|
||||
mesh->AddHex(0,1,2,3,4,5,6,7);
|
||||
mesh->FinalizeHexMesh(1, 0, 1);
|
||||
}
|
||||
|
||||
for (int lev = 0; lev < ref_levels; lev++)
|
||||
{
|
||||
mesh->UniformRefinement();
|
||||
}
|
||||
|
||||
// 3. Define the necessary finite element space on the mesh.
|
||||
H1_FECollection fe_coll(1, mesh->Dimension());
|
||||
FiniteElementSpace *fespace = new FiniteElementSpace(mesh, &fe_coll);
|
||||
|
||||
// 4. Construction Coefficients for the level set and the integrand.
|
||||
FunctionCoefficient levelset(lvlset);
|
||||
FunctionCoefficient u(integrand);
|
||||
|
||||
// 5. Define the necessary Integration rules on element 0.
|
||||
IsoparametricTransformation Tr;
|
||||
mesh->GetElementTransformation(0, &Tr);
|
||||
SIntegrationRule* sir = new SIntegrationRule(order, levelset, 2, mesh);
|
||||
CIntegrationRule* cir = NULL;
|
||||
if (itype == IntegrationType::Volumetric1D
|
||||
|| itype == IntegrationType::Volumetric2D
|
||||
|| itype == IntegrationType::Volumetric3D)
|
||||
{
|
||||
cir = new CIntegrationRule(order, levelset, 2, mesh);
|
||||
}
|
||||
|
||||
// 6. Define and assemble the linear forms on the finite element space.
|
||||
LinearForm surface(fespace);
|
||||
LinearForm volume(fespace);
|
||||
|
||||
surface.AddDomainIntegrator(new SurfaceLFIntegrator(u, levelset, sir));
|
||||
surface.Assemble();
|
||||
|
||||
if (itype == IntegrationType::Volumetric1D
|
||||
|| itype == IntegrationType::Volumetric2D
|
||||
|| itype == IntegrationType::Volumetric3D)
|
||||
{
|
||||
volume.AddDomainIntegrator(new SubdomainLFIntegrator(u, levelset, cir));
|
||||
volume.Assemble();
|
||||
}
|
||||
|
||||
// 7. Print information, computed values and errors to the console.
|
||||
int qorder = 0;
|
||||
int nbasis = 2 * (order + 1) + (int)(order * (order + 1) / 2);
|
||||
IntegrationRules irs(0, Quadrature1D::GaussLegendre);
|
||||
IntegrationRule ir = irs.Get(Geometry::SQUARE, qorder);
|
||||
for (; ir.GetNPoints() <= nbasis; qorder++)
|
||||
{
|
||||
ir = irs.Get(Geometry::SQUARE, qorder);
|
||||
}
|
||||
cout << "============================================" << endl;
|
||||
cout << "Mesh size dx: ";
|
||||
if (itype != IntegrationType::Volumetric1D)
|
||||
{
|
||||
cout << 3.2 / pow(2., (real_t)ref_levels) << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << .25 / pow(2., (real_t)ref_levels) << endl;
|
||||
}
|
||||
if (itype == IntegrationType::Surface2D
|
||||
|| itype == IntegrationType::Volumetric2D)
|
||||
{
|
||||
cout << "Number of div free basis functions: " << nbasis << endl;
|
||||
cout << "Number of quadrature points: " << ir.GetNPoints() << endl;
|
||||
}
|
||||
cout << scientific << setprecision(2);
|
||||
cout << "============================================" << endl;
|
||||
cout << "Computed value of surface integral: " << surface.Sum() << endl;
|
||||
cout << "True value of surface integral: " << Surface() << endl;
|
||||
cout << "Absolute Error (Surface): ";
|
||||
cout << abs(surface.Sum() - Surface()) << endl;
|
||||
cout << "Relative Error (Surface): ";
|
||||
cout << abs(surface.Sum() - Surface()) / Surface() << endl;
|
||||
if (itype == IntegrationType::Volumetric1D
|
||||
|| itype == IntegrationType::Volumetric2D
|
||||
|| itype == IntegrationType::Volumetric3D)
|
||||
{
|
||||
cout << "--------------------------------------------" << endl;
|
||||
cout << "Computed value of volume integral: " << volume.Sum() << endl;
|
||||
cout << "True value of volume integral: " << Volume() << endl;
|
||||
cout << "Absolute Error (Volume): ";
|
||||
cout << abs(volume.Sum() - Volume()) << endl;
|
||||
cout << "Relative Error (Volume): ";
|
||||
cout << abs(volume.Sum() - Volume()) / Volume() << endl;
|
||||
}
|
||||
cout << "============================================" << endl;
|
||||
|
||||
// 8. Plot the level-set function on a high order finite element space.
|
||||
if (visualization)
|
||||
{
|
||||
H1_FECollection fe_coll2(5, mesh->Dimension());
|
||||
FiniteElementSpace fespace2(mesh, &fe_coll2);
|
||||
FunctionCoefficient levelset_coeff(levelset);
|
||||
GridFunction lgf(&fespace2);
|
||||
lgf.ProjectCoefficient(levelset_coeff);
|
||||
char vishost[] = "localhost";
|
||||
int visport = 19916;
|
||||
socketstream sol_sock(vishost, visport);
|
||||
sol_sock.precision(8);
|
||||
sol_sock << "solution\n" << *mesh << lgf << flush;
|
||||
sol_sock << "keys pppppppppppppppppppppppppppcmmlRj\n";
|
||||
sol_sock << "levellines " << 0. << " " << 0. << " " << 1 << "\n" << flush;
|
||||
}
|
||||
|
||||
delete sir;
|
||||
delete cir;
|
||||
delete fespace;
|
||||
delete mesh;
|
||||
return EXIT_SUCCESS;
|
||||
#endif //MFEM_USE_LAPACK
|
||||
}
|
||||
+2
-2
@@ -55,7 +55,7 @@ using namespace mfem;
|
||||
// Exact solution, E, and r.h.s., f. See below for implementation.
|
||||
void E_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
int dim;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -263,7 +263,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 15. Compute and print the L^2 norm of the error.
|
||||
{
|
||||
double error = x.ComputeL2Error(E);
|
||||
real_t error = x.ComputeL2Error(E);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\n|| E_h - E ||_{L^2} = " << error << '\n' << endl;
|
||||
|
||||
+8
-8
@@ -54,7 +54,7 @@ using namespace mfem;
|
||||
// Exact solution, F, and r.h.s., f. See below for implementation.
|
||||
void F_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -269,9 +269,9 @@ void F_exact(const Vector &p, Vector &F)
|
||||
{
|
||||
int dim = p.Size();
|
||||
|
||||
double x = p(0);
|
||||
double y = p(1);
|
||||
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
|
||||
real_t x = p(0);
|
||||
real_t y = p(1);
|
||||
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
|
||||
|
||||
F(0) = cos(kappa*x)*sin(kappa*y);
|
||||
F(1) = cos(kappa*y)*sin(kappa*x);
|
||||
@@ -286,11 +286,11 @@ void f_exact(const Vector &p, Vector &f)
|
||||
{
|
||||
int dim = p.Size();
|
||||
|
||||
double x = p(0);
|
||||
double y = p(1);
|
||||
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
|
||||
real_t x = p(0);
|
||||
real_t y = p(1);
|
||||
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
|
||||
|
||||
double temp = 1 + 2*kappa*kappa;
|
||||
real_t temp = 1 + 2*kappa*kappa;
|
||||
|
||||
f(0) = temp*cos(kappa*x)*sin(kappa*y);
|
||||
f(1) = temp*cos(kappa*y)*sin(kappa*x);
|
||||
|
||||
+9
-9
@@ -54,7 +54,7 @@ using namespace mfem;
|
||||
// Exact solution, F, and r.h.s., f. See below for implementation.
|
||||
void F_exact(const Vector &, Vector &);
|
||||
void f_exact(const Vector &, Vector &);
|
||||
double freq = 1.0, kappa;
|
||||
real_t freq = 1.0, kappa;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -255,7 +255,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 15. Compute and print the L^2 norm of the error.
|
||||
{
|
||||
double error = x.ComputeL2Error(F);
|
||||
real_t error = x.ComputeL2Error(F);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\n|| F_h - F ||_{L^2} = " << error << '\n' << endl;
|
||||
@@ -311,9 +311,9 @@ void F_exact(const Vector &p, Vector &F)
|
||||
{
|
||||
int dim = p.Size();
|
||||
|
||||
double x = p(0);
|
||||
double y = p(1);
|
||||
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
|
||||
real_t x = p(0);
|
||||
real_t y = p(1);
|
||||
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if F is changed to depend on z
|
||||
|
||||
F(0) = cos(kappa*x)*sin(kappa*y);
|
||||
F(1) = cos(kappa*y)*sin(kappa*x);
|
||||
@@ -328,11 +328,11 @@ void f_exact(const Vector &p, Vector &f)
|
||||
{
|
||||
int dim = p.Size();
|
||||
|
||||
double x = p(0);
|
||||
double y = p(1);
|
||||
// double z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
|
||||
real_t x = p(0);
|
||||
real_t y = p(1);
|
||||
// real_t z = (dim == 3) ? p(2) : 0.0; // Uncomment if f is changed to depend on z
|
||||
|
||||
double temp = 1 + 2*kappa*kappa;
|
||||
real_t temp = 1 + 2*kappa*kappa;
|
||||
|
||||
f(0) = temp*cos(kappa*x)*sin(kappa*y);
|
||||
f(1) = temp*cos(kappa*y)*sin(kappa*x);
|
||||
|
||||
+18
-18
@@ -45,10 +45,10 @@ using namespace mfem;
|
||||
|
||||
// Define the analytical solution and forcing terms / boundary conditions
|
||||
void uFun_ex(const Vector & x, Vector & u);
|
||||
double pFun_ex(const Vector & x);
|
||||
real_t pFun_ex(const Vector & x);
|
||||
void fFun(const Vector & x, Vector & f);
|
||||
double gFun(const Vector & x);
|
||||
double f_natural(const Vector & x);
|
||||
real_t gFun(const Vector & x);
|
||||
real_t f_natural(const Vector & x);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -270,8 +270,8 @@ int main(int argc, char *argv[])
|
||||
// 11. Solve the linear system with MINRES.
|
||||
// Check the norm of the unpreconditioned residual.
|
||||
int maxIter(1000);
|
||||
double rtol(1.e-6);
|
||||
double atol(1.e-10);
|
||||
real_t rtol(1.e-6);
|
||||
real_t atol(1.e-10);
|
||||
|
||||
chrono.Clear();
|
||||
chrono.Start();
|
||||
@@ -313,10 +313,10 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double err_u = u.ComputeL2Error(ucoeff, irs);
|
||||
double norm_u = ComputeLpNorm(2., ucoeff, *mesh, irs);
|
||||
double err_p = p.ComputeL2Error(pcoeff, irs);
|
||||
double norm_p = ComputeLpNorm(2., pcoeff, *mesh, irs);
|
||||
real_t err_u = u.ComputeL2Error(ucoeff, irs);
|
||||
real_t norm_u = ComputeLpNorm(2., ucoeff, *mesh, irs);
|
||||
real_t err_p = p.ComputeL2Error(pcoeff, irs);
|
||||
real_t norm_p = ComputeLpNorm(2., pcoeff, *mesh, irs);
|
||||
|
||||
std::cout << "|| u_h - u_ex || / || u_ex || = " << err_u / norm_u << "\n";
|
||||
std::cout << "|| p_h - p_ex || / || p_ex || = " << err_p / norm_p << "\n";
|
||||
@@ -391,9 +391,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
void uFun_ex(const Vector & x, Vector & u)
|
||||
{
|
||||
double xi(x(0));
|
||||
double yi(x(1));
|
||||
double zi(0.0);
|
||||
real_t xi(x(0));
|
||||
real_t yi(x(1));
|
||||
real_t zi(0.0);
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
zi = x(2);
|
||||
@@ -409,11 +409,11 @@ void uFun_ex(const Vector & x, Vector & u)
|
||||
}
|
||||
|
||||
// Change if needed
|
||||
double pFun_ex(const Vector & x)
|
||||
real_t pFun_ex(const Vector & x)
|
||||
{
|
||||
double xi(x(0));
|
||||
double yi(x(1));
|
||||
double zi(0.0);
|
||||
real_t xi(x(0));
|
||||
real_t yi(x(1));
|
||||
real_t zi(0.0);
|
||||
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
@@ -428,7 +428,7 @@ void fFun(const Vector & x, Vector & f)
|
||||
f = 0.0;
|
||||
}
|
||||
|
||||
double gFun(const Vector & x)
|
||||
real_t gFun(const Vector & x)
|
||||
{
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
@@ -440,7 +440,7 @@ double gFun(const Vector & x)
|
||||
}
|
||||
}
|
||||
|
||||
double f_natural(const Vector & x)
|
||||
real_t f_natural(const Vector & x)
|
||||
{
|
||||
return (-pFun_ex(x));
|
||||
}
|
||||
|
||||
+18
-18
@@ -46,10 +46,10 @@ using namespace mfem;
|
||||
|
||||
// Define the analytical solution and forcing terms / boundary conditions
|
||||
void uFun_ex(const Vector & x, Vector & u);
|
||||
double pFun_ex(const Vector & x);
|
||||
real_t pFun_ex(const Vector & x);
|
||||
void fFun(const Vector & x, Vector & f);
|
||||
double gFun(const Vector & x);
|
||||
double f_natural(const Vector & x);
|
||||
real_t gFun(const Vector & x);
|
||||
real_t f_natural(const Vector & x);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -326,8 +326,8 @@ int main(int argc, char *argv[])
|
||||
// 13. Solve the linear system with MINRES.
|
||||
// Check the norm of the unpreconditioned residual.
|
||||
int maxIter(pa ? 1000 : 500);
|
||||
double rtol(1.e-6);
|
||||
double atol(1.e-10);
|
||||
real_t rtol(1.e-6);
|
||||
real_t atol(1.e-10);
|
||||
|
||||
chrono.Clear();
|
||||
chrono.Start();
|
||||
@@ -371,10 +371,10 @@ int main(int argc, char *argv[])
|
||||
irs[i] = &(IntRules.Get(i, order_quad));
|
||||
}
|
||||
|
||||
double err_u = u->ComputeL2Error(ucoeff, irs);
|
||||
double norm_u = ComputeGlobalLpNorm(2, ucoeff, *pmesh, irs);
|
||||
double err_p = p->ComputeL2Error(pcoeff, irs);
|
||||
double norm_p = ComputeGlobalLpNorm(2, pcoeff, *pmesh, irs);
|
||||
real_t err_u = u->ComputeL2Error(ucoeff, irs);
|
||||
real_t norm_u = ComputeGlobalLpNorm(2, ucoeff, *pmesh, irs);
|
||||
real_t err_p = p->ComputeL2Error(pcoeff, irs);
|
||||
real_t norm_p = ComputeGlobalLpNorm(2, pcoeff, *pmesh, irs);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
@@ -493,9 +493,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
void uFun_ex(const Vector & x, Vector & u)
|
||||
{
|
||||
double xi(x(0));
|
||||
double yi(x(1));
|
||||
double zi(0.0);
|
||||
real_t xi(x(0));
|
||||
real_t yi(x(1));
|
||||
real_t zi(0.0);
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
zi = x(2);
|
||||
@@ -511,11 +511,11 @@ void uFun_ex(const Vector & x, Vector & u)
|
||||
}
|
||||
|
||||
// Change if needed
|
||||
double pFun_ex(const Vector & x)
|
||||
real_t pFun_ex(const Vector & x)
|
||||
{
|
||||
double xi(x(0));
|
||||
double yi(x(1));
|
||||
double zi(0.0);
|
||||
real_t xi(x(0));
|
||||
real_t yi(x(1));
|
||||
real_t zi(0.0);
|
||||
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
@@ -530,7 +530,7 @@ void fFun(const Vector & x, Vector & f)
|
||||
f = 0.0;
|
||||
}
|
||||
|
||||
double gFun(const Vector & x)
|
||||
real_t gFun(const Vector & x)
|
||||
{
|
||||
if (x.Size() == 3)
|
||||
{
|
||||
@@ -542,7 +542,7 @@ double gFun(const Vector & x)
|
||||
}
|
||||
}
|
||||
|
||||
double f_natural(const Vector & x)
|
||||
real_t f_natural(const Vector & x)
|
||||
{
|
||||
return (-pFun_ex(x));
|
||||
}
|
||||
|
||||
+8
-8
@@ -28,8 +28,8 @@ using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
// Exact solution and r.h.s., see below for implementation.
|
||||
double analytic_solution(const Vector &x);
|
||||
double analytic_rhs(const Vector &x);
|
||||
real_t analytic_solution(const Vector &x);
|
||||
real_t analytic_rhs(const Vector &x);
|
||||
void SnapNodes(Mesh &mesh);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -81,7 +81,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (elem_type == 0) // inscribed octahedron
|
||||
{
|
||||
const double tri_v[6][3] =
|
||||
const real_t tri_v[6][3] =
|
||||
{
|
||||
{ 1, 0, 0}, { 0, 1, 0}, {-1, 0, 0},
|
||||
{ 0, -1, 0}, { 0, 0, 1}, { 0, 0, -1}
|
||||
@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else // inscribed cube
|
||||
{
|
||||
const double quad_v[8][3] =
|
||||
const real_t quad_v[8][3] =
|
||||
{
|
||||
{-1, -1, -1}, {+1, -1, -1}, {+1, +1, -1}, {-1, +1, -1},
|
||||
{-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1}
|
||||
@@ -249,15 +249,15 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double analytic_solution(const Vector &x)
|
||||
real_t analytic_solution(const Vector &x)
|
||||
{
|
||||
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
return x(0)*x(1)/l2;
|
||||
}
|
||||
|
||||
double analytic_rhs(const Vector &x)
|
||||
real_t analytic_rhs(const Vector &x)
|
||||
{
|
||||
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
return 7*x(0)*x(1)/l2;
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -28,8 +28,8 @@ using namespace std;
|
||||
using namespace mfem;
|
||||
|
||||
// Exact solution and r.h.s., see below for implementation.
|
||||
double analytic_solution(const Vector &x);
|
||||
double analytic_rhs(const Vector &x);
|
||||
real_t analytic_solution(const Vector &x);
|
||||
real_t analytic_rhs(const Vector &x);
|
||||
void SnapNodes(Mesh &mesh);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (elem_type == 0) // inscribed octahedron
|
||||
{
|
||||
const double tri_v[6][3] =
|
||||
const real_t tri_v[6][3] =
|
||||
{
|
||||
{ 1, 0, 0}, { 0, 1, 0}, {-1, 0, 0},
|
||||
{ 0, -1, 0}, { 0, 0, 1}, { 0, 0, -1}
|
||||
@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else // inscribed cube
|
||||
{
|
||||
const double quad_v[8][3] =
|
||||
const real_t quad_v[8][3] =
|
||||
{
|
||||
{-1, -1, -1}, {+1, -1, -1}, {+1, +1, -1}, {-1, +1, -1},
|
||||
{-1, -1, +1}, {+1, -1, +1}, {+1, +1, +1}, {-1, +1, +1}
|
||||
@@ -281,7 +281,7 @@ int main(int argc, char *argv[])
|
||||
delete b;
|
||||
|
||||
// 12. Compute and print the L^2 norm of the error.
|
||||
double error = x.ComputeL2Error(sol_coef);
|
||||
real_t error = x.ComputeL2Error(sol_coef);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\nL2 norm of error: " << error << endl;
|
||||
@@ -323,15 +323,15 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
double analytic_solution(const Vector &x)
|
||||
real_t analytic_solution(const Vector &x)
|
||||
{
|
||||
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
return x(0)*x(1)/l2;
|
||||
}
|
||||
|
||||
double analytic_rhs(const Vector &x)
|
||||
real_t analytic_rhs(const Vector &x)
|
||||
{
|
||||
double l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
real_t l2 = x(0)*x(0) + x(1)*x(1) + x(2)*x(2);
|
||||
return 7*x(0)*x(1)/l2;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -206,7 +206,7 @@ int main(int argc, char *argv[])
|
||||
SparseMatrix * Shat = RAP(matBhat, matSinv, matBhat);
|
||||
|
||||
#ifndef MFEM_USE_SUITESPARSE
|
||||
const double prec_rtol = 1e-3;
|
||||
const real_t prec_rtol = 1e-3;
|
||||
const int prec_maxit = 200;
|
||||
CGSolver *S0inv = new CGSolver;
|
||||
S0inv->SetOperator(matS0);
|
||||
@@ -240,7 +240,7 @@ int main(int argc, char *argv[])
|
||||
Vector LSres(s_test);
|
||||
B.Mult(x, LSres);
|
||||
LSres -= F;
|
||||
double res = sqrt(matSinv.InnerProduct(LSres, LSres));
|
||||
real_t res = sqrt(matSinv.InnerProduct(LSres, LSres));
|
||||
cout << "\n|| B0*x0 + Bhat*xhat - F ||_{S^-1} = " << res << endl;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -283,7 +283,7 @@ int main(int argc, char *argv[])
|
||||
B.Mult(x, LSres);
|
||||
LSres -= *trueF;
|
||||
matSinv->Mult(LSres, tmp);
|
||||
double res = sqrt(InnerProduct(LSres, tmp));
|
||||
real_t res = sqrt(InnerProduct(LSres, tmp));
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\n|| B0*x0 + Bhat*xhat - F ||_{S^-1} = " << res << endl;
|
||||
|
||||
+25
-25
@@ -58,10 +58,10 @@ int problem;
|
||||
void velocity_function(const Vector &x, Vector &v);
|
||||
|
||||
// Initial condition
|
||||
double u0_function(const Vector &x);
|
||||
real_t u0_function(const Vector &x);
|
||||
|
||||
// Inflow boundary condition
|
||||
double inflow_function(const Vector &x);
|
||||
real_t inflow_function(const Vector &x);
|
||||
|
||||
// Mesh bounding box
|
||||
Vector bb_min, bb_max;
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
SparseMatrix &M, &K, A;
|
||||
GMRESSolver linear_solver;
|
||||
BlockILU prec;
|
||||
double dt;
|
||||
real_t dt;
|
||||
public:
|
||||
DG_Solver(SparseMatrix &M_, SparseMatrix &K_, const FiniteElementSpace &fes)
|
||||
: M(M_),
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
linear_solver.SetPreconditioner(prec);
|
||||
}
|
||||
|
||||
void SetTimeStep(double dt_)
|
||||
void SetTimeStep(real_t dt_)
|
||||
{
|
||||
if (dt_ != dt)
|
||||
{
|
||||
@@ -135,7 +135,7 @@ public:
|
||||
FE_Evolution(BilinearForm &M_, BilinearForm &K_, const Vector &b_);
|
||||
|
||||
virtual void Mult(const Vector &x, Vector &y) const;
|
||||
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
|
||||
|
||||
virtual ~FE_Evolution();
|
||||
};
|
||||
@@ -153,8 +153,8 @@ int main(int argc, char *argv[])
|
||||
bool fa = false;
|
||||
const char *device_config = "cpu";
|
||||
int ode_solver_type = 4;
|
||||
double t_final = 10.0;
|
||||
double dt = 0.01;
|
||||
real_t t_final = 10.0;
|
||||
real_t dt = 0.01;
|
||||
bool visualization = true;
|
||||
bool visit = false;
|
||||
bool paraview = false;
|
||||
@@ -293,7 +293,7 @@ int main(int argc, char *argv[])
|
||||
k.SetAssemblyLevel(AssemblyLevel::FULL);
|
||||
}
|
||||
m.AddDomainIntegrator(new MassIntegrator);
|
||||
constexpr double alpha = -1.0;
|
||||
constexpr real_t alpha = -1.0;
|
||||
k.AddDomainIntegrator(new ConvectionIntegrator(velocity, alpha));
|
||||
k.AddInteriorFaceIntegrator(
|
||||
new NonconservativeDGTraceIntegrator(velocity, alpha));
|
||||
@@ -393,14 +393,14 @@ int main(int argc, char *argv[])
|
||||
// iterations, ti, with a time-step dt).
|
||||
FE_Evolution adv(m, k, b);
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
adv.SetTime(t);
|
||||
ode_solver->Init(adv);
|
||||
|
||||
bool done = false;
|
||||
for (int ti = 0; !done; )
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
ode_solver->Step(u, t, dt_real);
|
||||
ti++;
|
||||
|
||||
@@ -482,7 +482,7 @@ void FE_Evolution::Mult(const Vector &x, Vector &y) const
|
||||
M_solver.Mult(z, y);
|
||||
}
|
||||
|
||||
void FE_Evolution::ImplicitSolve(const double dt, const Vector &x, Vector &k)
|
||||
void FE_Evolution::ImplicitSolve(const real_t dt, const Vector &x, Vector &k)
|
||||
{
|
||||
MFEM_VERIFY(dg_solver != NULL,
|
||||
"Implicit time integration is not supported with partial assembly");
|
||||
@@ -507,7 +507,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
Vector X(dim);
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
double center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
case 2:
|
||||
{
|
||||
// Clockwise rotation in 2D around the origin
|
||||
const double w = M_PI/2;
|
||||
const real_t w = M_PI/2;
|
||||
switch (dim)
|
||||
{
|
||||
case 1: v(0) = 1.0; break;
|
||||
@@ -541,8 +541,8 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
case 3:
|
||||
{
|
||||
// Clockwise twisting rotation in 2D around the origin
|
||||
const double w = M_PI/2;
|
||||
double d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
|
||||
const real_t w = M_PI/2;
|
||||
real_t d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
|
||||
d = d*d;
|
||||
switch (dim)
|
||||
{
|
||||
@@ -556,7 +556,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
}
|
||||
|
||||
// Initial condition
|
||||
double u0_function(const Vector &x)
|
||||
real_t u0_function(const Vector &x)
|
||||
{
|
||||
int dim = x.Size();
|
||||
|
||||
@@ -564,7 +564,7 @@ double u0_function(const Vector &x)
|
||||
Vector X(dim);
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
double center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
|
||||
}
|
||||
|
||||
@@ -580,28 +580,28 @@ double u0_function(const Vector &x)
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
double rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
|
||||
real_t rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
|
||||
if (dim == 3)
|
||||
{
|
||||
const double s = (1. + 0.25*cos(2*M_PI*X(2)));
|
||||
const real_t s = (1. + 0.25*cos(2*M_PI*X(2)));
|
||||
rx *= s;
|
||||
ry *= s;
|
||||
}
|
||||
return ( erfc(w*(X(0)-cx-rx))*erfc(-w*(X(0)-cx+rx)) *
|
||||
erfc(w*(X(1)-cy-ry))*erfc(-w*(X(1)-cy+ry)) )/16;
|
||||
return ( std::erfc(w*(X(0)-cx-rx))*std::erfc(-w*(X(0)-cx+rx)) *
|
||||
std::erfc(w*(X(1)-cy-ry))*std::erfc(-w*(X(1)-cy+ry)) )/16;
|
||||
}
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
double x_ = X(0), y_ = X(1), rho, phi;
|
||||
rho = hypot(x_, y_);
|
||||
real_t x_ = X(0), y_ = X(1), rho, phi;
|
||||
rho = std::hypot(x_, y_);
|
||||
phi = atan2(y_, x_);
|
||||
return pow(sin(M_PI*rho),2)*sin(3*phi);
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
const double f = M_PI;
|
||||
const real_t f = M_PI;
|
||||
return sin(f*X(0))*sin(f*X(1));
|
||||
}
|
||||
}
|
||||
@@ -609,7 +609,7 @@ double u0_function(const Vector &x)
|
||||
}
|
||||
|
||||
// Inflow boundary condition (zero for the problems considered in this example)
|
||||
double inflow_function(const Vector &x)
|
||||
real_t inflow_function(const Vector &x)
|
||||
{
|
||||
switch (problem)
|
||||
{
|
||||
|
||||
+25
-25
@@ -59,10 +59,10 @@ int problem;
|
||||
void velocity_function(const Vector &x, Vector &v);
|
||||
|
||||
// Initial condition
|
||||
double u0_function(const Vector &x);
|
||||
real_t u0_function(const Vector &x);
|
||||
|
||||
// Inflow boundary condition
|
||||
double inflow_function(const Vector &x);
|
||||
real_t inflow_function(const Vector &x);
|
||||
|
||||
// Mesh bounding box
|
||||
Vector bb_min, bb_max;
|
||||
@@ -135,7 +135,7 @@ private:
|
||||
HypreParMatrix *A;
|
||||
GMRESSolver linear_solver;
|
||||
Solver *prec;
|
||||
double dt;
|
||||
real_t dt;
|
||||
public:
|
||||
DG_Solver(HypreParMatrix &M_, HypreParMatrix &K_, const FiniteElementSpace &fes,
|
||||
PrecType prec_type)
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
M.GetDiag(M_diag);
|
||||
}
|
||||
|
||||
void SetTimeStep(double dt_)
|
||||
void SetTimeStep(real_t dt_)
|
||||
{
|
||||
if (dt_ != dt)
|
||||
{
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
PrecType prec_type);
|
||||
|
||||
virtual void Mult(const Vector &x, Vector &y) const;
|
||||
virtual void ImplicitSolve(const double dt, const Vector &x, Vector &k);
|
||||
virtual void ImplicitSolve(const real_t dt, const Vector &x, Vector &k);
|
||||
|
||||
virtual ~FE_Evolution();
|
||||
};
|
||||
@@ -249,8 +249,8 @@ int main(int argc, char *argv[])
|
||||
bool fa = false;
|
||||
const char *device_config = "cpu";
|
||||
int ode_solver_type = 4;
|
||||
double t_final = 10.0;
|
||||
double dt = 0.01;
|
||||
real_t t_final = 10.0;
|
||||
real_t dt = 0.01;
|
||||
bool visualization = true;
|
||||
bool visit = false;
|
||||
bool paraview = false;
|
||||
@@ -425,7 +425,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
m->AddDomainIntegrator(new MassIntegrator);
|
||||
constexpr double alpha = -1.0;
|
||||
constexpr real_t alpha = -1.0;
|
||||
k->AddDomainIntegrator(new ConvectionIntegrator(velocity, alpha));
|
||||
k->AddInteriorFaceIntegrator(
|
||||
new NonconservativeDGTraceIntegrator(velocity, alpha));
|
||||
@@ -566,14 +566,14 @@ int main(int argc, char *argv[])
|
||||
// iterations, ti, with a time-step dt).
|
||||
FE_Evolution adv(*m, *k, *B, prec_type);
|
||||
|
||||
double t = 0.0;
|
||||
real_t t = 0.0;
|
||||
adv.SetTime(t);
|
||||
ode_solver->Init(adv);
|
||||
|
||||
bool done = false;
|
||||
for (int ti = 0; !done; )
|
||||
{
|
||||
double dt_real = min(dt, t_final - t);
|
||||
real_t dt_real = min(dt, t_final - t);
|
||||
ode_solver->Step(*U, t, dt_real);
|
||||
ti++;
|
||||
|
||||
@@ -704,7 +704,7 @@ FE_Evolution::FE_Evolution(ParBilinearForm &M_, ParBilinearForm &K_,
|
||||
// u_t = M^{-1}(Ku + b),
|
||||
// by solving associated linear system
|
||||
// (M - dt*K) d = K*u + b
|
||||
void FE_Evolution::ImplicitSolve(const double dt, const Vector &x, Vector &k)
|
||||
void FE_Evolution::ImplicitSolve(const real_t dt, const Vector &x, Vector &k)
|
||||
{
|
||||
K->Mult(x, z);
|
||||
z += b;
|
||||
@@ -736,7 +736,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
Vector X(dim);
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
double center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
|
||||
}
|
||||
|
||||
@@ -758,7 +758,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
case 2:
|
||||
{
|
||||
// Clockwise rotation in 2D around the origin
|
||||
const double w = M_PI/2;
|
||||
const real_t w = M_PI/2;
|
||||
switch (dim)
|
||||
{
|
||||
case 1: v(0) = 1.0; break;
|
||||
@@ -770,8 +770,8 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
case 3:
|
||||
{
|
||||
// Clockwise twisting rotation in 2D around the origin
|
||||
const double w = M_PI/2;
|
||||
double d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
|
||||
const real_t w = M_PI/2;
|
||||
real_t d = max((X(0)+1.)*(1.-X(0)),0.) * max((X(1)+1.)*(1.-X(1)),0.);
|
||||
d = d*d;
|
||||
switch (dim)
|
||||
{
|
||||
@@ -785,7 +785,7 @@ void velocity_function(const Vector &x, Vector &v)
|
||||
}
|
||||
|
||||
// Initial condition
|
||||
double u0_function(const Vector &x)
|
||||
real_t u0_function(const Vector &x)
|
||||
{
|
||||
int dim = x.Size();
|
||||
|
||||
@@ -793,7 +793,7 @@ double u0_function(const Vector &x)
|
||||
Vector X(dim);
|
||||
for (int i = 0; i < dim; i++)
|
||||
{
|
||||
double center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
real_t center = (bb_min[i] + bb_max[i]) * 0.5;
|
||||
X(i) = 2 * (x(i) - center) / (bb_max[i] - bb_min[i]);
|
||||
}
|
||||
|
||||
@@ -809,28 +809,28 @@ double u0_function(const Vector &x)
|
||||
case 2:
|
||||
case 3:
|
||||
{
|
||||
double rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
|
||||
real_t rx = 0.45, ry = 0.25, cx = 0., cy = -0.2, w = 10.;
|
||||
if (dim == 3)
|
||||
{
|
||||
const double s = (1. + 0.25*cos(2*M_PI*X(2)));
|
||||
const real_t s = (1. + 0.25*cos(2*M_PI*X(2)));
|
||||
rx *= s;
|
||||
ry *= s;
|
||||
}
|
||||
return ( erfc(w*(X(0)-cx-rx))*erfc(-w*(X(0)-cx+rx)) *
|
||||
erfc(w*(X(1)-cy-ry))*erfc(-w*(X(1)-cy+ry)) )/16;
|
||||
return ( std::erfc(w*(X(0)-cx-rx))*std::erfc(-w*(X(0)-cx+rx)) *
|
||||
std::erfc(w*(X(1)-cy-ry))*std::erfc(-w*(X(1)-cy+ry)) )/16;
|
||||
}
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
double x_ = X(0), y_ = X(1), rho, phi;
|
||||
rho = hypot(x_, y_);
|
||||
real_t x_ = X(0), y_ = X(1), rho, phi;
|
||||
rho = std::hypot(x_, y_);
|
||||
phi = atan2(y_, x_);
|
||||
return pow(sin(M_PI*rho),2)*sin(3*phi);
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
const double f = M_PI;
|
||||
const real_t f = M_PI;
|
||||
return sin(f*X(0))*sin(f*X(1));
|
||||
}
|
||||
}
|
||||
@@ -838,7 +838,7 @@ double u0_function(const Vector &x)
|
||||
}
|
||||
|
||||
// Inflow boundary condition (zero for the problems considered in this example)
|
||||
double inflow_function(const Vector &x)
|
||||
real_t inflow_function(const Vector &x)
|
||||
{
|
||||
switch (problem)
|
||||
{
|
||||
|
||||
+23
-23
@@ -3,28 +3,28 @@
|
||||
//
|
||||
// Compile with: make ex1
|
||||
//
|
||||
// Sample runs: ex1 -m ../data/square-disc.mesh
|
||||
// ex1 -m ../data/star.mesh
|
||||
// ex1 -m ../data/star-mixed.mesh
|
||||
// ex1 -m ../data/escher.mesh
|
||||
// ex1 -m ../data/fichera.mesh
|
||||
// ex1 -m ../data/fichera-mixed.mesh
|
||||
// ex1 -m ../data/toroid-wedge.mesh
|
||||
// ex1 -m ../data/square-disc-p2.vtk -o 2
|
||||
// ex1 -m ../data/square-disc-p3.mesh -o 3
|
||||
// ex1 -m ../data/square-disc-nurbs.mesh -o -1
|
||||
// ex1 -m ../data/star-mixed-p2.mesh -o 2
|
||||
// ex1 -m ../data/disc-nurbs.mesh -o -1
|
||||
// ex1 -m ../data/pipe-nurbs.mesh -o -1
|
||||
// ex1 -m ../data/fichera-mixed-p2.mesh -o 2
|
||||
// ex1 -m ../data/star-surf.mesh
|
||||
// ex1 -m ../data/square-disc-surf.mesh
|
||||
// ex1 -m ../data/inline-segment.mesh
|
||||
// ex1 -m ../data/amr-quad.mesh
|
||||
// ex1 -m ../data/amr-hex.mesh
|
||||
// ex1 -m ../data/fichera-amr.mesh
|
||||
// ex1 -m ../data/mobius-strip.mesh
|
||||
// ex1 -m ../data/mobius-strip.mesh -o -1 -sc
|
||||
// Sample runs: ex1 -m ../../data/square-disc.mesh
|
||||
// ex1 -m ../../data/star.mesh
|
||||
// ex1 -m ../../data/star-mixed.mesh
|
||||
// ex1 -m ../../data/escher.mesh
|
||||
// ex1 -m ../../data/fichera.mesh
|
||||
// ex1 -m ../../data/fichera-mixed.mesh
|
||||
// ex1 -m ../../data/toroid-wedge.mesh
|
||||
// ex1 -m ../../data/square-disc-p2.vtk -o 2
|
||||
// ex1 -m ../../data/square-disc-p3.mesh -o 3
|
||||
// ex1 -m ../../data/square-disc-nurbs.mesh -o -1
|
||||
// ex1 -m ../../data/star-mixed-p2.mesh -o 2
|
||||
// ex1 -m ../../data/disc-nurbs.mesh -o -1
|
||||
// ex1 -m ../../data/pipe-nurbs.mesh -o -1
|
||||
// ex1 -m ../../data/fichera-mixed-p2.mesh -o 2
|
||||
// ex1 -m ../../data/star-surf.mesh
|
||||
// ex1 -m ../../data/square-disc-surf.mesh
|
||||
// ex1 -m ../../data/inline-segment.mesh
|
||||
// ex1 -m ../../data/amr-quad.mesh
|
||||
// ex1 -m ../../data/amr-hex.mesh
|
||||
// ex1 -m ../../data/fichera-amr.mesh
|
||||
// ex1 -m ../../data/mobius-strip.mesh
|
||||
// ex1 -m ../../data/mobius-strip.mesh -o -1 -sc
|
||||
//
|
||||
// Device sample runs:
|
||||
// ex1 -pa -d cuda
|
||||
@@ -32,7 +32,7 @@
|
||||
// ex1 -pa -d occa-cuda
|
||||
// ex1 -pa -d raja-omp
|
||||
// ex1 -pa -d occa-omp
|
||||
// ex1 -m ../data/beam-hex.mesh -pa -d cuda
|
||||
// ex1 -m ../../data/beam-hex.mesh -pa -d cuda
|
||||
//
|
||||
// Description: This example code demonstrates the use of MFEM to define a
|
||||
// simple finite element discretization of the Laplace problem
|
||||
|
||||
+10
-6
@@ -22,15 +22,19 @@ MFEM_LIB_FILE = mfem_is_not_built
|
||||
-include $(CONFIG_MK)
|
||||
|
||||
SEQ_EXAMPLES = ex0 ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 ex10 ex14 ex15 ex16 \
|
||||
ex17 ex18 ex19 ex20 ex21 ex22 ex23 ex24 ex25 ex26 ex27 ex28 ex29 ex30 \
|
||||
ex31 ex33 ex34 ex36 ex37
|
||||
ex17 ex18 ex19 ex20 ex21 ex22 ex23 ex24 ex25 ex26 ex27 ex28 ex29 ex30 \
|
||||
ex31 ex33 ex34 ex36 ex37
|
||||
PAR_EXAMPLES = ex0p ex1p ex2p ex3p ex4p ex5p ex6p ex7p ex8p ex9p ex10p ex11p \
|
||||
ex12p ex13p ex14p ex15p ex16p ex17p ex18p ex19p ex20p ex21p ex22p ex24p \
|
||||
ex25p ex26p ex27p ex28p ex29p ex30p ex31p ex32p ex33p ex34p ex35p ex36p \
|
||||
ex37p
|
||||
ex12p ex13p ex14p ex15p ex16p ex17p ex18p ex19p ex20p ex21p ex22p ex24p \
|
||||
ex25p ex26p ex27p ex28p ex29p ex30p ex31p ex32p ex33p ex34p ex35p ex36p \
|
||||
ex37p
|
||||
SEQ_DEVICE_EXAMPLES = ex1 ex3 ex4 ex5 ex6 ex9 ex22 ex24 ex25 ex26 ex34
|
||||
PAR_DEVICE_EXAMPLES = ex1p ex2p ex3p ex4p ex5p ex6p ex7p ex9p ex13p ex22p \
|
||||
ex24p ex25p ex26p ex34p ex35p
|
||||
ex24p ex25p ex26p ex34p ex35p
|
||||
|
||||
ifeq ($(MFEM_USE_LAPACK),YES)
|
||||
SEQ_EXAMPLES += ex38
|
||||
endif
|
||||
|
||||
ifeq ($(MFEM_USE_MPI),NO)
|
||||
EXAMPLES = $(SEQ_EXAMPLES)
|
||||
|
||||
@@ -273,12 +273,13 @@ int main(int argc, char *argv[])
|
||||
#ifdef MFEM_USE_STRUMPACK
|
||||
if (sp_solver)
|
||||
{
|
||||
STRUMPACKSolver * strumpack = new STRUMPACKSolver(argc, argv, MPI_COMM_WORLD);
|
||||
STRUMPACKSolver * strumpack = new STRUMPACKSolver(MPI_COMM_WORLD, argc, argv);
|
||||
strumpack->SetPrintFactorStatistics(true);
|
||||
strumpack->SetPrintSolveStatistics(false);
|
||||
strumpack->SetKrylovSolver(strumpack::KrylovSolver::DIRECT);
|
||||
strumpack->SetReorderingStrategy(strumpack::ReorderingStrategy::METIS);
|
||||
strumpack->DisableMatching();
|
||||
strumpack->SetMatching(strumpack::MatchingJob::NONE);
|
||||
strumpack->SetCompression(strumpack::CompressionType::NONE);
|
||||
strumpack->SetOperator(*Arow);
|
||||
strumpack->SetFromCommandLine();
|
||||
precond = strumpack;
|
||||
|
||||
+6
-3
@@ -25,6 +25,8 @@ set(SRCS
|
||||
integ/bilininteg_diffusion_ea.cpp
|
||||
integ/bilininteg_diffusion_patch.cpp
|
||||
integ/bilininteg_divdiv_pa.cpp
|
||||
integ/bilininteg_elasticity_ea.cpp
|
||||
integ/bilininteg_elasticity_pa.cpp
|
||||
integ/bilininteg_gradient_pa.cpp
|
||||
integ/bilininteg_interp_pa.cpp
|
||||
integ/bilininteg_mass_mf.cpp
|
||||
@@ -41,6 +43,7 @@ set(SRCS
|
||||
integ/bilininteg_vectorfediv_pa.cpp
|
||||
integ/bilininteg_vectorfemass_pa.cpp
|
||||
integ/bilininteg_diffusion_kernels.cpp
|
||||
integ/bilininteg_elasticity_kernels.cpp
|
||||
integ/bilininteg_hcurl_kernels.cpp
|
||||
integ/bilininteg_hdiv_kernels.cpp
|
||||
integ/bilininteg_hcurlhdiv_kernels.cpp
|
||||
@@ -77,6 +80,7 @@ set(SRCS
|
||||
gridfunc.cpp
|
||||
hybridization.cpp
|
||||
intrules.cpp
|
||||
intrules_cut.cpp
|
||||
ceed/interface/basis.cpp
|
||||
ceed/interface/restriction.cpp
|
||||
ceed/interface/operator.cpp
|
||||
@@ -96,9 +100,6 @@ set(SRCS
|
||||
lor/lor_ads.cpp
|
||||
lor/lor_ams.cpp
|
||||
lor/lor_batched.cpp
|
||||
lor/lor_h1.cpp
|
||||
lor/lor_nd.cpp
|
||||
lor/lor_rt.cpp
|
||||
multigrid.cpp
|
||||
nonlinearform.cpp
|
||||
nonlinearform_ext.cpp
|
||||
@@ -155,6 +156,7 @@ set(HDRS
|
||||
bilinearform_ext.hpp
|
||||
bilininteg.hpp
|
||||
integ/bilininteg_diffusion_kernels.hpp
|
||||
integ/bilininteg_elasticity_kernels.hpp
|
||||
integ/bilininteg_hcurl_kernels.hpp
|
||||
integ/bilininteg_hdiv_kernels.hpp
|
||||
integ/bilininteg_hcurlhdiv_kernels.hpp
|
||||
@@ -186,6 +188,7 @@ set(HDRS
|
||||
gridfunc.hpp
|
||||
hybridization.hpp
|
||||
intrules.hpp
|
||||
intrules_cut.hpp
|
||||
ceed/interface/basis.hpp
|
||||
ceed/interface/integrator.hpp
|
||||
ceed/interface/interface.hpp
|
||||
|
||||
+100
-52
@@ -56,7 +56,7 @@ void BilinearForm::AllocMat()
|
||||
|
||||
int *I = dof_dof.GetI();
|
||||
int *J = dof_dof.GetJ();
|
||||
double *data = Memory<double>(I[height]);
|
||||
real_t *data = Memory<real_t>(I[height]);
|
||||
|
||||
mat = new SparseMatrix(I, J, data, height, height, true, true, true);
|
||||
*mat = 0.0;
|
||||
@@ -101,6 +101,7 @@ BilinearForm::BilinearForm (FiniteElementSpace * f, BilinearForm * bf, int ps)
|
||||
|
||||
// Copy the pointers to the integrators
|
||||
domain_integs = bf->domain_integs;
|
||||
domain_integs_marker = bf->domain_integs_marker;
|
||||
|
||||
boundary_integs = bf->boundary_integs;
|
||||
boundary_integs_marker = bf->boundary_integs_marker;
|
||||
@@ -208,12 +209,12 @@ void BilinearForm::UseSparsity(SparseMatrix &A)
|
||||
UseSparsity(A.GetI(), A.GetJ(), A.ColumnsAreSorted());
|
||||
}
|
||||
|
||||
double& BilinearForm::Elem (int i, int j)
|
||||
real_t& BilinearForm::Elem (int i, int j)
|
||||
{
|
||||
return mat -> Elem(i,j);
|
||||
}
|
||||
|
||||
const double& BilinearForm::Elem (int i, int j) const
|
||||
const real_t& BilinearForm::Elem (int i, int j) const
|
||||
{
|
||||
return mat -> Elem(i,j);
|
||||
}
|
||||
@@ -433,6 +434,9 @@ void BilinearForm::Assemble(int skip_zeros)
|
||||
// Element-wise integration
|
||||
for (int i = 0; i < fes -> GetNE(); i++)
|
||||
{
|
||||
// Set both doftrans (potentially needed to assemble the element
|
||||
// matrix) and vdofs, which is also needed when the element matrices
|
||||
// are pre-assembled.
|
||||
doftrans = fes->GetElementVDofs(i, vdofs);
|
||||
if (element_matrices)
|
||||
{
|
||||
@@ -441,6 +445,8 @@ void BilinearForm::Assemble(int skip_zeros)
|
||||
else
|
||||
{
|
||||
const int elem_attr = fes->GetMesh()->GetAttribute(i);
|
||||
eltrans = fes->GetElementTransformation(i);
|
||||
|
||||
elmat.SetSize(0);
|
||||
for (int k = 0; k < domain_integs.Size(); k++)
|
||||
{
|
||||
@@ -448,9 +454,8 @@ void BilinearForm::Assemble(int skip_zeros)
|
||||
(*(domain_integs_marker[k]))[elem_attr-1] == 1)
|
||||
&& !domain_integs[k]->Patchwise())
|
||||
{
|
||||
const FiniteElement &fe = *fes->GetFE(i);
|
||||
eltrans = fes->GetElementTransformation(i);
|
||||
domain_integs[k]->AssembleElementMatrix(fe, *eltrans, elemmat);
|
||||
domain_integs[k]->AssembleElementMatrix(*fes->GetFE(i),
|
||||
*eltrans, elemmat);
|
||||
if (elmat.Size() == 0)
|
||||
{
|
||||
elmat = elemmat;
|
||||
@@ -996,7 +1001,7 @@ void BilinearForm::EliminateEssentialBC(const Array<int> &bdr_attr_is_ess,
|
||||
}
|
||||
|
||||
void BilinearForm::EliminateEssentialBCDiag (const Array<int> &bdr_attr_is_ess,
|
||||
double value)
|
||||
real_t value)
|
||||
{
|
||||
Array<int> ess_dofs, conf_ess_dofs;
|
||||
fes->GetEssentialVDofs(bdr_attr_is_ess, ess_dofs);
|
||||
@@ -1072,7 +1077,8 @@ void BilinearForm::EliminateEssentialBCFromDofs(
|
||||
void BilinearForm::EliminateEssentialBCFromDofs (const Array<int> &ess_dofs,
|
||||
DiagonalPolicy dpolicy)
|
||||
{
|
||||
MFEM_ASSERT(ess_dofs.Size() == height, "incorrect dof Array size");
|
||||
MFEM_ASSERT(ess_dofs.Size() == height,
|
||||
"incorrect dof Array size: " << ess_dofs.Size() << ' ' << height);
|
||||
|
||||
for (int i = 0; i < ess_dofs.Size(); i++)
|
||||
if (ess_dofs[i] < 0)
|
||||
@@ -1082,9 +1088,10 @@ void BilinearForm::EliminateEssentialBCFromDofs (const Array<int> &ess_dofs,
|
||||
}
|
||||
|
||||
void BilinearForm::EliminateEssentialBCFromDofsDiag (const Array<int> &ess_dofs,
|
||||
double value)
|
||||
real_t value)
|
||||
{
|
||||
MFEM_ASSERT(ess_dofs.Size() == height, "incorrect dof Array size");
|
||||
MFEM_ASSERT(ess_dofs.Size() == height,
|
||||
"incorrect dof Array size: " << ess_dofs.Size() << ' ' << height);
|
||||
|
||||
for (int i = 0; i < ess_dofs.Size(); i++)
|
||||
if (ess_dofs[i] < 0)
|
||||
@@ -1222,11 +1229,14 @@ MixedBilinearForm::MixedBilinearForm (FiniteElementSpace *tr_fes,
|
||||
|
||||
// Copy the pointers to the integrators
|
||||
domain_integs = mbf->domain_integs;
|
||||
boundary_integs = mbf->boundary_integs;
|
||||
trace_face_integs = mbf->trace_face_integs;
|
||||
boundary_trace_face_integs = mbf->boundary_trace_face_integs;
|
||||
domain_integs_marker = mbf->domain_integs_marker;
|
||||
|
||||
boundary_integs = mbf->boundary_integs;
|
||||
boundary_integs_marker = mbf->boundary_integs_marker;
|
||||
|
||||
trace_face_integs = mbf->trace_face_integs;
|
||||
|
||||
boundary_trace_face_integs = mbf->boundary_trace_face_integs;
|
||||
boundary_trace_face_integs_marker = mbf->boundary_trace_face_integs_marker;
|
||||
|
||||
assembly = AssemblyLevel::LEGACY;
|
||||
@@ -1264,12 +1274,12 @@ void MixedBilinearForm::SetAssemblyLevel(AssemblyLevel assembly_level)
|
||||
}
|
||||
}
|
||||
|
||||
double & MixedBilinearForm::Elem (int i, int j)
|
||||
real_t & MixedBilinearForm::Elem (int i, int j)
|
||||
{
|
||||
return (*mat)(i, j);
|
||||
}
|
||||
|
||||
const double & MixedBilinearForm::Elem (int i, int j) const
|
||||
const real_t & MixedBilinearForm::Elem (int i, int j) const
|
||||
{
|
||||
return (*mat)(i, j);
|
||||
}
|
||||
@@ -1281,7 +1291,7 @@ void MixedBilinearForm::Mult(const Vector & x, Vector & y) const
|
||||
}
|
||||
|
||||
void MixedBilinearForm::AddMult(const Vector & x, Vector & y,
|
||||
const double a) const
|
||||
const real_t a) const
|
||||
{
|
||||
if (ext)
|
||||
{
|
||||
@@ -1300,7 +1310,7 @@ void MixedBilinearForm::MultTranspose(const Vector & x, Vector & y) const
|
||||
}
|
||||
|
||||
void MixedBilinearForm::AddMultTranspose(const Vector & x, Vector & y,
|
||||
const double a) const
|
||||
const real_t a) const
|
||||
{
|
||||
if (ext)
|
||||
{
|
||||
@@ -1349,6 +1359,14 @@ void MixedBilinearForm::GetBlocks(Array2D<SparseMatrix *> &blocks) const
|
||||
void MixedBilinearForm::AddDomainIntegrator (BilinearFormIntegrator * bfi)
|
||||
{
|
||||
domain_integs.Append (bfi);
|
||||
domain_integs_marker.Append(NULL); // NULL marker means apply everywhere
|
||||
}
|
||||
|
||||
void MixedBilinearForm::AddDomainIntegrator (BilinearFormIntegrator * bfi,
|
||||
Array<int> &elem_marker)
|
||||
{
|
||||
domain_integs.Append (bfi);
|
||||
domain_integs_marker.Append(&elem_marker);
|
||||
}
|
||||
|
||||
void MixedBilinearForm::AddBoundaryIntegrator (BilinearFormIntegrator * bfi)
|
||||
@@ -1383,7 +1401,7 @@ void MixedBilinearForm::AddBdrTraceFaceIntegrator(BilinearFormIntegrator *bfi,
|
||||
boundary_trace_face_integs_marker.Append(&bdr_marker);
|
||||
}
|
||||
|
||||
void MixedBilinearForm::Assemble (int skip_zeros)
|
||||
void MixedBilinearForm::Assemble(int skip_zeros)
|
||||
{
|
||||
if (ext)
|
||||
{
|
||||
@@ -1405,8 +1423,20 @@ void MixedBilinearForm::Assemble (int skip_zeros)
|
||||
|
||||
if (domain_integs.Size())
|
||||
{
|
||||
for (int k = 0; k < domain_integs.Size(); k++)
|
||||
{
|
||||
if (domain_integs_marker[k] != NULL)
|
||||
{
|
||||
MFEM_VERIFY(domain_integs_marker[k]->Size() ==
|
||||
(mesh->attributes.Size() ? mesh->attributes.Max() : 0),
|
||||
"invalid element marker for domain integrator #"
|
||||
<< k << ", counting from zero");
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < test_fes -> GetNE(); i++)
|
||||
{
|
||||
const int elem_attr = mesh->GetAttribute(i);
|
||||
dom_dof_trans = trial_fes -> GetElementVDofs (i, trial_vdofs);
|
||||
ran_dof_trans = test_fes -> GetElementVDofs (i, test_vdofs);
|
||||
eltrans = test_fes -> GetElementTransformation (i);
|
||||
@@ -1415,10 +1445,14 @@ void MixedBilinearForm::Assemble (int skip_zeros)
|
||||
elmat = 0.0;
|
||||
for (int k = 0; k < domain_integs.Size(); k++)
|
||||
{
|
||||
domain_integs[k] -> AssembleElementMatrix2 (*trial_fes -> GetFE(i),
|
||||
*test_fes -> GetFE(i),
|
||||
*eltrans, elemmat);
|
||||
elmat += elemmat;
|
||||
if (domain_integs_marker[k] == NULL ||
|
||||
(*(domain_integs_marker[k]))[elem_attr-1] == 1)
|
||||
{
|
||||
domain_integs[k] -> AssembleElementMatrix2 (*trial_fes -> GetFE(i),
|
||||
*test_fes -> GetFE(i),
|
||||
*eltrans, elemmat);
|
||||
elmat += elemmat;
|
||||
}
|
||||
}
|
||||
if (ran_dof_trans || dom_dof_trans)
|
||||
{
|
||||
@@ -1941,41 +1975,56 @@ void DiscreteLinearOperator::Assemble(int skip_zeros)
|
||||
return;
|
||||
}
|
||||
|
||||
Array<int> dom_vdofs, ran_vdofs;
|
||||
ElementTransformation *T;
|
||||
ElementTransformation *eltrans;
|
||||
DofTransformation * dom_dof_trans;
|
||||
DofTransformation * ran_dof_trans;
|
||||
const FiniteElement *dom_fe, *ran_fe;
|
||||
DenseMatrix totelmat, elmat;
|
||||
DenseMatrix elmat;
|
||||
|
||||
Mesh *mesh = test_fes->GetMesh();
|
||||
|
||||
if (mat == NULL)
|
||||
{
|
||||
mat = new SparseMatrix(height, width);
|
||||
}
|
||||
|
||||
if (domain_integs.Size() > 0)
|
||||
if (domain_integs.Size())
|
||||
{
|
||||
for (int k = 0; k < domain_integs.Size(); k++)
|
||||
{
|
||||
if (domain_integs_marker[k] != NULL)
|
||||
{
|
||||
MFEM_VERIFY(domain_integs_marker[k]->Size() ==
|
||||
(mesh->attributes.Size() ? mesh->attributes.Max() : 0),
|
||||
"invalid element marker for domain integrator #"
|
||||
<< k << ", counting from zero");
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < test_fes->GetNE(); i++)
|
||||
{
|
||||
dom_dof_trans = trial_fes->GetElementVDofs(i, dom_vdofs);
|
||||
ran_dof_trans = test_fes->GetElementVDofs(i, ran_vdofs);
|
||||
T = test_fes->GetElementTransformation(i);
|
||||
dom_fe = trial_fes->GetFE(i);
|
||||
ran_fe = test_fes->GetFE(i);
|
||||
const int elem_attr = mesh->GetAttribute(i);
|
||||
dom_dof_trans = trial_fes->GetElementVDofs(i, trial_vdofs);
|
||||
ran_dof_trans = test_fes->GetElementVDofs(i, test_vdofs);
|
||||
eltrans = test_fes->GetElementTransformation(i);
|
||||
|
||||
domain_integs[0]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T,
|
||||
totelmat);
|
||||
for (int j = 1; j < domain_integs.Size(); j++)
|
||||
elmat.SetSize(test_vdofs.Size(), trial_vdofs.Size());
|
||||
elmat = 0.0;
|
||||
for (int k = 0; k < domain_integs.Size(); k++)
|
||||
{
|
||||
domain_integs[j]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T,
|
||||
elmat);
|
||||
totelmat += elmat;
|
||||
if (domain_integs_marker[k] == NULL ||
|
||||
(*(domain_integs_marker[k]))[elem_attr-1] == 1)
|
||||
{
|
||||
domain_integs[k]->AssembleElementMatrix2(*trial_fes->GetFE(i),
|
||||
*test_fes->GetFE(i),
|
||||
*eltrans, elemmat);
|
||||
elmat += elemmat;
|
||||
}
|
||||
}
|
||||
if (ran_dof_trans || dom_dof_trans)
|
||||
{
|
||||
TransformPrimal(ran_dof_trans, dom_dof_trans, totelmat);
|
||||
TransformPrimal(ran_dof_trans, dom_dof_trans, elemmat);
|
||||
}
|
||||
mat->SetSubMatrix(ran_vdofs, dom_vdofs, totelmat, skip_zeros);
|
||||
mat->SetSubMatrix(test_vdofs, trial_vdofs, elemmat, skip_zeros);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1984,21 +2033,20 @@ void DiscreteLinearOperator::Assemble(int skip_zeros)
|
||||
const int nfaces = test_fes->GetMesh()->GetNumFaces();
|
||||
for (int i = 0; i < nfaces; i++)
|
||||
{
|
||||
trial_fes->GetFaceVDofs(i, dom_vdofs);
|
||||
test_fes->GetFaceVDofs(i, ran_vdofs);
|
||||
T = test_fes->GetMesh()->GetFaceTransformation(i);
|
||||
dom_fe = trial_fes->GetFaceElement(i);
|
||||
ran_fe = test_fes->GetFaceElement(i);
|
||||
trial_fes->GetFaceVDofs(i, trial_vdofs);
|
||||
test_fes->GetFaceVDofs(i, test_vdofs);
|
||||
eltrans = test_fes->GetMesh()->GetFaceTransformation(i);
|
||||
|
||||
trace_face_integs[0]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T,
|
||||
totelmat);
|
||||
for (int j = 1; j < trace_face_integs.Size(); j++)
|
||||
elmat.SetSize(test_vdofs.Size(), trial_vdofs.Size());
|
||||
elmat = 0.0;
|
||||
for (int k = 0; k < trace_face_integs.Size(); k++)
|
||||
{
|
||||
trace_face_integs[j]->AssembleElementMatrix2(*dom_fe, *ran_fe, *T,
|
||||
elmat);
|
||||
totelmat += elmat;
|
||||
trace_face_integs[k]->AssembleElementMatrix2(*trial_fes->GetFaceElement(i),
|
||||
*test_fes->GetFaceElement(i),
|
||||
*eltrans, elemmat);
|
||||
elmat += elemmat;
|
||||
}
|
||||
mat->SetSubMatrix(ran_vdofs, dom_vdofs, totelmat, skip_zeros);
|
||||
mat->SetSubMatrix(test_vdofs, trial_vdofs, elmat, skip_zeros);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+37
-22
@@ -100,7 +100,7 @@ protected:
|
||||
/// Includes all by default.
|
||||
/// 0 - ignore attribute
|
||||
/// 1 - include attribute
|
||||
Array<Array<int>*> domain_integs_marker;
|
||||
Array<Array<int>*> domain_integs_marker; ///< Entries are not owned.
|
||||
|
||||
/// Set of Boundary Integrators to be applied.
|
||||
Array<BilinearFormIntegrator*> boundary_integs;
|
||||
@@ -279,13 +279,13 @@ public:
|
||||
{ return &boundary_face_integs_marker; }
|
||||
|
||||
/// Returns a reference to: \f$ M_{ij} \f$
|
||||
const double &operator()(int i, int j) { return (*mat)(i,j); }
|
||||
const real_t &operator()(int i, int j) { return (*mat)(i,j); }
|
||||
|
||||
/// Returns a reference to: \f$ M_{ij} \f$
|
||||
virtual double &Elem(int i, int j);
|
||||
virtual real_t &Elem(int i, int j);
|
||||
|
||||
/// Returns constant reference to: \f$ M_{ij} \f$
|
||||
virtual const double &Elem(int i, int j) const;
|
||||
virtual const real_t &Elem(int i, int j) const;
|
||||
|
||||
/// Matrix vector multiplication: \f$ y = M x \f$
|
||||
virtual void Mult(const Vector &x, Vector &y) const;
|
||||
@@ -297,7 +297,7 @@ public:
|
||||
{ mat->Mult(x, y); mat_e->AddMult(x, y); }
|
||||
|
||||
/// Add the matrix vector multiple to a vector: \f$ y += a M x \f$
|
||||
virtual void AddMult(const Vector &x, Vector &y, const double a = 1.0) const
|
||||
virtual void AddMult(const Vector &x, Vector &y, const real_t a = 1.0) const
|
||||
{ mat -> AddMult (x, y, a); }
|
||||
|
||||
/** @brief Add the original uneliminated matrix vector multiple to a vector.
|
||||
@@ -308,7 +308,7 @@ public:
|
||||
|
||||
/// Add the matrix transpose vector multiplication: \f$ y += a M^T x \f$
|
||||
virtual void AddMultTranspose(const Vector & x, Vector & y,
|
||||
const double a = 1.0) const
|
||||
const real_t a = 1.0) const
|
||||
{ mat->AddMultTranspose(x, y, a); }
|
||||
|
||||
/** @brief Add the original uneliminated matrix transpose vector
|
||||
@@ -321,7 +321,7 @@ public:
|
||||
virtual void MultTranspose(const Vector & x, Vector & y) const;
|
||||
|
||||
/// Compute \f$ y^T M x \f$
|
||||
double InnerProduct(const Vector &x, const Vector &y) const
|
||||
real_t InnerProduct(const Vector &x, const Vector &y) const
|
||||
{ return mat->InnerProduct (x, y); }
|
||||
|
||||
/// Returns a pointer to (approximation) of the matrix inverse: \f$ M^{-1} \f$
|
||||
@@ -423,7 +423,7 @@ public:
|
||||
Array<int> &bdr_marker);
|
||||
|
||||
/// Sets all sparse values of \f$ M \f$ and \f$ M_e \f$ to 'a'.
|
||||
void operator=(const double a)
|
||||
void operator=(const real_t a)
|
||||
{
|
||||
if (mat != NULL) { *mat = a; }
|
||||
if (mat_e != NULL) { *mat_e = a; }
|
||||
@@ -614,7 +614,7 @@ public:
|
||||
DiagonalPolicy dpolicy = DIAG_ONE);
|
||||
/// Perform elimination and set the diagonal entry to the given value
|
||||
void EliminateEssentialBCDiag(const Array<int> &bdr_attr_is_ess,
|
||||
double value);
|
||||
real_t value);
|
||||
|
||||
/// Eliminate the given @a vdofs. NOTE: here, @a vdofs is a list of DOFs.
|
||||
/** In this case the eliminations are applied to the internal \f$ M \f$
|
||||
@@ -643,7 +643,7 @@ public:
|
||||
DiagonalPolicy dpolicy = DIAG_ONE);
|
||||
/// Perform elimination and set the diagonal entry to the given value
|
||||
void EliminateEssentialBCFromDofsDiag(const Array<int> &ess_dofs,
|
||||
double value);
|
||||
real_t value);
|
||||
|
||||
/** @brief Use the stored eliminated part of the matrix (see
|
||||
EliminateVDofs(const Array<int> &, DiagonalPolicy)) to modify the r.h.s.
|
||||
@@ -652,7 +652,7 @@ public:
|
||||
Vector &b);
|
||||
|
||||
/// Compute inner product for full uneliminated matrix \f$ y^T M x + y^T M_e x \f$
|
||||
double FullInnerProduct(const Vector &x, const Vector &y) const
|
||||
real_t FullInnerProduct(const Vector &x, const Vector &y) const
|
||||
{ return mat->InnerProduct(x, y) + mat_e->InnerProduct(x, y); }
|
||||
|
||||
/// Update the @a FiniteElementSpace and delete all data associated with the old one.
|
||||
@@ -722,10 +722,13 @@ protected:
|
||||
|
||||
/// Domain integrators.
|
||||
Array<BilinearFormIntegrator*> domain_integs;
|
||||
/// Entries are not owned.
|
||||
Array<Array<int>*> domain_integs_marker;
|
||||
|
||||
/// Boundary integrators.
|
||||
Array<BilinearFormIntegrator*> boundary_integs;
|
||||
Array<Array<int>*> boundary_integs_marker; ///< Entries are not owned.
|
||||
/// Entries are not owned.
|
||||
Array<Array<int>*> boundary_integs_marker;
|
||||
|
||||
/// Trace face (skeleton) integrators.
|
||||
Array<BilinearFormIntegrator*> trace_face_integs;
|
||||
@@ -767,20 +770,20 @@ public:
|
||||
MixedBilinearForm *mbf);
|
||||
|
||||
/// Returns a reference to: \f$ M_{ij} \f$
|
||||
virtual double &Elem(int i, int j);
|
||||
virtual real_t &Elem(int i, int j);
|
||||
|
||||
/// Returns a reference to: \f$ M_{ij} \f$
|
||||
virtual const double &Elem(int i, int j) const;
|
||||
virtual const real_t &Elem(int i, int j) const;
|
||||
|
||||
/// Matrix multiplication: \f$ y = M x \f$
|
||||
virtual void Mult(const Vector & x, Vector & y) const;
|
||||
|
||||
virtual void AddMult(const Vector & x, Vector & y,
|
||||
const double a = 1.0) const;
|
||||
const real_t a = 1.0) const;
|
||||
|
||||
virtual void MultTranspose(const Vector & x, Vector & y) const;
|
||||
virtual void AddMultTranspose(const Vector & x, Vector & y,
|
||||
const double a = 1.0) const;
|
||||
const real_t a = 1.0) const;
|
||||
|
||||
virtual MatrixInverse *Inverse() const;
|
||||
|
||||
@@ -805,12 +808,16 @@ public:
|
||||
/// Adds a domain integrator. Assumes ownership of @a bfi.
|
||||
void AddDomainIntegrator(BilinearFormIntegrator *bfi);
|
||||
|
||||
/// Adds a domain integrator. Assumes ownership of @a bfi.
|
||||
void AddDomainIntegrator(BilinearFormIntegrator *bfi,
|
||||
Array<int> &elem_marker);
|
||||
|
||||
/// Adds a boundary integrator. Assumes ownership of @a bfi.
|
||||
void AddBoundaryIntegrator(BilinearFormIntegrator *bfi);
|
||||
|
||||
/// Adds a boundary integrator. Assumes ownership of @a bfi.
|
||||
void AddBoundaryIntegrator (BilinearFormIntegrator * bfi,
|
||||
Array<int> &bdr_marker);
|
||||
void AddBoundaryIntegrator(BilinearFormIntegrator * bfi,
|
||||
Array<int> &bdr_marker);
|
||||
|
||||
/** @brief Add a trace face integrator. Assumes ownership of @a bfi.
|
||||
|
||||
@@ -820,14 +827,18 @@ public:
|
||||
void AddTraceFaceIntegrator(BilinearFormIntegrator *bfi);
|
||||
|
||||
/// Adds a boundary trace face integrator. Assumes ownership of @a bfi.
|
||||
void AddBdrTraceFaceIntegrator (BilinearFormIntegrator * bfi);
|
||||
void AddBdrTraceFaceIntegrator(BilinearFormIntegrator * bfi);
|
||||
|
||||
/// Adds a boundary trace face integrator. Assumes ownership of @a bfi.
|
||||
void AddBdrTraceFaceIntegrator (BilinearFormIntegrator * bfi,
|
||||
Array<int> &bdr_marker);
|
||||
void AddBdrTraceFaceIntegrator(BilinearFormIntegrator * bfi,
|
||||
Array<int> &bdr_marker);
|
||||
|
||||
/// Access all integrators added with AddDomainIntegrator().
|
||||
Array<BilinearFormIntegrator*> *GetDBFI() { return &domain_integs; }
|
||||
/** @brief Access all domain markers added with AddDomainIntegrator().
|
||||
If no marker was specified when the integrator was added, the
|
||||
corresponding pointer (to Array<int>) will be NULL. */
|
||||
Array<Array<int>*> *GetDBFI_Marker() { return &domain_integs_marker; }
|
||||
|
||||
/// Access all integrators added with AddBoundaryIntegrator().
|
||||
Array<BilinearFormIntegrator*> *GetBBFI() { return &boundary_integs; }
|
||||
@@ -849,7 +860,7 @@ public:
|
||||
{ return &boundary_trace_face_integs_marker; }
|
||||
|
||||
/// Sets all sparse values of \f$ M \f$ to @a a.
|
||||
void operator=(const double a) { *mat = a; }
|
||||
void operator=(const real_t a) { *mat = a; }
|
||||
|
||||
/// Set the desired assembly level. The default is AssemblyLevel::LEGACY.
|
||||
/** This method must be called before assembly. */
|
||||
@@ -1065,6 +1076,9 @@ public:
|
||||
/// Adds a domain interpolator. Assumes ownership of @a di.
|
||||
void AddDomainInterpolator(DiscreteInterpolator *di)
|
||||
{ AddDomainIntegrator(di); }
|
||||
void AddDomainInterpolator(DiscreteInterpolator *di,
|
||||
Array<int> &elem_marker)
|
||||
{ AddDomainIntegrator(di, elem_marker); }
|
||||
|
||||
/// Adds a trace face interpolator. Assumes ownership of @a di.
|
||||
void AddTraceFaceInterpolator(DiscreteInterpolator *di)
|
||||
@@ -1072,6 +1086,7 @@ public:
|
||||
|
||||
/// Access all interpolators added with AddDomainInterpolator().
|
||||
Array<BilinearFormIntegrator*> *GetDI() { return &domain_integs; }
|
||||
Array<Array<int>*> *GetDI_Marker() { return &domain_integs_marker; }
|
||||
|
||||
/// Set the desired assembly level. The default is AssemblyLevel::FULL.
|
||||
/** This method must be called before assembly. */
|
||||
|
||||
+15
-17
@@ -255,9 +255,7 @@ PABilinearFormExtension::PABilinearFormExtension(BilinearForm *form)
|
||||
void PABilinearFormExtension::SetupRestrictionOperators(const L2FaceValues m)
|
||||
{
|
||||
if ( Device::Allows(Backend::CEED_MASK) ) { return; }
|
||||
ElementDofOrdering ordering = UsesTensorBasis(*a->FESpace())?
|
||||
ElementDofOrdering::LEXICOGRAPHIC:
|
||||
ElementDofOrdering::NATIVE;
|
||||
ElementDofOrdering ordering = GetEVectorOrdering(*a->FESpace());
|
||||
elem_restrict = trial_fes->GetElementRestriction(ordering);
|
||||
if (elem_restrict)
|
||||
{
|
||||
@@ -303,7 +301,7 @@ void PABilinearFormExtension::SetupRestrictionOperators(const L2FaceValues m)
|
||||
std::unordered_map<int,int> f_to_be;
|
||||
for (int i = 0; i < mesh.GetNBE(); ++i)
|
||||
{
|
||||
const int f = mesh.GetBdrElementEdgeIndex(i);
|
||||
const int f = mesh.GetBdrElementFaceIndex(i);
|
||||
f_to_be[f] = i;
|
||||
}
|
||||
const int nf_bdr = trial_fes->GetNFbyType(FaceType::Boundary);
|
||||
@@ -791,7 +789,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int e = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A(i, j, e)*X(i, e);
|
||||
@@ -826,7 +824,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A_int(i, j, 0, f)*X(i, 0, f);
|
||||
@@ -845,7 +843,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A_ext(i, j, 0, f)*X(i, 0, f);
|
||||
@@ -882,7 +880,7 @@ void EABilinearFormExtension::Mult(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A(i, j, f)*X(i, f);
|
||||
@@ -919,7 +917,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int e = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A(j, i, e)*X(i, e);
|
||||
@@ -954,7 +952,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A_int(j, i, 0, f)*X(i, 0, f);
|
||||
@@ -973,7 +971,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A_ext(j, i, 1, f)*X(i, 0, f);
|
||||
@@ -1010,7 +1008,7 @@ void EABilinearFormExtension::MultTranspose(const Vector &x, Vector &y) const
|
||||
{
|
||||
const int f = glob_j/NDOFS;
|
||||
const int j = glob_j%NDOFS;
|
||||
double res = 0.0;
|
||||
real_t res = 0.0;
|
||||
for (int i = 0; i < NDOFS; i++)
|
||||
{
|
||||
res += A(j, i, f)*X(i, f);
|
||||
@@ -1438,7 +1436,7 @@ void PAMixedBilinearFormExtension::SetupMultInputs(
|
||||
const Operator *elem_restrict_y,
|
||||
Vector &y,
|
||||
Vector &localY,
|
||||
const double c) const
|
||||
const real_t c) const
|
||||
{
|
||||
// * G operation: localX = c*local(x)
|
||||
if (elem_restrict_x)
|
||||
@@ -1478,7 +1476,7 @@ void PAMixedBilinearFormExtension::Mult(const Vector &x, Vector &y) const
|
||||
}
|
||||
|
||||
void PAMixedBilinearFormExtension::AddMult(const Vector &x, Vector &y,
|
||||
const double c) const
|
||||
const real_t c) const
|
||||
{
|
||||
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
|
||||
const int iSz = integrators.Size();
|
||||
@@ -1510,7 +1508,7 @@ void PAMixedBilinearFormExtension::MultTranspose(const Vector &x,
|
||||
}
|
||||
|
||||
void PAMixedBilinearFormExtension::AddMultTranspose(const Vector &x, Vector &y,
|
||||
const double c) const
|
||||
const real_t c) const
|
||||
{
|
||||
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
|
||||
const int iSz = integrators.Size();
|
||||
@@ -1644,7 +1642,7 @@ void PADiscreteLinearOperatorExtension::Assemble()
|
||||
}
|
||||
|
||||
void PADiscreteLinearOperatorExtension::AddMult(
|
||||
const Vector &x, Vector &y, const double c) const
|
||||
const Vector &x, Vector &y, const real_t c) const
|
||||
{
|
||||
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
|
||||
const int iSz = integrators.Size();
|
||||
@@ -1677,7 +1675,7 @@ void PADiscreteLinearOperatorExtension::AddMult(
|
||||
}
|
||||
|
||||
void PADiscreteLinearOperatorExtension::AddMultTranspose(
|
||||
const Vector &x, Vector &y, const double c) const
|
||||
const Vector &x, Vector &y, const real_t c) const
|
||||
{
|
||||
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
|
||||
const int iSz = integrators.Size();
|
||||
|
||||
@@ -248,7 +248,7 @@ protected:
|
||||
void SetupMultInputs(const Operator *elem_restrict_x,
|
||||
const Vector &x, Vector &localX,
|
||||
const Operator *elem_restrict_y,
|
||||
Vector &y, Vector &localY, const double c) const;
|
||||
Vector &y, Vector &localY, const real_t c) const;
|
||||
|
||||
public:
|
||||
PAMixedBilinearFormExtension(MixedBilinearForm *form);
|
||||
@@ -277,11 +277,11 @@ public:
|
||||
/// y = A*x
|
||||
void Mult(const Vector &x, Vector &y) const;
|
||||
/// y += c*A*x
|
||||
void AddMult(const Vector &x, Vector &y, const double c=1.0) const;
|
||||
void AddMult(const Vector &x, Vector &y, const real_t c=1.0) const;
|
||||
/// y = A^T*x
|
||||
void MultTranspose(const Vector &x, Vector &y) const;
|
||||
/// y += c*A^T*x
|
||||
void AddMultTranspose(const Vector &x, Vector &y, const double c=1.0) const;
|
||||
void AddMultTranspose(const Vector &x, Vector &y, const real_t c=1.0) const;
|
||||
/// Assemble the diagonal of ADA^T for a diagonal vector D.
|
||||
void AssembleDiagonal_ADAt(const Vector &D, Vector &diag) const;
|
||||
|
||||
@@ -305,9 +305,9 @@ public:
|
||||
/// Partial assembly of all internal integrators
|
||||
void Assemble();
|
||||
|
||||
void AddMult(const Vector &x, Vector &y, const double c=1.0) const;
|
||||
void AddMult(const Vector &x, Vector &y, const real_t c=1.0) const;
|
||||
|
||||
void AddMultTranspose(const Vector &x, Vector &y, const double c=1.0) const;
|
||||
void AddMultTranspose(const Vector &x, Vector &y, const real_t c=1.0) const;
|
||||
|
||||
void FormRectangularSystemOperator(const Array<int>&, const Array<int>&,
|
||||
OperatorHandle& A);
|
||||
|
||||
+105
-97
@@ -14,6 +14,7 @@
|
||||
#include "fem.hpp"
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -497,7 +498,7 @@ void MixedScalarIntegrator::AssembleElementMatrix2(
|
||||
this->CalcTestShape(test_fe, Trans, test_shape);
|
||||
this->CalcTrialShape(trial_fe, Trans, trial_shape);
|
||||
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
if (Q)
|
||||
{
|
||||
@@ -591,7 +592,7 @@ void MixedVectorIntegrator::AssembleElementMatrix2(
|
||||
this->CalcTrialShape(trial_fe, Trans, trial_shape);
|
||||
}
|
||||
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
if (MQ)
|
||||
{
|
||||
@@ -705,7 +706,7 @@ void MixedScalarVectorIntegrator::AssembleElementMatrix2(
|
||||
int sca_nd = sca_fe->GetDof();
|
||||
int vec_nd = vec_fe->GetDof();
|
||||
int vdim = GetVDim(*vec_fe);
|
||||
double vtmp;
|
||||
real_t vtmp;
|
||||
|
||||
MFEM_VERIFY(VQ->GetVDim() == vdim, "MixedScalarVectorIntegrator: "
|
||||
"Dimensions of VectorCoefficient and Vector-valued basis "
|
||||
@@ -744,7 +745,7 @@ void MixedScalarVectorIntegrator::AssembleElementMatrix2(
|
||||
this->CalcShape(*sca_fe, Trans, shape);
|
||||
this->CalcVShape(*vec_fe, Trans, vshape);
|
||||
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
VQ->Eval(V, Trans, ip);
|
||||
V *= w;
|
||||
@@ -769,7 +770,7 @@ void GradientIntegrator::AssembleElementMatrix2(
|
||||
dim = test_fe.GetDim();
|
||||
int trial_dof = trial_fe.GetDof();
|
||||
int test_dof = test_fe.GetDof();
|
||||
double c;
|
||||
real_t c;
|
||||
Vector d_col;
|
||||
|
||||
dshape.SetSize(trial_dof, dim);
|
||||
@@ -787,13 +788,13 @@ void GradientIntegrator::AssembleElementMatrix2(
|
||||
for (int i = 0; i < ir->GetNPoints(); i++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir->IntPoint(i);
|
||||
|
||||
trial_fe.CalcDShape(ip, dshape);
|
||||
test_fe.CalcShape(ip, shape);
|
||||
|
||||
Trans.SetIntPoint(&ip);
|
||||
|
||||
CalcAdjugate(Trans.Jacobian(), Jadj);
|
||||
|
||||
test_fe.CalcPhysShape(Trans, shape);
|
||||
trial_fe.CalcDShape(ip, dshape);
|
||||
|
||||
Mult(dshape, Jadj, gshape);
|
||||
|
||||
c = ip.weight;
|
||||
@@ -836,7 +837,7 @@ void DiffusionIntegrator::AssembleElementMatrix
|
||||
dim = el.GetDim();
|
||||
int spaceDim = Trans.GetSpaceDim();
|
||||
bool square = (dim == spaceDim);
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
if (VQ)
|
||||
{
|
||||
@@ -930,7 +931,7 @@ void DiffusionIntegrator::AssembleElementMatrix2(
|
||||
dim = trial_fe.GetDim();
|
||||
int spaceDim = Trans.GetSpaceDim();
|
||||
bool square = (dim == spaceDim);
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
if (VQ)
|
||||
{
|
||||
@@ -1012,7 +1013,7 @@ void DiffusionIntegrator::AssembleElementVector(
|
||||
int nd = el.GetDof();
|
||||
dim = el.GetDim();
|
||||
int spaceDim = Tr.GetSpaceDim();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
if (VQ)
|
||||
{
|
||||
@@ -1186,7 +1187,7 @@ void DiffusionIntegrator::ComputeElementFlux
|
||||
}
|
||||
}
|
||||
|
||||
double DiffusionIntegrator::ComputeFluxEnergy
|
||||
real_t DiffusionIntegrator::ComputeFluxEnergy
|
||||
( const FiniteElement &fluxelem, ElementTransformation &Trans,
|
||||
Vector &flux, Vector* d_energy)
|
||||
{
|
||||
@@ -1209,7 +1210,7 @@ double DiffusionIntegrator::ComputeFluxEnergy
|
||||
int order = 2 * fluxelem.GetOrder(); // <--
|
||||
const IntegrationRule *ir = &IntRules.Get(fluxelem.GetGeomType(), order);
|
||||
|
||||
double energy = 0.0;
|
||||
real_t energy = 0.0;
|
||||
if (d_energy) { *d_energy = 0.0; }
|
||||
|
||||
for (int i = 0; i < ir->GetNPoints(); i++)
|
||||
@@ -1227,7 +1228,7 @@ double DiffusionIntegrator::ComputeFluxEnergy
|
||||
}
|
||||
|
||||
Trans.SetIntPoint(&ip);
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
if (MQ)
|
||||
{
|
||||
@@ -1242,7 +1243,7 @@ double DiffusionIntegrator::ComputeFluxEnergy
|
||||
}
|
||||
else
|
||||
{
|
||||
double e = (pointflux * pointflux);
|
||||
real_t e = (pointflux * pointflux);
|
||||
if (Q) { e *= Q->Eval(Trans, ip); }
|
||||
energy += w * e;
|
||||
}
|
||||
@@ -1290,7 +1291,7 @@ void MassIntegrator::AssembleElementMatrix
|
||||
{
|
||||
int nd = el.GetDof();
|
||||
// int dim = el.GetDim();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector shape;
|
||||
@@ -1324,7 +1325,7 @@ void MassIntegrator::AssembleElementMatrix2(
|
||||
{
|
||||
int tr_nd = trial_fe.GetDof();
|
||||
int te_nd = test_fe.GetDof();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector shape, te_shape;
|
||||
@@ -1340,10 +1341,11 @@ void MassIntegrator::AssembleElementMatrix2(
|
||||
for (int i = 0; i < ir->GetNPoints(); i++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir->IntPoint(i);
|
||||
trial_fe.CalcShape(ip, shape);
|
||||
test_fe.CalcShape(ip, te_shape);
|
||||
|
||||
Trans.SetIntPoint (&ip);
|
||||
|
||||
trial_fe.CalcPhysShape(Trans, shape);
|
||||
test_fe.CalcPhysShape(Trans, te_shape);
|
||||
|
||||
w = Trans.Weight() * ip.weight;
|
||||
if (Q)
|
||||
{
|
||||
@@ -1378,7 +1380,7 @@ void BoundaryMassIntegrator::AssembleFaceMatrix(
|
||||
"support for interior faces is not implemented");
|
||||
|
||||
int nd1 = el1.GetDof();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector shape;
|
||||
@@ -1497,15 +1499,15 @@ void GroupConvectionIntegrator::AssembleElementMatrix(
|
||||
|
||||
Mult(dshape, adjJ, grad);
|
||||
|
||||
double w = alpha * ip.weight;
|
||||
real_t w = alpha * ip.weight;
|
||||
|
||||
// elmat(k,l) += \sum_s w*shape(k)*Q_nodal(s,k)*grad(l,s)
|
||||
for (int k = 0; k < nd; k++)
|
||||
{
|
||||
double wsk = w*shape(k);
|
||||
real_t wsk = w*shape(k);
|
||||
for (int l = 0; l < nd; l++)
|
||||
{
|
||||
double a = 0.0;
|
||||
real_t a = 0.0;
|
||||
for (int s = 0; s < dim; s++)
|
||||
{
|
||||
a += Q_nodal(s,k)*grad(l,s);
|
||||
@@ -1538,7 +1540,7 @@ void VectorMassIntegrator::AssembleElementMatrix
|
||||
int nd = el.GetDof();
|
||||
int spaceDim = Trans.GetSpaceDim();
|
||||
|
||||
double norm;
|
||||
real_t norm;
|
||||
|
||||
// If vdim is not set, set it to the space dimension
|
||||
vdim = (vdim == -1) ? spaceDim : vdim;
|
||||
@@ -1620,7 +1622,7 @@ void VectorMassIntegrator::AssembleElementMatrix2(
|
||||
int tr_nd = trial_fe.GetDof();
|
||||
int te_nd = test_fe.GetDof();
|
||||
|
||||
double norm;
|
||||
real_t norm;
|
||||
|
||||
// If vdim is not set, set it to the space dimension
|
||||
vdim = (vdim == -1) ? Trans.GetSpaceDim() : vdim;
|
||||
@@ -1727,7 +1729,7 @@ void VectorFEDivergenceIntegrator::AssembleElementMatrix2(
|
||||
trial_fe.CalcDivShape(ip, divshape);
|
||||
Trans.SetIntPoint(&ip);
|
||||
test_fe.CalcPhysShape(Trans, shape);
|
||||
double w = ip.weight;
|
||||
real_t w = ip.weight;
|
||||
if (Q)
|
||||
{
|
||||
Trans.SetIntPoint(&ip);
|
||||
@@ -1808,7 +1810,7 @@ void VectorFEWeakDivergenceIntegrator::AssembleElementMatrix2(
|
||||
|
||||
trial_fe.CalcVShape(Trans, vshape);
|
||||
|
||||
double w = ip.weight;
|
||||
real_t w = ip.weight;
|
||||
|
||||
if (Q)
|
||||
{
|
||||
@@ -1898,7 +1900,7 @@ void VectorFECurlIntegrator::AssembleElementMatrix2(
|
||||
}
|
||||
}
|
||||
|
||||
double w = ip.weight;
|
||||
real_t w = ip.weight;
|
||||
|
||||
if (Q)
|
||||
{
|
||||
@@ -1929,7 +1931,7 @@ void DerivativeIntegrator::AssembleElementMatrix2 (
|
||||
int spaceDim = Trans.GetSpaceDim();
|
||||
|
||||
int i, l;
|
||||
double det;
|
||||
real_t det;
|
||||
|
||||
elmat.SetSize (test_nd,trial_nd);
|
||||
dshape.SetSize (trial_nd,dim);
|
||||
@@ -1992,7 +1994,7 @@ void CurlCurlIntegrator::AssembleElementMatrix
|
||||
int nd = el.GetDof();
|
||||
dim = el.GetDim();
|
||||
int dimc = el.GetCurlDim();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector D;
|
||||
@@ -2065,7 +2067,7 @@ void CurlCurlIntegrator::AssembleElementMatrix2(const FiniteElement &trial_fe,
|
||||
int te_nd = test_fe.GetDof();
|
||||
dim = trial_fe.GetDim();
|
||||
int dimc = trial_fe.GetCurlDim();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector D;
|
||||
@@ -2152,7 +2154,7 @@ void CurlCurlIntegrator
|
||||
// TODO: Q, wcoef?
|
||||
}
|
||||
|
||||
double CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
real_t CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
ElementTransformation &Trans,
|
||||
Vector &flux, Vector *d_energy)
|
||||
{
|
||||
@@ -2169,7 +2171,7 @@ double CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
int order = 2 * fluxelem.GetOrder(); // <--
|
||||
const IntegrationRule &ir = IntRules.Get(fluxelem.GetGeomType(), order);
|
||||
|
||||
double energy = 0.0;
|
||||
real_t energy = 0.0;
|
||||
if (d_energy) { *d_energy = 0.0; }
|
||||
|
||||
Vector* pfluxes = NULL;
|
||||
@@ -2187,9 +2189,9 @@ double CurlCurlIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
// fluxelem.CalcVShape(ip, vshape);
|
||||
vshape.MultTranspose(flux, pointflux);
|
||||
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
double e = w * (pointflux * pointflux);
|
||||
real_t e = w * (pointflux * pointflux);
|
||||
|
||||
if (Q)
|
||||
{
|
||||
@@ -2291,7 +2293,7 @@ void VectorCurlCurlIntegrator::AssembleElementMatrix(
|
||||
|
||||
Trans.SetIntPoint(&ip);
|
||||
CalcAdjugate(Trans.Jacobian(), Jadj);
|
||||
double w = ip.weight / Trans.Weight();
|
||||
real_t w = ip.weight / Trans.Weight();
|
||||
|
||||
Mult(dshape_hat, Jadj, dshape);
|
||||
dshape.GradToCurl(curlshape);
|
||||
@@ -2305,7 +2307,7 @@ void VectorCurlCurlIntegrator::AssembleElementMatrix(
|
||||
}
|
||||
}
|
||||
|
||||
double VectorCurlCurlIntegrator::GetElementEnergy(
|
||||
real_t VectorCurlCurlIntegrator::GetElementEnergy(
|
||||
const FiniteElement &el, ElementTransformation &Tr, const Vector &elfun)
|
||||
{
|
||||
int dim = el.GetDim();
|
||||
@@ -2330,7 +2332,7 @@ double VectorCurlCurlIntegrator::GetElementEnergy(
|
||||
ir = &IntRules.Get(el.GetGeomType(), order);
|
||||
}
|
||||
|
||||
double energy = 0.;
|
||||
real_t energy = 0.;
|
||||
for (int i = 0; i < ir->GetNPoints(); i++)
|
||||
{
|
||||
const IntegrationPoint &ip = ir->IntPoint(i);
|
||||
@@ -2340,20 +2342,20 @@ double VectorCurlCurlIntegrator::GetElementEnergy(
|
||||
|
||||
Tr.SetIntPoint(&ip);
|
||||
CalcAdjugate(Tr.Jacobian(), Jadj);
|
||||
double w = ip.weight / Tr.Weight();
|
||||
real_t w = ip.weight / Tr.Weight();
|
||||
|
||||
Mult(grad_hat, Jadj, grad);
|
||||
|
||||
if (dim == 2)
|
||||
{
|
||||
double curl = grad(0,1) - grad(1,0);
|
||||
real_t curl = grad(0,1) - grad(1,0);
|
||||
w *= curl * curl;
|
||||
}
|
||||
else
|
||||
{
|
||||
double curl_x = grad(2,1) - grad(1,2);
|
||||
double curl_y = grad(0,2) - grad(2,0);
|
||||
double curl_z = grad(1,0) - grad(0,1);
|
||||
real_t curl_x = grad(2,1) - grad(1,2);
|
||||
real_t curl_y = grad(0,2) - grad(2,0);
|
||||
real_t curl_z = grad(1,0) - grad(0,1);
|
||||
w *= curl_x * curl_x + curl_y * curl_y + curl_z * curl_z;
|
||||
}
|
||||
|
||||
@@ -2403,7 +2405,7 @@ void MixedCurlIntegrator::AssembleElementMatrix2(
|
||||
shape.SetSize(test_dof);
|
||||
elmat = 0.0;
|
||||
|
||||
double c;
|
||||
real_t c;
|
||||
Vector d_col;
|
||||
const IntegrationRule *ir = IntRule;
|
||||
|
||||
@@ -2436,7 +2438,7 @@ void MixedCurlIntegrator::AssembleElementMatrix2(
|
||||
|
||||
for (int d = 0; d < dimc; ++d)
|
||||
{
|
||||
double * curldata = &(curlshape.GetData())[d*trial_dof];
|
||||
real_t * curldata = &(curlshape.GetData())[d*trial_dof];
|
||||
for (int jj = 0; jj < trial_dof; ++jj)
|
||||
{
|
||||
for (int ii = 0; ii < test_dof; ++ii)
|
||||
@@ -2458,7 +2460,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix(
|
||||
int spaceDim = Trans.GetSpaceDim();
|
||||
int vdim = std::max(spaceDim, el.GetRangeDim());
|
||||
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector D(DQ ? DQ->GetVDim() : 0);
|
||||
@@ -2527,7 +2529,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix2(
|
||||
int vdim = std::max(spaceDim, trial_fe.GetRangeDim());
|
||||
int trial_dof = trial_fe.GetDof();
|
||||
int test_dof = test_fe.GetDof();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
DenseMatrix trial_vshape(trial_dof, spaceDim);
|
||||
@@ -2587,7 +2589,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix2(
|
||||
{
|
||||
for (int k = 0; k < trial_dof; k++)
|
||||
{
|
||||
double Kv = 0.0;
|
||||
real_t Kv = 0.0;
|
||||
for (int vd = 0; vd < spaceDim; vd++)
|
||||
{
|
||||
Kv += K(d, vd) * trial_vshape(k, vd);
|
||||
@@ -2626,7 +2628,7 @@ void VectorFEMassIntegrator::AssembleElementMatrix2(
|
||||
int test_vdim = std::max(spaceDim, test_fe.GetRangeDim());
|
||||
int trial_dof = trial_fe.GetDof();
|
||||
int test_dof = test_fe.GetDof();
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
DenseMatrix trial_vshape(trial_dof,trial_vdim);
|
||||
@@ -2700,7 +2702,7 @@ void VectorDivergenceIntegrator::AssembleElementMatrix2(
|
||||
dim = trial_fe.GetDim();
|
||||
int trial_dof = trial_fe.GetDof();
|
||||
int test_dof = test_fe.GetDof();
|
||||
double c;
|
||||
real_t c;
|
||||
|
||||
dshape.SetSize (trial_dof, dim);
|
||||
gshape.SetSize (trial_dof, dim);
|
||||
@@ -2757,7 +2759,7 @@ void DivDivIntegrator::AssembleElementMatrix(
|
||||
DenseMatrix &elmat)
|
||||
{
|
||||
int dof = el.GetDof();
|
||||
double c;
|
||||
real_t c;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector divshape(dof);
|
||||
@@ -2802,7 +2804,7 @@ void DivDivIntegrator::AssembleElementMatrix2(
|
||||
{
|
||||
int tr_nd = trial_fe.GetDof();
|
||||
int te_nd = test_fe.GetDof();
|
||||
double c;
|
||||
real_t c;
|
||||
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector divshape(tr_nd);
|
||||
@@ -2886,7 +2888,7 @@ void VectorDiffusionIntegrator::AssembleElementMatrix(
|
||||
el.CalcDShape(ip, dshape);
|
||||
|
||||
Trans.SetIntPoint(&ip);
|
||||
double w = Trans.Weight();
|
||||
real_t w = Trans.Weight();
|
||||
w = ip.weight / (square ? w : w*w*w);
|
||||
// AdjugateJacobian = / adj(J), if J is square
|
||||
// \ adj(J^t.J).J^t, otherwise
|
||||
@@ -2971,7 +2973,7 @@ void VectorDiffusionIntegrator::AssembleElementVector(
|
||||
el.CalcDShape(ip, dshape);
|
||||
|
||||
Tr.SetIntPoint(&ip);
|
||||
double w = Tr.Weight();
|
||||
real_t w = Tr.Weight();
|
||||
w = ip.weight / (square ? w : w*w*w);
|
||||
Mult(dshape, Tr.AdjugateJacobian(), dshapedxt);
|
||||
MultAAt(dshapedxt, pelmat);
|
||||
@@ -3015,13 +3017,19 @@ void VectorDiffusionIntegrator::AssembleElementVector(
|
||||
}
|
||||
}
|
||||
|
||||
ElasticityComponentIntegrator::ElasticityComponentIntegrator(
|
||||
ElasticityIntegrator &parent_, int i_, int j_)
|
||||
: parent(parent_),
|
||||
i_block(i_),
|
||||
j_block(j_)
|
||||
{ }
|
||||
|
||||
void ElasticityIntegrator::AssembleElementMatrix(
|
||||
const FiniteElement &el, ElementTransformation &Trans, DenseMatrix &elmat)
|
||||
{
|
||||
int dof = el.GetDof();
|
||||
int dim = el.GetDim();
|
||||
double w, L, M;
|
||||
real_t w, L, M;
|
||||
|
||||
MFEM_ASSERT(dim == Trans.GetSpaceDim(), "");
|
||||
|
||||
@@ -3106,7 +3114,7 @@ void ElasticityIntegrator::ComputeElementFlux(
|
||||
const int dof = el.GetDof();
|
||||
const int dim = el.GetDim();
|
||||
const int tdim = dim*(dim+1)/2; // num. entries in a symmetric tensor
|
||||
double L, M;
|
||||
real_t L, M;
|
||||
|
||||
MFEM_ASSERT(dim == 2 || dim == 3,
|
||||
"dimension is not supported: dim = " << dim);
|
||||
@@ -3120,7 +3128,7 @@ void ElasticityIntegrator::ComputeElementFlux(
|
||||
dshape.SetSize(dof, dim);
|
||||
#endif
|
||||
|
||||
double gh_data[9], grad_data[9];
|
||||
real_t gh_data[9], grad_data[9];
|
||||
DenseMatrix gh(gh_data, dim, dim);
|
||||
DenseMatrix grad(grad_data, dim, dim);
|
||||
|
||||
@@ -3154,7 +3162,7 @@ void ElasticityIntegrator::ComputeElementFlux(
|
||||
|
||||
// stress = 2*M*e(u) + L*tr(e(u))*I, where
|
||||
// e(u) = (1/2)*(grad(u) + grad(u)^T)
|
||||
const double M2 = 2.0*M;
|
||||
const real_t M2 = 2.0*M;
|
||||
if (dim == 2)
|
||||
{
|
||||
L *= (grad(0,0) + grad(1,1));
|
||||
@@ -3177,14 +3185,14 @@ void ElasticityIntegrator::ComputeElementFlux(
|
||||
}
|
||||
}
|
||||
|
||||
double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
real_t ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
ElementTransformation &Trans,
|
||||
Vector &flux, Vector *d_energy)
|
||||
{
|
||||
const int dof = fluxelem.GetDof();
|
||||
const int dim = fluxelem.GetDim();
|
||||
const int tdim = dim*(dim+1)/2; // num. entries in a symmetric tensor
|
||||
double L, M;
|
||||
real_t L, M;
|
||||
|
||||
// The MFEM_ASSERT constraints in ElasticityIntegrator::ComputeElementFlux
|
||||
// are assumed here too.
|
||||
@@ -3196,7 +3204,7 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
#else
|
||||
Vector shape(dof);
|
||||
#endif
|
||||
double pointstress_data[6];
|
||||
real_t pointstress_data[6];
|
||||
Vector pointstress(pointstress_data, tdim);
|
||||
|
||||
// View of the 'flux' vector as a (dof x tdim) matrix
|
||||
@@ -3212,7 +3220,7 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
ir = &IntRules.Get(fluxelem.GetGeomType(), order);
|
||||
}
|
||||
|
||||
double energy = 0.0;
|
||||
real_t energy = 0.0;
|
||||
|
||||
for (int i = 0; i < ir->GetNPoints(); i++)
|
||||
{
|
||||
@@ -3222,7 +3230,7 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
flux_mat.MultTranspose(shape, pointstress);
|
||||
|
||||
Trans.SetIntPoint(&ip);
|
||||
double w = Trans.Weight() * ip.weight;
|
||||
real_t w = Trans.Weight() * ip.weight;
|
||||
|
||||
M = mu->Eval(Trans, ip);
|
||||
if (lambda)
|
||||
@@ -3246,19 +3254,19 @@ double ElasticityIntegrator::ComputeFluxEnergy(const FiniteElement &fluxelem,
|
||||
// Then from the first identity above we can find the strain:
|
||||
// e = (1/(2*mu))*(s - lambda*tr(e)*I)
|
||||
|
||||
double pt_e; // point strain energy density
|
||||
const double *s = pointstress_data;
|
||||
real_t pt_e; // point strain energy density
|
||||
const real_t *s = pointstress_data;
|
||||
if (dim == 2)
|
||||
{
|
||||
// s entries: s_xx, s_yy, s_xy
|
||||
const double tr_e = (s[0] + s[1])/(2*(M + L));
|
||||
const real_t tr_e = (s[0] + s[1])/(2*(M + L));
|
||||
L *= tr_e;
|
||||
pt_e = (0.25/M)*(s[0]*(s[0] - L) + s[1]*(s[1] - L) + 2*s[2]*s[2]);
|
||||
}
|
||||
else // (dim == 3)
|
||||
{
|
||||
// s entries: s_xx, s_yy, s_zz, s_xy, s_xz, s_yz
|
||||
const double tr_e = (s[0] + s[1] + s[2])/(2*M + 3*L);
|
||||
const real_t tr_e = (s[0] + s[1] + s[2])/(2*M + 3*L);
|
||||
L *= tr_e;
|
||||
pt_e = (0.25/M)*(s[0]*(s[0] - L) + s[1]*(s[1] - L) + s[2]*(s[2] - L) +
|
||||
2*(s[3]*s[3] + s[4]*s[4] + s[5]*s[5]));
|
||||
@@ -3277,7 +3285,7 @@ void DGTraceIntegrator::AssembleFaceMatrix(const FiniteElement &el1,
|
||||
{
|
||||
int ndof1, ndof2;
|
||||
|
||||
double un, a, b, w;
|
||||
real_t un, a, b, w;
|
||||
|
||||
dim = el1.GetDim();
|
||||
ndof1 = el1.GetDof();
|
||||
@@ -3350,7 +3358,7 @@ void DGTraceIntegrator::AssembleFaceMatrix(const FiniteElement &el1,
|
||||
|
||||
if (rho)
|
||||
{
|
||||
double rho_p;
|
||||
real_t rho_p;
|
||||
if (un >= 0.0 && ndof2)
|
||||
{
|
||||
rho_p = rho->Eval(*Trans.Elem2, eip2);
|
||||
@@ -3417,7 +3425,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
{
|
||||
int dim, ndof1, ndof2, ndofs;
|
||||
bool kappa_is_nonzero = (kappa != 0.);
|
||||
double w, wq = 0.0;
|
||||
real_t w, wq = 0.0;
|
||||
|
||||
dim = el1.GetDim();
|
||||
ndof1 = el1.GetDof();
|
||||
@@ -3592,7 +3600,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
wq *= kappa;
|
||||
for (int i = 0; i < ndof1; i++)
|
||||
{
|
||||
const double wsi = wq*shape1(i);
|
||||
const real_t wsi = wq*shape1(i);
|
||||
for (int j = 0; j <= i; j++)
|
||||
{
|
||||
jmat(i, j) += wsi * shape1(j);
|
||||
@@ -3603,7 +3611,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
for (int i = 0; i < ndof2; i++)
|
||||
{
|
||||
const int i2 = ndof1 + i;
|
||||
const double wsi = wq*shape2(i);
|
||||
const real_t wsi = wq*shape2(i);
|
||||
for (int j = 0; j < ndof1; j++)
|
||||
{
|
||||
jmat(i2, j) -= wsi * shape1(j);
|
||||
@@ -3624,7 +3632,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
{
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
|
||||
real_t aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
|
||||
elmat(i,j) = sigma*aji - aij + mij;
|
||||
elmat(j,i) = sigma*aij - aji + mij;
|
||||
}
|
||||
@@ -3637,7 +3645,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
{
|
||||
for (int j = 0; j < i; j++)
|
||||
{
|
||||
double aij = elmat(i,j), aji = elmat(j,i);
|
||||
real_t aij = elmat(i,j), aji = elmat(j,i);
|
||||
elmat(i,j) = sigma*aji - aij;
|
||||
elmat(j,i) = sigma*aij - aji;
|
||||
}
|
||||
@@ -3651,7 +3659,7 @@ void DGDiffusionIntegrator::AssembleFaceMatrix(
|
||||
void DGElasticityIntegrator::AssembleBlock(
|
||||
const int dim, const int row_ndofs, const int col_ndofs,
|
||||
const int row_offset, const int col_offset,
|
||||
const double jmatcoef, const Vector &col_nL, const Vector &col_nM,
|
||||
const real_t jmatcoef, const Vector &col_nL, const Vector &col_nM,
|
||||
const Vector &row_shape, const Vector &col_shape,
|
||||
const Vector &col_dshape_dnM, const DenseMatrix &col_dshape,
|
||||
DenseMatrix &elmat, DenseMatrix &jmat)
|
||||
@@ -3660,12 +3668,12 @@ void DGElasticityIntegrator::AssembleBlock(
|
||||
{
|
||||
for (int jdof = 0; jdof < col_ndofs; ++jdof, ++j)
|
||||
{
|
||||
const double t2 = col_dshape_dnM(jdof);
|
||||
const real_t t2 = col_dshape_dnM(jdof);
|
||||
for (int im = 0, i = row_offset; im < dim; ++im)
|
||||
{
|
||||
const double t1 = col_dshape(jdof, jm) * col_nL(im);
|
||||
const double t3 = col_dshape(jdof, im) * col_nM(jm);
|
||||
const double tt = t1 + ((im == jm) ? t2 : 0.0) + t3;
|
||||
const real_t t1 = col_dshape(jdof, jm) * col_nL(im);
|
||||
const real_t t3 = col_dshape(jdof, im) * col_nM(jm);
|
||||
const real_t tt = t1 + ((im == jm) ? t2 : 0.0) + t3;
|
||||
for (int idof = 0; idof < row_ndofs; ++idof, ++i)
|
||||
{
|
||||
elmat(i, j) += row_shape(idof) * tt;
|
||||
@@ -3682,7 +3690,7 @@ void DGElasticityIntegrator::AssembleBlock(
|
||||
const int io = row_offset + d*row_ndofs;
|
||||
for (int jdof = 0, j = jo; jdof < col_ndofs; ++jdof, ++j)
|
||||
{
|
||||
const double sj = jmatcoef * col_shape(jdof);
|
||||
const real_t sj = jmatcoef * col_shape(jdof);
|
||||
for (int i = max(io,j), idof = i - io; idof < row_ndofs; ++idof, ++i)
|
||||
{
|
||||
jmat(i, j) += row_shape(idof) * sj;
|
||||
@@ -3782,7 +3790,7 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
|
||||
CalcOrtho(Trans.Jacobian(), nor);
|
||||
}
|
||||
|
||||
double w, wLM;
|
||||
real_t w, wLM;
|
||||
if (ndofs2)
|
||||
{
|
||||
el2.CalcShape(eip2, shape2);
|
||||
@@ -3791,9 +3799,9 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
|
||||
Mult(dshape2, adjJ, dshape2_ps);
|
||||
|
||||
w = ip.weight/2;
|
||||
const double w2 = w / Trans.Elem2->Weight();
|
||||
const double wL2 = w2 * lambda->Eval(*Trans.Elem2, eip2);
|
||||
const double wM2 = w2 * mu->Eval(*Trans.Elem2, eip2);
|
||||
const real_t w2 = w / Trans.Elem2->Weight();
|
||||
const real_t wL2 = w2 * lambda->Eval(*Trans.Elem2, eip2);
|
||||
const real_t wM2 = w2 * mu->Eval(*Trans.Elem2, eip2);
|
||||
nL2.Set(wL2, nor);
|
||||
nM2.Set(wM2, nor);
|
||||
wLM = (wL2 + 2.0*wM2);
|
||||
@@ -3806,16 +3814,16 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
|
||||
}
|
||||
|
||||
{
|
||||
const double w1 = w / Trans.Elem1->Weight();
|
||||
const double wL1 = w1 * lambda->Eval(*Trans.Elem1, eip1);
|
||||
const double wM1 = w1 * mu->Eval(*Trans.Elem1, eip1);
|
||||
const real_t w1 = w / Trans.Elem1->Weight();
|
||||
const real_t wL1 = w1 * lambda->Eval(*Trans.Elem1, eip1);
|
||||
const real_t wM1 = w1 * mu->Eval(*Trans.Elem1, eip1);
|
||||
nL1.Set(wL1, nor);
|
||||
nM1.Set(wM1, nor);
|
||||
wLM += (wL1 + 2.0*wM1);
|
||||
dshape1_ps.Mult(nM1, dshape1_dnM);
|
||||
}
|
||||
|
||||
const double jmatcoef = kappa * (nor*nor) * wLM;
|
||||
const real_t jmatcoef = kappa * (nor*nor) * wLM;
|
||||
|
||||
// (1,1) block
|
||||
AssembleBlock(
|
||||
@@ -3848,7 +3856,7 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
|
||||
{
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
double aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
|
||||
real_t aij = elmat(i,j), aji = elmat(j,i), mij = jmat(i,j);
|
||||
elmat(i,j) = alpha*aji - aij + mij;
|
||||
elmat(j,i) = alpha*aij - aji + mij;
|
||||
}
|
||||
@@ -3861,7 +3869,7 @@ void DGElasticityIntegrator::AssembleFaceMatrix(
|
||||
{
|
||||
for (int j = 0; j < i; ++j)
|
||||
{
|
||||
double aij = elmat(i,j), aji = elmat(j,i);
|
||||
real_t aij = elmat(i,j), aji = elmat(j,i);
|
||||
elmat(i,j) = alpha*aji - aij;
|
||||
elmat(j,i) = alpha*aij - aji;
|
||||
}
|
||||
@@ -3879,7 +3887,7 @@ void TraceJumpIntegrator::AssembleFaceMatrix(
|
||||
int i, j, face_ndof, ndof1, ndof2;
|
||||
int order;
|
||||
|
||||
double w;
|
||||
real_t w;
|
||||
|
||||
face_ndof = trial_face_fe.GetDof();
|
||||
ndof1 = test_fe1.GetDof();
|
||||
@@ -4087,7 +4095,7 @@ void TraceIntegrator::AssembleTraceFaceMatrix(int elem,
|
||||
MFEM_VERIFY(elem == Trans.Elem2->ElementNo, "Elem != Trans.Elem2->ElementNo");
|
||||
}
|
||||
|
||||
double scale = 1.0;
|
||||
real_t scale = 1.0;
|
||||
if (iel != elem) { scale = -1.; }
|
||||
for (int p = 0; p < ir->GetNPoints(); p++)
|
||||
{
|
||||
@@ -4153,7 +4161,7 @@ void NormalTraceIntegrator::AssembleTraceFaceMatrix(int elem,
|
||||
MFEM_VERIFY(elem == Trans.Elem2->ElementNo, "Elem != Trans.Elem2->ElementNo");
|
||||
}
|
||||
|
||||
double scale = 1.0;
|
||||
real_t scale = 1.0;
|
||||
if (iel != elem) { scale = -1.; }
|
||||
|
||||
for (int p = 0; p < ir->GetNPoints(); p++)
|
||||
@@ -4232,7 +4240,7 @@ void TangentTraceIntegrator::AssembleTraceFaceMatrix(int elem,
|
||||
MFEM_VERIFY(elem == Trans.Elem2->ElementNo, "Elem != Trans.Elem2->ElementNo");
|
||||
}
|
||||
|
||||
double scale = 1.0;
|
||||
real_t scale = 1.0;
|
||||
if (iel != elem) { scale = -1.; }
|
||||
for (int p = 0; p < ir->GetNPoints(); p++)
|
||||
{
|
||||
@@ -4256,7 +4264,7 @@ void TangentTraceIntegrator::AssembleTraceFaceMatrix(int elem,
|
||||
// rotate
|
||||
cross_product(normal, shape, shape_n);
|
||||
|
||||
const double w = scale*ip.weight;
|
||||
const real_t w = scale*ip.weight;
|
||||
AddMult_a_ABt(w,shape_n, face_shape, elmat);
|
||||
}
|
||||
}
|
||||
|
||||
+321
-252
File diff suppressed because it is too large
Load Diff
@@ -12,10 +12,14 @@
|
||||
#ifndef MFEM_LIBCEED_CEED
|
||||
#define MFEM_LIBCEED_CEED
|
||||
|
||||
#include "../../../config/config.hpp"
|
||||
|
||||
#ifdef MFEM_USE_CEED
|
||||
|
||||
#include <ceed.h>
|
||||
#if !CEED_VERSION_GE(0,10,0)
|
||||
#error MFEM requires a libCEED version >= 0.10.0
|
||||
|
||||
#if !CEED_VERSION_GE(0,12,0)
|
||||
#error MFEM requires a libCEED version >= 0.12.0
|
||||
#endif
|
||||
|
||||
namespace mfem
|
||||
|
||||
@@ -294,14 +294,14 @@ public:
|
||||
nelem, nqpts, ncomp, strides,
|
||||
&quadCoeff->restr);
|
||||
CeedOperatorSetField(build_oper, "coeff", quadCoeff->restr,
|
||||
CEED_BASIS_COLLOCATED, quadCoeff->coeffVector);
|
||||
CEED_BASIS_NONE, quadCoeff->coeffVector);
|
||||
}
|
||||
CeedOperatorSetField(build_oper, "dx", mesh_restr,
|
||||
mesh_basis, CEED_VECTOR_ACTIVE);
|
||||
CeedOperatorSetField(build_oper, "weights", CEED_ELEMRESTRICTION_NONE,
|
||||
mesh_basis, CEED_VECTOR_NONE);
|
||||
CeedOperatorSetField(build_oper, "qdata", restr_i,
|
||||
CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
|
||||
CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
|
||||
|
||||
// Compute the quadrature data for the operator.
|
||||
CeedOperatorApply(build_oper, node_coords, qdata, CEED_REQUEST_IMMEDIATE);
|
||||
@@ -355,7 +355,7 @@ public:
|
||||
{
|
||||
case EvalMode::None:
|
||||
CeedOperatorSetField(oper, "u", trial_restr,
|
||||
CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
|
||||
CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
|
||||
break;
|
||||
case EvalMode::Interp:
|
||||
CeedOperatorSetField(oper, "u", trial_restr, trial_basis, CEED_VECTOR_ACTIVE);
|
||||
@@ -369,14 +369,14 @@ public:
|
||||
break;
|
||||
}
|
||||
// qdata
|
||||
CeedOperatorSetField(oper, "qdata", restr_i, CEED_BASIS_COLLOCATED,
|
||||
CeedOperatorSetField(oper, "qdata", restr_i, CEED_BASIS_NONE,
|
||||
qdata);
|
||||
// output
|
||||
switch (op.test_op)
|
||||
{
|
||||
case EvalMode::None:
|
||||
CeedOperatorSetField(oper, "v", test_restr,
|
||||
CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
|
||||
CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
|
||||
break;
|
||||
case EvalMode::Interp:
|
||||
CeedOperatorSetField(oper, "v", test_restr, test_basis, CEED_VECTOR_ACTIVE);
|
||||
@@ -685,14 +685,14 @@ public:
|
||||
nelem, nqpts, ncomp, strides,
|
||||
&quadCoeff->restr);
|
||||
CeedOperatorSetField(oper, "coeff", quadCoeff->restr,
|
||||
CEED_BASIS_COLLOCATED, quadCoeff->coeffVector);
|
||||
CEED_BASIS_NONE, quadCoeff->coeffVector);
|
||||
}
|
||||
// input
|
||||
switch (op.trial_op)
|
||||
{
|
||||
case EvalMode::None:
|
||||
CeedOperatorSetField(oper, "u", trial_restr,
|
||||
CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
|
||||
CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
|
||||
break;
|
||||
case EvalMode::Interp:
|
||||
CeedOperatorSetField(oper, "u", trial_restr, trial_basis,
|
||||
@@ -718,7 +718,7 @@ public:
|
||||
{
|
||||
case EvalMode::None:
|
||||
CeedOperatorSetField(oper, "v", test_restr,
|
||||
CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
|
||||
CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
|
||||
break;
|
||||
case EvalMode::Interp:
|
||||
CeedOperatorSetField(oper, "v", test_restr, test_basis,
|
||||
|
||||
@@ -70,7 +70,7 @@ void Operator::Mult(const mfem::Vector &x, mfem::Vector &y) const
|
||||
}
|
||||
|
||||
void Operator::AddMult(const mfem::Vector &x, mfem::Vector &y,
|
||||
const double a) const
|
||||
const real_t a) const
|
||||
{
|
||||
#ifdef MFEM_USE_CEED
|
||||
MFEM_VERIFY(a == 1.0, "General coefficient case is not yet supported!");
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
#endif
|
||||
void Mult(const mfem::Vector &x, mfem::Vector &y) const override;
|
||||
void AddMult(const mfem::Vector &x, mfem::Vector &y,
|
||||
const double a = 1.0) const override;
|
||||
const real_t a = 1.0) const override;
|
||||
void GetDiagonal(mfem::Vector &diag) const;
|
||||
using mfem::Operator::SetupRAP;
|
||||
virtual ~Operator()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user