Compare commits
596
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0639425ff2 | ||
|
|
8f4d4300c2 | ||
|
|
f881903103 | ||
|
|
bab667fe8c | ||
|
|
cef328b0db | ||
|
|
0b81ece2f4 | ||
|
|
3dfdc52328 | ||
|
|
2b8b1ebe58 | ||
|
|
08d4b29232 | ||
|
|
56d092df0e | ||
|
|
9e442b4c22 | ||
|
|
957a514da3 | ||
|
|
88cca21c90 | ||
|
|
51cab29634 | ||
|
|
e08b2beb23 | ||
|
|
5bf8d8a5d1 | ||
|
|
edabdac542 | ||
|
|
9bc340d88d | ||
|
|
70fb6d1c66 | ||
|
|
910fd79c19 | ||
|
|
4ea60b1dec | ||
|
|
c62be8d181 | ||
|
|
d7b8ed1a5b | ||
|
|
fdac3fd03c | ||
|
|
c6425db3da | ||
|
|
4ae682b2d3 | ||
|
|
c31ded06c2 | ||
|
|
2f45c61c68 | ||
|
|
2419c94b37 | ||
|
|
e145ad97c8 | ||
|
|
8b54fe906f | ||
|
|
17dcec0590 | ||
|
|
a09afff6c5 | ||
|
|
5c200cb54a | ||
|
|
e490a474c9 | ||
|
|
e848c67ec5 | ||
|
|
f6ffbae4a1 | ||
|
|
e65dc1ed36 | ||
|
|
e3585a53ae | ||
|
|
bb34d35459 | ||
|
|
f4a2077c8b | ||
|
|
20e40f5778 | ||
|
|
6990897b29 | ||
|
|
63f9463d93 | ||
|
|
b8a3e423fd | ||
|
|
7d84029fc8 | ||
|
|
d6e160753f | ||
|
|
8328b3d220 | ||
|
|
5bd76ca866 | ||
|
|
cc024ce5c2 | ||
|
|
7ecd331a0b | ||
|
|
8402306443 | ||
|
|
b942f9966f | ||
|
|
a461f7258e | ||
|
|
256bb5627f | ||
|
|
485ea34cac | ||
|
|
9f7ab4e642 | ||
|
|
4e6b6f7d47 | ||
|
|
309696aa72 | ||
|
|
33a015aede | ||
|
|
6ed2314eec | ||
|
|
0c4d7aa085 | ||
|
|
d0132c415a | ||
|
|
a5f85a865b | ||
|
|
47c054ce40 | ||
|
|
39b521e647 | ||
|
|
384a8bb319 | ||
|
|
80a3df260c | ||
|
|
915b044b14 | ||
|
|
01caa8dcb7 | ||
|
|
f0b78ba810 | ||
|
|
d1ea0ecbab | ||
|
|
07ab64b635 | ||
|
|
367d0c4c32 | ||
|
|
2cd1d901a6 | ||
|
|
564d7aa1ca | ||
|
|
6fccaa0ce8 | ||
|
|
77c1fe11f0 | ||
|
|
fa80f24449 | ||
|
|
64b10ab759 | ||
|
|
606ba7c190 | ||
|
|
fb41c298e3 | ||
|
|
46df499e23 | ||
|
|
a78d206931 | ||
|
|
20aadc8f95 | ||
|
|
a88269f1f3 | ||
|
|
d85396e2df | ||
|
|
0bc28bca46 | ||
|
|
265b6a59c1 | ||
|
|
5e5a2c66a4 | ||
|
|
b67d03f0ad | ||
|
|
df528c10f1 | ||
|
|
cff66a06eb | ||
|
|
2ec73641dc | ||
|
|
81386ed445 | ||
|
|
4404a4dbca | ||
|
|
cf4acf95a6 | ||
|
|
69c916076f | ||
|
|
b7d7338dca | ||
|
|
003a055712 | ||
|
|
2e12de2cae | ||
|
|
6489b32bcb | ||
|
|
a96065ed18 | ||
|
|
5a66397861 | ||
|
|
2d89962838 | ||
|
|
e33c78fda1 | ||
|
|
3b10d36ee9 | ||
|
|
90431de2a8 | ||
|
|
6cabf89962 | ||
|
|
33ca7a4265 | ||
|
|
4a6a421ea9 | ||
|
|
cbfb0a7ed2 | ||
|
|
ee35e2aef2 | ||
|
|
baffb28a4b | ||
|
|
c0091548e6 | ||
|
|
7dcf76eabc | ||
|
|
9c2a368c3f | ||
|
|
2007823084 | ||
|
|
50cae500a8 | ||
|
|
86cbbe9d92 | ||
|
|
187d444429 | ||
|
|
8a5b431132 | ||
|
|
1d5ef9dc83 | ||
|
|
a7462fa72d | ||
|
|
42646153b8 | ||
|
|
719ef61a5a | ||
|
|
50452026cf | ||
|
|
b86e0302a6 | ||
|
|
aa5b1101b4 | ||
|
|
0eb0d82bda | ||
|
|
88ffc396c3 | ||
|
|
773320ab88 | ||
|
|
3b9000c617 | ||
|
|
5da4d3afc7 | ||
|
|
40fb41470b | ||
|
|
5b9b21748b | ||
|
|
cf3173ab92 | ||
|
|
73916e5140 | ||
|
|
6a9c53e8dd | ||
|
|
bf3b040c9d | ||
|
|
bba2c08025 | ||
|
|
5e03149861 | ||
|
|
581c46d394 | ||
|
|
f640103e26 | ||
|
|
88695cefff | ||
|
|
b23a3921bf | ||
|
|
27c4f22338 | ||
|
|
e4bcd7c58c | ||
|
|
30a3c76325 | ||
|
|
99e1a076ba | ||
|
|
1ae61b0ada | ||
|
|
f0398ff391 | ||
|
|
df1deca20e | ||
|
|
d1b79a7fc3 | ||
|
|
426a77be6c | ||
|
|
9b67afef13 | ||
|
|
308e7f9509 | ||
|
|
3252583bcb | ||
|
|
29dda8468f | ||
|
|
e08cb481e4 | ||
|
|
d06a8110b8 | ||
|
|
3da0d9fc2f | ||
|
|
20dced51fd | ||
|
|
b904336a5e | ||
|
|
8107e14ccd | ||
|
|
a04b471a33 | ||
|
|
4c53371c2a | ||
|
|
70fba19635 | ||
|
|
df6526ef5d | ||
|
|
00c4f59c76 | ||
|
|
dc1b6cf38a | ||
|
|
5a6e0dad2e | ||
|
|
774794595b | ||
|
|
cfa82dccc0 | ||
|
|
30803b8f00 | ||
|
|
113423b423 | ||
|
|
11ed189dec | ||
|
|
0301d39b94 | ||
|
|
b796e1ab50 | ||
|
|
c9a3df3e61 | ||
|
|
d2f040c9bb | ||
|
|
ac4bc120ec | ||
|
|
0b21e3d42f | ||
|
|
d0e444cae0 | ||
|
|
0168811bb0 | ||
|
|
5607e7f863 | ||
|
|
76fcc0374e | ||
|
|
f3d656a9b8 | ||
|
|
92112fccaa | ||
|
|
70bd112ea4 | ||
|
|
6ba7e82f91 | ||
|
|
1411616361 | ||
|
|
1cc284cd42 | ||
|
|
f5da256306 | ||
|
|
ba83609892 | ||
|
|
c771e61f08 | ||
|
|
c7781e1dc7 | ||
|
|
74fc2de695 | ||
|
|
3dbaa74933 | ||
|
|
105d1e767b | ||
|
|
408bba19ca | ||
|
|
f7ee013d35 | ||
|
|
d5a5daf20b | ||
|
|
dfeb8a63d0 | ||
|
|
9c8cf76c6e | ||
|
|
df6e73654a | ||
|
|
a07fc07206 | ||
|
|
5e672f26bc | ||
|
|
f3f37e8e5a | ||
|
|
475d3d8102 | ||
|
|
0f239c22e0 | ||
|
|
783f0e0304 | ||
|
|
cee93c0b36 | ||
|
|
dd03eb6d79 | ||
|
|
8f43daf84f | ||
|
|
0f4bd5925a | ||
|
|
ca3e2b3098 | ||
|
|
b14bd1f237 | ||
|
|
224eef2034 | ||
|
|
0249c8460c | ||
|
|
a393064c00 | ||
|
|
9b6a80c193 | ||
|
|
536f3c24da | ||
|
|
bcc7b129b9 | ||
|
|
fa25a70da6 | ||
|
|
e9b9152f59 | ||
|
|
fc172e9303 | ||
|
|
703706762b | ||
|
|
1bf24380f2 | ||
|
|
bd7527e922 | ||
|
|
96d66067a3 | ||
|
|
60a1d3d1d4 | ||
|
|
2026c6944a | ||
|
|
82a52d42d8 | ||
|
|
74d1cc13a9 | ||
|
|
d6ced2de1a | ||
|
|
07ba5bd336 | ||
|
|
4027c86797 | ||
|
|
2a128ae159 | ||
|
|
1566657332 | ||
|
|
8300a563ae | ||
|
|
753f351934 | ||
|
|
f53f3f84db | ||
|
|
71c73a973b | ||
|
|
9310e05a15 | ||
|
|
985fff881c | ||
|
|
5b841fb239 | ||
|
|
6f7b29ac14 | ||
|
|
589d2775cb | ||
|
|
8a565cad67 | ||
|
|
5f9ee51d40 | ||
|
|
acb85daaff | ||
|
|
36ec075849 | ||
|
|
8b0262bd29 | ||
|
|
d9a18088a2 | ||
|
|
830ea90cf8 | ||
|
|
9377a43d28 | ||
|
|
87cd94a1fe | ||
|
|
1aa1e0633b | ||
|
|
57f3462a00 | ||
|
|
186f65ccc1 | ||
|
|
8e11743052 | ||
|
|
649163a36f | ||
|
|
a58567695e | ||
|
|
53c04ef171 | ||
|
|
2c09747196 | ||
|
|
f54842b6a7 | ||
|
|
2214f65e20 | ||
|
|
094f032de5 | ||
|
|
e9feadbbfc | ||
|
|
a00c3fe39b | ||
|
|
588e211f5a | ||
|
|
2659ee5f3f | ||
|
|
ec176a6bf8 | ||
|
|
81dceb94b6 | ||
|
|
39022bce0f | ||
|
|
15242ffcf6 | ||
|
|
0db5a18c0c | ||
|
|
9a5cafafc6 | ||
|
|
11275857a3 | ||
|
|
d06a528958 | ||
|
|
f54b8bd6d8 | ||
|
|
239c672988 | ||
|
|
aabf4ce84d | ||
|
|
84a1f1e343 | ||
|
|
f64c3175c6 | ||
|
|
63d2303a48 | ||
|
|
01322ef72f | ||
|
|
f086ff03f4 | ||
|
|
f811da79e4 | ||
|
|
f95c2e156b | ||
|
|
2bd1148127 | ||
|
|
c37a187f9d | ||
|
|
d02545cc3e | ||
|
|
80fa63cb64 | ||
|
|
97796f0beb | ||
|
|
c1562552f1 | ||
|
|
a44a8640d1 | ||
|
|
001f1a8b79 | ||
|
|
92e42d4332 | ||
|
|
9c7150c93e | ||
|
|
19a2ad26e1 | ||
|
|
568562a7d5 | ||
|
|
aa8be1b59c | ||
|
|
85a79cbea5 | ||
|
|
3bf7e07457 | ||
|
|
c94cd73dd1 | ||
|
|
ff427a04a6 | ||
|
|
2d10dd0abe | ||
|
|
a53353776d | ||
|
|
2f1c03796a | ||
|
|
199d19c195 | ||
|
|
eb6ef4a537 | ||
|
|
af7c58aa0e | ||
|
|
d4f404cf74 | ||
|
|
2080fde2a1 | ||
|
|
7ff5874904 | ||
|
|
757ee1a24a | ||
|
|
861c7c4a04 | ||
|
|
301d0c3b39 | ||
|
|
f30ab6b09b | ||
|
|
8bee3a173d | ||
|
|
797194af84 | ||
|
|
8afc72f6dc | ||
|
|
60b5110031 | ||
|
|
fe08c6bd36 | ||
|
|
977e978ad7 | ||
|
|
db43873b7d | ||
|
|
40f672c230 | ||
|
|
e49a744288 | ||
|
|
388350029b | ||
|
|
3c3d220460 | ||
|
|
0279dd9787 | ||
|
|
46d800d05e | ||
|
|
4e1420f1e2 | ||
|
|
a9e93adb3f | ||
|
|
3bd47c26fd | ||
|
|
3348ba2dbd | ||
|
|
d8df06ab70 | ||
|
|
5dcd85c7c7 | ||
|
|
047ca50acb | ||
|
|
4d1a0ac51d | ||
|
|
c887336fa4 | ||
|
|
cde981b141 | ||
|
|
8d1780147d | ||
|
|
f452882d29 | ||
|
|
9f554c8b42 | ||
|
|
84f6acaeac | ||
|
|
5113b1a8ed | ||
|
|
0d45eab46d | ||
|
|
6fe9c25cf3 | ||
|
|
ed5e10466d | ||
|
|
0c811d8487 | ||
|
|
15fbf80e57 | ||
|
|
e3450da53e | ||
|
|
1c4b657f63 | ||
|
|
3c0b64a2d6 | ||
|
|
a19e625fc9 | ||
|
|
37bd0ec75d | ||
|
|
b1cfab5f5f | ||
|
|
d9ba858f6f | ||
|
|
020d2173c3 | ||
|
|
f8c5f3e925 | ||
|
|
b9e3b3c20a | ||
|
|
cae40473f7 | ||
|
|
e0e91ce0ee | ||
|
|
f4ca1e3e60 | ||
|
|
dd77aa8eb7 | ||
|
|
e0cac54513 | ||
|
|
0ce2bc6275 | ||
|
|
3e66449ad2 | ||
|
|
24a162f0ef | ||
|
|
ce38dbbca6 | ||
|
|
7f6cc5580d | ||
|
|
4f74e10f30 | ||
|
|
170f9a5ff5 | ||
|
|
0467b670b7 | ||
|
|
e3788a948f | ||
|
|
b15998374d | ||
|
|
0bcbc0235a | ||
|
|
46e21def4e | ||
|
|
9b5f87398c | ||
|
|
05ed290c34 | ||
|
|
80a59acf5f | ||
|
|
a41c0d4a0c | ||
|
|
45c7ce02f8 | ||
|
|
ede2efd9c3 | ||
|
|
b889952837 | ||
|
|
8d96e40489 | ||
|
|
d493efa295 | ||
|
|
a43de945bd | ||
|
|
32a7939e4e | ||
|
|
1f17768e33 | ||
|
|
91f59a269c | ||
|
|
f8d501562f | ||
|
|
b6530be3f9 | ||
|
|
3cbfee625a | ||
|
|
0ec9789849 | ||
|
|
7a20d17f90 | ||
|
|
317032fdbd | ||
|
|
d6a0a5a13d | ||
|
|
c1c39a51b5 | ||
|
|
c5a7b179d8 | ||
|
|
e88b99c2e2 | ||
|
|
793222a7e1 | ||
|
|
05bf01378c | ||
|
|
71b7497037 | ||
|
|
5279744c6e | ||
|
|
19fae213a5 | ||
|
|
0768f1940f | ||
|
|
0c9296ab4b | ||
|
|
7632309ed6 | ||
|
|
439a3d773c | ||
|
|
ec2e958e04 | ||
|
|
ba27c951d1 | ||
|
|
b1b6ccc9f4 | ||
|
|
c35156168c | ||
|
|
4b213c4a30 | ||
|
|
04062029de | ||
|
|
889d0355bc | ||
|
|
f153972fc1 | ||
|
|
223387e0fb | ||
|
|
a7f6abd48c | ||
|
|
f148cdf20c | ||
|
|
8b5eee5a7a | ||
|
|
41f63281bc | ||
|
|
c7f6a45001 | ||
|
|
2edc9c3d20 | ||
|
|
1e16d9a4fd | ||
|
|
7a274ad4fc | ||
|
|
ea1280f8ef | ||
|
|
d54ab59b1d | ||
|
|
910c309181 | ||
|
|
06ed4029d5 | ||
|
|
b8f4c85fca | ||
|
|
c651b027a2 | ||
|
|
3e716fb5ac | ||
|
|
53eb418526 | ||
|
|
eea189ba98 | ||
|
|
19f8f85021 | ||
|
|
50d83bd8b6 | ||
|
|
2699ceb23d | ||
|
|
53d8356f19 | ||
|
|
6fbd833e2f | ||
|
|
71b6300e81 | ||
|
|
7a4a46c93f | ||
|
|
cb003387b2 | ||
|
|
7f169fd7df | ||
|
|
f524854baf | ||
|
|
98efd8b6cb | ||
|
|
c5b0129377 | ||
|
|
2dffe400aa | ||
|
|
46cf70049b | ||
|
|
c07f50c71a | ||
|
|
5fb5a9ee5b | ||
|
|
dc3f16701f | ||
|
|
c7ce2bb3d6 | ||
|
|
24dde29cb0 | ||
|
|
e30eaaf4bf | ||
|
|
47aa908825 | ||
|
|
692b904b23 | ||
|
|
0533b79ec4 | ||
|
|
64e95743a9 | ||
|
|
4c3757dc44 | ||
|
|
1e22977079 | ||
|
|
f613037904 | ||
|
|
7e07042bed | ||
|
|
f4a83b021c | ||
|
|
6eeabb3f6d | ||
|
|
18df4d9a31 | ||
|
|
d636a287e6 | ||
|
|
601d14c6c6 | ||
|
|
9c6c6d972a | ||
|
|
645c288fc3 | ||
|
|
1b272bcfce | ||
|
|
4bc31d4ba8 | ||
|
|
4698aa2aad | ||
|
|
a34fcc4beb | ||
|
|
51ab9a5201 | ||
|
|
57f6fa5e31 | ||
|
|
10f94bd3d8 | ||
|
|
a0ff5b224e | ||
|
|
6d0ec00469 | ||
|
|
d687efa75e | ||
|
|
19c00aa755 | ||
|
|
0e5b2fae45 | ||
|
|
2573feaa77 | ||
|
|
51afd9c351 | ||
|
|
00fe120a12 | ||
|
|
c9fa398939 | ||
|
|
ceee771885 | ||
|
|
385e97341e | ||
|
|
7125a6b086 | ||
|
|
4a75d3d064 | ||
|
|
bca3c7d6c0 | ||
|
|
893dab63a7 | ||
|
|
aebec64808 | ||
|
|
199cc085cf | ||
|
|
c233928f99 | ||
|
|
c567c02cee | ||
|
|
826f962006 | ||
|
|
1b1a805d70 | ||
|
|
eb845c118c | ||
|
|
2ba909fa53 | ||
|
|
64dd08320a | ||
|
|
f87ce9723b | ||
|
|
7d3e7db6b2 | ||
|
|
2a1805c8cd | ||
|
|
328fef8289 | ||
|
|
13d280478b | ||
|
|
0cf01aa0c5 | ||
|
|
a2ab9fef67 | ||
|
|
826a4406ed | ||
|
|
df3e3989c2 | ||
|
|
a4ea8a28e1 | ||
|
|
0db14e6db7 | ||
|
|
2117ec17c7 | ||
|
|
ff0bce510d | ||
|
|
03cbfdf2aa | ||
|
|
3cc0016704 | ||
|
|
92ea168f68 | ||
|
|
4e6e99764d | ||
|
|
8b57087e5c | ||
|
|
952dd5a3ed | ||
|
|
1be9a05195 | ||
|
|
b00b5a8e63 | ||
|
|
62fc2a997d | ||
|
|
bebdb155fa | ||
|
|
67888de8a3 | ||
|
|
6a8a33467f | ||
|
|
a4d9f61114 | ||
|
|
d1486d8026 | ||
|
|
d97ce04481 | ||
|
|
917f9e0620 | ||
|
|
ab60ce3e2d | ||
|
|
49a1cc415e | ||
|
|
14725937f9 | ||
|
|
42bb97c1a4 | ||
|
|
82bc1e8bfc | ||
|
|
69de37ddb6 | ||
|
|
baa3ca223d | ||
|
|
1c34e76c1f | ||
|
|
39cd66e5e8 | ||
|
|
2d4316a42c | ||
|
|
e799a999fe | ||
|
|
af0dbf487d | ||
|
|
e1d453899f | ||
|
|
b265d83286 | ||
|
|
4768b45dee | ||
|
|
bcd2dc2e39 | ||
|
|
8b8925b134 | ||
|
|
864521344e | ||
|
|
4fe70877cd | ||
|
|
3fd61eecd4 | ||
|
|
2078e7fce3 | ||
|
|
91d5c78813 | ||
|
|
4a1f4d4223 | ||
|
|
7284dc3824 | ||
|
|
7f6d23730e | ||
|
|
495bc95d50 | ||
|
|
0cca55a3b4 | ||
|
|
213a3a793a | ||
|
|
f182378fbb | ||
|
|
583bc2ad32 | ||
|
|
f385f975fa | ||
|
|
d2364caddd | ||
|
|
0d384b6248 | ||
|
|
2869972f15 | ||
|
|
277112253c | ||
|
|
b24ac45dc3 | ||
|
|
e9cff9edad | ||
|
|
365070ad88 | ||
|
|
9cd7b94c2f | ||
|
|
ad8c7967d3 | ||
|
|
77b16c1101 | ||
|
|
03ab1e50f6 | ||
|
|
a0a0a8132a | ||
|
|
5253b7c9ab | ||
|
|
852cd5b11e | ||
|
|
9b523e3cd9 | ||
|
|
a1f3518511 | ||
|
|
52b145d3da | ||
|
|
966cfb70ce | ||
|
|
0683e8c754 | ||
|
|
d19abbbcd4 | ||
|
|
5a53f301d7 | ||
|
|
8a87ccceae | ||
|
|
d6f828838a | ||
|
|
2f9a63acab | ||
|
|
1d59a2667f | ||
|
|
13462698ab | ||
|
|
826411f669 | ||
|
|
52bb0871b3 | ||
|
|
f9fb52a91c | ||
|
|
674e5511c5 | ||
|
|
f936173a7f |
@@ -259,6 +259,8 @@ miniapps/performance/sol.*
|
||||
|
||||
miniapps/shifted/distance
|
||||
miniapps/shifted/ParaViewDistance
|
||||
miniapps/shifted/extrapolate
|
||||
miniapps/shifted/ParaViewExtrapolate
|
||||
miniapps/shifted/diffusion
|
||||
miniapps/shifted/diffusion.mesh
|
||||
miniapps/shifted/diffusion.gf
|
||||
|
||||
@@ -45,5 +45,5 @@ variables:
|
||||
- echo ${MFEM_DATA_DIR}
|
||||
- echo ${SPEC}
|
||||
# Next script uses 'THREADS': leaving it empty --> it uses 'make all -j'
|
||||
- lalloc 1 -W 30 -q pdebug tests/gitlab/build_and_test --spec "${SPEC}" --data-dir "${MFEM_DATA_DIR}" --data
|
||||
- lalloc 1 -W 30 -q pdebug --atsdisable tests/gitlab/build_and_test --spec "${SPEC}" --data-dir "${MFEM_DATA_DIR}" --data
|
||||
needs: [setup]
|
||||
|
||||
@@ -19,6 +19,11 @@ opt_mpi_cuda_xl_16_1_1_8:
|
||||
SPEC: "%xl@16.1.1.8 +mpi +cuda cuda_arch=70"
|
||||
extends: .build_and_test_on_lassen
|
||||
|
||||
opt_mpi_cuda_hypre_cuda_xl:
|
||||
variables:
|
||||
SPEC: "%xl@16.1.1.8 +mpi +cuda cuda_arch=70 ^hypre+cuda~shared cuda_arch=70"
|
||||
extends: .build_and_test_on_lassen
|
||||
|
||||
# Jobs report
|
||||
report_job_success:
|
||||
stage: report
|
||||
|
||||
@@ -59,7 +59,7 @@ opt_par_gcc_6_1_0_sundials:
|
||||
|
||||
opt_par_gcc_6_1_0_petsc:
|
||||
variables:
|
||||
SPEC: "%gcc@6.1.0 +petsc ^petsc+mumps"
|
||||
SPEC: "%gcc@6.1.0 +petsc ^petsc+mumps~superlu-dist"
|
||||
extends: .build_and_test_on_quartz
|
||||
|
||||
opt_par_gcc_6_1_0_pumi:
|
||||
|
||||
@@ -29,9 +29,9 @@ mkdir _${BASELINE_TEST} && cd _${BASELINE_TEST}
|
||||
|
||||
# run
|
||||
if [[ "${MACHINE_NAME}" == "quartz" || "${MACHINE_NAME}" == "ruby" ]]; then
|
||||
srun --nodes=1 -p pdebug ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}"
|
||||
salloc --nodes=1 -p pdebug ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}"
|
||||
elif [[ ${MACHINE_NAME} == "corona" ]]; then
|
||||
srun --nodes=1 -t 60 -p mi60 ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}"
|
||||
salloc --nodes=1 -t 60 -p pbatch ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}"
|
||||
elif [[ ${MACHINE_NAME} == "lassen" ]]; then
|
||||
lalloc 1 -q pdebug ../runtest ../../mfem "${BASELINE_TEST} ${TPLS_DIR}"
|
||||
else
|
||||
|
||||
@@ -10,10 +10,27 @@
|
||||
|
||||
Version 4.3.1 (development)
|
||||
===========================
|
||||
- Added support for automatic differentiation. Users can select between
|
||||
native implementation and external library implementation at the
|
||||
configuration phase. A parallel and two serial examples are implemented
|
||||
in the autodiff miniapp directory.
|
||||
|
||||
- Add hipSPARSE support for sparse mat-vec multiplications.
|
||||
|
||||
- Added support for using the HYPRE library built with HIP support. Similar to
|
||||
the HYPRE + CUDA support added earlier, most of the MFEM examples and miniapps
|
||||
work transparently with HYPRE + HIP builds. This includes the BoomerAMG, AMS,
|
||||
and ADS solvers.
|
||||
|
||||
- More explicit and consistent formating of the output of iterative solvers
|
||||
with the new IterativeSolver::PrintLevel options. See linalg/solvers.hpp.
|
||||
|
||||
- Added a miniapp for PDE-based extrapolation of finite element functions. See
|
||||
miniapps/shifted/extrapolate.cpp.
|
||||
|
||||
- Added support for automatic differentiation. Users can select between native
|
||||
implementation and external library implementation during configuration. One
|
||||
parallel and two serial examples are implemented in the miniapps/autodiff/
|
||||
directory.
|
||||
|
||||
- GridFunctionCoefficient (and the related vector, gradient, divergence, and
|
||||
curl classes) now work properly with LORDiscretization and LORSolver.
|
||||
|
||||
- Added support for mesh preprocessing to resolve fine scale problem data
|
||||
before simulation. This feature uses adaptive mesh refinement to control the
|
||||
@@ -71,13 +88,19 @@ Version 4.3.1 (development)
|
||||
|
||||
- Added initial TMOP-based capabilities for surface fitting and tangential
|
||||
relaxation in the mesh-optimizer and pmesh-optimizer miniapps.
|
||||
|
||||
|
||||
- Added ParMesh Adjaceny Set (adjset) creation support to the Conduit Mesh
|
||||
Blueprint MFEM wrapper functions in ConduitDataCollection.
|
||||
|
||||
- `HypreParVector` and `Vector` now support move semantics, and the copy
|
||||
constructor for `HypreParVector` now copies the local vector data.
|
||||
|
||||
- The HPC versions of ex1 and ex1p (in miniapps/performance) now support
|
||||
runtime selection of either 2D or 3D meshes.
|
||||
|
||||
- Added ParaView visualization of `QuadratureFunction` fields, through both
|
||||
`QuadratureFunction::SaveVTU` and `ParaViewDataCollection::RegisterQField`.
|
||||
|
||||
|
||||
Version 4.3, released on July 29, 2021
|
||||
======================================
|
||||
@@ -118,6 +141,12 @@ Discretization improvements
|
||||
|
||||
- Added support for nonscalar coefficient with VectorDiffusionIntegrator.
|
||||
|
||||
- Added support for Partial Assembly with Discontinuous Galerkin methods on
|
||||
nonconforming meshes.
|
||||
|
||||
- Added a simpler interface to request face information: see
|
||||
`Mesh::FaceInformation` and `Mesh::GetFaceInformation`.
|
||||
|
||||
Linear and nonlinear solvers
|
||||
----------------------------
|
||||
- Added support for AMG preconditioners on GPUs based on the hypre library
|
||||
|
||||
+22
-22
@@ -16,9 +16,6 @@ set(USER_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/config/user.cmake" CACHE PATH
|
||||
|
||||
# Require C++11 and disable compiler-specific extensions
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
if (MFEM_USE_GINKGO)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
@@ -84,6 +81,9 @@ if (MFEM_USE_STRUMPACK)
|
||||
# Just needed to find the MPI_Fortran libraries to link with
|
||||
set(XSDK_ENABLE_Fortran ON)
|
||||
endif()
|
||||
if (MFEM_USE_GINKGO AND ("${CMAKE_CXX_STANDARD}" LESS "14"))
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
|
||||
# Include xSDK default CMake file.
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/config/XSDKDefaults.cmake")
|
||||
@@ -180,6 +180,19 @@ else()
|
||||
set(MFEM_DEBUG OFF)
|
||||
endif()
|
||||
|
||||
# AMD HIP
|
||||
if (MFEM_USE_HIP)
|
||||
if (HIP_ARCH)
|
||||
message(STATUS "Using HIP architecture: ${HIP_ARCH}")
|
||||
set(GPU_TARGETS "${HIP_ARCH}" CACHE STRING "HIP targets to compile for")
|
||||
endif()
|
||||
if (ROCM_PATH)
|
||||
list(INSERT CMAKE_PREFIX_PATH 0 ${ROCM_PATH})
|
||||
endif()
|
||||
find_package(HIP REQUIRED)
|
||||
find_package(HIPSPARSE REQUIRED)
|
||||
endif()
|
||||
|
||||
# MPI -> hypre; PETSc (optional)
|
||||
if (MFEM_USE_MPI)
|
||||
find_package(MPI REQUIRED)
|
||||
@@ -354,7 +367,7 @@ endif()
|
||||
if (MFEM_USE_PUMI)
|
||||
# If PUMI_DIR was specified, only link to that directory,
|
||||
# i.e. don't link to another installation in /usr/lib by mistake
|
||||
find_package(SCOREC 2.1.0 REQUIRED OPTIONAL_COMPONENTS gmi_sim
|
||||
find_package(SCOREC 2.2.6 REQUIRED OPTIONAL_COMPONENTS gmi_sim
|
||||
CONFIG PATHS ${PUMI_DIR} NO_DEFAULT_PATH)
|
||||
if (SCOREC_FOUND)
|
||||
# Define a header file with the MFEM_USE_SIMMETRIX preprocessor variable
|
||||
@@ -403,18 +416,6 @@ if (MFEM_USE_CALIPER)
|
||||
find_package(Caliper REQUIRED)
|
||||
endif()
|
||||
|
||||
# AMD HIP
|
||||
if (MFEM_USE_HIP)
|
||||
find_package(HIP REQUIRED)
|
||||
if (HIP_ARCH)
|
||||
message(STATUS "Using HIP architecture: ${HIP_ARCH}")
|
||||
list(APPEND HIP_HIPCC_FLAGS "--amdgpu-target=${HIP_ARCH}")
|
||||
if (MFEM_USE_GINKGO)
|
||||
list(APPEND HIP_HIPCC_FLAGS "-std=c++14")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ADIOS2 for parallel I/O
|
||||
if (MFEM_USE_ADIOS2)
|
||||
find_package(ADIOS2 REQUIRED)
|
||||
@@ -454,10 +455,11 @@ endif()
|
||||
# With newer versions of SuiteSparse which include METIS header using 64-bit
|
||||
# integers, the METIS header (with 32-bit indices, as used by mfem) needs to
|
||||
# be before SuiteSparse.
|
||||
set(MFEM_TPLS OPENMP HYPRE BLAS LAPACK SuperLUDist METIS SuiteSparse SUNDIALS PETSC
|
||||
SLEPC MESQUITE MUMPS STRUMPACK AXOM FMS CONDUIT Ginkgo GNUTLS GSLIB NETCDF
|
||||
MPFR PUMI HIOP POSIXCLOCKS MFEMBacktrace ZLIB OCCA CEED RAJA UMPIRE ADIOS2
|
||||
CUSPARSE MKL_CPARDISO AMGX CALIPER CODIPACK BENCHMARK PARELAG MPI_CXX)
|
||||
set(MFEM_TPLS OPENMP HYPRE BLAS LAPACK SuperLUDist METIS SuiteSparse SUNDIALS
|
||||
PETSC SLEPC MESQUITE MUMPS STRUMPACK AXOM FMS CONDUIT Ginkgo GNUTLS GSLIB
|
||||
NETCDF MPFR PUMI HIOP POSIXCLOCKS MFEMBacktrace ZLIB OCCA CEED RAJA UMPIRE
|
||||
ADIOS2 CUSPARSE MKL_CPARDISO AMGX CALIPER CODIPACK BENCHMARK PARELAG
|
||||
MPI_CXX HIP HIPSPARSE)
|
||||
|
||||
# Add all *_FOUND libraries in the variable TPL_LIBRARIES.
|
||||
set(TPL_LIBRARIES "")
|
||||
@@ -500,8 +502,6 @@ endforeach()
|
||||
|
||||
if (MFEM_USE_CUDA)
|
||||
set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE CUDA)
|
||||
elseif(MFEM_USE_HIP)
|
||||
set_source_files_properties(${SOURCES} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT TRUE)
|
||||
endif()
|
||||
|
||||
add_subdirectory(config)
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
# MFEM Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||
identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||
any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at mfem@llnl.gov.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident. Anyone involved in the reported behavior will recuse
|
||||
themselves from the investigation and decision making about the resolution of
|
||||
the complaint.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||
community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||
[https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
@@ -21,6 +21,9 @@ documentation; new examples and miniapps; HPC performance improvements; etc.
|
||||
MFEM is distributed under the terms of the BSD-3 license. All new contributions
|
||||
must be made under this license.
|
||||
|
||||
Note also that MFEM has a [Code of Conduct](CODE_OF_CONDUCT.md). By participating
|
||||
in the MFEM community, you agree to abide by its rules.
|
||||
|
||||
If you plan on contributing to MFEM, consider reviewing the
|
||||
[issue tracker](https://github.com/mfem/mfem/issues) first to check if a thread
|
||||
already exists for your desired feature or the bug you ran into. Use a pull
|
||||
|
||||
@@ -37,7 +37,7 @@ as CUDA, HIP, OCCA, OpenMP and RAJA.
|
||||
https://developer.nvidia.com/cuda-toolkit
|
||||
|
||||
- HIP support requires an AMD GPU and an installation of the ROCm software stack
|
||||
https://rocm.github.io/ROCmInstall.html#installing-from-amd-rocm-repositories
|
||||
https://rocmdocs.amd.com
|
||||
|
||||
- OCCA support requires the OCCA library
|
||||
https://libocca.org
|
||||
@@ -58,7 +58,8 @@ following package managers:
|
||||
|
||||
- Spack, https://github.com/spack/spack
|
||||
- OpenHPC, http://openhpc.community
|
||||
- Conda-forge, https://conda-forge.org (pre-built binaries linked with OpenMPI/MPICH, hypre, and METIS)
|
||||
- Conda-forge, https://conda-forge.org (pre-built binaries linked with
|
||||
OpenMPI/MPICH, hypre, and METIS)
|
||||
- Homebrew/Science, https://github.com/Homebrew/homebrew-science (deprecated)
|
||||
|
||||
We also recommend downloading and building the MFEM-based GLVis visualization
|
||||
@@ -78,7 +79,7 @@ Parallel build:
|
||||
|
||||
CUDA build:
|
||||
make cuda -j 4
|
||||
(build for a specific compute capability: 'make cuda -j 4 CUDA_ARCH=sm_30')
|
||||
(build for a specific compute capability: 'make cuda -j 4 CUDA_ARCH=sm_70')
|
||||
|
||||
HIP build:
|
||||
make hip -j 4
|
||||
@@ -566,7 +567,7 @@ The specific libraries and their options are:
|
||||
Options: HYPRE_OPT, HYPRE_LIB.
|
||||
Versions: HYPRE >= 2.10.0b (HYPRE built without CUDA)
|
||||
HYPRE >= 2.20.0 (HYPRE built with '--enable-mixedint')
|
||||
HYPRE >= 2.22.1 (HYPRE built with CUDA)
|
||||
HYPRE >= 2.22.1 (HYPRE built with CUDA or HIP)
|
||||
|
||||
- METIS, used when MFEM_USE_METIS = YES. If using METIS 5, set
|
||||
MFEM_USE_METIS_5 = YES (default is to use METIS 4).
|
||||
@@ -639,7 +640,8 @@ The specific libraries and their options are:
|
||||
C++ compiler that supports the C++-14 standard. For additional requirements
|
||||
and dependencies of specific modules, see the Ginkgo webpage below.
|
||||
URL: https://ginkgo-project.github.io
|
||||
Options: GINKGO_OPT, GINKGO_LIB, GINKGO_DIR, GINKGO_BUILD_TYPE (Release or Debug).
|
||||
Options: GINKGO_OPT, GINKGO_LIB, GINKGO_DIR, GINKGO_BUILD_TYPE (Release or
|
||||
Debug).
|
||||
Versions: Ginkgo >= 1.4.0.
|
||||
|
||||
- AmgX (optional), used when MFEM_USE_AMGX = YES.
|
||||
@@ -704,7 +706,7 @@ The specific libraries and their options are:
|
||||
URL: https://scorec.rpi.edu/pumi
|
||||
https://github.com/SCOREC/core
|
||||
Options: PUMI_OPT, PUMI_LIB.
|
||||
Versions: PUMI == 2.2.3.
|
||||
Versions: PUMI >= 2.2.6.
|
||||
|
||||
- HiOp (optional), used when MFEM_USE_HIOP = YES.
|
||||
URL: https://github.com/LLNL/hiop
|
||||
@@ -737,7 +739,7 @@ The specific libraries and their options are:
|
||||
Versions: CUDA >= 10.1.168.
|
||||
|
||||
- HIP (optional), used when MFEM_USE_HIP = YES.
|
||||
URL: https://rocm.github.io/ROCmInstall.html
|
||||
URL: https://rocmdocs.amd.com
|
||||
Options: HIP_CXX, HIP_ARCH, HIP_OPT, HIP_LIB.
|
||||
|
||||
- OCCA (optional), used when MFEM_USE_OCCA = YES.
|
||||
@@ -924,6 +926,7 @@ MFEM_USE_HIOP
|
||||
MFEM_USE_CODIPACK
|
||||
MFEM_USE_ADFORWARD
|
||||
MFEM_USE_CUDA
|
||||
MFEM_USE_HIP
|
||||
MFEM_USE_OCCA
|
||||
MFEM_USE_CEED
|
||||
MFEM_USE_RAJA
|
||||
|
||||
@@ -12,6 +12,9 @@ to enable high-performance scalable finite element discretization research and
|
||||
application development on a wide variety of platforms, ranging from laptops to
|
||||
supercomputers.
|
||||
|
||||
We welcome contributions and feedback from the community. Please see the file
|
||||
CONTRIBUTING.md for additional details about our development process.
|
||||
|
||||
* For building instructions, see the file INSTALL, or type "make help".
|
||||
|
||||
* Copyright and licensing information can be found in files LICENSE and NOTICE.
|
||||
@@ -19,9 +22,6 @@ supercomputers.
|
||||
* The best starting point for new users interested in MFEM's features is to
|
||||
review the examples and miniapps at https://mfem.org/examples.
|
||||
|
||||
* Developers interested in contributing to the library, should read the
|
||||
instructions and documentation in the CONTRIBUTING.md file.
|
||||
|
||||
Conceptually, MFEM can be viewed as a finite element toolbox that provides the
|
||||
building blocks for developing finite element algorithms in a manner similar to
|
||||
that of MATLAB for linear algebra methods. In particular, MFEM provides support
|
||||
|
||||
@@ -1,692 +0,0 @@
|
||||
###############################################################################
|
||||
# FindHIP.cmake
|
||||
###############################################################################
|
||||
include(CheckCXXCompilerFlag)
|
||||
###############################################################################
|
||||
# SET: Variable defaults
|
||||
###############################################################################
|
||||
# User defined flags
|
||||
set(HIP_HIPCC_FLAGS "" CACHE STRING "Semicolon delimited flags for HIPCC")
|
||||
set(HIP_HCC_FLAGS "" CACHE STRING "Semicolon delimited flags for HCC")
|
||||
set(HIP_CLANG_FLAGS "" CACHE STRING "Semicolon delimited flags for CLANG")
|
||||
set(HIP_NVCC_FLAGS "" CACHE STRING "Semicolon delimted flags for NVCC")
|
||||
mark_as_advanced(HIP_HIPCC_FLAGS HIP_HCC_FLAGS HIP_CLANG_FLAGS HIP_NVCC_FLAGS)
|
||||
|
||||
set(_hip_configuration_types ${CMAKE_CONFIGURATION_TYPES} ${CMAKE_BUILD_TYPE} Debug MinSizeRel Release RelWithDebInfo)
|
||||
list(REMOVE_DUPLICATES _hip_configuration_types)
|
||||
foreach(config ${_hip_configuration_types})
|
||||
string(TOUPPER ${config} config_upper)
|
||||
set(HIP_HIPCC_FLAGS_${config_upper} "" CACHE STRING "Semicolon delimited flags for HIPCC")
|
||||
set(HIP_HCC_FLAGS_${config_upper} "" CACHE STRING "Semicolon delimited flags for HCC")
|
||||
set(HIP_CLANG_FLAGS_${config_upper} "" CACHE STRING "Semicolon delimited flags for CLANG")
|
||||
set(HIP_NVCC_FLAGS_${config_upper} "" CACHE STRING "Semicolon delimited flags for NVCC")
|
||||
mark_as_advanced(HIP_HIPCC_FLAGS_${config_upper} HIP_HCC_FLAGS_${config_upper} HIP_CLANG_FLAGS_${config_upper} HIP_NVCC_FLAGS_${config_upper})
|
||||
endforeach()
|
||||
option(HIP_HOST_COMPILATION_CPP "Host code compilation mode" ON)
|
||||
option(HIP_VERBOSE_BUILD "Print out the commands run while compiling the HIP source file. With the Makefile generator this defaults to VERBOSE variable specified on the command line, but can be forced on with this option." OFF)
|
||||
mark_as_advanced(HIP_HOST_COMPILATION_CPP)
|
||||
|
||||
###############################################################################
|
||||
# FIND: HIP and associated helper binaries
|
||||
###############################################################################
|
||||
|
||||
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}/../" REALPATH)
|
||||
|
||||
# HIP is supported on Linux only
|
||||
if(UNIX AND NOT APPLE AND NOT CYGWIN)
|
||||
# Search for HIP installation
|
||||
if(NOT HIP_ROOT_DIR)
|
||||
# Search in user specified path first
|
||||
find_path(
|
||||
HIP_ROOT_DIR
|
||||
NAMES bin/hipconfig
|
||||
PATHS
|
||||
"$ENV{ROCM_PATH}/hip"
|
||||
ENV HIP_PATH
|
||||
${_IMPORT_PREFIX}
|
||||
/opt/rocm/hip
|
||||
DOC "HIP installed location"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT EXISTS ${HIP_ROOT_DIR})
|
||||
if(HIP_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Specify HIP_ROOT_DIR")
|
||||
elseif(NOT HIP_FIND_QUIETLY)
|
||||
message("HIP_ROOT_DIR not found or specified")
|
||||
endif()
|
||||
endif()
|
||||
# And push it back to the cache
|
||||
set(HIP_ROOT_DIR ${HIP_ROOT_DIR} CACHE PATH "HIP installed location" FORCE)
|
||||
endif()
|
||||
|
||||
# Find HIPCC executable
|
||||
find_program(
|
||||
HIP_HIPCC_EXECUTABLE
|
||||
NAMES hipcc
|
||||
PATHS
|
||||
"${HIP_ROOT_DIR}"
|
||||
ENV ROCM_PATH
|
||||
ENV HIP_PATH
|
||||
/opt/rocm
|
||||
/opt/rocm/hip
|
||||
PATH_SUFFIXES bin
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT HIP_HIPCC_EXECUTABLE)
|
||||
# Now search in default paths
|
||||
find_program(HIP_HIPCC_EXECUTABLE hipcc)
|
||||
endif()
|
||||
mark_as_advanced(HIP_HIPCC_EXECUTABLE)
|
||||
|
||||
# Find HIPCONFIG executable
|
||||
find_program(
|
||||
HIP_HIPCONFIG_EXECUTABLE
|
||||
NAMES hipconfig
|
||||
PATHS
|
||||
"${HIP_ROOT_DIR}"
|
||||
ENV ROCM_PATH
|
||||
ENV HIP_PATH
|
||||
/opt/rocm
|
||||
/opt/rocm/hip
|
||||
PATH_SUFFIXES bin
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT HIP_HIPCONFIG_EXECUTABLE)
|
||||
# Now search in default paths
|
||||
find_program(HIP_HIPCONFIG_EXECUTABLE hipconfig)
|
||||
endif()
|
||||
mark_as_advanced(HIP_HIPCONFIG_EXECUTABLE)
|
||||
|
||||
# Find HIPCC_CMAKE_LINKER_HELPER executable
|
||||
find_program(
|
||||
HIP_HIPCC_CMAKE_LINKER_HELPER
|
||||
NAMES hipcc_cmake_linker_helper
|
||||
PATHS
|
||||
"${HIP_ROOT_DIR}"
|
||||
ENV ROCM_PATH
|
||||
ENV HIP_PATH
|
||||
/opt/rocm
|
||||
/opt/rocm/hip
|
||||
PATH_SUFFIXES bin
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
if(NOT HIP_HIPCC_CMAKE_LINKER_HELPER)
|
||||
# Now search in default paths
|
||||
find_program(HIP_HIPCC_CMAKE_LINKER_HELPER hipcc_cmake_linker_helper)
|
||||
endif()
|
||||
mark_as_advanced(HIP_HIPCC_CMAKE_LINKER_HELPER)
|
||||
|
||||
if(HIP_HIPCONFIG_EXECUTABLE AND NOT HIP_VERSION)
|
||||
# Compute the version
|
||||
execute_process(
|
||||
COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --version
|
||||
OUTPUT_VARIABLE _hip_version
|
||||
ERROR_VARIABLE _hip_error
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(NOT _hip_error)
|
||||
set(HIP_VERSION ${_hip_version} CACHE STRING "Version of HIP as computed from hipcc")
|
||||
else()
|
||||
set(HIP_VERSION "0.0.0" CACHE STRING "Version of HIP as computed by FindHIP()")
|
||||
endif()
|
||||
mark_as_advanced(HIP_VERSION)
|
||||
endif()
|
||||
if(HIP_VERSION)
|
||||
string(REPLACE "." ";" _hip_version_list "${HIP_VERSION}")
|
||||
list(GET _hip_version_list 0 HIP_VERSION_MAJOR)
|
||||
list(GET _hip_version_list 1 HIP_VERSION_MINOR)
|
||||
list(GET _hip_version_list 2 HIP_VERSION_PATCH)
|
||||
set(HIP_VERSION_STRING "${HIP_VERSION}")
|
||||
endif()
|
||||
|
||||
if(HIP_HIPCONFIG_EXECUTABLE AND NOT HIP_PLATFORM)
|
||||
# Compute the platform
|
||||
execute_process(
|
||||
COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --platform
|
||||
OUTPUT_VARIABLE _hip_platform
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
set(HIP_PLATFORM ${_hip_platform} CACHE STRING "HIP platform as computed by hipconfig")
|
||||
mark_as_advanced(HIP_PLATFORM)
|
||||
endif()
|
||||
|
||||
if(HIP_HIPCONFIG_EXECUTABLE AND NOT HIP_COMPILER)
|
||||
# Compute the compiler
|
||||
execute_process(
|
||||
COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --compiler
|
||||
OUTPUT_VARIABLE _hip_compiler
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
set(HIP_COMPILER ${_hip_compiler} CACHE STRING "HIP compiler as computed by hipconfig")
|
||||
mark_as_advanced(HIP_COMPILER)
|
||||
endif()
|
||||
|
||||
if(HIP_HIPCONFIG_EXECUTABLE AND NOT HIP_RUNTIME)
|
||||
# Compute the runtime
|
||||
execute_process(
|
||||
COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --runtime
|
||||
OUTPUT_VARIABLE _hip_runtime
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
set(HIP_RUNTIME ${_hip_runtime} CACHE STRING "HIP runtime as computed by hipconfig")
|
||||
mark_as_advanced(HIP_RUNTIME)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
HIP
|
||||
REQUIRED_VARS
|
||||
HIP_ROOT_DIR
|
||||
HIP_HIPCC_EXECUTABLE
|
||||
HIP_HIPCONFIG_EXECUTABLE
|
||||
HIP_PLATFORM
|
||||
HIP_COMPILER
|
||||
HIP_RUNTIME
|
||||
VERSION_VAR HIP_VERSION
|
||||
)
|
||||
|
||||
###############################################################################
|
||||
# Set HIP CMAKE Flags
|
||||
###############################################################################
|
||||
# Copy the invocation styles from CXX to HIP
|
||||
set(CMAKE_HIP_ARCHIVE_CREATE ${CMAKE_CXX_ARCHIVE_CREATE})
|
||||
set(CMAKE_HIP_ARCHIVE_APPEND ${CMAKE_CXX_ARCHIVE_APPEND})
|
||||
set(CMAKE_HIP_ARCHIVE_FINISH ${CMAKE_CXX_ARCHIVE_FINISH})
|
||||
set(CMAKE_SHARED_LIBRARY_SONAME_HIP_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG})
|
||||
set(CMAKE_SHARED_LIBRARY_CREATE_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS})
|
||||
set(CMAKE_SHARED_LIBRARY_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS})
|
||||
#set(CMAKE_SHARED_LIBRARY_LINK_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS})
|
||||
set(CMAKE_SHARED_LIBRARY_RUNTIME_HIP_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG})
|
||||
set(CMAKE_SHARED_LIBRARY_RUNTIME_HIP_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP})
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_STATIC_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS})
|
||||
set(CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_HIP_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS})
|
||||
|
||||
set(HIP_CLANG_PARALLEL_BUILD_COMPILE_OPTIONS "")
|
||||
set(HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS "")
|
||||
|
||||
if("${HIP_COMPILER}" STREQUAL "nvcc")
|
||||
# Set the CMake Flags to use the nvcc Compiler.
|
||||
set(CMAKE_HIP_CREATE_SHARED_LIBRARY "${HIP_HIPCC_CMAKE_LINKER_HELPER} <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
set(CMAKE_HIP_CREATE_SHARED_MODULE "${HIP_HIPCC_CMAKE_LINKER_HELPER} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <LINK_LIBRARIES> -shared" )
|
||||
set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
elseif("${HIP_COMPILER}" STREQUAL "hcc")
|
||||
# Set the CMake Flags to use the hcc Compiler.
|
||||
set(CMAKE_HIP_CREATE_SHARED_LIBRARY "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
set(CMAKE_HIP_CREATE_SHARED_MODULE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <LINK_LIBRARIES> -shared" )
|
||||
set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
elseif("${HIP_COMPILER}" STREQUAL "clang")
|
||||
#Number of parallel jobs by default is 1
|
||||
if(NOT DEFINED HIP_CLANG_NUM_PARALLEL_JOBS)
|
||||
set(HIP_CLANG_NUM_PARALLEL_JOBS 1)
|
||||
endif()
|
||||
#Add support for parallel build and link
|
||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
|
||||
check_cxx_compiler_flag("-parallel-jobs=1" HIP_CLANG_SUPPORTS_PARALLEL_JOBS)
|
||||
endif()
|
||||
if(HIP_CLANG_NUM_PARALLEL_JOBS GREATER 1)
|
||||
if(${HIP_CLANG_SUPPORTS_PARALLEL_JOBS})
|
||||
set(HIP_CLANG_PARALLEL_BUILD_COMPILE_OPTIONS "-Wno-format-nonliteral -parallel-jobs=${HIP_CLANG_NUM_PARALLEL_JOBS}")
|
||||
set(HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS "-parallel-jobs=${HIP_CLANG_NUM_PARALLEL_JOBS}")
|
||||
else()
|
||||
message("clang compiler doesn't support parallel jobs")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Set the CMake Flags to use the HIP-Clang Compiler.
|
||||
set(CMAKE_HIP_CREATE_SHARED_LIBRARY "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HIP_CLANG_PATH} ${HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS} <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
set(CMAKE_HIP_CREATE_SHARED_MODULE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HIP_CLANG_PATH} ${HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <LINK_LIBRARIES> -shared" )
|
||||
set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HIP_CLANG_PATH} ${HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
|
||||
if("${HIP_RUNTIME}" STREQUAL "rocclr")
|
||||
if(TARGET host)
|
||||
message(STATUS "host interface - found")
|
||||
set(HIP_HOST_INTERFACE host)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
###############################################################################
|
||||
# MACRO: Locate helper files
|
||||
###############################################################################
|
||||
macro(HIP_FIND_HELPER_FILE _name _extension)
|
||||
set(_hip_full_name "${_name}.${_extension}")
|
||||
get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
set(HIP_${_name} "${CMAKE_CURRENT_LIST_DIR}/FindHIP/${_hip_full_name}")
|
||||
if(NOT EXISTS "${HIP_${_name}}")
|
||||
set(error_message "${_hip_full_name} not found in ${CMAKE_CURRENT_LIST_DIR}/FindHIP")
|
||||
if(HIP_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "${error_message}")
|
||||
else()
|
||||
if(NOT HIP_FIND_QUIETLY)
|
||||
message(STATUS "${error_message}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
# Set this variable as internal, so the user isn't bugged with it.
|
||||
set(HIP_${_name} ${HIP_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE)
|
||||
endmacro()
|
||||
|
||||
###############################################################################
|
||||
hip_find_helper_file(run_make2cmake cmake)
|
||||
hip_find_helper_file(run_hipcc cmake)
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
# MACRO: Reset compiler flags
|
||||
###############################################################################
|
||||
macro(HIP_RESET_FLAGS)
|
||||
unset(HIP_HIPCC_FLAGS)
|
||||
unset(HIP_HCC_FLAGS)
|
||||
unset(HIP_CLANG_FLAGS)
|
||||
unset(HIP_NVCC_FLAGS)
|
||||
foreach(config ${_hip_configuration_types})
|
||||
string(TOUPPER ${config} config_upper)
|
||||
unset(HIP_HIPCC_FLAGS_${config_upper})
|
||||
unset(HIP_HCC_FLAGS_${config_upper})
|
||||
unset(HIP_CLANG_FLAGS_${config_upper})
|
||||
unset(HIP_NVCC_FLAGS_${config_upper})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
###############################################################################
|
||||
# MACRO: Separate the options from the sources
|
||||
###############################################################################
|
||||
macro(HIP_GET_SOURCES_AND_OPTIONS _sources _cmake_options _hipcc_options _hcc_options _clang_options _nvcc_options)
|
||||
set(${_sources})
|
||||
set(${_cmake_options})
|
||||
set(${_hipcc_options})
|
||||
set(${_hcc_options})
|
||||
set(${_clang_options})
|
||||
set(${_nvcc_options})
|
||||
set(_hipcc_found_options FALSE)
|
||||
set(_hcc_found_options FALSE)
|
||||
set(_clang_found_options FALSE)
|
||||
set(_nvcc_found_options FALSE)
|
||||
foreach(arg ${ARGN})
|
||||
if("x${arg}" STREQUAL "xHIPCC_OPTIONS")
|
||||
set(_hipcc_found_options TRUE)
|
||||
set(_hcc_found_options FALSE)
|
||||
set(_clang_found_options FALSE)
|
||||
set(_nvcc_found_options FALSE)
|
||||
elseif("x${arg}" STREQUAL "xHCC_OPTIONS")
|
||||
set(_hipcc_found_options FALSE)
|
||||
set(_hcc_found_options TRUE)
|
||||
set(_clang_found_options FALSE)
|
||||
set(_nvcc_found_options FALSE)
|
||||
elseif("x${arg}" STREQUAL "xCLANG_OPTIONS")
|
||||
set(_hipcc_found_options FALSE)
|
||||
set(_hcc_found_options FALSE)
|
||||
set(_clang_found_options TRUE)
|
||||
set(_nvcc_found_options FALSE)
|
||||
elseif("x${arg}" STREQUAL "xNVCC_OPTIONS")
|
||||
set(_hipcc_found_options FALSE)
|
||||
set(_hcc_found_options FALSE)
|
||||
set(_clang_found_options FALSE)
|
||||
set(_nvcc_found_options TRUE)
|
||||
elseif(
|
||||
"x${arg}" STREQUAL "xEXCLUDE_FROM_ALL" OR
|
||||
"x${arg}" STREQUAL "xSTATIC" OR
|
||||
"x${arg}" STREQUAL "xSHARED" OR
|
||||
"x${arg}" STREQUAL "xMODULE"
|
||||
)
|
||||
list(APPEND ${_cmake_options} ${arg})
|
||||
else()
|
||||
if(_hipcc_found_options)
|
||||
list(APPEND ${_hipcc_options} ${arg})
|
||||
elseif(_hcc_found_options)
|
||||
list(APPEND ${_hcc_options} ${arg})
|
||||
elseif(_clang_found_options)
|
||||
list(APPEND ${_clang_options} ${arg})
|
||||
elseif(_nvcc_found_options)
|
||||
list(APPEND ${_nvcc_options} ${arg})
|
||||
else()
|
||||
# Assume this is a file
|
||||
list(APPEND ${_sources} ${arg})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
###############################################################################
|
||||
# MACRO: Add include directories to pass to the hipcc command
|
||||
###############################################################################
|
||||
set(HIP_HIPCC_INCLUDE_ARGS_USER "")
|
||||
macro(HIP_INCLUDE_DIRECTORIES)
|
||||
foreach(dir ${ARGN})
|
||||
list(APPEND HIP_HIPCC_INCLUDE_ARGS_USER $<$<BOOL:${dir}>:-I${dir}>)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
###############################################################################
|
||||
# FUNCTION: Helper to avoid clashes of files with the same basename but different paths
|
||||
###############################################################################
|
||||
function(HIP_COMPUTE_BUILD_PATH path build_path)
|
||||
# Convert to cmake style paths
|
||||
file(TO_CMAKE_PATH "${path}" bpath)
|
||||
if(IS_ABSOLUTE "${bpath}")
|
||||
string(FIND "${bpath}" "${CMAKE_CURRENT_BINARY_DIR}" _binary_dir_pos)
|
||||
if(_binary_dir_pos EQUAL 0)
|
||||
file(RELATIVE_PATH bpath "${CMAKE_CURRENT_BINARY_DIR}" "${bpath}")
|
||||
else()
|
||||
file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Remove leading /
|
||||
string(REGEX REPLACE "^[/]+" "" bpath "${bpath}")
|
||||
# Avoid absolute paths by removing ':'
|
||||
string(REPLACE ":" "_" bpath "${bpath}")
|
||||
# Avoid relative paths that go up the tree
|
||||
string(REPLACE "../" "__/" bpath "${bpath}")
|
||||
# Avoid spaces
|
||||
string(REPLACE " " "_" bpath "${bpath}")
|
||||
# Strip off the filename
|
||||
get_filename_component(bpath "${bpath}" PATH)
|
||||
|
||||
set(${build_path} "${bpath}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
###############################################################################
|
||||
# MACRO: Parse OPTIONS from ARGN & set variables prefixed by _option_prefix
|
||||
###############################################################################
|
||||
macro(HIP_PARSE_HIPCC_OPTIONS _option_prefix)
|
||||
set(_hip_found_config)
|
||||
foreach(arg ${ARGN})
|
||||
# Determine if we are dealing with a per-configuration flag
|
||||
foreach(config ${_hip_configuration_types})
|
||||
string(TOUPPER ${config} config_upper)
|
||||
if(arg STREQUAL "${config_upper}")
|
||||
set(_hip_found_config _${arg})
|
||||
# Clear arg to prevent it from being processed anymore
|
||||
set(arg)
|
||||
endif()
|
||||
endforeach()
|
||||
if(arg)
|
||||
list(APPEND ${_option_prefix}${_hip_found_config} "${arg}")
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
###############################################################################
|
||||
# MACRO: Try and include dependency file if it exists
|
||||
###############################################################################
|
||||
macro(HIP_INCLUDE_HIPCC_DEPENDENCIES dependency_file)
|
||||
set(HIP_HIPCC_DEPEND)
|
||||
set(HIP_HIPCC_DEPEND_REGENERATE FALSE)
|
||||
|
||||
# Create the dependency file if it doesn't exist
|
||||
if(NOT EXISTS ${dependency_file})
|
||||
file(WRITE ${dependency_file} "# Generated by: FindHIP.cmake. Do not edit.\n")
|
||||
endif()
|
||||
# Include the dependency file
|
||||
include(${dependency_file})
|
||||
|
||||
# Verify the existence of all the included files
|
||||
if(HIP_HIPCC_DEPEND)
|
||||
foreach(f ${HIP_HIPCC_DEPEND})
|
||||
if(NOT EXISTS ${f})
|
||||
# If they aren't there, regenerate the file again
|
||||
set(HIP_HIPCC_DEPEND_REGENERATE TRUE)
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
# No dependencies, so regenerate the file
|
||||
set(HIP_HIPCC_DEPEND_REGENERATE TRUE)
|
||||
endif()
|
||||
|
||||
# Regenerate the dependency file if needed
|
||||
if(HIP_HIPCC_DEPEND_REGENERATE)
|
||||
set(HIP_HIPCC_DEPEND ${dependency_file})
|
||||
file(WRITE ${dependency_file} "# Generated by: FindHIP.cmake. Do not edit.\n")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
###############################################################################
|
||||
# MACRO: Prepare cmake commands for the target
|
||||
###############################################################################
|
||||
macro(HIP_PREPARE_TARGET_COMMANDS _target _format _generated_files _source_files)
|
||||
set(_hip_flags "")
|
||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" _hip_build_configuration)
|
||||
if(HIP_HOST_COMPILATION_CPP)
|
||||
set(HIP_C_OR_CXX CXX)
|
||||
else()
|
||||
set(HIP_C_OR_CXX C)
|
||||
endif()
|
||||
set(generated_extension ${CMAKE_${HIP_C_OR_CXX}_OUTPUT_EXTENSION})
|
||||
|
||||
# Initialize list of includes with those specified by the user. Append with
|
||||
# ones specified to cmake directly.
|
||||
set(HIP_HIPCC_INCLUDE_ARGS ${HIP_HIPCC_INCLUDE_ARGS_USER})
|
||||
|
||||
# Add the include directories
|
||||
set(include_directories_generator "$<TARGET_PROPERTY:${_target},INCLUDE_DIRECTORIES>")
|
||||
list(APPEND HIP_HIPCC_INCLUDE_ARGS "$<$<BOOL:${include_directories_generator}>:-I$<JOIN:${include_directories_generator}, -I>>")
|
||||
|
||||
get_directory_property(_hip_include_directories INCLUDE_DIRECTORIES)
|
||||
list(REMOVE_DUPLICATES _hip_include_directories)
|
||||
if(_hip_include_directories)
|
||||
foreach(dir ${_hip_include_directories})
|
||||
list(APPEND HIP_HIPCC_INCLUDE_ARGS $<$<BOOL:${dir}>:-I${dir}>)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
HIP_GET_SOURCES_AND_OPTIONS(_hip_sources _hip_cmake_options _hipcc_options _hcc_options _clang_options _nvcc_options ${ARGN})
|
||||
HIP_PARSE_HIPCC_OPTIONS(HIP_HIPCC_FLAGS ${_hipcc_options})
|
||||
HIP_PARSE_HIPCC_OPTIONS(HIP_HCC_FLAGS ${_hcc_options})
|
||||
HIP_PARSE_HIPCC_OPTIONS(HIP_CLANG_FLAGS ${_clang_options})
|
||||
HIP_PARSE_HIPCC_OPTIONS(HIP_NVCC_FLAGS ${_nvcc_options})
|
||||
|
||||
# Add the compile definitions
|
||||
set(compile_definition_generator "$<TARGET_PROPERTY:${_target},COMPILE_DEFINITIONS>")
|
||||
list(APPEND HIP_HIPCC_FLAGS "$<$<BOOL:${compile_definition_generator}>:-D$<JOIN:${compile_definition_generator}, -D>>")
|
||||
|
||||
# Check if we are building shared library.
|
||||
set(_hip_build_shared_libs FALSE)
|
||||
list(FIND _hip_cmake_options SHARED _hip_found_SHARED)
|
||||
list(FIND _hip_cmake_options MODULE _hip_found_MODULE)
|
||||
if(_hip_found_SHARED GREATER -1 OR _hip_found_MODULE GREATER -1)
|
||||
set(_hip_build_shared_libs TRUE)
|
||||
endif()
|
||||
list(FIND _hip_cmake_options STATIC _hip_found_STATIC)
|
||||
if(_hip_found_STATIC GREATER -1)
|
||||
set(_hip_build_shared_libs FALSE)
|
||||
endif()
|
||||
|
||||
# If we are building a shared library, add extra flags to HIP_HIPCC_FLAGS
|
||||
if(_hip_build_shared_libs)
|
||||
list(APPEND HIP_HCC_FLAGS "-fPIC")
|
||||
list(APPEND HIP_CLANG_FLAGS "-fPIC")
|
||||
list(APPEND HIP_NVCC_FLAGS "--shared -Xcompiler '-fPIC'")
|
||||
endif()
|
||||
|
||||
# Set host compiler
|
||||
set(HIP_HOST_COMPILER "${CMAKE_${HIP_C_OR_CXX}_COMPILER}")
|
||||
|
||||
# Set compiler flags
|
||||
set(_HIP_HOST_FLAGS "set(CMAKE_HOST_FLAGS ${CMAKE_${HIP_C_OR_CXX}_FLAGS})")
|
||||
set(_HIP_HIPCC_FLAGS "set(HIP_HIPCC_FLAGS ${HIP_HIPCC_FLAGS})")
|
||||
set(_HIP_HCC_FLAGS "set(HIP_HCC_FLAGS ${HIP_HCC_FLAGS})")
|
||||
set(_HIP_CLANG_FLAGS "set(HIP_CLANG_FLAGS ${HIP_CLANG_FLAGS})")
|
||||
set(_HIP_NVCC_FLAGS "set(HIP_NVCC_FLAGS ${HIP_NVCC_FLAGS})")
|
||||
foreach(config ${_hip_configuration_types})
|
||||
string(TOUPPER ${config} config_upper)
|
||||
set(_HIP_HOST_FLAGS "${_HIP_HOST_FLAGS}\nset(CMAKE_HOST_FLAGS_${config_upper} ${CMAKE_${HIP_C_OR_CXX}_FLAGS_${config_upper}})")
|
||||
set(_HIP_HIPCC_FLAGS "${_HIP_HIPCC_FLAGS}\nset(HIP_HIPCC_FLAGS_${config_upper} ${HIP_HIPCC_FLAGS_${config_upper}})")
|
||||
set(_HIP_HCC_FLAGS "${_HIP_HCC_FLAGS}\nset(HIP_HCC_FLAGS_${config_upper} ${HIP_HCC_FLAGS_${config_upper}})")
|
||||
set(_HIP_CLANG_FLAGS "${_HIP_CLANG_FLAGS}\nset(HIP_CLANG_FLAGS_${config_upper} ${HIP_CLANG_FLAGS_${config_upper}})")
|
||||
set(_HIP_NVCC_FLAGS "${_HIP_NVCC_FLAGS}\nset(HIP_NVCC_FLAGS_${config_upper} ${HIP_NVCC_FLAGS_${config_upper}})")
|
||||
endforeach()
|
||||
|
||||
# Reset the output variable
|
||||
set(_hip_generated_files "")
|
||||
set(_hip_source_files "")
|
||||
|
||||
# Iterate over all arguments and create custom commands for all source files
|
||||
foreach(file ${ARGN})
|
||||
# Ignore any file marked as a HEADER_FILE_ONLY
|
||||
get_source_file_property(_is_header ${file} HEADER_FILE_ONLY)
|
||||
# Allow per source file overrides of the format. Also allows compiling non .cu files.
|
||||
get_source_file_property(_hip_source_format ${file} HIP_SOURCE_PROPERTY_FORMAT)
|
||||
if((${file} MATCHES "\\.cu$" OR _hip_source_format) AND NOT _is_header)
|
||||
set(host_flag FALSE)
|
||||
else()
|
||||
set(host_flag TRUE)
|
||||
endif()
|
||||
|
||||
if(NOT host_flag)
|
||||
# Determine output directory
|
||||
HIP_COMPUTE_BUILD_PATH("${file}" hip_build_path)
|
||||
set(hip_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}.dir/${hip_build_path}")
|
||||
|
||||
get_filename_component(basename ${file} NAME)
|
||||
set(generated_file_path "${hip_compile_output_dir}/${CMAKE_CFG_INTDIR}")
|
||||
set(generated_file_basename "${_target}_generated_${basename}${generated_extension}")
|
||||
|
||||
# Set file names
|
||||
set(generated_file "${generated_file_path}/${generated_file_basename}")
|
||||
set(cmake_dependency_file "${hip_compile_output_dir}/${generated_file_basename}.depend")
|
||||
set(custom_target_script_pregen "${hip_compile_output_dir}/${generated_file_basename}.cmake.pre-gen")
|
||||
set(custom_target_script "${hip_compile_output_dir}/${generated_file_basename}.cmake")
|
||||
|
||||
# Set properties for object files
|
||||
set_source_files_properties("${generated_file}"
|
||||
PROPERTIES
|
||||
EXTERNAL_OBJECT true # This is an object file not to be compiled, but only be linked
|
||||
)
|
||||
|
||||
# Don't add CMAKE_CURRENT_SOURCE_DIR if the path is already an absolute path
|
||||
get_filename_component(file_path "${file}" PATH)
|
||||
if(IS_ABSOLUTE "${file_path}")
|
||||
set(source_file "${file}")
|
||||
else()
|
||||
set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
|
||||
endif()
|
||||
|
||||
# Bring in the dependencies
|
||||
HIP_INCLUDE_HIPCC_DEPENDENCIES(${cmake_dependency_file})
|
||||
|
||||
# Configure the build script
|
||||
configure_file("${HIP_run_hipcc}" "${custom_target_script_pregen}" @ONLY)
|
||||
file(GENERATE
|
||||
OUTPUT "${custom_target_script}"
|
||||
INPUT "${custom_target_script_pregen}"
|
||||
)
|
||||
set(main_dep DEPENDS ${source_file})
|
||||
if(CMAKE_GENERATOR MATCHES "Makefiles")
|
||||
set(verbose_output "$(VERBOSE)")
|
||||
elseif(HIP_VERBOSE_BUILD)
|
||||
set(verbose_output ON)
|
||||
else()
|
||||
set(verbose_output OFF)
|
||||
endif()
|
||||
|
||||
# Create up the comment string
|
||||
file(RELATIVE_PATH generated_file_relative_path "${CMAKE_BINARY_DIR}" "${generated_file}")
|
||||
set(hip_build_comment_string "Building HIPCC object ${generated_file_relative_path}")
|
||||
|
||||
# Build the generated file and dependency file
|
||||
add_custom_command(
|
||||
OUTPUT ${generated_file}
|
||||
# These output files depend on the source_file and the contents of cmake_dependency_file
|
||||
${main_dep}
|
||||
DEPENDS ${HIP_HIPCC_DEPEND}
|
||||
DEPENDS ${custom_target_script}
|
||||
# Make sure the output directory exists before trying to write to it.
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${generated_file_path}"
|
||||
COMMAND ${CMAKE_COMMAND} ARGS
|
||||
-D verbose:BOOL=${verbose_output}
|
||||
-D build_configuration:STRING=${_hip_build_configuration}
|
||||
-D "generated_file:STRING=${generated_file}"
|
||||
-P "${custom_target_script}"
|
||||
WORKING_DIRECTORY "${hip_compile_output_dir}"
|
||||
COMMENT "${hip_build_comment_string}"
|
||||
)
|
||||
|
||||
# Make sure the build system knows the file is generated
|
||||
set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE)
|
||||
list(APPEND _hip_generated_files ${generated_file})
|
||||
list(APPEND _hip_source_files ${file})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Set the return parameter
|
||||
set(${_generated_files} ${_hip_generated_files})
|
||||
set(${_source_files} ${_hip_source_files})
|
||||
endmacro()
|
||||
|
||||
###############################################################################
|
||||
# HIP_ADD_EXECUTABLE
|
||||
###############################################################################
|
||||
macro(HIP_ADD_EXECUTABLE hip_target)
|
||||
# Separate the sources from the options
|
||||
HIP_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _hipcc_options _hcc_options _clang_options _nvcc_options ${ARGN})
|
||||
HIP_PREPARE_TARGET_COMMANDS(${hip_target} OBJ _generated_files _source_files ${_sources} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} CLANG_OPTIONS ${_clang_options} NVCC_OPTIONS ${_nvcc_options})
|
||||
if(_source_files)
|
||||
list(REMOVE_ITEM _sources ${_source_files})
|
||||
endif()
|
||||
if("${HIP_COMPILER}" STREQUAL "hcc")
|
||||
if("x${HCC_HOME}" STREQUAL "x")
|
||||
if (DEFINED ENV{ROCM_PATH})
|
||||
set(HCC_HOME "$ENV{ROCM_PATH}/hcc")
|
||||
elseif(DEFINED ENV{HIP_PATH})
|
||||
set(HCC_HOME "$ENV{HIP_PATH}/../hcc")
|
||||
else()
|
||||
set(HCC_HOME "/opt/rocm/hcc")
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
elseif("${HIP_COMPILER}" STREQUAL "clang")
|
||||
if("x${HIP_CLANG_PATH}" STREQUAL "x")
|
||||
if(DEFINED ENV{HIP_CLANG_PATH})
|
||||
set(HIP_CLANG_PATH $ENV{HIP_CLANG_PATH})
|
||||
elseif(DEFINED ENV{ROCM_PATH})
|
||||
set(HIP_CLANG_PATH "$ENV{ROCM_PATH}/llvm/bin")
|
||||
elseif(DEFINED ENV{HIP_PATH})
|
||||
set(HIP_CLANG_PATH "$ENV{HIP_PATH}/../llvm/bin")
|
||||
else()
|
||||
set(HIP_CLANG_PATH "/opt/rocm/llvm/bin")
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HIP_CLANG_PATH} ${HIP_CLANG_PARALLEL_BUILD_LINK_OPTIONS} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
else()
|
||||
set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
|
||||
endif()
|
||||
if ("${_sources}" STREQUAL "")
|
||||
add_executable(${hip_target} ${_cmake_options} ${_generated_files} "")
|
||||
else()
|
||||
add_executable(${hip_target} ${_cmake_options} ${_generated_files} ${_sources})
|
||||
endif()
|
||||
set_target_properties(${hip_target} PROPERTIES LINKER_LANGUAGE HIP)
|
||||
# Link with host
|
||||
if (HIP_HOST_INTERFACE)
|
||||
# hip rt should be rocclr, compiler should be clang
|
||||
target_link_libraries(${hip_target} ${HIP_HOST_INTERFACE})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
###############################################################################
|
||||
# HIP_ADD_LIBRARY
|
||||
###############################################################################
|
||||
macro(HIP_ADD_LIBRARY hip_target)
|
||||
# Separate the sources from the options
|
||||
HIP_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _hipcc_options _hcc_options _clang_options _nvcc_options ${ARGN})
|
||||
HIP_PREPARE_TARGET_COMMANDS(${hip_target} OBJ _generated_files _source_files ${_sources} ${_cmake_options} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} CLANG_OPTIONS ${_clang_options} NVCC_OPTIONS ${_nvcc_options})
|
||||
if(_source_files)
|
||||
list(REMOVE_ITEM _sources ${_source_files})
|
||||
endif()
|
||||
if ("${_sources}" STREQUAL "")
|
||||
add_library(${hip_target} ${_cmake_options} ${_generated_files} "")
|
||||
else()
|
||||
add_library(${hip_target} ${_cmake_options} ${_generated_files} ${_sources})
|
||||
endif()
|
||||
set_target_properties(${hip_target} PROPERTIES LINKER_LANGUAGE ${HIP_C_OR_CXX})
|
||||
# Link with host
|
||||
if (HIP_HOST_INTERFACE)
|
||||
# hip rt should be rocclr, compiler should be clang
|
||||
target_link_libraries(${hip_target} ${HIP_HOST_INTERFACE})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# vim: ts=4:sw=4:expandtab:smartindent
|
||||
@@ -1,182 +0,0 @@
|
||||
###############################################################################
|
||||
# Runs commands using HIPCC
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
# This file runs the hipcc commands to produce the desired output file
|
||||
# along with the dependency file needed by CMake to compute dependencies.
|
||||
#
|
||||
# Input variables:
|
||||
#
|
||||
# verbose:BOOL=<> OFF: Be as quiet as possible (default)
|
||||
# ON : Describe each step
|
||||
# build_configuration:STRING=<> Build configuration. Defaults to Debug.
|
||||
# generated_file:STRING=<> File to generate. Mandatory argument.
|
||||
|
||||
if(NOT build_configuration)
|
||||
set(build_configuration Debug)
|
||||
endif()
|
||||
if(NOT generated_file)
|
||||
message(FATAL_ERROR "You must specify generated_file on the command line")
|
||||
endif()
|
||||
|
||||
# Set these up as variables to make reading the generated file easier
|
||||
set(HIP_HIPCC_EXECUTABLE "@HIP_HIPCC_EXECUTABLE@") # path
|
||||
set(HIP_HIPCONFIG_EXECUTABLE "@HIP_HIPCONFIG_EXECUTABLE@") #path
|
||||
set(HIP_HOST_COMPILER "@HIP_HOST_COMPILER@") # path
|
||||
set(CMAKE_COMMAND "@CMAKE_COMMAND@") # path
|
||||
set(HIP_run_make2cmake "@HIP_run_make2cmake@") # path
|
||||
set(HCC_HOME "@HCC_HOME@") #path
|
||||
set(HIP_CLANG_PATH "@HIP_CLANG_PATH@") #path
|
||||
set(HIP_CLANG_PARALLEL_BUILD_COMPILE_OPTIONS "@HIP_CLANG_PARALLEL_BUILD_COMPILE_OPTIONS@")
|
||||
|
||||
@HIP_HOST_FLAGS@
|
||||
@_HIP_HIPCC_FLAGS@
|
||||
@_HIP_HCC_FLAGS@
|
||||
@_HIP_CLANG_FLAGS@
|
||||
@_HIP_NVCC_FLAGS@
|
||||
#Needed to bring the HIP_HIPCC_INCLUDE_ARGS variable in scope
|
||||
set(HIP_HIPCC_INCLUDE_ARGS @HIP_HIPCC_INCLUDE_ARGS@) # list
|
||||
|
||||
set(cmake_dependency_file "@cmake_dependency_file@") # path
|
||||
set(source_file "@source_file@") # path
|
||||
set(host_flag "@host_flag@") # bool
|
||||
|
||||
# Determine compiler and compiler flags
|
||||
execute_process(COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --platform OUTPUT_VARIABLE HIP_PLATFORM OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --compiler OUTPUT_VARIABLE HIP_COMPILER OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND ${HIP_HIPCONFIG_EXECUTABLE} --runtime OUTPUT_VARIABLE HIP_RUNTIME OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT host_flag)
|
||||
set(__CC ${HIP_HIPCC_EXECUTABLE})
|
||||
if("${HIP_PLATFORM}" STREQUAL "amd")
|
||||
if("${HIP_COMPILER}" STREQUAL "hcc")
|
||||
if(NOT "x${HCC_HOME}" STREQUAL "x")
|
||||
set(ENV{HCC_HOME} ${HCC_HOME})
|
||||
endif()
|
||||
set(__CC_FLAGS ${HIP_HIPCC_FLAGS} ${HIP_HCC_FLAGS} ${HIP_HIPCC_FLAGS_${build_configuration}} ${HIP_HCC_FLAGS_${build_configuration}})
|
||||
elseif("${HIP_COMPILER}" STREQUAL "clang")
|
||||
if(NOT "x${HIP_CLANG_PATH}" STREQUAL "x")
|
||||
set(ENV{HIP_CLANG_PATH} ${HIP_CLANG_PATH})
|
||||
endif()
|
||||
# Temporarily include HIP_HCC_FLAGS for HIP-Clang for PyTorch builds
|
||||
set(__CC_FLAGS ${HIP_CLANG_PARALLEL_BUILD_COMPILE_OPTIONS} ${HIP_HIPCC_FLAGS} ${HIP_HCC_FLAGS} ${HIP_CLANG_FLAGS} ${HIP_HIPCC_FLAGS_${build_configuration}} ${HIP_HCC_FLAGS_${build_configuration}} ${HIP_CLANG_FLAGS_${build_configuration}})
|
||||
endif()
|
||||
else()
|
||||
set(__CC_FLAGS ${HIP_HIPCC_FLAGS} ${HIP_NVCC_FLAGS} ${HIP_HIPCC_FLAGS_${build_configuration}} ${HIP_NVCC_FLAGS_${build_configuration}})
|
||||
endif()
|
||||
else()
|
||||
set(__CC ${HIP_HOST_COMPILER})
|
||||
set(__CC_FLAGS ${CMAKE_HOST_FLAGS} ${CMAKE_HOST_FLAGS_${build_configuration}})
|
||||
endif()
|
||||
set(__CC_INCLUDES ${HIP_HIPCC_INCLUDE_ARGS})
|
||||
|
||||
# hip_execute_process - Executes a command with optional command echo and status message.
|
||||
# status - Status message to print if verbose is true
|
||||
# command - COMMAND argument from the usual execute_process argument structure
|
||||
# ARGN - Remaining arguments are the command with arguments
|
||||
# HIP_result - Return value from running the command
|
||||
macro(hip_execute_process status command)
|
||||
set(_command ${command})
|
||||
if(NOT "x${_command}" STREQUAL "xCOMMAND")
|
||||
message(FATAL_ERROR "Malformed call to hip_execute_process. Missing COMMAND as second argument. (command = ${command})")
|
||||
endif()
|
||||
if(verbose)
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E echo -- ${status})
|
||||
# Build command string to print
|
||||
set(hip_execute_process_string)
|
||||
foreach(arg ${ARGN})
|
||||
# Escape quotes if any
|
||||
string(REPLACE "\"" "\\\"" arg ${arg})
|
||||
# Surround args with spaces with quotes
|
||||
if(arg MATCHES " ")
|
||||
list(APPEND hip_execute_process_string "\"${arg}\"")
|
||||
else()
|
||||
list(APPEND hip_execute_process_string ${arg})
|
||||
endif()
|
||||
endforeach()
|
||||
# Echo the command
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${hip_execute_process_string})
|
||||
endif()
|
||||
# Run the command
|
||||
execute_process(COMMAND ${ARGN} RESULT_VARIABLE HIP_result)
|
||||
endmacro()
|
||||
|
||||
# Delete the target file
|
||||
hip_execute_process(
|
||||
"Removing ${generated_file}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}"
|
||||
)
|
||||
|
||||
# Generate the dependency file
|
||||
hip_execute_process(
|
||||
"Generating dependency file: ${cmake_dependency_file}.pre"
|
||||
COMMAND "${__CC}"
|
||||
-M
|
||||
"${source_file}"
|
||||
-o "${cmake_dependency_file}.pre"
|
||||
${__CC_FLAGS}
|
||||
${__CC_INCLUDES}
|
||||
)
|
||||
|
||||
if(HIP_result)
|
||||
message(FATAL_ERROR "Error generating ${generated_file}")
|
||||
endif()
|
||||
|
||||
# Generate the cmake readable dependency file to a temp file
|
||||
hip_execute_process(
|
||||
"Generating temporary cmake readable file: ${cmake_dependency_file}.tmp"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-D "input_file:FILEPATH=${cmake_dependency_file}.pre"
|
||||
-D "output_file:FILEPATH=${cmake_dependency_file}.tmp"
|
||||
-D "verbose=${verbose}"
|
||||
-P "${HIP_run_make2cmake}"
|
||||
)
|
||||
|
||||
if(HIP_result)
|
||||
message(FATAL_ERROR "Error generating ${generated_file}")
|
||||
endif()
|
||||
|
||||
# Copy the file if it is different
|
||||
hip_execute_process(
|
||||
"Copy if different ${cmake_dependency_file}.tmp to ${cmake_dependency_file}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${cmake_dependency_file}.tmp" "${cmake_dependency_file}"
|
||||
)
|
||||
|
||||
if(HIP_result)
|
||||
message(FATAL_ERROR "Error generating ${generated_file}")
|
||||
endif()
|
||||
|
||||
# Delete the temporary file
|
||||
hip_execute_process(
|
||||
"Removing ${cmake_dependency_file}.tmp and ${cmake_dependency_file}.pre"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove "${cmake_dependency_file}.tmp" "${cmake_dependency_file}.pre"
|
||||
)
|
||||
|
||||
if(HIP_result)
|
||||
message(FATAL_ERROR "Error generating ${generated_file}")
|
||||
endif()
|
||||
|
||||
# Generate the output file
|
||||
hip_execute_process(
|
||||
"Generating ${generated_file}"
|
||||
COMMAND "${__CC}"
|
||||
-c
|
||||
"${source_file}"
|
||||
-o "${generated_file}"
|
||||
${__CC_FLAGS}
|
||||
${__CC_INCLUDES}
|
||||
)
|
||||
|
||||
if(HIP_result)
|
||||
# Make sure that we delete the output file
|
||||
hip_execute_process(
|
||||
"Removing ${generated_file}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}"
|
||||
)
|
||||
message(FATAL_ERROR "Error generating file ${generated_file}")
|
||||
else()
|
||||
if(verbose)
|
||||
message("Generated ${generated_file} successfully.")
|
||||
endif()
|
||||
endif()
|
||||
# vim: ts=4:sw=4:expandtab:smartindent
|
||||
@@ -1,50 +0,0 @@
|
||||
###############################################################################
|
||||
# Computes dependencies using HIPCC
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
# This file converts dependency files generated using hipcc to a format that
|
||||
# cmake can understand.
|
||||
|
||||
# Input variables:
|
||||
#
|
||||
# input_file:STRING=<> Dependency file to parse. Required argument
|
||||
# output_file:STRING=<> Output file to generate. Required argument
|
||||
|
||||
if(NOT input_file OR NOT output_file)
|
||||
message(FATAL_ERROR "You must specify input_file and output_file on the command line")
|
||||
endif()
|
||||
|
||||
file(READ ${input_file} depend_text)
|
||||
|
||||
if (NOT "${depend_text}" STREQUAL "")
|
||||
string(REPLACE " /" "\n/" depend_text ${depend_text})
|
||||
string(REGEX REPLACE "^.*:" "" depend_text ${depend_text})
|
||||
string(REGEX REPLACE "[ \\\\]*\n" ";" depend_text ${depend_text})
|
||||
|
||||
set(dependency_list "")
|
||||
|
||||
foreach(file ${depend_text})
|
||||
string(REGEX REPLACE "^ +" "" file ${file})
|
||||
if(NOT EXISTS "${file}")
|
||||
message(WARNING " Removing non-existent dependency file: ${file}")
|
||||
set(file "")
|
||||
endif()
|
||||
|
||||
if(NOT IS_DIRECTORY "${file}")
|
||||
get_filename_component(file_absolute "${file}" ABSOLUTE)
|
||||
list(APPEND dependency_list "${file_absolute}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Remove the duplicate entries and sort them.
|
||||
list(REMOVE_DUPLICATES dependency_list)
|
||||
list(SORT dependency_list)
|
||||
|
||||
foreach(file ${dependency_list})
|
||||
set(hip_hipcc_depend "${hip_hipcc_depend} \"${file}\"\n")
|
||||
endforeach()
|
||||
|
||||
file(WRITE ${output_file} "# Generated by: FindHIP.cmake. Do not edit.\nSET(HIP_HIPCC_DEPEND\n ${hip_hipcc_depend})\n\n")
|
||||
# vim: ts=4:sw=4:expandtab:smartindent
|
||||
@@ -14,10 +14,33 @@
|
||||
# - HYPRE_LIBRARIES
|
||||
# - HYPRE_INCLUDE_DIRS
|
||||
# - HYPRE_VERSION
|
||||
# - HYPRE_USING_HIP (internal)
|
||||
|
||||
if (HYPRE_FOUND)
|
||||
if (HYPRE_USING_HIP)
|
||||
find_package(rocsparse REQUIRED)
|
||||
find_package(rocrand REQUIRED)
|
||||
endif()
|
||||
return()
|
||||
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.")
|
||||
"Paths to headers required by HYPRE." "Libraries required by HYPRE."
|
||||
CHECK_BUILD HYPRE_USING_HIP FALSE
|
||||
"
|
||||
#undef HYPRE_USING_HIP
|
||||
#include <HYPRE_config.h>
|
||||
|
||||
#ifndef HYPRE_USING_HIP
|
||||
#error HYPRE is built without HIP.
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
")
|
||||
|
||||
if (HYPRE_FOUND AND (NOT HYPRE_VERSION))
|
||||
try_run(HYPRE_VERSION_RUN_RESULT HYPRE_VERSION_COMPILE_RESULT
|
||||
@@ -33,3 +56,12 @@ if (HYPRE_FOUND AND (NOT HYPRE_VERSION))
|
||||
message(FATAL_ERROR "Unable to determine HYPRE version.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (HYPRE_FOUND AND HYPRE_USING_HIP)
|
||||
find_package(rocsparse REQUIRED)
|
||||
find_package(rocrand REQUIRED)
|
||||
list(APPEND HYPRE_LIBRARIES ${rocsparse_LIBRARIES} ${rocrand_LIBRARIES})
|
||||
set(HYPRE_LIBRARIES ${HYPRE_LIBRARIES} CACHE STRING
|
||||
"HYPRE libraries + dependencies." FORCE)
|
||||
message(STATUS "Updated HYPRE_LIBRARIES: ${HYPRE_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
@@ -46,8 +46,7 @@ endfunction()
|
||||
# Wrapper for add_executable that calls the HIP wrapper if applicable
|
||||
macro(mfem_add_executable NAME)
|
||||
if (MFEM_USE_HIP)
|
||||
hip_add_executable(${NAME} ${ARGN})
|
||||
set_target_properties(${NAME} PROPERTIES LINKER_LANGUAGE CXX)
|
||||
add_executable(${NAME} ${ARGN})
|
||||
else()
|
||||
add_executable(${NAME} ${ARGN})
|
||||
endif()
|
||||
@@ -56,7 +55,7 @@ endmacro()
|
||||
# Wrapper for add_library that calls the HIP wrapper if applicable
|
||||
macro(mfem_add_library NAME)
|
||||
if (MFEM_USE_HIP)
|
||||
hip_add_library(${NAME} ${ARGN})
|
||||
add_library(${NAME} ${ARGN})
|
||||
else()
|
||||
add_library(${NAME} ${ARGN})
|
||||
endif()
|
||||
@@ -92,8 +91,6 @@ macro(add_mfem_examples EXE_SRCS)
|
||||
# If CUDA is enabled, tag source files to be compiled with nvcc.
|
||||
if (MFEM_USE_CUDA)
|
||||
set_source_files_properties(${SRC_FILE} PROPERTIES LANGUAGE CUDA)
|
||||
elseif(MFEM_USE_HIP)
|
||||
set_source_files_properties(${SRC_FILE} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT TRUE)
|
||||
endif()
|
||||
|
||||
get_filename_component(SRC_FILENAME ${SRC_FILE} NAME)
|
||||
@@ -159,8 +156,6 @@ macro(add_mfem_miniapp MFEM_EXE_NAME)
|
||||
endforeach()
|
||||
set(EXTRA_OPTIONS_LIST ${LIST_})
|
||||
endif()
|
||||
elseif(MFEM_USE_HIP)
|
||||
set_source_files_properties(${MAIN_LIST} ${EXTRA_SOURCES_LIST} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT TRUE)
|
||||
endif()
|
||||
|
||||
# Actually add the executable
|
||||
@@ -534,12 +529,15 @@ function(mfem_find_package Name Prefix DirVar IncSuffixes Header LibSuffixes
|
||||
if (NOT ImportConfig)
|
||||
set(ImportConfig RELEASE)
|
||||
endif()
|
||||
set(ImportConfigSuffix "_${ImportConfig}")
|
||||
get_target_property(ImpConfigs ${TargetName} IMPORTED_CONFIGURATIONS)
|
||||
list(FIND ImpConfigs ${ImportConfig} _Index)
|
||||
if (_Index EQUAL -1)
|
||||
message(FATAL_ERROR " *** ${ReqPack}: configuration "
|
||||
"${ImportConfig} not found. Set ${ReqPack}_IMPORT_CONFIG "
|
||||
"from the list: ${ImpConfigs}.")
|
||||
if ((_Index EQUAL -1) OR ("${ImportConfig}" STREQUAL "NO_CONFIG"))
|
||||
set(ImportConfig "NO_CONFIG")
|
||||
set(ImportConfigSuffix "")
|
||||
# message(FATAL_ERROR " *** ${ReqPack}: configuration "
|
||||
# "${ImportConfig} not found. Set ${ReqPack}_IMPORT_CONFIG "
|
||||
# "from the list: ${ImpConfigs}.")
|
||||
endif()
|
||||
endif()
|
||||
# Set _Pack_LIBS
|
||||
@@ -551,8 +549,8 @@ function(mfem_find_package Name Prefix DirVar IncSuffixes Header LibSuffixes
|
||||
endif()
|
||||
else()
|
||||
# Set _Pack_LIBS from the target properties for ImportConfig
|
||||
foreach (_prop IMPORTED_LOCATION_${ImportConfig}
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES_${ImportConfig})
|
||||
foreach (_prop IMPORTED_LOCATION${ImportConfigSuffix}
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES${ImportConfigSuffix})
|
||||
get_target_property(_value ${TargetName} ${_prop})
|
||||
if (_value)
|
||||
list(APPEND _Pack_LIBS ${_value})
|
||||
@@ -564,7 +562,7 @@ function(mfem_find_package Name Prefix DirVar IncSuffixes Header LibSuffixes
|
||||
endif()
|
||||
endif()
|
||||
# Set _Pack_INCS
|
||||
foreach (_prop INCLUDE_DIRECTORIES)
|
||||
foreach (_prop INCLUDE_DIRECTORIES INTERFACE_INCLUDE_DIRECTORIES)
|
||||
get_target_property(_value ${TargetName} ${_prop})
|
||||
if (_value)
|
||||
list(APPEND _Pack_INCS ${_value})
|
||||
@@ -742,6 +740,133 @@ function(mfem_find_library Name Prefix Lib LibDoc CheckVar CheckSrc)
|
||||
endfunction(mfem_find_library)
|
||||
|
||||
|
||||
#
|
||||
# Extract compile and link options needed by the given target.
|
||||
#
|
||||
function(mfem_get_target_options Target CompileOptsVar LinkOptsVar)
|
||||
|
||||
if (NOT TARGET ${Target})
|
||||
return()
|
||||
endif()
|
||||
|
||||
# CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG -> '-Wl,-rpath,'
|
||||
set(shared_link_flag ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG})
|
||||
if (NOT shared_link_flag)
|
||||
set(shared_link_flag "-Wl,-rpath,")
|
||||
endif()
|
||||
|
||||
set(tgt "${Target}")
|
||||
unset(CompileOpts)
|
||||
unset(LinkOpts)
|
||||
get_target_property(IsImported ${tgt} IMPORTED)
|
||||
# message(STATUS "${tgt}[IMPORTED]: ${IsImported}")
|
||||
# Generally, the possible target types are: STATIC_LIBRARY, MODULE_LIBRARY,
|
||||
# SHARED_LIBRARY, INTERFACE_LIBRARY, EXECUTABLE.
|
||||
get_target_property(type ${tgt} TYPE)
|
||||
# message(STATUS "${tgt}[TYPE]: ${type}")
|
||||
unset(ImportConfig)
|
||||
get_target_property(ImportConfigs ${tgt} IMPORTED_CONFIGURATIONS)
|
||||
if (ImportConfigs)
|
||||
list(GET ImportConfigs 0 ImportConfig)
|
||||
endif()
|
||||
if (NOT ImportConfig)
|
||||
set(ImportConfig RELEASE)
|
||||
endif()
|
||||
# message(STATUS "${tgt}[ImportConfig]: ${ImportConfig}")
|
||||
# List all properties with: cmake --help-property-list
|
||||
get_target_property(Defs ${tgt} INTERFACE_COMPILE_DEFINITIONS)
|
||||
if (Defs)
|
||||
list(REMOVE_DUPLICATES Defs)
|
||||
foreach(Def ${Defs})
|
||||
list(APPEND CompileOpts "-D${Def}")
|
||||
endforeach()
|
||||
endif()
|
||||
get_target_property(Opts ${tgt} INTERFACE_COMPILE_OPTIONS)
|
||||
if (Opts)
|
||||
foreach(Opt ${Opts})
|
||||
list(APPEND CompileOpts "${Opt}")
|
||||
endforeach()
|
||||
endif()
|
||||
get_target_property(Dirs ${tgt} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if (Dirs)
|
||||
list(REMOVE_DUPLICATES Dirs)
|
||||
foreach(Dir ${Dirs})
|
||||
list(APPEND CompileOpts "-I\"${Dir}\"")
|
||||
endforeach()
|
||||
endif()
|
||||
get_target_property(SysDirs ${tgt} INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
|
||||
if (SysDirs)
|
||||
list(REMOVE_DUPLICATES SysDirs)
|
||||
foreach(SysDir ${SysDirs})
|
||||
list(APPEND CompileOpts "-isystem \"${SysDir}\"")
|
||||
endforeach()
|
||||
endif()
|
||||
if ("${type}" STREQUAL "STATIC_LIBRARY")
|
||||
get_target_property(Location ${tgt} LOCATION)
|
||||
if (Location)
|
||||
list(APPEND LinkOpts "\"${Location}\"")
|
||||
else()
|
||||
message(STATUS " *** Warning: [${tgt}] LOCATION not defined!")
|
||||
endif()
|
||||
elseif ("${type}" STREQUAL "SHARED_LIBRARY")
|
||||
get_target_property(Location ${tgt} LOCATION)
|
||||
if (Location)
|
||||
get_filename_component(Dir ${Location} DIRECTORY)
|
||||
get_filename_component(NameWE ${Location} NAME_WE)
|
||||
string(REGEX REPLACE "^lib" "" LibName ${NameWE})
|
||||
list(APPEND LinkOpts
|
||||
"-L\"${Dir}\""
|
||||
"${shared_link_flag}\"${Dir}\""
|
||||
"-l${LibName}")
|
||||
else()
|
||||
message(STATUS " *** Warning: [${tgt}] LOCATION not defined!")
|
||||
endif()
|
||||
elseif ("${type}" STREQUAL "INTERFACE_LIBRARY")
|
||||
get_target_property(Libs ${tgt} INTERFACE_LINK_LIBRARIES)
|
||||
if (Libs)
|
||||
foreach(Lib ${Libs})
|
||||
if (NOT (TARGET ${Lib}))
|
||||
list(APPEND LinkOpts "${Lib}")
|
||||
else()
|
||||
mfem_get_target_options(${Lib} COpts LOpts)
|
||||
list(APPEND CompileOpts ${COpts})
|
||||
list(APPEND LinkOpts ${LOpts})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
# Other properties we may need to handle:
|
||||
# INTERFACE_LINK_DEPENDS
|
||||
# INTERFACE_LINK_DIRECTORIES
|
||||
# INTERFACE_LINK_OPTIONS
|
||||
else()
|
||||
message(STATUS " *** Warning: [${tgt}] uses target type '${type}'"
|
||||
" which is not supported!")
|
||||
endif()
|
||||
|
||||
# Other potentially relevant properties:
|
||||
# - For all target types:
|
||||
# IMPORTED_LIBNAME
|
||||
# IMPORTED_LIBNAME_${ImportConfig}
|
||||
# INTERFACE_AUTOUIC_OPTIONS
|
||||
# INTERFACE_COMPILE_FEATURES
|
||||
# INTERFACE_POSITION_INDEPENDENT_CODE
|
||||
# INTERFACE_SOURCES
|
||||
# INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
|
||||
# - For non-"INTERFACE_LIBRARY" target types only:
|
||||
# IMPORTED_LOCATION
|
||||
# IMPORTED_LOCATION_${ImportConfig}
|
||||
# IMPORTED_LINK_INTERFACE_LIBRARIES
|
||||
# IMPORTED_LINK_INTERFACE_LIBRARIES_${ImportConfig}
|
||||
# LINK_FLAGS
|
||||
# LINK_FLAGS_${ImportConfig}
|
||||
# LOCATION_${ImportConfig})
|
||||
|
||||
set(${CompileOptsVar} "${CompileOpts}" PARENT_SCOPE)
|
||||
set(${LinkOptsVar} "${LinkOpts}" PARENT_SCOPE)
|
||||
|
||||
endfunction(mfem_get_target_options)
|
||||
|
||||
|
||||
#
|
||||
# Function that creates 'config.mk' from 'config.mk.in' for the both the
|
||||
# build- and the install-locations and define install rules for 'config.mk'
|
||||
@@ -760,13 +885,15 @@ function(mfem_export_mk_files)
|
||||
# Convert Boolean vars to YES/NO without writing the values to cache
|
||||
set(CONFIG_MK_BOOL_VARS MFEM_USE_MPI MFEM_USE_METIS MFEM_USE_METIS_5
|
||||
MFEM_DEBUG MFEM_USE_EXCEPTIONS MFEM_USE_ZLIB MFEM_USE_LIBUNWIND
|
||||
MFEM_USE_LAPACK MFEM_THREAD_SAFE MFEM_USE_OPENMP MFEM_USE_LEGACY_OPENMP
|
||||
MFEM_USE_LAPACK MFEM_THREAD_SAFE MFEM_USE_LEGACY_OPENMP MFEM_USE_OPENMP
|
||||
MFEM_USE_MEMALLOC MFEM_USE_SUNDIALS MFEM_USE_MESQUITE MFEM_USE_SUITESPARSE
|
||||
MFEM_USE_SUPERLU MFEM_USE_STRUMPACK MFEM_USE_GINKGO MFEM_USE_AMGX
|
||||
MFEM_USE_GNUTLS MFEM_USE_GSLIB MFEM_USE_NETCDF MFEM_USE_PETSC
|
||||
MFEM_USE_SLEPC MFEM_USE_MPFR MFEM_USE_SIDRE MFEM_USE_CONDUIT MFEM_USE_PUMI
|
||||
MFEM_USE_CUDA MFEM_USE_OCCA MFEM_USE_RAJA MFEM_USE_UMPIRE MFEM_USE_SIMD
|
||||
MFEM_USE_ADIOS2 MFEM_USE_BENCHMARK MFEM_USE_PARELAG)
|
||||
MFEM_USE_SUPERLU MFEM_USE_SUPERLU5 MFEM_USE_MUMPS MFEM_USE_STRUMPACK
|
||||
MFEM_USE_GINKGO MFEM_USE_AMGX MFEM_USE_GNUTLS MFEM_USE_NETCDF
|
||||
MFEM_USE_PETSC MFEM_USE_SLEPC MFEM_USE_MPFR MFEM_USE_SIDRE MFEM_USE_FMS
|
||||
MFEM_USE_CONDUIT MFEM_USE_PUMI MFEM_USE_HIOP MFEM_USE_GSLIB MFEM_USE_CUDA
|
||||
MFEM_USE_HIP MFEM_USE_RAJA MFEM_USE_OCCA MFEM_USE_CEED MFEM_USE_CALIPER
|
||||
MFEM_USE_UMPIRE MFEM_USE_SIMD MFEM_USE_ADIOS2 MFEM_USE_MKL_CPARDISO
|
||||
MFEM_USE_ADFORWARD MFEM_USE_CODIPACK MFEM_USE_BENCHMARK MFEM_USE_PARELAG)
|
||||
foreach(var ${CONFIG_MK_BOOL_VARS})
|
||||
if (${var})
|
||||
set(${var} YES)
|
||||
@@ -868,8 +995,18 @@ function(mfem_export_mk_files)
|
||||
get_filename_component(suffix ${lib} EXT)
|
||||
# handle interfaces (e.g., SCOREC::apf)
|
||||
if ("${lib}" MATCHES "SCOREC::.*" OR "${lib}" MATCHES "Ginkgo::.*")
|
||||
elseif (NOT "${lib}" MATCHES "SCOREC::.*" AND "${lib}" MATCHES ".*::.*")
|
||||
message(FATAL_ERROR "***** interface lib found ... exiting *****")
|
||||
elseif (TARGET "${lib}")
|
||||
mfem_get_target_options(${lib} CompileOpts LinkOpts)
|
||||
# Removing duplicates may lead to issues:
|
||||
# list(REMOVE_DUPLICATES CompileOpts)
|
||||
# list(REMOVE_DUPLICATES LinkOpts)
|
||||
string(REPLACE ";" " " COpts "${CompileOpts}")
|
||||
string(REPLACE ";" " " LOpts "${LinkOpts}")
|
||||
# message(STATUS "${lib}[COpts]: '${COpts}'")
|
||||
# message(STATUS "${lib}[LOpts]: '${LOpts}'")
|
||||
set(MFEM_TPLFLAGS "${MFEM_TPLFLAGS} ${COpts}")
|
||||
set(MFEM_EXT_LIBS "${MFEM_EXT_LIBS} ${LOpts}")
|
||||
# message(FATAL_ERROR "***** interface lib found ... exiting *****")
|
||||
# handle static and shared libs
|
||||
elseif ("${suffix}" STREQUAL "${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
get_filename_component(dir ${lib} DIRECTORY)
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ MFEM_MPIEXEC_NP = @MFEM_MPIEXEC_NP@
|
||||
MFEM_MPI_NP = @MFEM_MPI_NP@
|
||||
|
||||
# The NVCC compiler cannot link with -x=cu
|
||||
MFEM_LINK_FLAGS := $(filter-out -x=cu, $(MFEM_FLAGS))
|
||||
MFEM_LINK_FLAGS := $(filter-out -x=cu -xhip, $(MFEM_FLAGS))
|
||||
|
||||
# Optional extra configuration
|
||||
@MFEM_CONFIG_EXTRA@
|
||||
|
||||
@@ -50,6 +50,7 @@ option(MFEM_USE_CONDUIT "Enable Conduit usage" OFF)
|
||||
option(MFEM_USE_PUMI "Enable PUMI" OFF)
|
||||
option(MFEM_USE_HIOP "Enable HiOp" OFF)
|
||||
option(MFEM_USE_CUDA "Enable CUDA" OFF)
|
||||
option(MFEM_USE_HIP "Enable HIP" OFF)
|
||||
option(MFEM_USE_OCCA "Enable OCCA" OFF)
|
||||
option(MFEM_USE_RAJA "Enable RAJA" OFF)
|
||||
option(MFEM_USE_CEED "Enable CEED" OFF)
|
||||
@@ -107,6 +108,7 @@ if (MFEM_USE_CUDA)
|
||||
set(HYPRE_REQUIRED_LIBRARIES "-lcusparse" "-lcurand" CACHE STRING
|
||||
"Libraries that HYPRE depends on.")
|
||||
endif()
|
||||
# HIP dependency for HYPRE is handled in FindHYPRE.cmake.
|
||||
|
||||
set(METIS_DIR "${MFEM_DIR}/../metis-4.0" CACHE PATH "Path to the METIS library.")
|
||||
|
||||
@@ -226,6 +228,11 @@ set(MKL_LIBRARY_DIR "" CACHE STRING "Custom library subdirectory")
|
||||
|
||||
set(OCCA_DIR "${MFEM_DIR}/../occa" CACHE PATH "Path to OCCA")
|
||||
set(RAJA_DIR "${MFEM_DIR}/../raja" CACHE PATH "Path to RAJA")
|
||||
# If RAJA is built with external CAMP:
|
||||
# set(RAJA_REQUIRED_PACKAGES "camp"
|
||||
# CACHE STRING "Packages that RAJA depends on.")
|
||||
# set(camp_DIR "${MFEM_DIR}/../camp/lib/cmake/camp"
|
||||
# CACHE PATH "Path to CAMP CMake files.")
|
||||
set(CEED_DIR "${MFEM_DIR}/../libCEED" CACHE PATH "Path to libCEED")
|
||||
set(UMPIRE_DIR "${MFEM_DIR}/../umpire" CACHE PATH "Path to Umpire")
|
||||
set(CALIPER_DIR "${MFEM_DIR}/../caliper" CACHE PATH "Path to Caliper")
|
||||
@@ -245,7 +252,8 @@ set(BLAS_LIBRARIES "" CACHE STRING "The BLAS library.")
|
||||
set(LAPACK_INCLUDE_DIRS "" CACHE STRING "Path to LAPACK headers.")
|
||||
set(LAPACK_LIBRARIES "" CACHE STRING "The LAPACK library.")
|
||||
|
||||
set(CODIPACK_INCLUDE_DIRS "${MFEM_DIR}/../CoDiPack/inlude" CACHE STRING "Path to CoDiPack headers.")
|
||||
set(CODIPACK_INCLUDE_DIRS "${MFEM_DIR}/../CoDiPack/include" CACHE STRING
|
||||
"Path to CoDiPack headers.")
|
||||
set(CODIPACK_LIBRARIES "")
|
||||
|
||||
# Some useful variables:
|
||||
|
||||
+21
-2
@@ -172,6 +172,20 @@ ifeq ($(MFEM_USE_MPI)$(MFEM_USE_HIP),YESYES)
|
||||
MPI_LIB = -L$(MPI_DIR)/lib $(XLINKER)-rpath,$(MPI_DIR)/lib -lmpi
|
||||
endif
|
||||
|
||||
# ROCM/HIP directory such that ROCM/HIP libraries like rocsparse and rocrand are
|
||||
# found in $(HIP_DIR)/lib, usually as links. Typically, this directoory is of
|
||||
# the form /opt/rocm-X.Y.Z which is called ROCM_PATH by hipconfig.
|
||||
ifeq ($(MFEM_USE_HIP),YES)
|
||||
HIP_DIR := $(patsubst %/,%,$(dir $(shell which $(HIP_CXX))))
|
||||
HIP_DIR := $(patsubst %/,%,$(dir $(HIP_DIR)))
|
||||
ifeq (,$(wildcard $(HIP_DIR)/lib/librocsparse.*))
|
||||
HIP_DIR := $(shell hipconfig --rocmpath 2> /dev/null)
|
||||
ifeq (,$(wildcard $(HIP_DIR)/lib/librocsparse.*))
|
||||
$(error Unable to determine HIP_DIR. Please set it manually.)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Compile and link options for zlib.
|
||||
ZLIB_DIR =
|
||||
ZLIB_OPT = $(if $(ZLIB_DIR),-I$(ZLIB_DIR)/include)
|
||||
@@ -189,6 +203,11 @@ ifeq (YES,$(MFEM_USE_CUDA))
|
||||
# This is only necessary when hypre is built with cuda:
|
||||
HYPRE_LIB += -lcusparse -lcurand
|
||||
endif
|
||||
ifeq (YES,$(MFEM_USE_HIP))
|
||||
# This is only necessary when hypre is built with hip:
|
||||
HYPRE_LIB += -L$(HIP_DIR)/lib $(XLINKER)-rpath,$(HIP_DIR)/lib\
|
||||
-lrocsparse -lrocrand
|
||||
endif
|
||||
|
||||
# METIS library configuration
|
||||
ifeq ($(MFEM_USE_SUPERLU)$(MFEM_USE_STRUMPACK)$(MFEM_USE_MUMPS),NONONO)
|
||||
@@ -430,9 +449,9 @@ GSLIB_LIB = -L$(GSLIB_DIR)/lib -lgs
|
||||
CUDA_OPT =
|
||||
CUDA_LIB = -lcusparse
|
||||
|
||||
# HIP library configuration (currently not needed)
|
||||
# HIP library configuration
|
||||
HIP_OPT =
|
||||
HIP_LIB =
|
||||
HIP_LIB = -L$(HIP_DIR)/lib $(XLINKER)-rpath,$(HIP_DIR)/lib -lhipsparse
|
||||
|
||||
# OCCA library configuration
|
||||
OCCA_DIR = @MFEM_DIR@/../occa
|
||||
|
||||
+3
-3
@@ -58,14 +58,14 @@ ifneq (,$(filter test%,$(MAKECMDGOALS)))
|
||||
MAKEFLAGS += -k
|
||||
endif
|
||||
# Test runs of the examples/miniapps with parameters - check exit code:
|
||||
# 0 means success, 255 means the test was skipped, anything else means error
|
||||
# 0 means success, 242 means the test was skipped, anything else means error
|
||||
mfem-test = \
|
||||
printf " $(3) [$(2) $(1) ... ]: "; \
|
||||
$(call $(TIMEFUN),$(TIMECMD),$(2) ./$(1) $(if $(5),,-no-vis )$(4) \
|
||||
> $(1).stderr 2>&1); \
|
||||
err="$$3"; \
|
||||
if [ "$$3" = 0 ]; then $(PRINT_OK); \
|
||||
else if [ "$$3" = 255 ]; then $(PRINT_SKIP); err=0; \
|
||||
else if [ "$$3" = 242 ]; then $(PRINT_SKIP); err=0; \
|
||||
else $(PRINT_FAILED); cat $(1).stderr; fi; fi; \
|
||||
rm -f $(1).stderr; exit $$err
|
||||
|
||||
@@ -76,7 +76,7 @@ mfem-test-file = \
|
||||
$(call $(TIMEFUN),$(TIMECMD),$(2) ./$(1) -no-vis > $(1).stderr 2>&1); \
|
||||
err="$$3"; \
|
||||
if [ "$$3" = 0 ] && [ -e $(4) ]; then $(PRINT_OK); \
|
||||
else if [ "$$3" = 255 ] && [ -e $(4) ]; then $(PRINT_SKIP); err=0; \
|
||||
else if [ "$$3" = 242 ] && [ -e $(4) ]; then $(PRINT_SKIP); err=0; \
|
||||
else $(PRINT_FAILED); cat $(1).stderr; err=64; fi; fi; \
|
||||
rm -f $(1).stderr; exit $$err
|
||||
|
||||
|
||||
+13
-12
@@ -149,7 +149,7 @@ void InitialDeformation(const Vector &x, Vector &y);
|
||||
|
||||
void InitialVelocity(const Vector &x, Vector &v);
|
||||
|
||||
void visualize(ostream &out, Mesh *mesh, GridFunction *deformed_nodes,
|
||||
void visualize(ostream &os, Mesh *mesh, GridFunction *deformed_nodes,
|
||||
GridFunction *field, const char *field_name = NULL,
|
||||
bool init_vis = false);
|
||||
|
||||
@@ -376,10 +376,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
|
||||
void visualize(ostream &out, Mesh *mesh, GridFunction *deformed_nodes,
|
||||
void visualize(ostream &os, Mesh *mesh, GridFunction *deformed_nodes,
|
||||
GridFunction *field, const char *field_name, bool init_vis)
|
||||
{
|
||||
if (!out)
|
||||
if (!os)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -389,24 +389,25 @@ void visualize(ostream &out, Mesh *mesh, GridFunction *deformed_nodes,
|
||||
|
||||
mesh->SwapNodes(nodes, owns_nodes);
|
||||
|
||||
out << "solution\n" << *mesh << *field;
|
||||
os << "solution\n" << *mesh << *field;
|
||||
|
||||
mesh->SwapNodes(nodes, owns_nodes);
|
||||
|
||||
if (init_vis)
|
||||
{
|
||||
out << "window_size 800 800\n";
|
||||
out << "window_title '" << field_name << "'\n";
|
||||
os << "window_size 800 800\n";
|
||||
os << "window_title '" << field_name << "'\n";
|
||||
if (mesh->SpaceDimension() == 2)
|
||||
{
|
||||
out << "view 0 0\n"; // view from top
|
||||
out << "keys jl\n"; // turn off perspective and light
|
||||
os << "view 0 0\n"; // view from top
|
||||
os << "keys jl\n"; // turn off perspective and light
|
||||
}
|
||||
out << "keys cm\n"; // show colorbar and mesh
|
||||
out << "autoscale value\n"; // update value-range; keep mesh-extents fixed
|
||||
out << "pause\n";
|
||||
os << "keys cm\n"; // show colorbar and mesh
|
||||
// update value-range; keep mesh-extents fixed
|
||||
os << "autoscale value\n";
|
||||
os << "pause\n";
|
||||
}
|
||||
out << flush;
|
||||
os << flush;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+17
-13
@@ -154,7 +154,8 @@ void InitialDeformation(const Vector &x, Vector &y);
|
||||
|
||||
void InitialVelocity(const Vector &x, Vector &v);
|
||||
|
||||
void visualize(ostream &out, ParMesh *mesh, ParGridFunction *deformed_nodes,
|
||||
void visualize(ostream &os, ParMesh *mesh,
|
||||
ParGridFunction *deformed_nodes,
|
||||
ParGridFunction *field, const char *field_name = NULL,
|
||||
bool init_vis = false);
|
||||
|
||||
@@ -438,10 +439,11 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
void visualize(ostream &out, ParMesh *mesh, ParGridFunction *deformed_nodes,
|
||||
void visualize(ostream &os, ParMesh *mesh,
|
||||
ParGridFunction *deformed_nodes,
|
||||
ParGridFunction *field, const char *field_name, bool init_vis)
|
||||
{
|
||||
if (!out)
|
||||
if (!os)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -451,25 +453,27 @@ void visualize(ostream &out, ParMesh *mesh, ParGridFunction *deformed_nodes,
|
||||
|
||||
mesh->SwapNodes(nodes, owns_nodes);
|
||||
|
||||
out << "parallel " << mesh->GetNRanks() << " " << mesh->GetMyRank() << "\n";
|
||||
out << "solution\n" << *mesh << *field;
|
||||
os << "parallel " << mesh->GetNRanks()
|
||||
<< " " << mesh->GetMyRank() << "\n";
|
||||
os << "solution\n" << *mesh << *field;
|
||||
|
||||
mesh->SwapNodes(nodes, owns_nodes);
|
||||
|
||||
if (init_vis)
|
||||
{
|
||||
out << "window_size 800 800\n";
|
||||
out << "window_title '" << field_name << "'\n";
|
||||
os << "window_size 800 800\n";
|
||||
os << "window_title '" << field_name << "'\n";
|
||||
if (mesh->SpaceDimension() == 2)
|
||||
{
|
||||
out << "view 0 0\n"; // view from top
|
||||
out << "keys jl\n"; // turn off perspective and light
|
||||
os << "view 0 0\n"; // view from top
|
||||
os << "keys jl\n"; // turn off perspective and light
|
||||
}
|
||||
out << "keys cm\n"; // show colorbar and mesh
|
||||
out << "autoscale value\n"; // update value-range; keep mesh-extents fixed
|
||||
out << "pause\n";
|
||||
os << "keys cm\n"; // show colorbar and mesh
|
||||
// update value-range; keep mesh-extents fixed
|
||||
os << "autoscale value\n";
|
||||
os << "pause\n";
|
||||
}
|
||||
out << flush;
|
||||
os << flush;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+10
-10
@@ -32,7 +32,7 @@ private:
|
||||
mutable DenseTensor flux;
|
||||
mutable Vector z;
|
||||
|
||||
void GetFlux(const DenseMatrix &state, DenseTensor &flux) const;
|
||||
void GetFlux(const DenseMatrix &state_, DenseTensor &flux_) const;
|
||||
|
||||
public:
|
||||
FE_Evolution(FiniteElementSpace &vfes_,
|
||||
@@ -256,26 +256,26 @@ inline double ComputeMaxCharSpeed(const Vector &state, const int dim)
|
||||
}
|
||||
|
||||
// Compute the flux at solution nodes.
|
||||
void FE_Evolution::GetFlux(const DenseMatrix &x, DenseTensor &flux) const
|
||||
void FE_Evolution::GetFlux(const DenseMatrix &x_, DenseTensor &flux_) const
|
||||
{
|
||||
const int dof = flux.SizeI();
|
||||
const int dim = flux.SizeJ();
|
||||
const int flux_dof = flux_.SizeI();
|
||||
const int flux_dim = flux_.SizeJ();
|
||||
|
||||
for (int i = 0; i < dof; i++)
|
||||
for (int i = 0; i < flux_dof; i++)
|
||||
{
|
||||
for (int k = 0; k < num_equation; k++) { state(k) = x(i, k); }
|
||||
ComputeFlux(state, dim, f);
|
||||
for (int k = 0; k < num_equation; k++) { state(k) = x_(i, k); }
|
||||
ComputeFlux(state, flux_dim, f);
|
||||
|
||||
for (int d = 0; d < dim; d++)
|
||||
for (int d = 0; d < flux_dim; d++)
|
||||
{
|
||||
for (int k = 0; k < num_equation; k++)
|
||||
{
|
||||
flux(i, d, k) = f(k, d);
|
||||
flux_(i, d, k) = f(k, d);
|
||||
}
|
||||
}
|
||||
|
||||
// Update max char speed
|
||||
const double mcs = ComputeMaxCharSpeed(state, dim);
|
||||
const double mcs = ComputeMaxCharSpeed(state, flux_dim);
|
||||
if (mcs > max_char_speed) { max_char_speed = mcs; }
|
||||
}
|
||||
}
|
||||
|
||||
+13
-11
@@ -171,7 +171,7 @@ public:
|
||||
};
|
||||
|
||||
// Visualization driver
|
||||
void visualize(ostream &out, Mesh *mesh, GridFunction *deformed_nodes,
|
||||
void visualize(ostream &os, Mesh *mesh, GridFunction *deformed_nodes,
|
||||
GridFunction *field, const char *field_name = NULL,
|
||||
bool init_vis = false);
|
||||
|
||||
@@ -542,10 +542,10 @@ RubberOperator::~RubberOperator()
|
||||
|
||||
|
||||
// Inline visualization
|
||||
void visualize(ostream &out, Mesh *mesh, GridFunction *deformed_nodes,
|
||||
void visualize(ostream &os, Mesh *mesh, GridFunction *deformed_nodes,
|
||||
GridFunction *field, const char *field_name, bool init_vis)
|
||||
{
|
||||
if (!out)
|
||||
if (!os)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -555,23 +555,25 @@ void visualize(ostream &out, Mesh *mesh, GridFunction *deformed_nodes,
|
||||
|
||||
mesh->SwapNodes(nodes, owns_nodes);
|
||||
|
||||
out << "solution\n" << *mesh << *field;
|
||||
os << "solution\n" << *mesh << *field;
|
||||
|
||||
mesh->SwapNodes(nodes, owns_nodes);
|
||||
|
||||
if (init_vis)
|
||||
{
|
||||
out << "window_size 800 800\n";
|
||||
out << "window_title '" << field_name << "'\n";
|
||||
os << "window_size 800 800\n";
|
||||
os << "window_title '" << field_name << "'\n";
|
||||
if (mesh->SpaceDimension() == 2)
|
||||
{
|
||||
out << "view 0 0\n"; // view from top
|
||||
out << "keys jlA\n"; // turn off perspective and light, +anti-aliasing
|
||||
os << "view 0 0\n"; // view from top
|
||||
// turn off perspective and light, +anti-aliasing
|
||||
os << "keys jlA\n";
|
||||
}
|
||||
out << "keys cmA\n"; // show colorbar and mesh, +anti-aliasing
|
||||
out << "autoscale value\n"; // update value-range; keep mesh-extents fixed
|
||||
os << "keys cmA\n"; // show colorbar and mesh, +anti-aliasing
|
||||
// update value-range; keep mesh-extents fixed
|
||||
os << "autoscale value\n";
|
||||
}
|
||||
out << flush;
|
||||
os << flush;
|
||||
}
|
||||
|
||||
void ReferenceConfiguration(const Vector &x, Vector &y)
|
||||
|
||||
+22
-17
@@ -185,7 +185,8 @@ public:
|
||||
};
|
||||
|
||||
// Visualization driver
|
||||
void visualize(ostream &out, ParMesh *mesh, ParGridFunction *deformed_nodes,
|
||||
void visualize(ostream &os, ParMesh *mesh,
|
||||
ParGridFunction *deformed_nodes,
|
||||
ParGridFunction *field, const char *field_name = NULL,
|
||||
bool init_vis = false);
|
||||
|
||||
@@ -196,10 +197,10 @@ void InitialDeformation(const Vector &x, Vector &y);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef HYPRE_USING_CUDA
|
||||
#ifdef HYPRE_USING_GPU
|
||||
cout << "\nAs of mfem-4.3 and hypre-2.22.0 (July 2021) this example\n"
|
||||
<< "is NOT supported with the CUDA version of hypre.\n\n";
|
||||
return 255;
|
||||
<< "is NOT supported with the GPU version of hypre.\n\n";
|
||||
return 242;
|
||||
#endif
|
||||
|
||||
// 1. Initialize MPI
|
||||
@@ -486,8 +487,8 @@ void JacobianPreconditioner::SetOperator(const Operator &op)
|
||||
|
||||
if (!spaces[0]->GetParMesh()->Nonconforming())
|
||||
{
|
||||
#ifndef HYPRE_USING_CUDA
|
||||
// Not available yet when hypre is built with CUDA
|
||||
#if !defined(HYPRE_USING_GPU)
|
||||
// Not available yet when hypre is built with GPU support
|
||||
stiff_prec_amg->SetElasticityOptions(spaces[0]);
|
||||
#endif
|
||||
}
|
||||
@@ -617,10 +618,11 @@ RubberOperator::~RubberOperator()
|
||||
|
||||
|
||||
// Inline visualization
|
||||
void visualize(ostream &out, ParMesh *mesh, ParGridFunction *deformed_nodes,
|
||||
void visualize(ostream &os, ParMesh *mesh,
|
||||
ParGridFunction *deformed_nodes,
|
||||
ParGridFunction *field, const char *field_name, bool init_vis)
|
||||
{
|
||||
if (!out)
|
||||
if (!os)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -630,24 +632,27 @@ void visualize(ostream &out, ParMesh *mesh, ParGridFunction *deformed_nodes,
|
||||
|
||||
mesh->SwapNodes(nodes, owns_nodes);
|
||||
|
||||
out << "parallel " << mesh->GetNRanks() << " " << mesh->GetMyRank() << "\n";
|
||||
out << "solution\n" << *mesh << *field;
|
||||
os << "parallel " << mesh->GetNRanks() << " " << mesh->GetMyRank() <<
|
||||
"\n";
|
||||
os << "solution\n" << *mesh << *field;
|
||||
|
||||
mesh->SwapNodes(nodes, owns_nodes);
|
||||
|
||||
if (init_vis)
|
||||
{
|
||||
out << "window_size 800 800\n";
|
||||
out << "window_title '" << field_name << "'\n";
|
||||
os << "window_size 800 800\n";
|
||||
os << "window_title '" << field_name << "'\n";
|
||||
if (mesh->SpaceDimension() == 2)
|
||||
{
|
||||
out << "view 0 0\n"; // view from top
|
||||
out << "keys jlA\n"; // turn off perspective and light, +anti-aliasing
|
||||
os << "view 0 0\n"; // view from top
|
||||
// turn off perspective and light, +anti-aliasing
|
||||
os << "keys jlA\n";
|
||||
}
|
||||
out << "keys cmA\n"; // show colorbar and mesh, +anti-aliasing
|
||||
out << "autoscale value\n"; // update value-range; keep mesh-extents fixed
|
||||
os << "keys cmA\n"; // show colorbar and mesh, +anti-aliasing
|
||||
// update value-range; keep mesh-extents fixed
|
||||
os << "autoscale value\n";
|
||||
}
|
||||
out << flush;
|
||||
os << flush;
|
||||
}
|
||||
|
||||
void ReferenceConfiguration(const Vector &x, Vector &y)
|
||||
|
||||
+19
-18
@@ -75,7 +75,7 @@ Mesh * GenerateSerialMesh(int ref);
|
||||
// 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 &err);
|
||||
double &error);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -302,26 +302,26 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate the solution on the Dirichlet boundary and compare to the
|
||||
// expected value.
|
||||
double err, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, err);
|
||||
double error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
|
||||
|
||||
bool hom_dbc = (dbc_val == 0.0);
|
||||
err /= hom_dbc ? 1.0 : fabs(dbc_val);
|
||||
error /= hom_dbc ? 1.0 : fabs(dbc_val);
|
||||
mfem::out << "Average of solution on Gamma_dbc:\t"
|
||||
<< avg << ", \t"
|
||||
<< (hom_dbc ? "absolute" : "relative")
|
||||
<< " error " << err << endl;
|
||||
<< " error " << error << endl;
|
||||
}
|
||||
{
|
||||
// Integrate n.Grad(u) on the inhomogeneous Neumann boundary and compare
|
||||
// to the expected value.
|
||||
double err, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, err);
|
||||
double error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
|
||||
|
||||
bool hom_nbc = (nbc_val == 0.0);
|
||||
err /= hom_nbc ? 1.0 : fabs(nbc_val);
|
||||
error /= hom_nbc ? 1.0 : fabs(nbc_val);
|
||||
mfem::out << "Average of n.Grad(u) on Gamma_nbc:\t"
|
||||
<< avg << ", \t"
|
||||
<< (hom_nbc ? "absolute" : "relative")
|
||||
<< " error " << err << endl;
|
||||
<< " error " << error << endl;
|
||||
}
|
||||
{
|
||||
// Integrate n.Grad(u) on the homogeneous Neumann boundary and compare to
|
||||
@@ -330,25 +330,26 @@ int main(int argc, char *argv[])
|
||||
nbc0_bdr = 0;
|
||||
nbc0_bdr[3] = 1;
|
||||
|
||||
double err, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, err);
|
||||
double 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"
|
||||
<< avg << ", \t"
|
||||
<< (hom_nbc ? "absolute" : "relative")
|
||||
<< " error " << err << endl;
|
||||
<< " error " << error << endl;
|
||||
}
|
||||
{
|
||||
// Integrate n.Grad(u) + a * u on the Robin boundary and compare to the
|
||||
// expected value.
|
||||
double err, avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val, err);
|
||||
double error;
|
||||
double avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val, error);
|
||||
|
||||
bool hom_rbc = (rbc_b_val == 0.0);
|
||||
err /= hom_rbc ? 1.0 : fabs(rbc_b_val);
|
||||
error /= hom_rbc ? 1.0 : fabs(rbc_b_val);
|
||||
mfem::out << "Average of n.Grad(u)+a*u on Gamma_rbc:\t"
|
||||
<< avg << ", \t"
|
||||
<< (hom_rbc ? "absolute" : "relative")
|
||||
<< " error " << err << endl;
|
||||
<< " error " << error << endl;
|
||||
}
|
||||
|
||||
// 14. Save the refined mesh and the solution. This output can be viewed
|
||||
@@ -637,11 +638,11 @@ Mesh * GenerateSerialMesh(int ref)
|
||||
|
||||
double IntegrateBC(const GridFunction &x, const Array<int> &bdr,
|
||||
double alpha, double beta, double gamma,
|
||||
double &err)
|
||||
double &error)
|
||||
{
|
||||
double nrm = 0.0;
|
||||
double avg = 0.0;
|
||||
err = 0.0;
|
||||
error = 0.0;
|
||||
|
||||
const bool a_is_zero = alpha == 0.0;
|
||||
const bool b_is_zero = beta == 0.0;
|
||||
@@ -705,20 +706,20 @@ double IntegrateBC(const GridFunction &x, const Array<int> &bdr,
|
||||
|
||||
// Integrate |alpha * n.Grad(x) + beta * x - gamma|^2
|
||||
val -= gamma;
|
||||
err += (val*val) * ip.weight * face_weight;
|
||||
error += (val*val) * ip.weight * face_weight;
|
||||
}
|
||||
}
|
||||
|
||||
// Normalize by the length of the boundary
|
||||
if (std::abs(nrm) > 0.0)
|
||||
{
|
||||
err /= nrm;
|
||||
error /= nrm;
|
||||
avg /= nrm;
|
||||
}
|
||||
|
||||
// Compute l2 norm of the error in the boundary condition (negative
|
||||
// quadrature weights may produce negative 'err')
|
||||
err = (err >= 0.0) ? sqrt(err) : -sqrt(-err);
|
||||
// quadrature weights may produce negative 'error')
|
||||
error = (error >= 0.0) ? sqrt(error) : -sqrt(-error);
|
||||
|
||||
// Return the average value of alpha * n.Grad(x) + beta * x
|
||||
return avg;
|
||||
|
||||
+17
-16
@@ -75,7 +75,7 @@ Mesh * GenerateSerialMesh(int ref);
|
||||
// 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 &err);
|
||||
double &error);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -321,26 +321,26 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// Integrate the solution on the Dirichlet boundary and compare to the
|
||||
// expected value.
|
||||
double err, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, err);
|
||||
double error, avg = IntegrateBC(u, dbc_bdr, 0.0, 1.0, dbc_val, error);
|
||||
|
||||
bool hom_dbc = (dbc_val == 0.0);
|
||||
err /= hom_dbc ? 1.0 : fabs(dbc_val);
|
||||
error /= hom_dbc ? 1.0 : fabs(dbc_val);
|
||||
mfem::out << "Average of solution on Gamma_dbc:\t"
|
||||
<< avg << ", \t"
|
||||
<< (hom_dbc ? "absolute" : "relative")
|
||||
<< " error " << err << endl;
|
||||
<< " error " << error << endl;
|
||||
}
|
||||
{
|
||||
// Integrate n.Grad(u) on the inhomogeneous Neumann boundary and compare
|
||||
// to the expected value.
|
||||
double err, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, err);
|
||||
double error, avg = IntegrateBC(u, nbc_bdr, 1.0, 0.0, nbc_val, error);
|
||||
|
||||
bool hom_nbc = (nbc_val == 0.0);
|
||||
err /= hom_nbc ? 1.0 : fabs(nbc_val);
|
||||
error /= hom_nbc ? 1.0 : fabs(nbc_val);
|
||||
mfem::out << "Average of n.Grad(u) on Gamma_nbc:\t"
|
||||
<< avg << ", \t"
|
||||
<< (hom_nbc ? "absolute" : "relative")
|
||||
<< " error " << err << endl;
|
||||
<< " error " << error << endl;
|
||||
}
|
||||
{
|
||||
// Integrate n.Grad(u) on the homogeneous Neumann boundary and compare to
|
||||
@@ -349,25 +349,26 @@ int main(int argc, char *argv[])
|
||||
nbc0_bdr = 0;
|
||||
nbc0_bdr[3] = 1;
|
||||
|
||||
double err, avg = IntegrateBC(u, nbc0_bdr, 1.0, 0.0, 0.0, err);
|
||||
double 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"
|
||||
<< avg << ", \t"
|
||||
<< (hom_nbc ? "absolute" : "relative")
|
||||
<< " error " << err << endl;
|
||||
<< " error " << error << endl;
|
||||
}
|
||||
{
|
||||
// Integrate n.Grad(u) + a * u on the Robin boundary and compare to the
|
||||
// expected value.
|
||||
double err, avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val, err);
|
||||
double error, avg = IntegrateBC(u, rbc_bdr, 1.0, rbc_a_val, rbc_b_val,
|
||||
error);
|
||||
|
||||
bool hom_rbc = (rbc_b_val == 0.0);
|
||||
err /= hom_rbc ? 1.0 : fabs(rbc_b_val);
|
||||
error /= hom_rbc ? 1.0 : fabs(rbc_b_val);
|
||||
mfem::out << "Average of n.Grad(u)+a*u on Gamma_rbc:\t"
|
||||
<< avg << ", \t"
|
||||
<< (hom_rbc ? "absolute" : "relative")
|
||||
<< " error " << err << endl;
|
||||
<< " error " << error << endl;
|
||||
}
|
||||
|
||||
// 15. Save the refined mesh and the solution in parallel. This output can be
|
||||
@@ -667,11 +668,11 @@ double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
|
||||
double loc_vals[3];
|
||||
double &nrm = loc_vals[0];
|
||||
double &avg = loc_vals[1];
|
||||
double &err = loc_vals[2];
|
||||
double &error = loc_vals[2];
|
||||
|
||||
nrm = 0.0;
|
||||
avg = 0.0;
|
||||
err = 0.0;
|
||||
error = 0.0;
|
||||
|
||||
const bool a_is_zero = alpha == 0.0;
|
||||
const bool b_is_zero = beta == 0.0;
|
||||
@@ -735,7 +736,7 @@ double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
|
||||
|
||||
// Integrate |alpha * n.Grad(x) + beta * x - gamma|^2
|
||||
val -= gamma;
|
||||
err += (val*val) * ip.weight * face_weight;
|
||||
error += (val*val) * ip.weight * face_weight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,7 +755,7 @@ double IntegrateBC(const ParGridFunction &x, const Array<int> &bdr,
|
||||
}
|
||||
|
||||
// Compute l2 norm of the error in the boundary condition (negative
|
||||
// quadrature weights may produce negative 'err')
|
||||
// quadrature weights may produce negative 'error')
|
||||
glb_err = (glb_err >= 0.0) ? sqrt(glb_err) : -sqrt(-glb_err);
|
||||
|
||||
// Return the average value of alpha * n.Grad(x) + beta * x
|
||||
|
||||
+3
-3
@@ -81,10 +81,10 @@ Mesh * build_trapezoid_mesh(double offset)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef HYPRE_USING_CUDA
|
||||
#ifdef HYPRE_USING_GPU
|
||||
cout << "\nAs of mfem-4.3 and hypre-2.22.0 (July 2021) this example\n"
|
||||
<< "is NOT supported with the CUDA version of hypre.\n\n";
|
||||
return 255;
|
||||
<< "is NOT supported with the GPU version of hypre.\n\n";
|
||||
return 242;
|
||||
#endif
|
||||
|
||||
// 1. Initialize MPI.
|
||||
|
||||
+2
-2
@@ -167,9 +167,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 13. Compute error in the solution and its flux
|
||||
FunctionCoefficient uCoef(uExact);
|
||||
double err = x.ComputeL2Error(uCoef);
|
||||
double error = x.ComputeL2Error(uCoef);
|
||||
|
||||
cout << "|u - u_h|_2 = " << err << endl;
|
||||
cout << "|u - u_h|_2 = " << error << endl;
|
||||
|
||||
FiniteElementSpace flux_fespace(mesh, &fec, 3);
|
||||
GridFunction flux(&flux_fespace);
|
||||
|
||||
+2
-2
@@ -197,9 +197,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 15. Compute error in the solution and its flux
|
||||
FunctionCoefficient uCoef(uExact);
|
||||
double err = x.ComputeL2Error(uCoef);
|
||||
double error = x.ComputeL2Error(uCoef);
|
||||
|
||||
if (myid == 0) { cout << "|u - u_h|_2 = " << err << endl; }
|
||||
if (myid == 0) { cout << "|u - u_h|_2 = " << error << endl; }
|
||||
|
||||
ParFiniteElementSpace flux_fespace(&pmesh, &fec, 3);
|
||||
ParGridFunction flux(&flux_fespace);
|
||||
|
||||
+2
-2
@@ -255,10 +255,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 15. Compute and print the L^2 norm of the error.
|
||||
{
|
||||
double err = x.ComputeL2Error(E);
|
||||
double error = x.ComputeL2Error(E);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\n|| E_h - E ||_{L^2} = " << err << '\n' << endl;
|
||||
cout << "\n|| E_h - E ||_{L^2} = " << error << '\n' << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -256,10 +256,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
// 15. Compute and print the L^2 norm of the error.
|
||||
{
|
||||
double err = x.ComputeL2Error(F);
|
||||
double error = x.ComputeL2Error(F);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\n|| F_h - F ||_{L^2} = " << err << '\n' << endl;
|
||||
cout << "\n|| F_h - F ||_{L^2} = " << error << '\n' << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -197,7 +197,7 @@ int main(int argc, char *argv[])
|
||||
SparseMatrix &M(mVarf->SpMat());
|
||||
SparseMatrix &B(bVarf->SpMat());
|
||||
B *= -1.;
|
||||
if (Device::IsEnabled()) { B.BuildTranspose(); }
|
||||
B.EnsureMultTranspose();
|
||||
Bt = new TransposeOperator(&B);
|
||||
|
||||
darcyOp.SetBlock(0,0, &M);
|
||||
|
||||
+2
-2
@@ -282,10 +282,10 @@ int main(int argc, char *argv[])
|
||||
delete b;
|
||||
|
||||
// 12. Compute and print the L^2 norm of the error.
|
||||
double err = x.ComputeL2Error(sol_coef);
|
||||
double error = x.ComputeL2Error(sol_coef);
|
||||
if (myid == 0)
|
||||
{
|
||||
cout << "\nL2 norm of error: " << err << endl;
|
||||
cout << "\nL2 norm of error: " << error << endl;
|
||||
}
|
||||
|
||||
// 13. Save the refined mesh and the solution. This output can be viewed
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
// ex9 -pa -m ../data/periodic-cube.mesh -d cuda
|
||||
// ex9 -ea -m ../data/periodic-cube.mesh -d cuda
|
||||
// ex9 -fa -m ../data/periodic-cube.mesh -d cuda
|
||||
// ex9 -pa -m ../data/amr-quad.mesh -p 1 -r 2 -dt 0.002 -tf 9 -d cuda
|
||||
//
|
||||
// Description: This example code solves the time-dependent advection equation
|
||||
// du/dt + v.grad(u) = 0, where v is a given fluid velocity, and
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
// mpirun -np 4 ex9p -pa -m ../data/periodic-cube.mesh -d cuda
|
||||
// mpirun -np 4 ex9p -ea -m ../data/periodic-cube.mesh -d cuda
|
||||
// mpirun -np 4 ex9p -fa -m ../data/periodic-cube.mesh -d cuda
|
||||
// mpirun -np 4 ex9p -pa -m ../data/amr-quad.mesh -p 1 -rp 1 -dt 0.002 -tf 9 -d cuda
|
||||
//
|
||||
// Description: This example code solves the time-dependent advection equation
|
||||
// du/dt + v.grad(u) = 0, where v is a given fluid velocity, and
|
||||
|
||||
+19
-3
@@ -31,6 +31,10 @@
|
||||
// also illustrated. The example also shows how to form a linear
|
||||
// system using a PETSc matrix and solve with a PETSc solver.
|
||||
//
|
||||
// The example also show how to use the non-overlapping feature of
|
||||
// the ParBilinearForm class to obtain the linear operator in
|
||||
// a format suitable for the BDDC preconditioner in PETSc.
|
||||
//
|
||||
// We recommend viewing Example 1 before viewing this example.
|
||||
|
||||
#include "mfem.hpp"
|
||||
@@ -61,10 +65,15 @@ int main(int argc, char *argv[])
|
||||
bool use_petsc = true;
|
||||
const char *petscrc_file = "";
|
||||
bool use_nonoverlapping = false;
|
||||
int ser_ref_levels = -1, par_ref_levels = 1;
|
||||
|
||||
OptionsParser args(argc, argv);
|
||||
args.AddOption(&mesh_file, "-m", "--mesh",
|
||||
"Mesh file to use.");
|
||||
args.AddOption(&ser_ref_levels, "-rs", "--refine-serial",
|
||||
"Number of times to refine the mesh uniformly in serial.");
|
||||
args.AddOption(&par_ref_levels, "-rp", "--refine-parallel",
|
||||
"Number of times to refine the mesh uniformly in parallel.");
|
||||
args.AddOption(&order, "-o", "--order",
|
||||
"Finite element order (polynomial degree).");
|
||||
args.AddOption(&amg_elast, "-elast", "--amg-for-elasticity", "-sys",
|
||||
@@ -131,8 +140,8 @@ int main(int argc, char *argv[])
|
||||
// 'ref_levels' to be the largest number that gives a final mesh with no
|
||||
// more than 1,000 elements.
|
||||
{
|
||||
int ref_levels =
|
||||
(int)floor(log(1000./mesh->GetNE())/log(2.)/dim);
|
||||
int ref_levels = ser_ref_levels >= 0 ? ser_ref_levels :
|
||||
(int)floor(log(1000./mesh->GetNE())/log(2.)/dim);
|
||||
for (int l = 0; l < ref_levels; l++)
|
||||
{
|
||||
mesh->UniformRefinement();
|
||||
@@ -145,7 +154,6 @@ int main(int argc, char *argv[])
|
||||
ParMesh *pmesh = new ParMesh(MPI_COMM_WORLD, *mesh);
|
||||
delete mesh;
|
||||
{
|
||||
int par_ref_levels = 1;
|
||||
for (int l = 0; l < par_ref_levels; l++)
|
||||
{
|
||||
pmesh->UniformRefinement();
|
||||
@@ -296,12 +304,20 @@ int main(int argc, char *argv[])
|
||||
PetscPreconditioner *prec = NULL;
|
||||
if (use_nonoverlapping)
|
||||
{
|
||||
// Compute dofs belonging to the natural boundary
|
||||
Array<int> nat_tdof_list, nat_bdr(pmesh->bdr_attributes.Max());
|
||||
nat_bdr = 1;
|
||||
nat_bdr[0] = 0;
|
||||
fespace->GetEssentialTrueDofs(nat_bdr, nat_tdof_list);
|
||||
|
||||
// Auxiliary class for BDDC customization
|
||||
PetscBDDCSolverParams opts;
|
||||
// Inform the solver about the finite element space
|
||||
opts.SetSpace(fespace);
|
||||
// Inform the solver about essential dofs
|
||||
opts.SetEssBdrDofs(&ess_tdof_list);
|
||||
// Inform the solver about natural dofs
|
||||
opts.SetNatBdrDofs(&nat_tdof_list);
|
||||
// Create a BDDC solver with parameters
|
||||
prec = new PetscBDDCSolver(A,opts);
|
||||
pcg->SetPreconditioner(*prec);
|
||||
|
||||
@@ -77,6 +77,7 @@ EX1_ARGS_P := -m ../../data/amr-quad.mesh --usepetsc --petscopts rc_e
|
||||
EX1_ARGS_CUDA := -m ../../data/star.mesh --usepetsc --partial-assembly --device cuda --petscopts rc_ex1p_cuda
|
||||
EX1_ARGS_CUDAAMG := -m ../../data/star.mesh --usepetsc --device cuda --petscopts rc_ex1p_cudaamg
|
||||
EX2_ARGS := -m ../../data/beam-quad.mesh --usepetsc --petscopts rc_ex2p
|
||||
EX2_ARGS_BDDC := -m ../../data/beam-tri.mesh --usepetsc --nonoverlapping --petscopts rc_ex2p_bddc
|
||||
EX3_ARGS := -m ../../data/klein-bottle.mesh -o 2 -f 0.1 --usepetsc --petscopts rc_ex3p_bddc --nonoverlapping
|
||||
EX4_ARGS := -m ../../data/klein-bottle.mesh -o 2 --usepetsc --petscopts rc_ex4p_bddc --nonoverlapping
|
||||
EX4_HYB_ARGS := -m ../../data/klein-bottle.mesh -o 2 --usepetsc --petscopts rc_ex4p_bddc --nonoverlapping --hybridization
|
||||
@@ -107,6 +108,7 @@ ifeq ($(MFEM_USE_CUDA),YES)
|
||||
endif
|
||||
ex2p-test-par: ex2p
|
||||
@$(call mfem-test,$<, $(RUN_MPI), $(TESTNAME),$(EX2_ARGS))
|
||||
@$(call mfem-test,$<, $(RUN_MPI), $(TESTNAME),$(EX2_ARGS_BDDC))
|
||||
ex3p-test-par: ex3p
|
||||
@$(call mfem-test,$<, $(RUN_MPI), $(TESTNAME),$(EX3_ARGS))
|
||||
ex4p-test-par: ex4p
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# Sample options for BDDC
|
||||
|
||||
-ksp_converged_reason
|
||||
-ksp_view
|
||||
-pc_type bddc
|
||||
|
||||
# Turn on diagnostic for errors
|
||||
#-pc_bddc_check_level 1
|
||||
|
||||
# This is an H1 problem, local problems may be singular
|
||||
# Turn on automatic corner selection
|
||||
-pc_bddc_corner_selection
|
||||
|
||||
# Advanced customization
|
||||
|
||||
# Deluxe scaling
|
||||
-pc_bddc_use_deluxe_scaling
|
||||
|
||||
# Adaptive primal space (requires PETSc configured with MUMPS or PARDISO support)
|
||||
#-pc_bddc_adaptive_threshold 1.2 # tolerance for eigenvalue selection
|
||||
#-pc_bddc_adaptive_userdefined # preserve RBMs
|
||||
#-pc_bddc_monolithic # treat all displacements components at once -> smaller primal spaces, larger eigenvalue problems
|
||||
|
||||
# Select solver for coarse problem
|
||||
# -pc_bddc_coarse_pc_type cholesky
|
||||
@@ -145,7 +145,7 @@ int main(int argc, char *argv[])
|
||||
// Perform Uniform refinement
|
||||
if (ref_levels > 1)
|
||||
{
|
||||
ma::Input* uniInput = ma::configureUniformRefine(pumi_mesh, ref_levels);
|
||||
auto uniInput = ma::configureUniformRefine(pumi_mesh, ref_levels);
|
||||
|
||||
if (geom_order > 1)
|
||||
{
|
||||
|
||||
@@ -150,7 +150,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (ref_levels > 1)
|
||||
{
|
||||
ma::Input* uniInput = ma::configureUniformRefine(pumi_mesh, ref_levels);
|
||||
auto uniInput = ma::configureUniformRefine(pumi_mesh, ref_levels);
|
||||
|
||||
if ( geom_order > 1)
|
||||
{
|
||||
@@ -345,9 +345,7 @@ int main(int argc, char *argv[])
|
||||
apf::destroyField(ipfield);
|
||||
|
||||
// 18. Perform MesAdapt.
|
||||
ma::Input* erinput = ma::configure(pumi_mesh, sizefield);
|
||||
erinput->shouldFixShape = true;
|
||||
erinput->maximumIterations = 2;
|
||||
auto erinput = ma::configure(pumi_mesh, sizefield);
|
||||
if ( geom_order > 1)
|
||||
{
|
||||
crv::adapt(erinput);
|
||||
|
||||
@@ -514,6 +514,10 @@ void EABilinearFormExtension::Assemble()
|
||||
|
||||
Array<BilinearFormIntegrator*> &integrators = *a->GetDBFI();
|
||||
const int integratorCount = integrators.Size();
|
||||
if ( integratorCount == 0 )
|
||||
{
|
||||
ea_data = 0.0;
|
||||
}
|
||||
for (int i = 0; i < integratorCount; ++i)
|
||||
{
|
||||
integrators[i]->AssembleEA(*a->FESpace(), ea_data, i);
|
||||
|
||||
@@ -182,22 +182,26 @@ void DGTraceIntegrator::SetupPA(const FiniteElementSpace &fes, FaceType type)
|
||||
auto C = Reshape(vel.HostWrite(), dim, nq, nf);
|
||||
Vector Vq(dim);
|
||||
int f_ind = 0;
|
||||
for (int f = 0; f < fes.GetNF(); ++f)
|
||||
for (int f = 0; f < mesh->GetNumFacesWithGhost(); ++f)
|
||||
{
|
||||
int e1, e2;
|
||||
int inf1, inf2;
|
||||
fes.GetMesh()->GetFaceElements(f, &e1, &e2);
|
||||
fes.GetMesh()->GetFaceInfos(f, &inf1, &inf2);
|
||||
int face_id = inf1 / 64;
|
||||
if ((type==FaceType::Interior && (e2>=0 || (e2<0 && inf2>=0))) ||
|
||||
(type==FaceType::Boundary && e2<0 && inf2<0) )
|
||||
Mesh::FaceInformation face = mesh->GetFaceInformation(f);
|
||||
if (face.IsNonconformingCoarse())
|
||||
{
|
||||
// We skip nonconforming coarse faces as they are treated
|
||||
// by the corresponding nonconforming fine faces.
|
||||
continue;
|
||||
}
|
||||
else if ( face.IsOfFaceType(type) )
|
||||
{
|
||||
const int mask = FaceElementTransformations::HAVE_ELEM1 |
|
||||
FaceElementTransformations::HAVE_LOC1;
|
||||
FaceElementTransformations &T =
|
||||
*fes.GetMesh()->GetFaceElementTransformations(f);
|
||||
*fes.GetMesh()->GetFaceElementTransformations(f, mask);
|
||||
for (int q = 0; q < nq; ++q)
|
||||
{
|
||||
// Convert to lexicographic ordering
|
||||
int iq = ToLexOrdering(dim, face_id, quad1D, q);
|
||||
int iq = ToLexOrdering(dim, face.element[0].local_face_id,
|
||||
quad1D, q);
|
||||
T.SetAllIntPoints(&ir->IntPoint(q));
|
||||
const IntegrationPoint &eip1 = T.GetElement1IntPoint();
|
||||
u->Eval(Vq, *T.Elem1, eip1);
|
||||
@@ -242,29 +246,31 @@ void DGTraceIntegrator::SetupPA(const FiniteElementSpace &fes, FaceType type)
|
||||
auto n = Reshape(geom->normal.HostRead(), nq, dim, nf);
|
||||
auto C = Reshape(r.HostWrite(), nq, nf);
|
||||
int f_ind = 0;
|
||||
for (int f = 0; f < fes.GetNF(); ++f)
|
||||
for (int f = 0; f < mesh->GetNumFacesWithGhost(); ++f)
|
||||
{
|
||||
int e1, e2;
|
||||
int inf1, inf2;
|
||||
fes.GetMesh()->GetFaceElements(f, &e1, &e2);
|
||||
fes.GetMesh()->GetFaceInfos(f, &inf1, &inf2);
|
||||
int face_id = inf1 / 64;
|
||||
if ((type==FaceType::Interior && (e2>=0 || (e2<0 && inf2>=0))) ||
|
||||
(type==FaceType::Boundary && e2<0 && inf2<0) )
|
||||
Mesh::FaceInformation face = mesh->GetFaceInformation(f);
|
||||
if (face.IsNonconformingCoarse())
|
||||
{
|
||||
// We skip nonconforming coarse faces as they are treated
|
||||
// by the corresponding nonconforming fine faces.
|
||||
continue;
|
||||
}
|
||||
else if ( face.IsOfFaceType(type) )
|
||||
{
|
||||
FaceElementTransformations &T =
|
||||
*fes.GetMesh()->GetFaceElementTransformations(f);
|
||||
for (int q = 0; q < nq; ++q)
|
||||
{
|
||||
// Convert to lexicographic ordering
|
||||
int iq = ToLexOrdering(dim, face_id, quad1D, q);
|
||||
int iq = ToLexOrdering(dim, face.element[0].local_face_id,
|
||||
quad1D, q);
|
||||
|
||||
T.SetAllIntPoints(&ir->IntPoint(q));
|
||||
const IntegrationPoint &eip1 = T.GetElement1IntPoint();
|
||||
const IntegrationPoint &eip2 = T.GetElement2IntPoint();
|
||||
double r;
|
||||
|
||||
if (inf2 < 0)
|
||||
if ( face.IsBoundary() )
|
||||
{
|
||||
r = rho->Eval(*T.Elem1, eip1);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ void MassIntegrator::AssemblePA(const FiniteElementSpace &fes)
|
||||
ceedOp = new ceed::PAMassIntegrator(fes, *ir, Q);
|
||||
return;
|
||||
}
|
||||
int map_type = el.GetMapType();
|
||||
dim = mesh->Dimension();
|
||||
ne = fes.GetMesh()->GetNE();
|
||||
nq = ir->GetNPoints();
|
||||
@@ -93,6 +94,7 @@ void MassIntegrator::AssemblePA(const FiniteElementSpace &fes)
|
||||
const int NE = ne;
|
||||
const int Q1D = quad1D;
|
||||
const bool const_c = coeff.Size() == 1;
|
||||
const bool by_val = map_type == FiniteElement::VALUE;
|
||||
const auto W = Reshape(ir->GetWeights().Read(), Q1D,Q1D);
|
||||
const auto J = Reshape(geom->J.Read(), Q1D,Q1D,2,2,NE);
|
||||
const auto C = const_c ? Reshape(coeff.Read(), 1,1,1) :
|
||||
@@ -110,7 +112,7 @@ void MassIntegrator::AssemblePA(const FiniteElementSpace &fes)
|
||||
const double J22 = J(qx,qy,1,1,e);
|
||||
const double detJ = (J11*J22)-(J21*J12);
|
||||
const double coeff = const_c ? C(0,0,0) : C(qx,qy,e);
|
||||
v(qx,qy,e) = W(qx,qy) * coeff * detJ;
|
||||
v(qx,qy,e) = W(qx,qy) * coeff * (by_val ? detJ : 1.0/detJ);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -120,6 +122,7 @@ void MassIntegrator::AssemblePA(const FiniteElementSpace &fes)
|
||||
const int NE = ne;
|
||||
const int Q1D = quad1D;
|
||||
const bool const_c = coeff.Size() == 1;
|
||||
const bool by_val = map_type == FiniteElement::VALUE;
|
||||
const auto W = Reshape(ir->GetWeights().Read(), Q1D,Q1D,Q1D);
|
||||
const auto J = Reshape(geom->J.Read(), Q1D,Q1D,Q1D,3,3,NE);
|
||||
const auto C = const_c ? Reshape(coeff.Read(), 1,1,1,1) :
|
||||
@@ -146,7 +149,7 @@ void MassIntegrator::AssemblePA(const FiniteElementSpace &fes)
|
||||
/* */ J21 * (J12 * J33 - J32 * J13) +
|
||||
/* */ J31 * (J12 * J23 - J22 * J13);
|
||||
const double coeff = const_c ? C(0,0,0,0) : C(qx,qy,qz,e);
|
||||
v(qx,qy,qz,e) = W(qx,qy,qz) * coeff * detJ;
|
||||
v(qx,qy,qz,e) = W(qx,qy,qz) * coeff * (by_val ? detJ : 1.0/detJ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,7 +667,7 @@ AlgebraicSpaceHierarchy::AlgebraicSpaceHierarchy(FiniteElementSpace &fes)
|
||||
const SparseMatrix *R = fespaces[ilevel+1]->GetRestrictionMatrix();
|
||||
if (R)
|
||||
{
|
||||
R->BuildTranspose();
|
||||
R->EnsureMultTranspose();
|
||||
R_tr[ilevel] = new TransposeOperator(*R);
|
||||
}
|
||||
else
|
||||
|
||||
+222
-7
@@ -14,6 +14,7 @@
|
||||
#include "fem.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
|
||||
namespace mfem
|
||||
@@ -21,6 +22,42 @@ namespace mfem
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Given an ElementTransformation and IntegrationPoint in a refined mesh,
|
||||
// return the ElementTransformation of the parent coarse element, and set
|
||||
// coarse_ip to the location of the original ip within the coarse element.
|
||||
ElementTransformation *RefinedToCoarse(
|
||||
Mesh &coarse_mesh, const ElementTransformation &T,
|
||||
const IntegrationPoint &ip, IntegrationPoint &coarse_ip)
|
||||
{
|
||||
Mesh &fine_mesh = *T.mesh;
|
||||
// Get the element transformation of the coarse element containing the
|
||||
// fine element.
|
||||
int fine_element = T.ElementNo;
|
||||
const CoarseFineTransformations &cf = fine_mesh.GetRefinementTransforms();
|
||||
int coarse_element = cf.embeddings[fine_element].parent;
|
||||
ElementTransformation *coarse_T = coarse_mesh.GetElementTransformation(
|
||||
coarse_element);
|
||||
// Transform the integration point from fine element coordinates to coarse
|
||||
// element coordinates.
|
||||
Geometry::Type geom = T.GetGeometryType();
|
||||
IntegrationPointTransformation fine_to_coarse;
|
||||
IsoparametricTransformation &emb_tr = fine_to_coarse.Transf;
|
||||
emb_tr.SetIdentityTransformation(geom);
|
||||
emb_tr.SetPointMat(cf.point_matrices[geom](cf.embeddings[fine_element].matrix));
|
||||
fine_to_coarse.Transform(ip, coarse_ip);
|
||||
coarse_T->SetIntPoint(&coarse_ip);
|
||||
return coarse_T;
|
||||
}
|
||||
|
||||
void Coefficient::EvalRevDiff(const double Q_bar,
|
||||
ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar)
|
||||
{
|
||||
MFEM_ABORT("Coefficient::EvalRevDiff\n"
|
||||
"\tEvalRevDiff not implemented for this coefficient!\n");
|
||||
}
|
||||
|
||||
double PWConstCoefficient::Eval(ElementTransformation & T,
|
||||
const IntegrationPoint & ip)
|
||||
{
|
||||
@@ -92,10 +129,48 @@ double FunctionCoefficient::Eval(ElementTransformation & T,
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionCoefficient::EvalRevDiff(const double Q_bar,
|
||||
ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar)
|
||||
{
|
||||
int space_dim = T.GetSpaceDim();
|
||||
double x[3] = {};
|
||||
Vector transip(x, space_dim);
|
||||
T.Transform(ip, transip);
|
||||
|
||||
double x_bar[3] = {};
|
||||
Vector transip_bar(x_bar, space_dim);
|
||||
if (Function)
|
||||
{
|
||||
MFEM_ASSERT(FunctionRevDiff, "EvalRevDiff: reverse-mode differentiated "
|
||||
"version of Function must be provided");
|
||||
FunctionRevDiff(transip, Q_bar, transip_bar);
|
||||
}
|
||||
else
|
||||
{
|
||||
MFEM_ASSERT(TDFunctionRevDiff, "EvalRevDiff: reverse-mode differentiated"
|
||||
" version of TDFunction must be provided");
|
||||
TDFunctionRevDiff(transip, GetTime(), Q_bar, transip_bar);
|
||||
}
|
||||
static_cast<IsoparametricTransformation &>(T).TransformRevDiff(
|
||||
ip, transip_bar, PointMat_bar);
|
||||
}
|
||||
|
||||
double GridFunctionCoefficient::Eval (ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
return GridF -> GetValue (T, ip, Component);
|
||||
Mesh *gf_mesh = GridF->FESpace()->GetMesh();
|
||||
if (T.mesh == gf_mesh)
|
||||
{
|
||||
return GridF->GetValue(T, ip, Component);
|
||||
}
|
||||
else
|
||||
{
|
||||
IntegrationPoint coarse_ip;
|
||||
ElementTransformation *coarse_T = RefinedToCoarse(*gf_mesh, T, ip, coarse_ip);
|
||||
return GridF->GetValue(*coarse_T, coarse_ip, Component);
|
||||
}
|
||||
}
|
||||
|
||||
void TransformedCoefficient::SetTime(double t)
|
||||
@@ -152,6 +227,15 @@ void RestrictedCoefficient::SetTime(double t)
|
||||
this->Coefficient::SetTime(t);
|
||||
}
|
||||
|
||||
void VectorCoefficient::EvalRevDiff(const Vector &V_bar,
|
||||
ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar)
|
||||
{
|
||||
MFEM_ABORT("VectorCoefficient::EvalRevDiff\n"
|
||||
"\tEvalRevDiff not implemented for this coefficient!\n");
|
||||
}
|
||||
|
||||
void VectorCoefficient::Eval(DenseMatrix &M, ElementTransformation &T,
|
||||
const IntegrationRule &ir)
|
||||
{
|
||||
@@ -246,6 +330,35 @@ void VectorFunctionCoefficient::Eval(Vector &V, ElementTransformation &T,
|
||||
}
|
||||
}
|
||||
|
||||
void VectorFunctionCoefficient::EvalRevDiff(const Vector &V_bar,
|
||||
ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar)
|
||||
{
|
||||
MFEM_ASSERT( Q == NULL, "EvalRevDiff: not implemented for use with Q.")
|
||||
|
||||
double x[3];
|
||||
Vector transip(x, vdim);
|
||||
double x_bar[3];
|
||||
Vector transip_bar(x_bar, vdim);
|
||||
T.Transform(ip, transip);
|
||||
transip_bar = 0.0;
|
||||
if (Function)
|
||||
{
|
||||
MFEM_ASSERT(FunctionRevDiff, "EvalRevDiff: reverse-mode differentiated "
|
||||
"version of Function must be provided");
|
||||
FunctionRevDiff(transip, V_bar, transip_bar);
|
||||
}
|
||||
else
|
||||
{
|
||||
MFEM_ASSERT(TDFunctionRevDiff, "EvalRevDiff: reverse-mode differentiated"
|
||||
" version of TDFunction must be provided");
|
||||
TDFunctionRevDiff(transip, GetTime(), V_bar, transip_bar);
|
||||
}
|
||||
static_cast<IsoparametricTransformation &>(T).TransformRevDiff(
|
||||
ip, transip_bar, PointMat_bar);
|
||||
}
|
||||
|
||||
VectorArrayCoefficient::VectorArrayCoefficient (int dim)
|
||||
: VectorCoefficient(dim), Coeff(dim), ownCoeff(dim)
|
||||
{
|
||||
@@ -305,13 +418,30 @@ void VectorGridFunctionCoefficient::SetGridFunction(const GridFunction *gf)
|
||||
void VectorGridFunctionCoefficient::Eval(Vector &V, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
GridFunc->GetVectorValue(T, ip, V);
|
||||
Mesh *gf_mesh = GridFunc->FESpace()->GetMesh();
|
||||
if (T.mesh == gf_mesh)
|
||||
{
|
||||
GridFunc->GetVectorValue(T, ip, V);
|
||||
}
|
||||
else
|
||||
{
|
||||
IntegrationPoint coarse_ip;
|
||||
ElementTransformation *coarse_T = RefinedToCoarse(*gf_mesh, T, ip, coarse_ip);
|
||||
GridFunc->GetVectorValue(*coarse_T, coarse_ip, V);
|
||||
}
|
||||
}
|
||||
|
||||
void VectorGridFunctionCoefficient::Eval(
|
||||
DenseMatrix &M, ElementTransformation &T, const IntegrationRule &ir)
|
||||
{
|
||||
GridFunc->GetVectorValues(T, ir, M);
|
||||
if (T.mesh == GridFunc->FESpace()->GetMesh())
|
||||
{
|
||||
GridFunc->GetVectorValues(T, ir, M);
|
||||
}
|
||||
else
|
||||
{
|
||||
VectorCoefficient::Eval(M, T, ir);
|
||||
}
|
||||
}
|
||||
|
||||
GradientGridFunctionCoefficient::GradientGridFunctionCoefficient (
|
||||
@@ -331,13 +461,30 @@ void GradientGridFunctionCoefficient::SetGridFunction(const GridFunction *gf)
|
||||
void GradientGridFunctionCoefficient::Eval(Vector &V, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
GridFunc->GetGradient(T, V);
|
||||
Mesh *gf_mesh = GridFunc->FESpace()->GetMesh();
|
||||
if (T.mesh == gf_mesh)
|
||||
{
|
||||
GridFunc->GetGradient(T, V);
|
||||
}
|
||||
else
|
||||
{
|
||||
IntegrationPoint coarse_ip;
|
||||
ElementTransformation *coarse_T = RefinedToCoarse(*gf_mesh, T, ip, coarse_ip);
|
||||
GridFunc->GetGradient(*coarse_T, V);
|
||||
}
|
||||
}
|
||||
|
||||
void GradientGridFunctionCoefficient::Eval(
|
||||
DenseMatrix &M, ElementTransformation &T, const IntegrationRule &ir)
|
||||
{
|
||||
GridFunc->GetGradients(T, ir, M);
|
||||
if (T.mesh == GridFunc->FESpace()->GetMesh())
|
||||
{
|
||||
GridFunc->GetGradients(T, ir, M);
|
||||
}
|
||||
else
|
||||
{
|
||||
VectorCoefficient::Eval(M, T, ir);
|
||||
}
|
||||
}
|
||||
|
||||
CurlGridFunctionCoefficient::CurlGridFunctionCoefficient(
|
||||
@@ -363,7 +510,17 @@ void CurlGridFunctionCoefficient::SetGridFunction(const GridFunction *gf)
|
||||
void CurlGridFunctionCoefficient::Eval(Vector &V, ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
GridFunc->GetCurl(T, V);
|
||||
Mesh *gf_mesh = GridFunc->FESpace()->GetMesh();
|
||||
if (T.mesh == gf_mesh)
|
||||
{
|
||||
GridFunc->GetCurl(T, V);
|
||||
}
|
||||
else
|
||||
{
|
||||
IntegrationPoint coarse_ip;
|
||||
ElementTransformation *coarse_T = RefinedToCoarse(*gf_mesh, T, ip, coarse_ip);
|
||||
GridFunc->GetCurl(*coarse_T, V);
|
||||
}
|
||||
}
|
||||
|
||||
DivergenceGridFunctionCoefficient::DivergenceGridFunctionCoefficient (
|
||||
@@ -375,7 +532,17 @@ DivergenceGridFunctionCoefficient::DivergenceGridFunctionCoefficient (
|
||||
double DivergenceGridFunctionCoefficient::Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{
|
||||
return GridFunc->GetDivergence(T);
|
||||
Mesh *gf_mesh = GridFunc->FESpace()->GetMesh();
|
||||
if (T.mesh == gf_mesh)
|
||||
{
|
||||
return GridFunc->GetDivergence(T);
|
||||
}
|
||||
else
|
||||
{
|
||||
IntegrationPoint coarse_ip;
|
||||
ElementTransformation *coarse_T = RefinedToCoarse(*gf_mesh, T, ip, coarse_ip);
|
||||
return GridFunc->GetDivergence(*coarse_T);
|
||||
}
|
||||
}
|
||||
|
||||
void VectorDeltaCoefficient::SetTime(double t)
|
||||
@@ -706,6 +873,25 @@ void ProductCoefficient::SetTime(double t)
|
||||
this->Coefficient::SetTime(t);
|
||||
}
|
||||
|
||||
void ProductCoefficient::EvalRevDiff(const double Q_bar,
|
||||
ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar)
|
||||
{
|
||||
if (a == nullptr)
|
||||
{
|
||||
b->EvalRevDiff(Q_bar * aConst, T, ip, PointMat_bar);
|
||||
}
|
||||
else
|
||||
{
|
||||
double a_val = a->Eval(T, ip);
|
||||
double b_val = b->Eval(T, ip);
|
||||
|
||||
a->EvalRevDiff(Q_bar * b_val, T, ip, PointMat_bar);
|
||||
b->EvalRevDiff(Q_bar * a_val, T, ip, PointMat_bar);
|
||||
}
|
||||
}
|
||||
|
||||
void RatioCoefficient::SetTime(double t)
|
||||
{
|
||||
if (a) { a->SetTime(t); }
|
||||
@@ -876,6 +1062,35 @@ void ScalarVectorProductCoefficient::Eval(Vector &V, ElementTransformation &T,
|
||||
V *= sa;
|
||||
}
|
||||
|
||||
void ScalarVectorProductCoefficient::EvalRevDiff(
|
||||
const Vector &V_bar,
|
||||
ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar)
|
||||
{
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector W(V_bar.Size());
|
||||
Vector W_bar(V_bar.Size());
|
||||
#else
|
||||
W.SetSize(V_bar.Size());
|
||||
W_bar.SetSize(V_bar.Size());
|
||||
#endif
|
||||
|
||||
double sa = (a == nullptr) ? aConst : a->Eval(T, ip);
|
||||
b->Eval(W, T, ip);
|
||||
W *= sa;
|
||||
|
||||
/// reverse pass
|
||||
W_bar = 0.0;
|
||||
add(W_bar, sa, V_bar, W_bar);
|
||||
b->EvalRevDiff(W_bar, T, ip, PointMat_bar);
|
||||
if (a != nullptr)
|
||||
{
|
||||
const double sa_bar = V_bar * W;
|
||||
a->EvalRevDiff(sa_bar, T, ip, PointMat_bar);
|
||||
}
|
||||
}
|
||||
|
||||
NormalizedVectorCoefficient::NormalizedVectorCoefficient(VectorCoefficient &A,
|
||||
double tol_)
|
||||
: VectorCoefficient(A.GetVDim()), a(&A), tol(tol_)
|
||||
|
||||
@@ -58,6 +58,21 @@ public:
|
||||
virtual double Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip) = 0;
|
||||
|
||||
/** @brief Reverse-mode differentiation of Eval w.r.t. the mesh node
|
||||
locations in the element described by @a T, accumulating the result in
|
||||
@a PointMat_bar */
|
||||
/** @param[in] Q_bar - derivative of some output w.r.t. result of Eval */
|
||||
/** @param[in] T - an element transformation */
|
||||
/** @param[in] ip - defines location in reference space */
|
||||
/** @param[inout] PointMat_bar - derivative of output w.r.t. mesh nodes */
|
||||
/** @note When this method is called, the caller must make sure that the
|
||||
IntegrationPoint associated with @a T is the same as @a ip. This can be
|
||||
achieved by calling T.SetIntPoint(&ip). */
|
||||
virtual void EvalRevDiff(const double Q_bar,
|
||||
ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar);
|
||||
|
||||
/** @brief Evaluate the coefficient in the element described by @a T at the
|
||||
point @a ip at time @a t. */
|
||||
/** @note When this method is called, the caller must make sure that the
|
||||
@@ -211,7 +226,15 @@ class FunctionCoefficient : public Coefficient
|
||||
{
|
||||
protected:
|
||||
std::function<double(const Vector &)> Function;
|
||||
std::function<void(const Vector &,
|
||||
const double,
|
||||
Vector &)> FunctionRevDiff;
|
||||
|
||||
std::function<double(const Vector &, double)> TDFunction;
|
||||
std::function<void(const Vector &,
|
||||
double,
|
||||
const double,
|
||||
Vector &)> TDFunctionRevDiff;
|
||||
|
||||
public:
|
||||
/// Define a time-independent coefficient from a std function
|
||||
@@ -226,6 +249,23 @@ public:
|
||||
: TDFunction(std::move(TDF))
|
||||
{ }
|
||||
|
||||
/// Construct time-independent coefficient that can be differentiated
|
||||
FunctionCoefficient(std::function<double(const Vector &)> F,
|
||||
std::function<void(const Vector &,
|
||||
const double,
|
||||
Vector &)> dF)
|
||||
: Function(F), FunctionRevDiff(dF)
|
||||
{ }
|
||||
|
||||
/// Construct time-dependent coefficient that can be differentiated
|
||||
FunctionCoefficient(std::function<double(const Vector &, double)> TDF,
|
||||
std::function<void(const Vector &,
|
||||
double,
|
||||
const double,
|
||||
Vector &)> dTDF)
|
||||
: TDFunction(TDF), TDFunctionRevDiff(dTDF)
|
||||
{ }
|
||||
|
||||
/// (DEPRECATED) Define a time-independent coefficient from a C-function
|
||||
/** @deprecated Use the method where the C-function, @a f, uses a const
|
||||
Vector argument instead of Vector. */
|
||||
@@ -247,6 +287,11 @@ public:
|
||||
/// Evaluate the coefficient at @a ip.
|
||||
virtual double Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip);
|
||||
|
||||
virtual void EvalRevDiff(const double Q_bar,
|
||||
ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar);
|
||||
};
|
||||
|
||||
class GridFunction;
|
||||
@@ -456,6 +501,20 @@ public:
|
||||
virtual void Eval(Vector &V, ElementTransformation &T,
|
||||
const IntegrationPoint &ip) = 0;
|
||||
|
||||
/** @brief Reverse-mode differentiation of Eval w.r.t. the mesh node
|
||||
locations in the element described by @a T, accumulating the result in
|
||||
@a PointMat_bar */
|
||||
/** @param[in] V_bar - derivative of some output with respect to `V` */
|
||||
/** @param[in] T - an element transformation */
|
||||
/** @param[in] ip - defines location in reference space */
|
||||
/** @param[inout] PointMat_bar - derivative of output w.r.t. mesh nodes */
|
||||
/** @note When this method is called, the caller must make sure that the
|
||||
IntegrationPoint associated with @a T is the same as @a ip. This can be
|
||||
achieved by calling T.SetIntPoint(&ip). */
|
||||
virtual void EvalRevDiff(const Vector &V_bar, ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar);
|
||||
|
||||
/** @brief Evaluate the vector coefficient in the element described by @a T
|
||||
at all points of @a ir, storing the result in @a M. */
|
||||
/** The dimensions of @a M are GetVDim() by ir.GetNPoints() and they must be
|
||||
@@ -490,6 +549,10 @@ public:
|
||||
virtual void Eval(Vector &V, ElementTransformation &T,
|
||||
const IntegrationPoint &ip) { V = vec; }
|
||||
|
||||
virtual void EvalRevDiff(const Vector &V_bar, ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar) { }
|
||||
|
||||
/// Return a reference to the constant vector in this class.
|
||||
const Vector& GetVec() { return vec; }
|
||||
};
|
||||
@@ -574,6 +637,7 @@ public:
|
||||
/// Evaluate the coefficient.
|
||||
virtual void Eval(Vector &V, ElementTransformation &T,
|
||||
const IntegrationPoint &ip);
|
||||
using VectorCoefficient::Eval;
|
||||
};
|
||||
|
||||
/// A general vector function coefficient
|
||||
@@ -581,8 +645,17 @@ class VectorFunctionCoefficient : public VectorCoefficient
|
||||
{
|
||||
private:
|
||||
std::function<void(const Vector &, Vector &)> Function;
|
||||
std::function<void(const Vector &,
|
||||
const Vector &,
|
||||
Vector &)> FunctionRevDiff;
|
||||
|
||||
std::function<void(const Vector &, double, Vector &)> TDFunction;
|
||||
std::function<void(const Vector &,
|
||||
double,
|
||||
const Vector &,
|
||||
Vector &)> TDFunctionRevDiff;
|
||||
Coefficient *Q;
|
||||
// Coefficient *dQ;
|
||||
|
||||
public:
|
||||
/// Define a time-independent vector coefficient from a std function
|
||||
@@ -605,11 +678,37 @@ public:
|
||||
: VectorCoefficient(dim), TDFunction(std::move(TDF)), Q(q)
|
||||
{ }
|
||||
|
||||
/// Construct time-independent vector coefficient that can be differentiated
|
||||
VectorFunctionCoefficient(int dim,
|
||||
std::function<void(const Vector &,
|
||||
Vector &)> F,
|
||||
std::function<void(const Vector &,
|
||||
const Vector &,
|
||||
Vector &)> dF)
|
||||
: VectorCoefficient(dim), Function(std::move(F)),
|
||||
FunctionRevDiff(std::move(dF)), Q(NULL)
|
||||
{ }
|
||||
|
||||
/// Construct time-dependent vector coefficient that can be differentiated
|
||||
VectorFunctionCoefficient(int dim,
|
||||
std::function<void(const Vector &,
|
||||
double,
|
||||
Vector &)> TDF,
|
||||
std::function<void(const Vector &,
|
||||
double, const Vector &, Vector &)> dTDF)
|
||||
: VectorCoefficient(dim), TDFunction(std::move(TDF)),
|
||||
TDFunctionRevDiff(std::move(dTDF)), Q(NULL)
|
||||
{ }
|
||||
|
||||
using VectorCoefficient::Eval;
|
||||
/// Evaluate the vector coefficient at @a ip.
|
||||
virtual void Eval(Vector &V, ElementTransformation &T,
|
||||
const IntegrationPoint &ip);
|
||||
|
||||
virtual void EvalRevDiff(const Vector &V_bar, ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar);
|
||||
|
||||
virtual ~VectorFunctionCoefficient() { }
|
||||
};
|
||||
|
||||
@@ -1387,6 +1486,11 @@ public:
|
||||
virtual double Eval(ElementTransformation &T,
|
||||
const IntegrationPoint &ip)
|
||||
{ return ((a == NULL ) ? aConst : a->Eval(T, ip) ) * b->Eval(T, ip); }
|
||||
|
||||
void EvalRevDiff(const double Q_bar,
|
||||
ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar);
|
||||
};
|
||||
|
||||
/** @brief Scalar coefficient defined as the ratio of two scalars where one or
|
||||
@@ -1656,6 +1760,9 @@ private:
|
||||
double aConst;
|
||||
Coefficient * a;
|
||||
VectorCoefficient * b;
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
Vector W, W_bar;
|
||||
#endif
|
||||
|
||||
public:
|
||||
/// Constructor with constant and vector coefficient. Result is A * B.
|
||||
@@ -1686,6 +1793,11 @@ public:
|
||||
virtual void Eval(Vector &V, ElementTransformation &T,
|
||||
const IntegrationPoint &ip);
|
||||
using VectorCoefficient::Eval;
|
||||
|
||||
virtual void EvalRevDiff(const Vector &V_bar, ElementTransformation &T,
|
||||
const IntegrationPoint &ip,
|
||||
DenseMatrix &PointMat_bar);
|
||||
|
||||
};
|
||||
|
||||
/// Vector coefficient defined as a normalized vector field (returns v/|v|)
|
||||
|
||||
+2
-2
@@ -1243,7 +1243,7 @@ ParSesquilinearForm::FormLinearSystem(const Array<int> &ess_tdof_list,
|
||||
HypreParMatrix * Ah;
|
||||
A_i.Get(Ah);
|
||||
hypre_ParCSRMatrix *Aih = *Ah;
|
||||
#ifndef HYPRE_USING_CUDA
|
||||
#if !defined(HYPRE_USING_GPU)
|
||||
ess_tdof_list.HostRead();
|
||||
for (int k = 0; k < n; k++)
|
||||
{
|
||||
@@ -1256,7 +1256,7 @@ ParSesquilinearForm::FormLinearSystem(const Array<int> &ess_tdof_list,
|
||||
ess_tdof_list.GetMemory().Read(MemoryClass::DEVICE, n);
|
||||
const int *d_diag_i = Aih->diag->i;
|
||||
double *d_diag_data = Aih->diag->data;
|
||||
CuWrap1D(n, [=] MFEM_DEVICE (int k)
|
||||
MFEM_GPU_FORALL(k, n,
|
||||
{
|
||||
const int j = d_ess_tdof_list[k];
|
||||
d_diag_data[d_diag_i[j]] = 0.0;
|
||||
|
||||
@@ -330,7 +330,7 @@ ConduitDataCollection::BlueprintMeshToMesh(const Node &n_mesh,
|
||||
}
|
||||
else
|
||||
{
|
||||
Node &(n_bndry_conn_conv) =
|
||||
Node &n_bndry_conn_conv =
|
||||
n_conv["topologies"][bndry_topo_name]["elements/connectivity"];
|
||||
n_bndry_conn.to_int_array(n_bndry_conn_conv);
|
||||
bndry_indices = (n_bndry_conn_conv).value();
|
||||
|
||||
+127
-135
@@ -11,6 +11,7 @@
|
||||
|
||||
#include "fem.hpp"
|
||||
#include "../mesh/nurbs.hpp"
|
||||
#include "../mesh/vtk.hpp"
|
||||
#include "../general/binaryio.hpp"
|
||||
#include "../general/text.hpp"
|
||||
#include "picojson.h"
|
||||
@@ -787,53 +788,44 @@ void ParaViewDataCollection::Load(int )
|
||||
|
||||
std::string ParaViewDataCollection::GenerateCollectionPath()
|
||||
{
|
||||
std::string out = "";
|
||||
out = prefix_path + DataCollection::GetCollectionName();
|
||||
return out;
|
||||
return prefix_path + DataCollection::GetCollectionName();
|
||||
}
|
||||
|
||||
std::string ParaViewDataCollection::GeneratePVTUPath()
|
||||
{
|
||||
std::string out = "Cycle" + to_padded_string(cycle,pad_digits_cycle);
|
||||
return out;
|
||||
return "Cycle" + to_padded_string(cycle,pad_digits_cycle);
|
||||
}
|
||||
|
||||
std::string ParaViewDataCollection::GenerateVTUPath()
|
||||
{
|
||||
std::string out = GeneratePVTUPath();
|
||||
return out;
|
||||
return GeneratePVTUPath();
|
||||
}
|
||||
|
||||
std::string ParaViewDataCollection::GeneratePVDFileName()
|
||||
{
|
||||
std::string out = GetCollectionName()+".pvd";
|
||||
return out;
|
||||
return GetCollectionName() + ".pvd";
|
||||
}
|
||||
|
||||
std::string ParaViewDataCollection::GeneratePVTUFileName()
|
||||
std::string ParaViewDataCollection::GeneratePVTUFileName(
|
||||
const std::string &prefix)
|
||||
{
|
||||
std::string out = "data.pvtu";
|
||||
return out;
|
||||
return prefix + ".pvtu";
|
||||
}
|
||||
|
||||
std::string ParaViewDataCollection::GenerateVTUFileName()
|
||||
std::string ParaViewDataCollection::GenerateVTUFileName(
|
||||
const std::string &prefix, int rank)
|
||||
{
|
||||
std::string out = "proc" + to_padded_string(myid,pad_digits_rank)+".vtu";
|
||||
return out;
|
||||
}
|
||||
std::string ParaViewDataCollection::GenerateVTUFileName(int crank)
|
||||
{
|
||||
std::string out = "proc" + to_padded_string(crank,pad_digits_rank)+".vtu";
|
||||
return out;
|
||||
return prefix + to_padded_string(rank, pad_digits_rank) + ".vtu";
|
||||
}
|
||||
|
||||
void ParaViewDataCollection::Save()
|
||||
{
|
||||
// add a new collection to the PDV file
|
||||
|
||||
std::string col_path = GenerateCollectionPath();
|
||||
// check if the directories are created
|
||||
{
|
||||
std::string path = GenerateCollectionPath()+"/"+GenerateVTUPath();
|
||||
std::string path = col_path + "/" + GenerateVTUPath();
|
||||
int err = create_directory(path, mesh, myid);
|
||||
if (err)
|
||||
{
|
||||
@@ -850,8 +842,7 @@ void ParaViewDataCollection::Save()
|
||||
|
||||
if (myid == 0 && !pvd_stream.is_open())
|
||||
{
|
||||
std::string dpath=GenerateCollectionPath();
|
||||
std::string pvdname=dpath+"/"+GeneratePVDFileName();
|
||||
std::string pvdname = col_path + "/" + GeneratePVDFileName();
|
||||
|
||||
bool write_header = true;
|
||||
std::ifstream pvd_in;
|
||||
@@ -915,80 +906,87 @@ void ParaViewDataCollection::Save()
|
||||
}
|
||||
}
|
||||
|
||||
// define the vtu file
|
||||
std::string vtu_prefix = col_path + "/" + GenerateVTUPath() + "/";
|
||||
|
||||
// Save the local part of the mesh and grid functions fields to the local
|
||||
// VTU file
|
||||
{
|
||||
std::string fname = GenerateCollectionPath()+"/"+GenerateVTUPath()+"/"
|
||||
+GenerateVTUFileName();
|
||||
std::fstream out(fname, std::ios::out);
|
||||
std::ofstream out(vtu_prefix + GenerateVTUFileName("proc", myid));
|
||||
out.precision(precision);
|
||||
SaveDataVTU(out,levels_of_detail);
|
||||
out.close();
|
||||
SaveDataVTU(out, levels_of_detail);
|
||||
}
|
||||
|
||||
// define the pvtu file only on process 0
|
||||
if (myid==0)
|
||||
// Save the local part of the quadrature function fields
|
||||
for (const auto &qfield : q_field_map)
|
||||
{
|
||||
std::string fname = GenerateCollectionPath()+"/"+GeneratePVTUPath()+"/"
|
||||
+GeneratePVTUFileName();
|
||||
std::fstream out(fname, std::ios::out);
|
||||
const std::string &field_name = qfield.first;
|
||||
std::ofstream out(vtu_prefix + GenerateVTUFileName(field_name, myid));
|
||||
qfield.second->SaveVTU(out, pv_data_format, compression);
|
||||
}
|
||||
|
||||
out << "<?xml version=\"1.0\"?>\n";
|
||||
out << "<VTKFile type=\"PUnstructuredGrid\"";
|
||||
out << " version =\"0.1\" byte_order=\"" << VTKByteOrder() << "\">\n";
|
||||
out << "<PUnstructuredGrid GhostLevel=\"0\">\n";
|
||||
|
||||
out << "<PPoints>\n";
|
||||
out << "\t<PDataArray type=\"" << GetDataTypeString() << "\" ";
|
||||
out << " Name=\"Points\" NumberOfComponents=\"3\""
|
||||
<< " format=\"" << GetDataFormatString() << "\"/>\n";
|
||||
out << "</PPoints>\n";
|
||||
|
||||
out << "<PCells>\n";
|
||||
out << "\t<PDataArray type=\"Int32\" ";
|
||||
out << " Name=\"connectivity\" NumberOfComponents=\"1\""
|
||||
<< " format=\"" << GetDataFormatString() << "\"/>\n";
|
||||
out << "\t<PDataArray type=\"Int32\" ";
|
||||
out << " Name=\"offsets\" NumberOfComponents=\"1\""
|
||||
<< " format=\"" << GetDataFormatString() << "\"/>\n";
|
||||
out << "\t<PDataArray type=\"UInt8\" ";
|
||||
out << " Name=\"types\" NumberOfComponents=\"1\""
|
||||
<< " format=\"" << GetDataFormatString() << "\"/>\n";
|
||||
out << "</PCells>\n";
|
||||
|
||||
out << "<PPointData>\n";
|
||||
for (FieldMapIterator it=field_map.begin(); it!=field_map.end(); ++it)
|
||||
// MPI rank 0 also creates a "PVTU" file that points to all of the separately
|
||||
// written VTU files.
|
||||
// This file path is then appended to the PVD file.
|
||||
if (myid == 0)
|
||||
{
|
||||
// Create the main PVTU file
|
||||
{
|
||||
int vec_dim=it->second->VectorDim();
|
||||
out << "<PDataArray type=\"" << GetDataTypeString()
|
||||
<< "\" Name=\"" << it->first
|
||||
<< "\" NumberOfComponents=\"" << vec_dim << "\" "
|
||||
<< "format=\"" << GetDataFormatString() << "\" />\n";
|
||||
std::ofstream pvtu_out(vtu_prefix + GeneratePVTUFileName("data"));
|
||||
WritePVTUHeader(pvtu_out);
|
||||
|
||||
// Grid function fields
|
||||
pvtu_out << "<PPointData>\n";
|
||||
for (auto &field_it : field_map)
|
||||
{
|
||||
int vec_dim = field_it.second->VectorDim();
|
||||
pvtu_out << "<PDataArray type=\"" << GetDataTypeString()
|
||||
<< "\" Name=\"" << field_it.first
|
||||
<< "\" NumberOfComponents=\"" << vec_dim << "\" "
|
||||
<< "format=\"" << GetDataFormatString() << "\" />\n";
|
||||
}
|
||||
pvtu_out << "</PPointData>\n";
|
||||
// Element attributes
|
||||
pvtu_out << "<PCellData>\n";
|
||||
pvtu_out << "\t<PDataArray type=\"Int32\" Name=\"" << "attribute"
|
||||
<< "\" NumberOfComponents=\"1\""
|
||||
<< " format=\"" << GetDataFormatString() << "\"/>\n";
|
||||
pvtu_out << "</PCellData>\n";
|
||||
|
||||
WritePVTUFooter(pvtu_out, "proc");
|
||||
}
|
||||
out << "</PPointData>\n";
|
||||
|
||||
// CELL DATA
|
||||
out << "<PCellData>\n";
|
||||
out << "\t<PDataArray type=\"Int32\" Name=\"" << "attribute"
|
||||
<< "\" NumberOfComponents=\"1\""
|
||||
<< " format=\"" << GetDataFormatString() << "\"/>\n";
|
||||
out << "</PCellData>\n";
|
||||
// Add the latest PVTU to the PVD
|
||||
pvd_stream << "<DataSet timestep=\"" << GetTime()
|
||||
<< "\" group=\"\" part=\"" << 0 << "\" file=\""
|
||||
<< GeneratePVTUPath() + "/" + GeneratePVTUFileName("data")
|
||||
<< "\" name=\"mesh\"/>\n";
|
||||
|
||||
for (int ii=0; ii<num_procs; ii++)
|
||||
// Create PVTU files for each quadrature field and add them to the PVD
|
||||
// file
|
||||
for (auto &q_field : q_field_map)
|
||||
{
|
||||
// this one is generated without the path
|
||||
std::string nfname=GenerateVTUFileName(ii);
|
||||
out << "<Piece Source=\"" << nfname << "\"/>\n";
|
||||
}
|
||||
out << "</PUnstructuredGrid>\n";
|
||||
out << "</VTKFile>\n";
|
||||
out.close();
|
||||
const std::string &q_field_name = q_field.first;
|
||||
std::string q_fname = GeneratePVTUPath() + "/"
|
||||
+ GeneratePVTUFileName(q_field_name);
|
||||
|
||||
fname = GeneratePVTUPath()+"/"+GeneratePVTUFileName();
|
||||
// add the pvtu file to the pvd_stream
|
||||
pvd_stream << "<DataSet timestep=\"" << GetTime(); // GetCycle();
|
||||
pvd_stream << "\" group=\"\" part=\"" << 0 << "\" file=\"";
|
||||
pvd_stream << fname << "\"/>\n";
|
||||
std::ofstream pvtu_out(col_path + "/" + q_fname);
|
||||
WritePVTUHeader(pvtu_out);
|
||||
int vec_dim = q_field.second->GetVDim();
|
||||
pvtu_out << "<PPointData>\n";
|
||||
pvtu_out << "<PDataArray type=\"" << GetDataTypeString()
|
||||
<< "\" Name=\"" << q_field_name
|
||||
<< "\" NumberOfComponents=\"" << vec_dim << "\" "
|
||||
<< "format=\"" << GetDataFormatString() << "\" />\n";
|
||||
pvtu_out << "</PPointData>\n";
|
||||
WritePVTUFooter(pvtu_out, q_field_name);
|
||||
|
||||
pvd_stream << "<DataSet timestep=\"" << GetTime()
|
||||
<< "\" group=\"\" part=\"" << 0 << "\" file=\""
|
||||
<< q_fname << "\" name=\"" << q_field_name << "\"/>\n";
|
||||
}
|
||||
pvd_stream.flush();
|
||||
// Move the insertion point before the closing collection tag, so that
|
||||
// the PVD file is valid even when writing incrementally.
|
||||
std::fstream::pos_type pos = pvd_stream.tellp();
|
||||
pvd_stream << "</Collection>\n";
|
||||
pvd_stream << "</VTKFile>" << std::endl;
|
||||
@@ -996,6 +994,44 @@ void ParaViewDataCollection::Save()
|
||||
}
|
||||
}
|
||||
|
||||
void ParaViewDataCollection::WritePVTUHeader(std::ostream &out)
|
||||
{
|
||||
out << "<?xml version=\"1.0\"?>\n";
|
||||
out << "<VTKFile type=\"PUnstructuredGrid\"";
|
||||
out << " version =\"0.1\" byte_order=\"" << VTKByteOrder() << "\">\n";
|
||||
out << "<PUnstructuredGrid GhostLevel=\"0\">\n";
|
||||
|
||||
out << "<PPoints>\n";
|
||||
out << "\t<PDataArray type=\"" << GetDataTypeString() << "\" ";
|
||||
out << " Name=\"Points\" NumberOfComponents=\"3\""
|
||||
<< " format=\"" << GetDataFormatString() << "\"/>\n";
|
||||
out << "</PPoints>\n";
|
||||
|
||||
out << "<PCells>\n";
|
||||
out << "\t<PDataArray type=\"Int32\" ";
|
||||
out << " Name=\"connectivity\" NumberOfComponents=\"1\""
|
||||
<< " format=\"" << GetDataFormatString() << "\"/>\n";
|
||||
out << "\t<PDataArray type=\"Int32\" ";
|
||||
out << " Name=\"offsets\" NumberOfComponents=\"1\""
|
||||
<< " format=\"" << GetDataFormatString() << "\"/>\n";
|
||||
out << "\t<PDataArray type=\"UInt8\" ";
|
||||
out << " Name=\"types\" NumberOfComponents=\"1\""
|
||||
<< " format=\"" << GetDataFormatString() << "\"/>\n";
|
||||
out << "</PCells>\n";
|
||||
}
|
||||
|
||||
void ParaViewDataCollection::WritePVTUFooter(std::ostream &out,
|
||||
const std::string &vtu_prefix)
|
||||
{
|
||||
for (int ii=0; ii<num_procs; ii++)
|
||||
{
|
||||
std::string vtu_filename = GenerateVTUFileName(vtu_prefix, ii);
|
||||
out << "<Piece Source=\"" << vtu_filename << "\"/>\n";
|
||||
}
|
||||
out << "</PUnstructuredGrid>\n";
|
||||
out << "</VTKFile>\n";
|
||||
}
|
||||
|
||||
void ParaViewDataCollection::SaveDataVTU(std::ostream &out, int ref)
|
||||
{
|
||||
out << "<VTKFile type=\"UnstructuredGrid\"";
|
||||
@@ -1015,16 +1051,6 @@ void ParaViewDataCollection::SaveDataVTU(std::ostream &out, int ref)
|
||||
{
|
||||
SaveGFieldVTU(out,ref,it);
|
||||
}
|
||||
// iterate over all quadrature functions
|
||||
// if the Quadrature functions are dumped as cell data
|
||||
// the cycle should be moved before the grid functions
|
||||
// and the PrintVTU CellData section should be open in the mesh dump
|
||||
for (QFieldMapIterator it=q_field_map.begin(); it!=q_field_map.end(); ++it)
|
||||
{
|
||||
// save the quadrature functions
|
||||
// this one is not implemented yet
|
||||
SaveQFieldVTU(out,ref,it);
|
||||
}
|
||||
out << "</PointData>\n";
|
||||
// close the mesh
|
||||
out << "</Piece>\n"; // close the piece open in the PrintVTU method
|
||||
@@ -1032,27 +1058,21 @@ void ParaViewDataCollection::SaveDataVTU(std::ostream &out, int ref)
|
||||
out << "</VTKFile>" << std::endl;
|
||||
}
|
||||
|
||||
void ParaViewDataCollection::SaveQFieldVTU(std::ostream &out, int ref,
|
||||
const QFieldMapIterator& it )
|
||||
{
|
||||
MFEM_WARNING("SaveQFieldVTU is not currently implemented - field name:"<<it->second);
|
||||
}
|
||||
|
||||
void ParaViewDataCollection::SaveGFieldVTU(std::ostream &out, int ref_,
|
||||
const FieldMapIterator& it)
|
||||
const FieldMapIterator &it)
|
||||
{
|
||||
RefinedGeometry *RefG;
|
||||
Vector val;
|
||||
DenseMatrix vval, pmat;
|
||||
std::vector<char> buf;
|
||||
int vec_dim = it->second->VectorDim();
|
||||
out << "<DataArray type=\"" << GetDataTypeString()
|
||||
<< "\" Name=\"" << it->first;
|
||||
out << "\" NumberOfComponents=\"" << vec_dim << "\""
|
||||
<< " format=\"" << GetDataFormatString() << "\" >" << '\n';
|
||||
if (vec_dim == 1)
|
||||
{
|
||||
// scalar data
|
||||
out << "<DataArray type=\"" << GetDataTypeString()
|
||||
<< "\" Name=\"" << it->first;
|
||||
out << "\" NumberOfComponents=\"1\" format=\""
|
||||
<< GetDataFormatString() << "\" >\n";
|
||||
for (int i = 0; i < mesh->GetNE(); i++)
|
||||
{
|
||||
RefG = GlobGeometryRefiner.Refine(
|
||||
@@ -1060,51 +1080,23 @@ void ParaViewDataCollection::SaveGFieldVTU(std::ostream &out, int ref_,
|
||||
it->second->GetValues(i, RefG->RefPts, val, pmat);
|
||||
for (int j = 0; j < val.Size(); j++)
|
||||
{
|
||||
if (pv_data_format == VTKFormat::ASCII)
|
||||
{
|
||||
out << ZeroSubnormal(val(j)) << '\n';
|
||||
}
|
||||
else if (pv_data_format == VTKFormat::BINARY)
|
||||
{
|
||||
bin_io::AppendBytes(buf, val(j));
|
||||
}
|
||||
else
|
||||
{
|
||||
bin_io::AppendBytes<float>(buf, float(val(j)));
|
||||
}
|
||||
WriteBinaryOrASCII(out, buf, val(j), "\n", pv_data_format);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// vector data
|
||||
out << "<DataArray type=\"" << GetDataTypeString()
|
||||
<< "\" Name=\"" << it->first;
|
||||
out << "\" NumberOfComponents=\"" << vec_dim << "\""
|
||||
<< " format=\"" << GetDataFormatString() << "\" >" << '\n';
|
||||
for (int i = 0; i < mesh->GetNE(); i++)
|
||||
{
|
||||
RefG = GlobGeometryRefiner.Refine(
|
||||
mesh->GetElementBaseGeometry(i), ref_, 1);
|
||||
|
||||
it->second->GetVectorValues(i, RefG->RefPts, vval, pmat);
|
||||
|
||||
for (int jj = 0; jj < vval.Width(); jj++)
|
||||
{
|
||||
for (int ii = 0; ii < vval.Height(); ii++)
|
||||
{
|
||||
if (pv_data_format == VTKFormat::ASCII)
|
||||
{
|
||||
out << ZeroSubnormal(vval(ii,jj)) << ' ';
|
||||
}
|
||||
else if (pv_data_format == VTKFormat::BINARY)
|
||||
{
|
||||
bin_io::AppendBytes(buf, vval(ii,jj));
|
||||
}
|
||||
else
|
||||
{
|
||||
bin_io::AppendBytes<float>(buf, float(vval(ii,jj)));
|
||||
}
|
||||
WriteBinaryOrASCII(out, buf, vval(ii,jj), " ", pv_data_format);
|
||||
}
|
||||
if (pv_data_format == VTKFormat::ASCII) { out << '\n'; }
|
||||
}
|
||||
|
||||
@@ -491,19 +491,20 @@ private:
|
||||
bool restart_mode;
|
||||
|
||||
protected:
|
||||
void WritePVTUHeader(std::ostream &out);
|
||||
void WritePVTUFooter(std::ostream &out, const std::string &vtu_prefix);
|
||||
void SaveDataVTU(std::ostream &out, int ref);
|
||||
void SaveGFieldVTU(std::ostream& out, int ref_, const FieldMapIterator& it);
|
||||
void SaveQFieldVTU(std::ostream &out, int ref, const QFieldMapIterator& it);
|
||||
const char *GetDataFormatString() const;
|
||||
const char *GetDataTypeString() const;
|
||||
|
||||
std::string GenerateCollectionPath();
|
||||
std::string GenerateVTUFileName();
|
||||
std::string GenerateVTUFileName(int rank);
|
||||
std::string GenerateVTUPath();
|
||||
std::string GeneratePVDFileName();
|
||||
std::string GeneratePVTUFileName();
|
||||
std::string GeneratePVTUPath();
|
||||
std::string GenerateCollectionPath();
|
||||
std::string GenerateVTUFileName(const std::string &prefix, int rank);
|
||||
std::string GenerateVTUPath();
|
||||
std::string GeneratePVDFileName();
|
||||
std::string GeneratePVTUFileName(const std::string &prefix);
|
||||
std::string GeneratePVTUPath();
|
||||
|
||||
|
||||
public:
|
||||
/// Constructor. The collection name is used when saving the data.
|
||||
|
||||
@@ -243,6 +243,7 @@ public:
|
||||
void TransformDual(double *v) const;
|
||||
|
||||
void InvTransformDual(double *v) const;
|
||||
using DofTransformation::InvTransformDual;
|
||||
};
|
||||
|
||||
/// DoF transformation implementation for the Nedelec basis on tetrahedra
|
||||
|
||||
+78
-1
@@ -21,7 +21,8 @@ ElementTransformation::ElementTransformation()
|
||||
EvalState(0),
|
||||
geom(Geometry::INVALID),
|
||||
Attribute(-1),
|
||||
ElementNo(-1)
|
||||
ElementNo(-1),
|
||||
mesh(nullptr)
|
||||
{ }
|
||||
|
||||
double ElementTransformation::EvalWeight()
|
||||
@@ -531,6 +532,82 @@ void IsoparametricTransformation::Transform (const DenseMatrix &matrix,
|
||||
}
|
||||
}
|
||||
|
||||
void IsoparametricTransformation::TransformRevDiff(const IntegrationPoint &ip,
|
||||
const Vector &x_bar,
|
||||
DenseMatrix &PointMat_bar)
|
||||
{
|
||||
MFEM_ASSERT((PointMat_bar.Width() == PointMat.Width()) &&
|
||||
(PointMat_bar.Height() == PointMat.Height()),
|
||||
"PointMat_bar shape != PointMat shape");
|
||||
shape.SetSize(FElem->GetDof());
|
||||
FElem->CalcShape(ip, shape);
|
||||
AddMultVWt(x_bar, shape, PointMat_bar);
|
||||
}
|
||||
|
||||
void IsoparametricTransformation::JacobianRevDiff(const DenseMatrix &dFdx_bar,
|
||||
DenseMatrix &PointMat_bar)
|
||||
{
|
||||
MFEM_ASSERT((PointMat_bar.Width() == PointMat.Width()) &&
|
||||
(PointMat_bar.Height() == PointMat.Height()),
|
||||
"PointMat_bar shape != PointMat shape");
|
||||
|
||||
dshape.SetSize(FElem->GetDof(), FElem->GetDim());
|
||||
if (dshape.Width() > 0)
|
||||
{
|
||||
// The math here can be found in Giles' report "An extended collection of
|
||||
// matrix derivative results for forward and reverse mode algorithmic
|
||||
// differentiation"
|
||||
FElem->CalcDShape(*IntPoint, dshape);
|
||||
AddMultABt(dFdx_bar, dshape, PointMat_bar);
|
||||
}
|
||||
}
|
||||
|
||||
void IsoparametricTransformation::AdjugateJacobianRevDiff(
|
||||
const DenseMatrix &adjJ_bar, DenseMatrix &PointMat_bar)
|
||||
{
|
||||
Jacobian(); // Recompute the Jacobian, if necessary
|
||||
double dFdx_bar_buffer[9];
|
||||
DenseMatrix dFdx_bar(dFdx_bar_buffer, dFdx.Height(), dFdx.Width());
|
||||
if (dFdx.Width() > 0)
|
||||
{
|
||||
CalcAdjugateRevDiff(dFdx, adjJ_bar, dFdx_bar);
|
||||
}
|
||||
JacobianRevDiff(dFdx_bar, PointMat_bar);
|
||||
}
|
||||
|
||||
void IsoparametricTransformation::InverseJacobianRevDiff(
|
||||
const DenseMatrix &invJ_bar, DenseMatrix &PointMat_bar)
|
||||
{
|
||||
Jacobian(); // Recompute the Jacobian, if necessary
|
||||
double dFdx_bar_buffer[9];
|
||||
DenseMatrix dFdx_bar(dFdx_bar_buffer, dFdx.Height(), dFdx.Width());
|
||||
if (dFdx.Width() > 0)
|
||||
{
|
||||
CalcInverseRevDiff(dFdx, invJ_bar, dFdx_bar);
|
||||
}
|
||||
JacobianRevDiff(dFdx_bar, PointMat_bar);
|
||||
}
|
||||
|
||||
void IsoparametricTransformation::WeightRevDiff(DenseMatrix &PointMat_bar)
|
||||
{
|
||||
Jacobian(); // Recompute the Jacobian, if necessary
|
||||
double dFdx_bar_buffer[9];
|
||||
DenseMatrix dFdx_bar(dFdx_bar_buffer, dFdx.Height(), dFdx.Width());
|
||||
dFdx.WeightRevDiff(dFdx_bar);
|
||||
JacobianRevDiff(dFdx_bar, PointMat_bar);
|
||||
}
|
||||
|
||||
void IsoparametricTransformation::WeightRevDiff(double weight_bar,
|
||||
DenseMatrix &PointMat_bar)
|
||||
{
|
||||
Jacobian(); // Recompute the Jacobian, if necessary
|
||||
double dFdx_bar_buffer[9];
|
||||
DenseMatrix dFdx_bar(dFdx_bar_buffer, dFdx.Height(), dFdx.Width());
|
||||
dFdx.WeightRevDiff(dFdx_bar);
|
||||
dFdx_bar *= weight_bar;
|
||||
JacobianRevDiff(dFdx_bar, PointMat_bar);
|
||||
}
|
||||
|
||||
void IntegrationPointTransformation::Transform (const IntegrationPoint &ip1,
|
||||
IntegrationPoint &ip2)
|
||||
{
|
||||
|
||||
@@ -75,6 +75,12 @@ public:
|
||||
|
||||
int Attribute, ElementNo, ElementType;
|
||||
|
||||
/// The Mesh object containing the element.
|
||||
/** If the element transformation belongs to a mesh, this will point to the
|
||||
containing Mesh object. ElementNo will be the number of the element in
|
||||
this Mesh. This will be NULL if the element does not belong to a mesh. */
|
||||
class Mesh *mesh;
|
||||
|
||||
ElementTransformation();
|
||||
|
||||
/** @brief Force the reevaluation of the Jacobian in the next call. */
|
||||
@@ -440,6 +446,58 @@ public:
|
||||
return inv_tr.Transform(v, ip);
|
||||
}
|
||||
|
||||
/// @brief Reverse-mode differentiation of Transform() w.r.t. PointMat
|
||||
/// @param[in] ip - specifies the location in reference space
|
||||
/// @param[in] x_bar - derivative of some output w.r.t. x
|
||||
/// @param[out] PointMat_bar - derivative of output w.r.t. PointMat
|
||||
/// @note PointMat_bar must have the same shape as PointMat
|
||||
/// @warning This routine does not initialize PointMat_bar, and instead
|
||||
/// accumulates (with += or -=) contributions to its derivative.
|
||||
void TransformRevDiff(const IntegrationPoint &ip, const Vector &x_bar,
|
||||
DenseMatrix &PointMat_bar);
|
||||
|
||||
/// @brief Reverse-mode differentiation of Jacobian() w.r.t. PointMat
|
||||
/// @param[in] dFdx_bar - derivative of functional w.r.t. Jacobian
|
||||
/// @param[out] PointMat_bar - derivative w.r.t. PointMat
|
||||
/// @note PointMat_bar must have the same shape as PointMat
|
||||
/// @warning This routine does not initialize PointMat_bar, and instead
|
||||
/// accumulates (with += or -=) contributions to its derivative.
|
||||
void JacobianRevDiff(const DenseMatrix &dFdx_bar,
|
||||
DenseMatrix &PointMat_bar);
|
||||
|
||||
/// @brief Reverse-mode differentiation of AdjugateJacobian() w.r.t. PointMat
|
||||
/// @param[in] adjJ_bar - derivative of functional w.r.t. Adjugate
|
||||
/// @param[out] PointMat_bar - derivative w.r.t. PointMat
|
||||
/// @note PointMat_bar must have the same shape as PointMat
|
||||
/// @warning This routine does not initialize PointMat_bar, and instead
|
||||
/// accumulates (with += or -=) contributions to its derivative.
|
||||
void AdjugateJacobianRevDiff(const DenseMatrix &adjJ_bar,
|
||||
DenseMatrix &PointMat_bar);
|
||||
|
||||
/// @brief Reverse-mode differentiation of InverseJacobian() w.r.t PointMat
|
||||
/// @param[in] invJ_bar - derivative of functional w.r.t. Inverse
|
||||
/// @param[out] PointMat_bar - derivative w.r.t. PointMat
|
||||
/// @note PointMat_bar must have the same shape as PointMat
|
||||
/// @warning This routine does not initialize PointMat_bar, and instead
|
||||
/// accumulates (with += or -=) contributions to its derivative.
|
||||
void InverseJacobianRevDiff(const DenseMatrix &adjJ_bar,
|
||||
DenseMatrix &PointMat_bar);
|
||||
|
||||
/// @brief Reverse-mode differentiation of Weight()
|
||||
/// @param[out] PointMat_bar - derivative of functional w.r.t. PointMat
|
||||
/// @note PointMat_bar must have the same shape as PointMat
|
||||
/// @warning This routine does not initialize PointMat_bar, and instead
|
||||
/// accumulates (with += or -=) contributions to its derivative.
|
||||
void WeightRevDiff(DenseMatrix &PointMat_bar);
|
||||
|
||||
/// @brief Reverse-mode differentiation of Weight()
|
||||
/// @param[in] weight_bar - derivative of functional w.r.t Weight
|
||||
/// @param[out] PointMat_bar - derivative of functional w.r.t. PointMat
|
||||
/// @note PointMat_bar must have the same shape as PointMat
|
||||
/// @warning This routine does not initialize PointMat_bar, and instead
|
||||
/// accumulates (with += or -=) contributions to its derivative.
|
||||
void WeightRevDiff(double weight_bar, DenseMatrix &PointMat_bar);
|
||||
|
||||
virtual ~IsoparametricTransformation() { }
|
||||
|
||||
MFEM_DEPRECATED void FinalizeTransformation() {}
|
||||
|
||||
+286
-1
@@ -30,6 +30,7 @@ FiniteElement::FiniteElement(int D, Geometry::Type G, int Do, int O, int F)
|
||||
deriv_map_type = VALUE;
|
||||
for (int i = 0; i < Geometry::MaxDim; i++) { orders[i] = -1; }
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
shape.SetSize(dof);
|
||||
vshape.SetSize(dof, dim);
|
||||
#endif
|
||||
}
|
||||
@@ -46,6 +47,13 @@ void FiniteElement::CalcVShape (
|
||||
MFEM_ABORT("method is not implemented for this class");
|
||||
}
|
||||
|
||||
void FiniteElement::CalcVShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{
|
||||
MFEM_ABORT("method is not implemented for this class");
|
||||
}
|
||||
|
||||
void FiniteElement::CalcDivShape (
|
||||
const IntegrationPoint &ip, Vector &divshape) const
|
||||
{
|
||||
@@ -90,6 +98,60 @@ void FiniteElement::CalcPhysCurlShape(ElementTransformation &Trans,
|
||||
}
|
||||
}
|
||||
|
||||
void FiniteElement::CalcPhysCurlShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &curlshape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{
|
||||
switch (dim)
|
||||
{
|
||||
case 3:
|
||||
{
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
DenseMatrix vshape(dof, dim);
|
||||
#endif
|
||||
DenseMatrix vshapedxt(dof, dim);
|
||||
DenseMatrix vshapedxt_bar(dof, dim);
|
||||
|
||||
CalcCurlShape(Trans.GetIntPoint(), vshape);
|
||||
const auto &jac = Trans.Jacobian();
|
||||
MultABt(vshape, jac, vshapedxt);
|
||||
|
||||
const double weight = Trans.Weight();
|
||||
// curl_shape *= 1.0 / weight;
|
||||
|
||||
/// start reverse pass
|
||||
auto &isotrans = dynamic_cast<IsoparametricTransformation&>(Trans);
|
||||
|
||||
/// curl_shape = vshapedxt / weight;
|
||||
double weight_bar = 0.0;
|
||||
for (int j = 0; j < curlshape_bar.Width(); ++j)
|
||||
{
|
||||
for (int i = 0; i < curlshape_bar.Height(); ++i)
|
||||
{
|
||||
weight_bar -= curlshape_bar(i,j) * vshapedxt(i,j) / pow(weight, 2);
|
||||
}
|
||||
}
|
||||
vshapedxt_bar = curlshape_bar; vshapedxt_bar *= (1.0 / weight);
|
||||
|
||||
/// double weight = Trans.Weight();
|
||||
isotrans.WeightRevDiff(weight_bar, PointMat_bar);
|
||||
|
||||
/// const auto &jac = Trans.Jacobian();
|
||||
/// MultABt(vshape, jac, vshapedxt);
|
||||
double jac_bar_buffer[9];
|
||||
DenseMatrix jac_bar(jac_bar_buffer, jac.Width(), jac.Height());
|
||||
MultAtB(vshapedxt_bar, vshape, jac_bar);
|
||||
isotrans.JacobianRevDiff(jac_bar, PointMat_bar);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
MFEM_ABORT("CalcPhysCurlShapeRevDiff not implemented!\n");
|
||||
break;
|
||||
default:
|
||||
MFEM_ABORT("Invalid dimension, Dim = " << dim);
|
||||
}
|
||||
}
|
||||
|
||||
void FiniteElement::GetFaceDofs(int face, int **dofs, int *ndofs) const
|
||||
{
|
||||
MFEM_ABORT("method is not overloaded");
|
||||
@@ -138,6 +200,16 @@ void FiniteElement::ProjectFromNodes(Vector &vc, ElementTransformation &Trans,
|
||||
mfem_error ("FiniteElement::ProjectFromNodes() (vector) is not overloaded!");
|
||||
}
|
||||
|
||||
void FiniteElement::ProjectRevDiff (
|
||||
const Vector &P_bar,
|
||||
VectorCoefficient &vc,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{
|
||||
mfem_error ("FiniteElement::ProjectRevDiff (...) (vector) is not "
|
||||
"overloaded !");
|
||||
}
|
||||
|
||||
void FiniteElement::ProjectMatrixCoefficient(
|
||||
MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
|
||||
{
|
||||
@@ -186,6 +258,26 @@ void FiniteElement::CalcPhysShape(ElementTransformation &Trans,
|
||||
}
|
||||
}
|
||||
|
||||
void FiniteElement::CalcPhysShapeRevDiff(ElementTransformation &Trans,
|
||||
const Vector &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{
|
||||
if (map_type == INTEGRAL)
|
||||
{
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
Vector shape(dof);
|
||||
#endif
|
||||
CalcShape(Trans.GetIntPoint(), shape);
|
||||
// shape /= Trans.Weight();
|
||||
auto weight = Trans.Weight();
|
||||
auto weight_bar = -(shape_bar * shape) / pow(weight, 2);
|
||||
|
||||
// cast the ElementTransformation
|
||||
auto &isotrans = dynamic_cast<IsoparametricTransformation &>(Trans);
|
||||
isotrans.WeightRevDiff(weight_bar, PointMat_bar);
|
||||
}
|
||||
}
|
||||
|
||||
void FiniteElement::CalcPhysDShape(ElementTransformation &Trans,
|
||||
DenseMatrix &dshape) const
|
||||
{
|
||||
@@ -894,6 +986,46 @@ void VectorFiniteElement::CalcVShape_RT (
|
||||
shape *= (1.0 / Trans.Weight());
|
||||
}
|
||||
|
||||
void VectorFiniteElement::CalcVShape_RTRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &vshape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{
|
||||
MFEM_ASSERT(map_type == H_DIV, "");
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
DenseMatrix vshape(dof, dim);
|
||||
DenseMatrix vshapedxt(dof, dim);
|
||||
DenseMatrix vshapedxt_bar(dof, dim);
|
||||
#else
|
||||
vshapedxt.SetSize(dof, dim);
|
||||
vshapedxt_bar.SetSize(dof, dim);
|
||||
#endif
|
||||
CalcVShape(Trans.GetIntPoint(), vshape);
|
||||
const auto &jac = Trans.Jacobian();
|
||||
MultABt(vshape, jac, vshapedxt);
|
||||
|
||||
const double weight = Trans.Weight();
|
||||
// shape *= (1.0 / weight);
|
||||
|
||||
/// start reverse pass
|
||||
auto &isotrans = dynamic_cast<IsoparametricTransformation&>(Trans);
|
||||
|
||||
double weight_bar = 0.0;
|
||||
for (int j = 0; j < vshape_bar.Width(); ++j)
|
||||
{
|
||||
for (int i = 0; i < vshape_bar.Height(); ++i)
|
||||
{
|
||||
weight_bar -= vshape_bar(i,j) * vshapedxt(i,j) / pow(weight,2);
|
||||
}
|
||||
}
|
||||
isotrans.WeightRevDiff(weight_bar, PointMat_bar);
|
||||
|
||||
vshapedxt_bar = vshape_bar; vshapedxt_bar *= (1.0 / weight);
|
||||
double jac_bar_buffer[9];
|
||||
DenseMatrix jac_bar(jac_bar_buffer, jac.Width(), jac.Height());
|
||||
MultAtB(vshapedxt_bar, vshape, jac_bar);
|
||||
isotrans.JacobianRevDiff(jac_bar, PointMat_bar);
|
||||
}
|
||||
|
||||
void VectorFiniteElement::CalcVShape_ND (
|
||||
ElementTransformation &Trans, DenseMatrix &shape) const
|
||||
{
|
||||
@@ -905,6 +1037,46 @@ void VectorFiniteElement::CalcVShape_ND (
|
||||
Mult(vshape, Trans.InverseJacobian(), shape);
|
||||
}
|
||||
|
||||
void VectorFiniteElement::CalcVShape_NDRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &vshape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{
|
||||
MFEM_ASSERT(map_type == H_CURL, "");
|
||||
#ifdef MFEM_THREAD_SAFE
|
||||
DenseMatrix vshape(dof, dim);
|
||||
DenseMatrix vshapedxt(dof, dim);
|
||||
DenseMatrix vshapedxt_bar(dof, dim);
|
||||
#else
|
||||
vshapedxt.SetSize(dof, dim);
|
||||
vshapedxt_bar.SetSize(dof, dim);
|
||||
#endif
|
||||
CalcVShape(Trans.GetIntPoint(), vshape);
|
||||
const auto &adjJ = Trans.AdjugateJacobian();
|
||||
Mult(vshape, adjJ, vshapedxt);
|
||||
|
||||
const double weight = Trans.Weight();
|
||||
// shape *= (1.0 / weight);
|
||||
|
||||
/// start reverse pass
|
||||
auto &isotrans = dynamic_cast<IsoparametricTransformation&>(Trans);
|
||||
|
||||
double weight_bar = 0.0;
|
||||
for (int j = 0; j < vshape_bar.Width(); ++j)
|
||||
{
|
||||
for (int i = 0; i < vshape_bar.Height(); ++i)
|
||||
{
|
||||
weight_bar -= vshape_bar(i,j) * vshapedxt(i,j) / pow(weight, 2);
|
||||
}
|
||||
}
|
||||
isotrans.WeightRevDiff(weight_bar, PointMat_bar);
|
||||
|
||||
vshapedxt_bar = vshape_bar; vshapedxt_bar *= (1.0 / weight);
|
||||
double adjJ_bar_buffer[9];
|
||||
DenseMatrix adjJ_bar(adjJ_bar_buffer, adjJ.Width(), adjJ.Height());
|
||||
MultAtB(vshape, vshapedxt_bar, adjJ_bar);
|
||||
isotrans.AdjugateJacobianRevDiff(adjJ_bar, PointMat_bar);
|
||||
}
|
||||
|
||||
void VectorFiniteElement::Project_RT(
|
||||
const double *nk, const Array<int> &d2n,
|
||||
VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
|
||||
@@ -942,6 +1114,47 @@ void VectorFiniteElement::Project_RT(
|
||||
}
|
||||
}
|
||||
|
||||
void VectorFiniteElement::Project_RTRevDiff(
|
||||
const Vector &P_bar,
|
||||
const double *nk, const Array<int> &d2n,
|
||||
VectorCoefficient &vc, ElementTransformation &Trans,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{
|
||||
double vk[Geometry::MaxDim];
|
||||
const int sdim = Trans.GetSpaceDim();
|
||||
MFEM_ASSERT(vc.GetVDim() == sdim, "");
|
||||
Vector xk(vk, sdim);
|
||||
MFEM_ASSERT(dim == sdim, "VectorFiniteElement::Project_RTRevDiff\n"
|
||||
"\tOnly implemented if space dim == reference dim!\n");
|
||||
|
||||
DenseMatrix temp_bar(PointMat_bar.Height(), PointMat_bar.Width());
|
||||
|
||||
IsoparametricTransformation &isotrans =
|
||||
dynamic_cast<IsoparametricTransformation&>(Trans);
|
||||
|
||||
for (int k = 0; k < dof; k++)
|
||||
{
|
||||
temp_bar = 0.0;
|
||||
isotrans.SetIntPoint(&Nodes.IntPoint(k));
|
||||
vc.Eval(xk, isotrans, Nodes.IntPoint(k));
|
||||
// dof_k = nk^t adj(J) xk
|
||||
const Vector nk_vec(const_cast<double*>(nk + d2n[k]*dim), sdim);
|
||||
double adjJ_bar_buffer[Geometry::MaxDim*Geometry::MaxDim];
|
||||
DenseMatrix adjJ_bar(adjJ_bar_buffer, dim, dim);
|
||||
MultVWt(nk_vec, xk, adjJ_bar);
|
||||
isotrans.AdjugateJacobianRevDiff(adjJ_bar, temp_bar);
|
||||
|
||||
double V_bar_buffer[Geometry::MaxDim];
|
||||
Vector V_bar(V_bar_buffer, sdim);
|
||||
isotrans.AdjugateJacobian().MultTranspose(nk_vec, V_bar);
|
||||
vc.EvalRevDiff(V_bar, isotrans,
|
||||
Nodes.IntPoint(k), temp_bar);
|
||||
|
||||
temp_bar *= P_bar(k);
|
||||
PointMat_bar += temp_bar;
|
||||
}
|
||||
}
|
||||
|
||||
void VectorFiniteElement::ProjectMatrixCoefficient_RT(
|
||||
const double *nk, const Array<int> &d2n,
|
||||
MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
|
||||
@@ -1159,6 +1372,48 @@ void VectorFiniteElement::Project_ND(
|
||||
}
|
||||
}
|
||||
|
||||
void VectorFiniteElement::Project_NDRevDiff(
|
||||
const Vector &P_bar,
|
||||
const double *tk, const Array<int> &d2t,
|
||||
VectorCoefficient &vc, ElementTransformation &Trans,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{
|
||||
double vk[Geometry::MaxDim];
|
||||
const int sdim = Trans.GetSpaceDim();
|
||||
MFEM_ASSERT(vc.GetVDim() == sdim, "");
|
||||
Vector xk(vk, sdim);
|
||||
MFEM_ASSERT(dim == sdim, "VectorFiniteElement::Project_NDRevDiff\n"
|
||||
"\tOnly implemented if space dim == reference dim!\n");
|
||||
|
||||
DenseMatrix temp_bar(PointMat_bar.Height(), PointMat_bar.Width());
|
||||
|
||||
IsoparametricTransformation &isotrans =
|
||||
dynamic_cast<IsoparametricTransformation&>(Trans);
|
||||
|
||||
for (int k = 0; k < dof; k++)
|
||||
{
|
||||
temp_bar = 0.0;
|
||||
isotrans.SetIntPoint(&Nodes.IntPoint(k));
|
||||
vc.Eval(xk, isotrans, Nodes.IntPoint(k));
|
||||
// dof_k = nk^t J xk
|
||||
const Vector tk_vec(const_cast<double*>(tk + d2t[k]*dim), sdim);
|
||||
|
||||
double J_bar_buffer[Geometry::MaxDim*Geometry::MaxDim];
|
||||
DenseMatrix J_bar(J_bar_buffer, dim, dim);
|
||||
MultVWt(xk, tk_vec, J_bar);
|
||||
isotrans.JacobianRevDiff(J_bar, temp_bar);
|
||||
|
||||
double V_bar_buffer[Geometry::MaxDim];
|
||||
Vector V_bar(V_bar_buffer, sdim);
|
||||
isotrans.Jacobian().Mult(tk_vec, V_bar);
|
||||
vc.EvalRevDiff(V_bar, isotrans,
|
||||
Nodes.IntPoint(k), temp_bar);
|
||||
|
||||
temp_bar *= P_bar(k);
|
||||
PointMat_bar += temp_bar;
|
||||
}
|
||||
}
|
||||
|
||||
void VectorFiniteElement::ProjectMatrixCoefficient_ND(
|
||||
const double *tk, const Array<int> &d2t,
|
||||
MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
|
||||
@@ -1538,7 +1793,7 @@ void VectorFiniteElement::LocalRestriction_ND(
|
||||
|
||||
|
||||
Poly_1D::Basis::Basis(const int p, const double *nodes, EvalType etype)
|
||||
: etype(etype), auxiliary_basis(NULL)
|
||||
: etype(etype), auxiliary_basis(NULL), scale_integrated(false)
|
||||
{
|
||||
switch (etype)
|
||||
{
|
||||
@@ -1838,11 +2093,29 @@ void Poly_1D::Basis::EvalIntegrated(const Vector &d_aux, Vector &u) const
|
||||
MFEM_VERIFY(etype == Integrated,
|
||||
"EvalIntegrated is only valid for Integrated basis type");
|
||||
int p = d_aux.Size() - 1;
|
||||
// See Gerritsma, M. (2010). "Edge functions for spectral element methods",
|
||||
// in Lecture Notes in Computational Science and Engineering, 199--207.
|
||||
u[0] = -d_aux[0];
|
||||
for (int j=1; j<p; ++j)
|
||||
{
|
||||
u[j] = u[j-1] - d_aux[j];
|
||||
}
|
||||
// If scale_integrated is true, the degrees of freedom represent mean values,
|
||||
// otherwise they represent subcell integrals. Generally, scale_integrated
|
||||
// should be true for MapType::VALUE, and false for other map types.
|
||||
if (scale_integrated)
|
||||
{
|
||||
Vector &aux_nodes = auxiliary_basis->x;
|
||||
for (int j=0; j<aux_nodes.Size()-1; ++j)
|
||||
{
|
||||
u[j] *= aux_nodes[j+1] - aux_nodes[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Poly_1D::Basis::ScaleIntegrated(bool scale_integrated_)
|
||||
{
|
||||
scale_integrated = scale_integrated_;
|
||||
}
|
||||
|
||||
Poly_1D::Basis::~Basis()
|
||||
@@ -2379,6 +2652,18 @@ NodalTensorFiniteElement::NodalTensorFiniteElement(const int dims,
|
||||
lex_ordering = dof_map;
|
||||
}
|
||||
|
||||
void NodalTensorFiniteElement::SetMapType(const int map_type)
|
||||
{
|
||||
ScalarFiniteElement::SetMapType(map_type);
|
||||
// If we are using the "integrated" basis, the basis functions should be
|
||||
// scaled for MapType::VALUE, and not scaled for MapType::INTEGRAL. This
|
||||
// ensures spectral equivalence of the mass matrix with its low-order-refined
|
||||
// counterpart (cf. LORDiscretization)
|
||||
if (basis1d.IsIntegratedType())
|
||||
{
|
||||
basis1d.ScaleIntegrated(map_type == VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
VectorTensorFiniteElement::VectorTensorFiniteElement(const int dims,
|
||||
const int d,
|
||||
|
||||
+107
-15
@@ -245,6 +245,7 @@ protected:
|
||||
mutable int orders[Geometry::MaxDim]; ///< Anisotropic orders
|
||||
IntegrationRule Nodes;
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
mutable Vector shape;
|
||||
mutable DenseMatrix vshape; // Dof x Dim
|
||||
#endif
|
||||
/// Container for all DofToQuad objects created by the FiniteElement.
|
||||
@@ -362,6 +363,10 @@ public:
|
||||
/** The size (#dof) of the result Vector @a shape must be set in advance. */
|
||||
void CalcPhysShape(ElementTransformation &Trans, Vector &shape) const;
|
||||
|
||||
void CalcPhysShapeRevDiff(ElementTransformation &Trans,
|
||||
const Vector &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const;
|
||||
|
||||
/** @brief Evaluate the gradients of all shape functions of a scalar finite
|
||||
element in reference space at the given point @a ip. */
|
||||
/** Each row of the result DenseMatrix @a dshape contains the derivatives of
|
||||
@@ -400,6 +405,10 @@ public:
|
||||
virtual void CalcVShape(ElementTransformation &Trans,
|
||||
DenseMatrix &shape) const;
|
||||
|
||||
virtual void CalcVShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const;
|
||||
|
||||
/// Equivalent to the CalcVShape() method with the same arguments.
|
||||
void CalcPhysVShape(ElementTransformation &Trans, DenseMatrix &shape) const
|
||||
{ CalcVShape(Trans, shape); }
|
||||
@@ -435,6 +444,10 @@ public:
|
||||
void CalcPhysCurlShape(ElementTransformation &Trans,
|
||||
DenseMatrix &curl_shape) const;
|
||||
|
||||
void CalcPhysCurlShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &curlshape_bar,
|
||||
DenseMatrix &PointMat_bar) const;
|
||||
|
||||
/** @brief Get the dofs associated with the given @a face.
|
||||
@a *dofs is set to an internal array of the local dofc on the
|
||||
face, while *ndofs is set to the number of dofs on that face.
|
||||
@@ -519,6 +532,14 @@ public:
|
||||
virtual void Project(VectorCoefficient &vc,
|
||||
ElementTransformation &Trans, Vector &dofs) const;
|
||||
|
||||
/** Given a vector coefficient and a transformation, compute the derivative of
|
||||
its projection (approximation) in the local finite dimensional space
|
||||
w.r.t. the mesh nodes (VectorFiniteElements) */
|
||||
virtual void ProjectRevDiff(const Vector &P_bar,
|
||||
VectorCoefficient &vc,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &PointMat_bar) const;
|
||||
|
||||
/** @brief Given a vector of values at the finite element nodes and a
|
||||
transformation, compute its projection (approximation) in the local
|
||||
finite dimensional space in terms of the degrees of freedom. Valid for
|
||||
@@ -657,7 +678,7 @@ public:
|
||||
/** @brief Set the FiniteElement::MapType of the element to either VALUE or
|
||||
INTEGRAL. Also sets the FiniteElement::DerivType to GRAD if the
|
||||
FiniteElement::MapType is VALUE. */
|
||||
void SetMapType(int M)
|
||||
virtual void SetMapType(int M)
|
||||
{
|
||||
MFEM_VERIFY(M == VALUE || M == INTEGRAL, "unknown MapType");
|
||||
map_type = M;
|
||||
@@ -791,15 +812,24 @@ protected:
|
||||
#ifndef MFEM_THREAD_SAFE
|
||||
mutable DenseMatrix J, Jinv;
|
||||
mutable DenseMatrix curlshape, curlshape_J;
|
||||
mutable DenseMatrix vshapedxt, vshapedxt_bar;
|
||||
#endif
|
||||
void SetDerivMembers();
|
||||
|
||||
void CalcVShape_RT(ElementTransformation &Trans,
|
||||
DenseMatrix &shape) const;
|
||||
|
||||
void CalcVShape_RTRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const;
|
||||
|
||||
void CalcVShape_ND(ElementTransformation &Trans,
|
||||
DenseMatrix &shape) const;
|
||||
|
||||
void CalcVShape_NDRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const;
|
||||
|
||||
/** @brief Project a vector coefficient onto the RT basis functions
|
||||
@param nk Face normal vectors for this element type
|
||||
@param d2n Offset into nk for each degree of freedom
|
||||
@@ -845,6 +875,23 @@ protected:
|
||||
const FiniteElement &fe, ElementTransformation &Trans,
|
||||
DenseMatrix &I) const;
|
||||
|
||||
/** Reverse-mode differentiation of Project_ND w.r.t. the mesh node
|
||||
locations in the element described by @a T
|
||||
@param[in] P_bar - derivative of function with respect to the projection
|
||||
@param[in] nk - Face normal vectors for this element type
|
||||
@param[in] d2n - Offset into nk for each degree of freedom
|
||||
@param[in] vc - VectorCoefficient being projected
|
||||
@param[in] Trans - an element transformation
|
||||
@param[out] PointMat_bar - derivative of projected degrees of freedom w.r.t.
|
||||
mesh nodes
|
||||
@warning - only implemented for the same space and reference dimension
|
||||
*/
|
||||
void Project_RTRevDiff(const Vector &P_bar,
|
||||
const double *nk, const Array<int> &d2n,
|
||||
VectorCoefficient &vc,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &PointMat_bar) const;
|
||||
|
||||
// rotated gradient in 2D
|
||||
void ProjectGrad_RT(const double *nk, const Array<int> &d2n,
|
||||
const FiniteElement &fe, ElementTransformation &Trans,
|
||||
@@ -883,6 +930,22 @@ protected:
|
||||
Vector &vc, ElementTransformation &Trans,
|
||||
Vector &dofs) const;
|
||||
|
||||
/** Reverse-mode differentiation of Project_ND w.r.t. the mesh node
|
||||
locations in the element described by @a T
|
||||
@param[in] P_bar - derivative of output with respect to the projection
|
||||
@param[in] tk - Edge tangent vectors for this element type
|
||||
@param[in] d2t - Offset into tk for each degree of freedom
|
||||
@param[in] vc - Vector coefficient being projected
|
||||
@param[in] Trans - Transformation from reference to physical coordinates
|
||||
@param[out] PointMat_bar - derivative of some output w.r.t. mesh nodes
|
||||
@warning - only implemented for the same space and reference dimension
|
||||
*/
|
||||
void Project_NDRevDiff(const Vector &P_bar,
|
||||
const double *tk, const Array<int> &d2t,
|
||||
VectorCoefficient &vc,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &PointMat_bar) const;
|
||||
|
||||
/// Project the rows of the matrix coefficient in an ND space
|
||||
void ProjectMatrixCoefficient_ND(
|
||||
const double *tk, const Array<int> &d2t,
|
||||
@@ -955,41 +1018,68 @@ public:
|
||||
};
|
||||
|
||||
|
||||
/// Class for computing 1D special polynomials and their associated basis
|
||||
/// @brief Class for computing 1D special polynomials and their associated basis
|
||||
/// functions
|
||||
class Poly_1D
|
||||
{
|
||||
public:
|
||||
/// One-dimensional basis evaluation type
|
||||
enum EvalType
|
||||
{
|
||||
ChangeOfBasis = 0, // Use change of basis, O(p^2) Evals
|
||||
Barycentric = 1, // Use barycentric Lagrangian interpolation, O(p) Evals
|
||||
Positive = 2, // Fast evaluation of Bernstein polynomials
|
||||
Integrated = 3, // Integrated indicator functions (cf. Gerritsma)
|
||||
NumEvalTypes = 4 // Keep count of the number of eval types
|
||||
ChangeOfBasis = 0, ///< Use change of basis, O(p^2) Evals
|
||||
Barycentric = 1, ///< Use barycentric Lagrangian interpolation, O(p) Evals
|
||||
Positive = 2, ///< Fast evaluation of Bernstein polynomials
|
||||
Integrated = 3, ///< Integrated indicator functions (cf. Gerritsma)
|
||||
NumEvalTypes = 4 ///< Keep count of the number of eval types
|
||||
};
|
||||
|
||||
/// @brief Class for evaluating 1D nodal, positive (Bernstein), or integrated
|
||||
/// (Gerritsma) bases.
|
||||
class Basis
|
||||
{
|
||||
private:
|
||||
int etype;
|
||||
EvalType etype; ///< Determines how the basis functions should be evaluated.
|
||||
DenseMatrixInverse Ai;
|
||||
mutable Vector x, w;
|
||||
// The following data members are used for "integrated basis type", which
|
||||
// is defined in terms of nodal basis of one degree higher.
|
||||
/// The following data members are used for "integrated basis type", which
|
||||
/// is defined in terms of nodal basis of one degree higher.
|
||||
///@{
|
||||
mutable Vector u_aux, d_aux, d2_aux;
|
||||
Basis *auxiliary_basis; // Non-NULL only for etype == Integrated
|
||||
///@}
|
||||
/// @brief An auxiliary nodal basis used to evaluate the integrated basis.
|
||||
/// This member variable is NULL whenever etype != Integrated.
|
||||
Basis *auxiliary_basis;
|
||||
/// Should the integrated basis functions be scaled? See ScaleIntegrated.
|
||||
bool scale_integrated;
|
||||
|
||||
public:
|
||||
/// Create a nodal or positive (Bernstein) basis
|
||||
/// Create a nodal or positive (Bernstein) basis of degree @a p
|
||||
Basis(const int p, const double *nodes, EvalType etype = Barycentric);
|
||||
/// Evaluate the basis functions at point @a x in [0,1]
|
||||
void Eval(const double x, Vector &u) const;
|
||||
/// @brief Evaluate the basis functions and their derivatives at point @a
|
||||
/// x in [0,1]
|
||||
void Eval(const double x, Vector &u, Vector &d) const;
|
||||
/// @brief Evaluate the basis functions and their first two derivatives at
|
||||
/// point @a x in [0,1]
|
||||
void Eval(const double x, Vector &u, Vector &d, Vector &d2) const;
|
||||
/// Evaluate the "integrated" basis, which is given by the negative
|
||||
/// partial sum of the corresponding closed basis derivatives. The closed
|
||||
/// basis derivatives are given by @a d, and the result is stored in @a i.
|
||||
/// @brief Evaluate the "integrated" basis type using pre-computed closed
|
||||
/// basis derivatives.
|
||||
///
|
||||
/// This basis is given by the negative partial sum of the corresponding
|
||||
/// closed basis derivatives. The closed basis derivatives are given by @a
|
||||
/// d, and the result is stored in @a i.
|
||||
void EvalIntegrated(const Vector &d, Vector &i) const;
|
||||
/// @brief Set whether the "integrated" basis should be scaled by the
|
||||
/// subcell sizes. Has no effect for non-integrated bases.
|
||||
///
|
||||
/// Generally, this should be true for mfem::FiniteElement::MapType VALUE
|
||||
/// and false for all other map types. If this option is enabled, the
|
||||
/// basis functions will be scaled by the widths of the subintervals, so
|
||||
/// that the basis functions represent mean values. Otherwise, the basis
|
||||
/// functions represent integrated values.
|
||||
void ScaleIntegrated(bool scale_integrated_);
|
||||
/// Returns true if the basis is "integrated", false otherwise.
|
||||
bool IsIntegratedType() const { return etype == Integrated; }
|
||||
~Basis();
|
||||
};
|
||||
@@ -1193,6 +1283,8 @@ public:
|
||||
ScalarFiniteElement::GetTensorDofToQuad(*this, ir, mode);
|
||||
}
|
||||
|
||||
virtual void SetMapType(const int map_type_);
|
||||
|
||||
virtual void GetTransferMatrix(const FiniteElement &fe,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &I) const
|
||||
|
||||
@@ -42,6 +42,11 @@ public:
|
||||
DenseMatrix &shape) const
|
||||
{ CalcVShape_ND(Trans, shape); }
|
||||
|
||||
virtual void CalcVShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{ CalcVShape_NDRevDiff(Trans, shape_bar, PointMat_bar); }
|
||||
|
||||
virtual void CalcCurlShape(const IntegrationPoint &ip,
|
||||
DenseMatrix &curl_shape) const;
|
||||
|
||||
@@ -120,6 +125,10 @@ public:
|
||||
virtual void CalcVShape(ElementTransformation &Trans,
|
||||
DenseMatrix &shape) const
|
||||
{ CalcVShape_ND(Trans, shape); }
|
||||
virtual void CalcVShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{ CalcVShape_NDRevDiff(Trans, shape_bar, PointMat_bar); }
|
||||
virtual void CalcCurlShape(const IntegrationPoint &ip,
|
||||
DenseMatrix &curl_shape) const;
|
||||
virtual void GetLocalInterpolation(ElementTransformation &Trans,
|
||||
@@ -139,6 +148,11 @@ public:
|
||||
if (obasis1d.IsIntegratedType()) { ProjectIntegrated(vc, Trans, dofs); }
|
||||
else { Project_ND(tk, dof2tk, vc, Trans, dofs); }
|
||||
}
|
||||
virtual void ProjectRevDiff(const Vector &P_bar,
|
||||
VectorCoefficient &vc,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &dofs_bar) const
|
||||
{ Project_NDRevDiff(P_bar, tk, dof2tk, vc, Trans, dofs_bar); }
|
||||
virtual void ProjectFromNodes(Vector &vc, ElementTransformation &Trans,
|
||||
Vector &dofs) const
|
||||
{ Project_ND(tk, dof2tk, vc, Trans, dofs); }
|
||||
@@ -182,6 +196,10 @@ public:
|
||||
virtual void CalcVShape(ElementTransformation &Trans,
|
||||
DenseMatrix &shape) const
|
||||
{ CalcVShape_ND(Trans, shape); }
|
||||
virtual void CalcVShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{ CalcVShape_NDRevDiff(Trans, shape_bar, PointMat_bar); }
|
||||
virtual void CalcCurlShape(const IntegrationPoint &ip,
|
||||
DenseMatrix &curl_shape) const;
|
||||
virtual void GetLocalInterpolation(ElementTransformation &Trans,
|
||||
@@ -198,6 +216,11 @@ public:
|
||||
virtual void Project(VectorCoefficient &vc,
|
||||
ElementTransformation &Trans, Vector &dofs) const
|
||||
{ Project_ND(tk, dof2tk, vc, Trans, dofs); }
|
||||
virtual void ProjectRevDiff(const Vector &P_bar,
|
||||
VectorCoefficient &vc,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &dofs_bar) const
|
||||
{ Project_NDRevDiff(P_bar, tk, dof2tk, vc, Trans, dofs_bar); }
|
||||
virtual void ProjectFromNodes(Vector &vc, ElementTransformation &Trans,
|
||||
Vector &dofs) const
|
||||
{ Project_ND(tk, dof2tk, vc, Trans, dofs); }
|
||||
@@ -241,6 +264,10 @@ public:
|
||||
virtual void CalcVShape(ElementTransformation &Trans,
|
||||
DenseMatrix &shape) const
|
||||
{ CalcVShape_ND(Trans, shape); }
|
||||
virtual void CalcVShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{ CalcVShape_NDRevDiff(Trans, shape_bar, PointMat_bar); }
|
||||
virtual void CalcCurlShape(const IntegrationPoint &ip,
|
||||
DenseMatrix &curl_shape) const;
|
||||
virtual void GetLocalInterpolation(ElementTransformation &Trans,
|
||||
@@ -292,6 +319,10 @@ public:
|
||||
virtual void CalcVShape(ElementTransformation &Trans,
|
||||
DenseMatrix &shape) const
|
||||
{ CalcVShape_ND(Trans, shape); }
|
||||
virtual void CalcVShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{ CalcVShape_NDRevDiff(Trans, shape_bar, PointMat_bar); }
|
||||
// virtual void CalcCurlShape(const IntegrationPoint &ip,
|
||||
// DenseMatrix &curl_shape) const;
|
||||
virtual void GetLocalInterpolation(ElementTransformation &Trans,
|
||||
|
||||
@@ -41,6 +41,10 @@ public:
|
||||
virtual void CalcVShape(ElementTransformation &Trans,
|
||||
DenseMatrix &shape) const
|
||||
{ CalcVShape_RT(Trans, shape); }
|
||||
virtual void CalcVShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{ CalcVShape_RTRevDiff(Trans, shape_bar, PointMat_bar); }
|
||||
virtual void CalcDivShape(const IntegrationPoint &ip,
|
||||
Vector &divshape) const;
|
||||
virtual void GetLocalInterpolation(ElementTransformation &Trans,
|
||||
@@ -60,6 +64,11 @@ public:
|
||||
if (obasis1d.IsIntegratedType()) { ProjectIntegrated(vc, Trans, dofs); }
|
||||
else { Project_RT(nk, dof2nk, vc, Trans, dofs); }
|
||||
}
|
||||
virtual void ProjectRevDiff(const Vector &P_bar,
|
||||
VectorCoefficient &vc,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &dofs_bar) const
|
||||
{ Project_RTRevDiff(P_bar, nk, dof2nk, vc, Trans, dofs_bar); }
|
||||
virtual void ProjectFromNodes(Vector &vc, ElementTransformation &Trans,
|
||||
Vector &dofs) const
|
||||
{ Project_RT(nk, dof2nk, vc, Trans, dofs); }
|
||||
@@ -110,6 +119,10 @@ public:
|
||||
virtual void CalcVShape(ElementTransformation &Trans,
|
||||
DenseMatrix &shape) const
|
||||
{ CalcVShape_RT(Trans, shape); }
|
||||
virtual void CalcVShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{ CalcVShape_RTRevDiff(Trans, shape_bar, PointMat_bar); }
|
||||
virtual void CalcDivShape(const IntegrationPoint &ip,
|
||||
Vector &divshape) const;
|
||||
virtual void GetLocalInterpolation(ElementTransformation &Trans,
|
||||
@@ -172,6 +185,10 @@ public:
|
||||
virtual void CalcVShape(ElementTransformation &Trans,
|
||||
DenseMatrix &shape) const
|
||||
{ CalcVShape_RT(Trans, shape); }
|
||||
virtual void CalcVShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{ CalcVShape_RTRevDiff(Trans, shape_bar, PointMat_bar); }
|
||||
virtual void CalcDivShape(const IntegrationPoint &ip,
|
||||
Vector &divshape) const;
|
||||
virtual void GetLocalInterpolation(ElementTransformation &Trans,
|
||||
@@ -232,6 +249,10 @@ public:
|
||||
virtual void CalcVShape(ElementTransformation &Trans,
|
||||
DenseMatrix &shape) const
|
||||
{ CalcVShape_RT(Trans, shape); }
|
||||
virtual void CalcVShapeRevDiff(ElementTransformation &Trans,
|
||||
const DenseMatrix &shape_bar,
|
||||
DenseMatrix &PointMat_bar) const
|
||||
{ CalcVShape_RTRevDiff(Trans, shape_bar, PointMat_bar); }
|
||||
virtual void CalcDivShape(const IntegrationPoint &ip,
|
||||
Vector &divshape) const;
|
||||
virtual void GetLocalInterpolation(ElementTransformation &Trans,
|
||||
@@ -248,6 +269,11 @@ public:
|
||||
virtual void Project(VectorCoefficient &vc,
|
||||
ElementTransformation &Trans, Vector &dofs) const
|
||||
{ Project_RT(nk, dof2nk, vc, Trans, dofs); }
|
||||
virtual void ProjectRevDiff(const Vector &P_bar,
|
||||
VectorCoefficient &vc,
|
||||
ElementTransformation &Trans,
|
||||
DenseMatrix &dofs_bar) const
|
||||
{ Project_RTRevDiff(P_bar, nk, dof2nk, vc, Trans, dofs_bar); }
|
||||
virtual void ProjectFromNodes(Vector &vc, ElementTransformation &Trans,
|
||||
Vector &dofs) const
|
||||
{ Project_RT(nk, dof2nk, vc, Trans, dofs); }
|
||||
|
||||
+20
-5
@@ -894,9 +894,10 @@ int FiniteElementSpace::GetDegenerateFaceDofs(int index, Array<int> &dofs,
|
||||
int FiniteElementSpace::GetNumBorderDofs(Geometry::Type geom, int order) const
|
||||
{
|
||||
// return the number of vertex and edge DOFs that precede inner DOFs
|
||||
int nv = fec->GetNumDof(Geometry::POINT, order);
|
||||
int ne = fec->GetNumDof(Geometry::SEGMENT, order);
|
||||
return Geometry::NumVerts[geom] * (nv + ne);
|
||||
const int nv = fec->GetNumDof(Geometry::POINT, order);
|
||||
const int ne = fec->GetNumDof(Geometry::SEGMENT, order);
|
||||
|
||||
return Geometry::NumVerts[geom] * (geom == Geometry::SEGMENT ? nv : (nv + ne));
|
||||
}
|
||||
|
||||
int FiniteElementSpace::GetEntityDofs(int entity, int index, Array<int> &dofs,
|
||||
@@ -934,6 +935,12 @@ void FiniteElementSpace::BuildConformingInterpolation() const
|
||||
if (cP_is_set) { return; }
|
||||
cP_is_set = true;
|
||||
|
||||
if (FEColl()->GetContType() == FiniteElementCollection::DISCONTINUOUS)
|
||||
{
|
||||
cP = cR = cR_hp = NULL; // will be treated as identities
|
||||
return;
|
||||
}
|
||||
|
||||
Array<int> master_dofs, slave_dofs, highest_dofs;
|
||||
|
||||
IsoparametricTransformation T;
|
||||
@@ -1054,6 +1061,7 @@ void FiniteElementSpace::BuildConformingInterpolation() const
|
||||
// get lowest order variant DOFs and FE
|
||||
int p = GetEntityDofs(entity, i, master_dofs, geom, 0);
|
||||
const auto *master_fe = fec->GetFE(geom, p);
|
||||
if (!master_fe) { break; }
|
||||
|
||||
// constrain all higher order DOFs: interpolate lowest order function
|
||||
for (int variant = 1; ; variant++)
|
||||
@@ -1192,7 +1200,7 @@ void FiniteElementSpace::BuildConformingInterpolation() const
|
||||
if (cR_hp) { MakeVDimMatrix(*cR_hp); }
|
||||
}
|
||||
|
||||
if (Device::IsEnabled()) { cP->BuildTranspose(); }
|
||||
cP->EnsureMultTranspose();
|
||||
}
|
||||
|
||||
void FiniteElementSpace::MakeVDimMatrix(SparseMatrix &mat) const
|
||||
@@ -1300,7 +1308,14 @@ const FaceRestriction *FiniteElementSpace::GetFaceRestriction(
|
||||
FaceRestriction *res;
|
||||
if (is_dg_space)
|
||||
{
|
||||
res = new L2FaceRestriction(*this, e_ordering, type, m);
|
||||
if (Conforming())
|
||||
{
|
||||
res = new L2FaceRestriction(*this, e_ordering, type, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = new NCL2FaceRestriction(*this, e_ordering, type, m);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+1
-2
@@ -112,7 +112,7 @@ FmsFieldToGridFunction(FmsMesh fms_mesh, FmsField f, Mesh *mesh,
|
||||
// NOTE: transplanted from the FmsMeshToMesh function
|
||||
// We should do this work once and save it.
|
||||
//--------------------------------------------------
|
||||
FmsInt dim, n_vert, n_elem, space_dim;
|
||||
FmsInt dim, n_elem, space_dim;
|
||||
|
||||
// Find the first component that has coordinates - that will be the new mfem
|
||||
// mesh.
|
||||
@@ -144,7 +144,6 @@ FmsFieldToGridFunction(FmsMesh fms_mesh, FmsField f, Mesh *mesh,
|
||||
n_ents[et] += num_ents;
|
||||
}
|
||||
}
|
||||
n_vert = n_ents[FMS_VERTEX];
|
||||
//--------------------------------------------------
|
||||
|
||||
// Interrogate the field.
|
||||
|
||||
@@ -3948,6 +3948,129 @@ std::ostream &operator<<(std::ostream &out, const QuadratureFunction &qf)
|
||||
return out;
|
||||
}
|
||||
|
||||
void QuadratureFunction::SaveVTU(std::ostream &out, VTKFormat format,
|
||||
int compression_level) const
|
||||
{
|
||||
out << R"(<VTKFile type="UnstructuredGrid" version="0.1")";
|
||||
if (compression_level != 0)
|
||||
{
|
||||
out << R"( compressor="vtkZLibDataCompressor")";
|
||||
}
|
||||
out << " byte_order=\"" << VTKByteOrder() << "\">\n";
|
||||
out << "<UnstructuredGrid>\n";
|
||||
|
||||
const char *fmt_str = (format == VTKFormat::ASCII) ? "ascii" : "binary";
|
||||
const char *type_str = (format != VTKFormat::BINARY32) ? "Float64" : "Float32";
|
||||
std::vector<char> buf;
|
||||
|
||||
int np = qspace->GetSize();
|
||||
int ne = qspace->GetNE();
|
||||
int sdim = qspace->GetMesh()->SpaceDimension();
|
||||
|
||||
// For quadrature functions, each point is a vertex cell, so number of cells
|
||||
// is equal to number of points
|
||||
out << "<Piece NumberOfPoints=\"" << np
|
||||
<< "\" NumberOfCells=\"" << np << "\">\n";
|
||||
|
||||
// print out the points
|
||||
out << "<Points>\n";
|
||||
out << "<DataArray type=\"" << type_str
|
||||
<< "\" NumberOfComponents=\"3\" format=\"" << fmt_str << "\">\n";
|
||||
|
||||
Vector pt(sdim);
|
||||
for (int i = 0; i < ne; i++)
|
||||
{
|
||||
ElementTransformation &T = *qspace->GetMesh()->GetElementTransformation(i);
|
||||
const IntegrationRule &ir = GetElementIntRule(i);
|
||||
for (int j = 0; j < ir.Size(); j++)
|
||||
{
|
||||
T.Transform(ir[j], pt);
|
||||
WriteBinaryOrASCII(out, buf, pt[0], " ", format);
|
||||
if (sdim > 1) { WriteBinaryOrASCII(out, buf, pt[1], " ", format); }
|
||||
else { WriteBinaryOrASCII(out, buf, 0.0, " ", format); }
|
||||
if (sdim > 2) { WriteBinaryOrASCII(out, buf, pt[2], "", format); }
|
||||
else { WriteBinaryOrASCII(out, buf, 0.0, "", format); }
|
||||
if (format == VTKFormat::ASCII) { out << '\n'; }
|
||||
}
|
||||
}
|
||||
if (format != VTKFormat::ASCII)
|
||||
{
|
||||
WriteBase64WithSizeAndClear(out, buf, compression_level);
|
||||
}
|
||||
out << "</DataArray>\n";
|
||||
out << "</Points>\n";
|
||||
|
||||
// Write cells (each cell is just a vertex)
|
||||
out << "<Cells>\n";
|
||||
// Connectivity
|
||||
out << R"(<DataArray type="Int32" Name="connectivity" format=")"
|
||||
<< fmt_str << "\">\n";
|
||||
|
||||
for (int i=0; i<np; ++i) { WriteBinaryOrASCII(out, buf, i, "\n", format); }
|
||||
if (format != VTKFormat::ASCII)
|
||||
{
|
||||
WriteBase64WithSizeAndClear(out, buf, compression_level);
|
||||
}
|
||||
out << "</DataArray>\n";
|
||||
// Offsets
|
||||
out << R"(<DataArray type="Int32" Name="offsets" format=")"
|
||||
<< fmt_str << "\">\n";
|
||||
for (int i=0; i<np; ++i) { WriteBinaryOrASCII(out, buf, i, "\n", format); }
|
||||
if (format != VTKFormat::ASCII)
|
||||
{
|
||||
WriteBase64WithSizeAndClear(out, buf, compression_level);
|
||||
}
|
||||
out << "</DataArray>\n";
|
||||
// Types
|
||||
out << R"(<DataArray type="UInt8" Name="types" format=")"
|
||||
<< fmt_str << "\">\n";
|
||||
for (int i = 0; i < np; i++)
|
||||
{
|
||||
uint8_t vtk_cell_type = VTKGeometry::POINT;
|
||||
WriteBinaryOrASCII(out, buf, vtk_cell_type, "\n", format);
|
||||
}
|
||||
if (format != VTKFormat::ASCII)
|
||||
{
|
||||
WriteBase64WithSizeAndClear(out, buf, compression_level);
|
||||
}
|
||||
out << "</DataArray>\n";
|
||||
out << "</Cells>\n";
|
||||
|
||||
out << "<PointData>\n";
|
||||
out << "<DataArray type=\"" << type_str << "\" Name=\"u\" format=\""
|
||||
<< fmt_str << "\" NumberOfComponents=\"" << vdim << "\">\n";
|
||||
for (int i = 0; i < ne; i++)
|
||||
{
|
||||
DenseMatrix vals;
|
||||
GetElementValues(i, vals);
|
||||
for (int j = 0; j < vals.Size(); ++j)
|
||||
{
|
||||
for (int vd = 0; vd < vdim; ++vd)
|
||||
{
|
||||
WriteBinaryOrASCII(out, buf, vals(vd, j), " ", format);
|
||||
}
|
||||
if (format == VTKFormat::ASCII) { out << '\n'; }
|
||||
}
|
||||
}
|
||||
if (format != VTKFormat::ASCII)
|
||||
{
|
||||
WriteBase64WithSizeAndClear(out, buf, compression_level);
|
||||
}
|
||||
out << "</DataArray>\n";
|
||||
out << "</PointData>\n";
|
||||
|
||||
out << "</Piece>\n";
|
||||
out << "</UnstructuredGrid>\n";
|
||||
out << "</VTKFile>" << std::endl;
|
||||
}
|
||||
|
||||
void QuadratureFunction::SaveVTU(const std::string &filename, VTKFormat format,
|
||||
int compression_level) const
|
||||
{
|
||||
std::ofstream f(filename + ".vtu");
|
||||
SaveVTU(f, format, compression_level);
|
||||
}
|
||||
|
||||
|
||||
double ZZErrorEstimator(BilinearFormIntegrator &blfi,
|
||||
GridFunction &u,
|
||||
|
||||
@@ -902,6 +902,22 @@ public:
|
||||
|
||||
/// Write the QuadratureFunction to the stream @a out.
|
||||
void Save(std::ostream &out) const;
|
||||
|
||||
/// @brief Write the QuadratureFunction to @a out in VTU (ParaView) format.
|
||||
///
|
||||
/// The data will be uncompressed if @a compression_level is zero, or if the
|
||||
/// format is VTKFormat::ASCII. Otherwise, zlib compression will be used for
|
||||
/// binary data.
|
||||
void SaveVTU(std::ostream &out, VTKFormat format=VTKFormat::ASCII,
|
||||
int compression_level=0) const;
|
||||
|
||||
/// @brief Save the QuadratureFunction to a VTU (ParaView) file.
|
||||
///
|
||||
/// The extension ".vtu" will be appended to @a filename.
|
||||
/// @sa SaveVTU(std::ostream &out, VTKFormat format=VTKFormat::ASCII,
|
||||
/// int compression_level=0)
|
||||
void SaveVTU(const std::string &filename, VTKFormat format=VTKFormat::ASCII,
|
||||
int compression_level=0) const;
|
||||
};
|
||||
|
||||
/// Overload operator<< for std::ostream and QuadratureFunction.
|
||||
|
||||
+6
-1
@@ -78,6 +78,8 @@ void FindPointsGSLIB::Setup(Mesh &m, const double bb_t, const double newt_tol,
|
||||
MFEM_VERIFY(m.GetNodes() != NULL, "Mesh nodes are required.");
|
||||
MFEM_VERIFY(m.GetNumGeometries(m.Dimension()) == 1,
|
||||
"Mixed meshes are not currently supported in FindPointsGSLIB.");
|
||||
MFEM_VERIFY(!(m.GetNodes()->FESpace()->IsVariableOrder()),
|
||||
"Variable order mesh is not currently supported.");
|
||||
|
||||
// call FreeData if FindPointsGSLIB::Setup has been called already
|
||||
if (setupflag) { FreeData(); }
|
||||
@@ -590,7 +592,8 @@ void FindPointsGSLIB::Interpolate(const GridFunction &field_in,
|
||||
const L2_FECollection *fec_l2 = dynamic_cast<const L2_FECollection *>(fec_in);
|
||||
|
||||
if (fec_h1 && gf_order == mesh_order &&
|
||||
fec_h1->GetBasisType() == BasisType::GaussLobatto)
|
||||
fec_h1->GetBasisType() == BasisType::GaussLobatto &&
|
||||
!field_in.FESpace()->IsVariableOrder())
|
||||
{
|
||||
InterpolateH1(field_in, field_out);
|
||||
return;
|
||||
@@ -857,6 +860,8 @@ void OversetFindPointsGSLIB::Setup(Mesh &m, const int meshid,
|
||||
MFEM_VERIFY(m.GetNodes() != NULL, "Mesh nodes are required.");
|
||||
MFEM_VERIFY(m.GetNumGeometries(m.Dimension()) == 1,
|
||||
"Mixed meshes are not currently supported in FindPointsGSLIB.");
|
||||
MFEM_VERIFY(!(m.GetNodes()->FESpace()->IsVariableOrder()),
|
||||
"Variable order mesh is not currently supported.");
|
||||
|
||||
// FreeData if OversetFindPointsGSLIB::Setup has been called already
|
||||
if (setupflag) { FreeData(); }
|
||||
|
||||
+10
-2
@@ -776,7 +776,7 @@ void Hybridization::MultAfInv(const Vector &b, const Vector &lambda, Vector &bf,
|
||||
if (vdof_marker[vdof]) { el_vals(j) = 0.0; }
|
||||
else { vdof_marker[vdof] = true; }
|
||||
}
|
||||
bf_i.SetDataAndSize(&bf[hat_offsets[i]], vdofs.Size());
|
||||
bf_i.MakeRef(bf, hat_offsets[i], vdofs.Size());
|
||||
if (mode == 1)
|
||||
{
|
||||
el_vals -= bf_i;
|
||||
@@ -821,7 +821,15 @@ void Hybridization::ReduceRHS(const Vector &b, Vector &b_r) const
|
||||
else
|
||||
{
|
||||
Vector bl(pC ? pC->Height() : Ct->Width());
|
||||
pC ? pC->Mult(bf, bl) : Ct->MultTranspose(bf, bl);
|
||||
if (pC)
|
||||
{
|
||||
pC->Mult(bf, bl);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ct->EnsureMultTranspose();
|
||||
Ct->MultTranspose(bf, bl);
|
||||
}
|
||||
b_r.SetSize(pH.Ptr()->Height());
|
||||
(P_pc ? P_pc : c_pfes->GetProlongationMatrix())->MultTranspose(bl, b_r);
|
||||
}
|
||||
|
||||
@@ -373,6 +373,7 @@ void ParBilinearForm::FormLinearSystem(
|
||||
P.MultTranspose(b, true_B);
|
||||
R.Mult(x, true_X);
|
||||
p_mat.EliminateBC(p_mat_e, ess_tdof_list, true_X, true_B);
|
||||
R.EnsureMultTranspose();
|
||||
R.MultTranspose(true_B, b);
|
||||
hybridization->ReduceRHS(true_B, B);
|
||||
X.SetSize(B.Size());
|
||||
|
||||
+21
-9
@@ -556,11 +556,25 @@ const FaceRestriction *ParFiniteElementSpace::GetFaceRestriction(
|
||||
FaceRestriction *res;
|
||||
if (is_dg_space)
|
||||
{
|
||||
res = new ParL2FaceRestriction(*this, e_ordering, type, m);
|
||||
if (Conforming())
|
||||
{
|
||||
res = new ParL2FaceRestriction(*this, e_ordering, type, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = new ParNCL2FaceRestriction(*this, e_ordering, type, m);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
res = new H1FaceRestriction(*this, e_ordering, type);
|
||||
if (Conforming())
|
||||
{
|
||||
res = new H1FaceRestriction(*this, e_ordering, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
res = new ParNCH1FaceRestriction(*this, e_ordering, type);
|
||||
}
|
||||
}
|
||||
L2F[key] = res;
|
||||
return res;
|
||||
@@ -1010,12 +1024,9 @@ void ParFiniteElementSpace::GetEssentialVDofs(const Array<int> &bdr_attr_is_ess,
|
||||
{
|
||||
FiniteElementSpace::GetEssentialVDofs(bdr_attr_is_ess, ess_dofs, component);
|
||||
|
||||
if (Conforming())
|
||||
{
|
||||
// Make sure that processors without boundary elements mark
|
||||
// their boundary dofs (if they have any).
|
||||
Synchronize(ess_dofs);
|
||||
}
|
||||
// Make sure that processors without boundary elements mark
|
||||
// their boundary dofs (if they have any).
|
||||
Synchronize(ess_dofs);
|
||||
}
|
||||
|
||||
void ParFiniteElementSpace::GetEssentialTrueDofs(const Array<int>
|
||||
@@ -1041,7 +1052,8 @@ void ParFiniteElementSpace::GetEssentialTrueDofs(const Array<int>
|
||||
{
|
||||
if (bool(ted[i]) != bool(true_ess_dofs2[i])) { counter++; }
|
||||
}
|
||||
MFEM_VERIFY(counter == 0, "internal MFEM error: counter = " << counter);
|
||||
MFEM_VERIFY(counter == 0, "internal MFEM error: counter = " << counter
|
||||
<< ", rank = " << MyRank);
|
||||
#endif
|
||||
|
||||
MarkerToList(true_ess_dofs, ess_tdof_list);
|
||||
|
||||
+878
-325
File diff suppressed because it is too large
Load Diff
+331
-17
@@ -23,34 +23,348 @@ namespace mfem
|
||||
|
||||
class ParFiniteElementSpace;
|
||||
|
||||
/// Operator that extracts Face degrees of freedom in parallel.
|
||||
/** Objects of this type are typically created and owned by FiniteElementSpace
|
||||
objects, see FiniteElementSpace::GetFaceRestriction(). */
|
||||
class ParL2FaceRestriction : public L2FaceRestriction
|
||||
/// Operator that extracts Face degrees of freedom for NCMesh in parallel.
|
||||
/** Objects of this type are typically created and owned by
|
||||
ParFiniteElementSpace objects, see
|
||||
ParFiniteElementSpace::GetFaceRestriction(). */
|
||||
class ParNCH1FaceRestriction : public H1FaceRestriction
|
||||
{
|
||||
protected:
|
||||
const FaceType type;
|
||||
InterpolationManager interpolations;
|
||||
mutable Vector x_interp;
|
||||
|
||||
public:
|
||||
ParL2FaceRestriction(const ParFiniteElementSpace&, ElementDofOrdering,
|
||||
/** @brief Constructs an ParNCH1FaceRestriction.
|
||||
|
||||
@param[in] fes The ParFiniteElementSpace on which this operates
|
||||
@param[in] ordering Request a specific ordering
|
||||
@param[in] type Request internal or boundary faces dofs */
|
||||
ParNCH1FaceRestriction(const ParFiniteElementSpace &fes,
|
||||
ElementDofOrdering ordering,
|
||||
FaceType type);
|
||||
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector.
|
||||
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
face_dofs x vdim x nf
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
void Mult(const Vector &x, Vector &y) const override;
|
||||
|
||||
/** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
|
||||
L-Vector.
|
||||
|
||||
@param[in] x The face E-Vector degrees of freedom with the given format:
|
||||
face_dofs x vdim x nf
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs should be ordered according to the given
|
||||
ElementDofOrdering.
|
||||
@param[in,out] y The L-vector degrees of freedom. */
|
||||
void AddMultTranspose(const Vector &x, Vector &y) const override;
|
||||
|
||||
private:
|
||||
/** @brief Compute the scatter indices: L-vector to E-vector, the offsets
|
||||
for the gathering: E-vector to L-vector, and the interpolators from
|
||||
coarse to fine face for master non-comforming faces.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeScatterIndicesAndOffsets(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
/** @brief Compute the gather indices: E-vector to L-vector.
|
||||
|
||||
Note: Requires the gather offsets to be computed.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeGatherIndices(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
};
|
||||
|
||||
/// Operator that extracts Face degrees of freedom in parallel.
|
||||
/** Objects of this type are typically created and owned by
|
||||
ParFiniteElementSpace objects, see
|
||||
ParFiniteElementSpace::GetFaceRestriction(). */
|
||||
class ParL2FaceRestriction : virtual public L2FaceRestriction
|
||||
{
|
||||
protected:
|
||||
/** @brief Constructs an ParL2FaceRestriction.
|
||||
|
||||
@param[in] fes The ParFiniteElementSpace on which this operates
|
||||
@param[in] ordering Request a specific ordering
|
||||
@param[in] type Request internal or boundary faces dofs
|
||||
@param[in] m Request the face dofs for elem1, or both elem1 and
|
||||
elem2
|
||||
@param[in] build Request the ParL2FaceRestriction to compute the
|
||||
scatter/gather indices. False should only be used
|
||||
when inheriting from ParL2FaceRestriction. */
|
||||
ParL2FaceRestriction(const ParFiniteElementSpace& fes,
|
||||
ElementDofOrdering ordering,
|
||||
FaceType type,
|
||||
L2FaceValues m,
|
||||
bool build);
|
||||
|
||||
public:
|
||||
/** @brief Constructs an ParL2FaceRestriction.
|
||||
|
||||
@param[in] fes The ParFiniteElementSpace on which this operates
|
||||
@param[in] ordering Request a specific ordering
|
||||
@param[in] type Request internal or boundary faces dofs
|
||||
@param[in] m Request the face dofs for elem1, or both elem1 and
|
||||
elem2 */
|
||||
ParL2FaceRestriction(const ParFiniteElementSpace& fes,
|
||||
ElementDofOrdering ordering,
|
||||
FaceType type,
|
||||
L2FaceValues m = L2FaceValues::DoubleValued);
|
||||
void Mult(const Vector &x, Vector &y) const;
|
||||
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector.
|
||||
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf),
|
||||
if L2FacesValues::SingleValued (face_dofs x vdim x nf),
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
void Mult(const Vector &x, Vector &y) const override;
|
||||
|
||||
/** Fill the I array of SparseMatrix corresponding to the sparsity pattern
|
||||
given by this L2FaceRestriction. */
|
||||
virtual void FillI(SparseMatrix &mat, const bool keep_nbr_block = false) const;
|
||||
given by this ParL2FaceRestriction.
|
||||
|
||||
@param[in,out] mat The sparse matrix for which we want to initialize the
|
||||
row offsets.
|
||||
@param[in] keep_nbr_block When set to true the SparseMatrix will
|
||||
include the rows (in addition to the columns)
|
||||
corresponding to face-neighbor dofs. The
|
||||
default behavior is to disregard those rows. */
|
||||
void FillI(SparseMatrix &mat,
|
||||
const bool keep_nbr_block = false) const override;
|
||||
|
||||
/** Fill the I array of SparseMatrix corresponding to the sparsity pattern
|
||||
given by this L2FaceRestriction. @a mat contains the interior dofs
|
||||
given by this ParL2FaceRestriction. @a mat contains the interior dofs
|
||||
contribution, the @a face_mat contains the shared dofs contribution.*/
|
||||
virtual void FillI(SparseMatrix &mat, SparseMatrix &face_mat) const;
|
||||
void FillI(SparseMatrix &mat,
|
||||
SparseMatrix &face_mat) const;
|
||||
|
||||
/** Fill the J and Data arrays of SparseMatrix corresponding to the sparsity
|
||||
pattern given by this L2FaceRestriction, and the values of ea_data.
|
||||
pattern given by this ParL2FaceRestriction, and the values of ea_data.
|
||||
@a mat contains the interior dofs contribution, the @a face_mat contains
|
||||
the shared dofs contribution.*/
|
||||
virtual void FillJAndData(const Vector &ea_data,
|
||||
SparseMatrix &mat,
|
||||
SparseMatrix &face_mat) const;
|
||||
void FillJAndData(const Vector &ea_data,
|
||||
SparseMatrix &mat,
|
||||
SparseMatrix &face_mat) const;
|
||||
|
||||
virtual void FillJAndData(const Vector &ea_data,
|
||||
SparseMatrix &mat,
|
||||
const bool keep_nbr_block = false) const;
|
||||
/** @brief Fill the J and Data arrays of the SparseMatrix corresponding to
|
||||
the sparsity pattern given by this ParL2FaceRestriction, and the values of
|
||||
fea_data.
|
||||
|
||||
@param[in] fea_data The dense matrices representing the local operators
|
||||
on each face. The format is:
|
||||
face_dofs x face_dofs x 2 x nf.
|
||||
On each face the first local matrix corresponds to
|
||||
the contribution of elem1 on elem2, and the second to
|
||||
the contribution of elem2 on elem1.
|
||||
@param[in,out] mat The sparse matrix that is getting filled.
|
||||
@param[in] keep_nbr_block When set to true the SparseMatrix will
|
||||
include the rows (in addition to the columns)
|
||||
corresponding to face-neighbor dofs. The
|
||||
default behavior is to disregard those rows. */
|
||||
void FillJAndData(const Vector &fea_data,
|
||||
SparseMatrix &mat,
|
||||
const bool keep_nbr_block = false) const override;
|
||||
|
||||
private:
|
||||
/** @brief Compute the scatter indices: L-vector to E-vector, and the offsets
|
||||
for the gathering: E-vector to L-vector.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeScatterIndicesAndOffsets(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
/** @brief Compute the gather indices: E-vector to L-vector.
|
||||
|
||||
Note: Requires the gather offsets to be computed.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeGatherIndices(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
public:
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector. Should only be used with conforming faces and when:
|
||||
m == L2FacesValues::DoubleValued
|
||||
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
face_dofs x vdim x 2 x nf
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
void DoubleValuedConformingMult(const Vector& x, Vector& y) const override;
|
||||
};
|
||||
|
||||
/// Operator that extracts Face degrees of freedom for NCMesh in parallel.
|
||||
/** Objects of this type are typically created and owned by
|
||||
ParFiniteElementSpace objects, see
|
||||
ParFiniteElementSpace::GetFaceRestriction(). */
|
||||
class ParNCL2FaceRestriction
|
||||
: public NCL2FaceRestriction, public ParL2FaceRestriction
|
||||
{
|
||||
public:
|
||||
/** @brief Constructs an ParNCL2FaceRestriction.
|
||||
|
||||
@param[in] fes The ParFiniteElementSpace on which this operates
|
||||
@param[in] ordering Request a specific ordering
|
||||
@param[in] type Request internal or boundary faces dofs
|
||||
@param[in] m Request the face dofs for elem1, or both elem1 and
|
||||
elem2 */
|
||||
ParNCL2FaceRestriction(const ParFiniteElementSpace& fes,
|
||||
ElementDofOrdering ordering,
|
||||
FaceType type,
|
||||
L2FaceValues m = L2FaceValues::DoubleValued);
|
||||
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector.
|
||||
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf),
|
||||
if L2FacesValues::SingleValued (face_dofs x vdim x nf),
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
void Mult(const Vector &x, Vector &y) const override;
|
||||
|
||||
/** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
|
||||
L-Vector.
|
||||
|
||||
@param[in] x The face E-Vector degrees of freedom with the given format:
|
||||
if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf),
|
||||
if L2FacesValues::SingleValued (face_dofs x vdim x nf),
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs should be ordered according to the given
|
||||
ElementDofOrdering
|
||||
@param[in,out] y The L-vector degrees of freedom. */
|
||||
void AddMultTranspose(const Vector &x, Vector &y) const override;
|
||||
|
||||
/** @brief Fill the I array of SparseMatrix corresponding to the sparsity
|
||||
pattern given by this ParNCL2FaceRestriction.
|
||||
|
||||
@param[in,out] mat The sparse matrix for which we want to initialize the
|
||||
row offsets.
|
||||
@param[in] keep_nbr_block When set to true the SparseMatrix will
|
||||
include the rows (in addition to the columns)
|
||||
corresponding to face-neighbor dofs. The
|
||||
default behavior is to disregard those rows.
|
||||
|
||||
@warning This method is not implemented yet. */
|
||||
void FillI(SparseMatrix &mat,
|
||||
const bool keep_nbr_block = false) const override;
|
||||
|
||||
/** Fill the I array of SparseMatrix corresponding to the sparsity pattern
|
||||
given by this ParNCL2FaceRestriction. @a mat contains the interior dofs
|
||||
contribution, the @a face_mat contains the shared dofs contribution.
|
||||
|
||||
@warning This method is not implemented yet. */
|
||||
void FillI(SparseMatrix &mat,
|
||||
SparseMatrix &face_mat) const;
|
||||
|
||||
/** Fill the J and Data arrays of SparseMatrix corresponding to the sparsity
|
||||
pattern given by this ParNCL2FaceRestriction, and the values of ea_data.
|
||||
@a mat contains the interior dofs contribution, the @a face_mat contains
|
||||
the shared dofs contribution.
|
||||
|
||||
@warning This method is not implemented yet. */
|
||||
void FillJAndData(const Vector &fea_data,
|
||||
SparseMatrix &mat,
|
||||
SparseMatrix &face_mat) const;
|
||||
|
||||
/** @brief Fill the J and Data arrays of the SparseMatrix corresponding to
|
||||
the sparsity pattern given by this ParNCL2FaceRestriction, and the values
|
||||
of ea_data.
|
||||
|
||||
@param[in] fea_data The dense matrices representing the local operators
|
||||
on each face. The format is:
|
||||
face_dofs x face_dofs x 2 x nf.
|
||||
On each face the first local matrix corresponds to
|
||||
the contribution of elem1 on elem2, and the second to
|
||||
the contribution of elem2 on elem1.
|
||||
@param[in,out] mat The sparse matrix that is getting filled.
|
||||
@param[in] keep_nbr_block When set to true the SparseMatrix will
|
||||
include the rows (in addition to the columns)
|
||||
corresponding to face-neighbor dofs. The
|
||||
default behavior is to disregard those rows.
|
||||
|
||||
@warning This method is not implemented yet. */
|
||||
void FillJAndData(const Vector &fea_data,
|
||||
SparseMatrix &mat,
|
||||
const bool keep_nbr_block = false) const override;
|
||||
|
||||
private:
|
||||
/** @brief Compute the scatter indices: L-vector to E-vector, the offsets
|
||||
for the gathering: E-vector to L-vector, and the interpolators from
|
||||
coarse to fine face for master non-comforming faces.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeScatterIndicesAndOffsets(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
/** @brief Compute the gather indices: E-vector to L-vector.
|
||||
|
||||
Note: Requires the gather offsets to be computed.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeGatherIndices(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
public:
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector. Should only be used with nonconforming faces and when:
|
||||
L2FaceValues m == L2FaceValues::SingleValued
|
||||
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
(face_dofs x vdim x nf),
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
void SingleValuedNonconformingMult(const Vector& x, Vector& y) const;
|
||||
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector. Should only be used with nonconforming faces and when:
|
||||
L2FaceValues m == L2FaceValues::DoubleValued
|
||||
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
(face_dofs x vdim x 2 x nf),
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
void DoubleValuedNonconformingMult(const Vector& x, Vector& y) const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -65,13 +65,13 @@ static void Values2D(const int NE,
|
||||
MFEM_SHARED double sm0[NBZ][MDQ*MDQ];
|
||||
MFEM_SHARED double sm1[NBZ][MDQ*MDQ];
|
||||
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,b,sB);
|
||||
|
||||
ConstDeviceMatrix B(sB, D1D,Q1D);
|
||||
DeviceMatrix DD(sm0[tidz], MD1, MD1);
|
||||
DeviceMatrix DQ(sm1[tidz], MD1, MQ1);
|
||||
DeviceMatrix QQ(sm0[tidz], MQ1, MQ1);
|
||||
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,b,sB);
|
||||
|
||||
for (int c = 0; c < VDIM; c++)
|
||||
{
|
||||
kernels::internal::LoadX(e,D1D,c,x,DD);
|
||||
@@ -126,14 +126,14 @@ static void Values3D(const int NE,
|
||||
MFEM_SHARED double sm0[MDQ*MDQ*MDQ];
|
||||
MFEM_SHARED double sm1[MDQ*MDQ*MDQ];
|
||||
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,b,sB);
|
||||
|
||||
ConstDeviceMatrix B(sB, D1D,Q1D);
|
||||
DeviceCube DDD(sm0, MD1,MD1,MD1);
|
||||
DeviceCube DDQ(sm1, MD1,MD1,MQ1);
|
||||
DeviceCube DQQ(sm0, MD1,MQ1,MQ1);
|
||||
DeviceCube QQQ(sm1, MQ1,MQ1,MQ1);
|
||||
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,b,sB);
|
||||
|
||||
for (int c = 0; c < VDIM; c++)
|
||||
{
|
||||
kernels::internal::LoadX(e,D1D,c,x,DDD);
|
||||
|
||||
@@ -21,18 +21,21 @@ namespace mfem
|
||||
static void GetSigns(const FiniteElementSpace &fes, const FaceType type,
|
||||
Array<bool> &signs)
|
||||
{
|
||||
const int dim = fes.GetMesh()->SpaceDimension();
|
||||
int e1, e2;
|
||||
int inf1, inf2;
|
||||
const Mesh &mesh = *fes.GetMesh();
|
||||
const int dim = mesh.SpaceDimension();
|
||||
int face_id;
|
||||
int f_ind = 0;
|
||||
for (int f = 0; f < fes.GetNF(); ++f)
|
||||
for (int f = 0; f < mesh.GetNumFacesWithGhost(); ++f)
|
||||
{
|
||||
fes.GetMesh()->GetFaceElements(f, &e1, &e2);
|
||||
fes.GetMesh()->GetFaceInfos(f, &inf1, &inf2);
|
||||
face_id = inf1 / 64;
|
||||
if ( (type==FaceType::Interior && (e2>=0 || (e2<0 && inf2>=0))) ||
|
||||
(type==FaceType::Boundary && e2<0 && inf2<0) )
|
||||
Mesh::FaceInformation face = mesh.GetFaceInformation(f);
|
||||
face_id = face.element[0].local_face_id;
|
||||
if (face.IsNonconformingCoarse())
|
||||
{
|
||||
// We skip nonconforming coarse-fine faces as they are treated
|
||||
// by the corresponding nonconforming fine-coarse faces.
|
||||
continue;
|
||||
}
|
||||
else if ( face.IsOfFaceType(type) )
|
||||
{
|
||||
if (dim==2)
|
||||
{
|
||||
|
||||
+1212
-522
File diff suppressed because it is too large
Load Diff
+665
-71
@@ -41,7 +41,7 @@ protected:
|
||||
const int nedofs;
|
||||
Array<int> offsets;
|
||||
Array<int> indices;
|
||||
Array<int> gatherMap;
|
||||
Array<int> gather_map;
|
||||
|
||||
public:
|
||||
ElementRestriction(const FiniteElementSpace&, ElementDofOrdering);
|
||||
@@ -172,125 +172,719 @@ class H1FaceRestriction : public FaceRestriction
|
||||
{
|
||||
protected:
|
||||
const FiniteElementSpace &fes;
|
||||
const int nf;
|
||||
const int nf; // Number of faces of the requested type
|
||||
const int vdim;
|
||||
const bool byvdim;
|
||||
const int ndofs;
|
||||
const int dof;
|
||||
const int nfdofs;
|
||||
Array<int> scatter_indices;
|
||||
Array<int> offsets;
|
||||
Array<int> gather_indices;
|
||||
const int face_dofs; // Number of dofs on each face
|
||||
const int elem_dofs; // Number of dofs in each element
|
||||
const int nfdofs; // Total number of face E-vector dofs
|
||||
const int ndofs; // Total number of dofs
|
||||
Array<int> scatter_indices; // Scattering indices for element 1 on each face
|
||||
Array<int> gather_offsets; // offsets for the gathering indices of each dof
|
||||
Array<int> gather_indices; // gathering indices for each dof
|
||||
|
||||
public:
|
||||
/** @brief Constructor for a H1FaceRestriction.
|
||||
/** @brief Construct an H1FaceRestriction.
|
||||
|
||||
@param[in] fes The FiniteElementSpace on which this H1FaceRestriction
|
||||
operates.
|
||||
@param[in] ordering The requested output ordering of the
|
||||
H1FaceRestriction, either Native or Lexicographic.
|
||||
@param[in] type The requested type of faces on which this operator
|
||||
extracts the degrees of freedom, either Interior or
|
||||
Boundary.
|
||||
@param[in] fes The FiniteElementSpace on which this operates
|
||||
@param[in] ordering Request a specific element ordering
|
||||
@param[in] type Request internal or boundary faces dofs
|
||||
@param[in] build Request the NCL2FaceRestriction to compute the
|
||||
scatter/gather indices. False should only be used
|
||||
when inheriting from H1FaceRestriction.
|
||||
*/
|
||||
H1FaceRestriction(const FiniteElementSpace& fes,
|
||||
const ElementDofOrdering ordering,
|
||||
const FaceType type,
|
||||
bool build);
|
||||
public:
|
||||
/** @brief Construct an H1FaceRestriction.
|
||||
|
||||
@param[in] fes The FiniteElementSpace on which this operates
|
||||
@param[in] ordering Request a specific element ordering
|
||||
@param[in] type Request internal or boundary faces dofs */
|
||||
H1FaceRestriction(const FiniteElementSpace& fes,
|
||||
const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
/** @brief Extract the face degrees of freedom from @a x into @a y.
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector.
|
||||
|
||||
@param[in] x The L-vector of degrees of freedom.
|
||||
@param[out] y The degrees of freedom on the face, corresponding to a face
|
||||
E-vector.
|
||||
*/
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
face_dofs x vdim x nf
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
void Mult(const Vector &x, Vector &y) const override;
|
||||
|
||||
/** @brief Add the face degrees of freedom @a x to the element degrees of
|
||||
freedom @a y.
|
||||
/** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
|
||||
L-Vector.
|
||||
|
||||
@param[in] x The face degrees of freedom on the face.
|
||||
@param[in,out] y The L-vector of degrees of freedom to which we add the
|
||||
face degrees of freedom.
|
||||
*/
|
||||
@param[in] x The face E-Vector degrees of freedom with the given format:
|
||||
face_dofs x vdim x nf
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs should be ordered according to the given
|
||||
ElementDofOrdering
|
||||
@param[in,out] y The L-vector degrees of freedom. */
|
||||
void AddMultTranspose(const Vector &x, Vector &y) const override;
|
||||
|
||||
private:
|
||||
/** @brief Compute the scatter indices: L-vector to E-vector, and the offsets
|
||||
for the gathering: E-vector to L-vector.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeScatterIndicesAndOffsets(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
/** @brief Compute the gather indices: E-vector to L-vector.
|
||||
|
||||
Note: Requires the gather offsets to be computed.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeGatherIndices(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
protected:
|
||||
mutable Array<int> face_map; // Used in the computation of GetFaceDofs
|
||||
|
||||
/** @brief Verify that H1FaceRestriction is build from an H1 FESpace.
|
||||
|
||||
@param[in] ordering The FESpace element ordering.
|
||||
*/
|
||||
void CheckFESpace(const ElementDofOrdering ordering);
|
||||
|
||||
/** @brief Set the scattering indices of elem1, and increment the offsets for
|
||||
the face described by the @a face.
|
||||
|
||||
@param[in] face The face information of the current face.
|
||||
@param[in] face_index The interior/boundary face index.
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
*/
|
||||
void SetFaceDofsScatterIndices(const Mesh::FaceInformation &face,
|
||||
const int face_index,
|
||||
const ElementDofOrdering ordering);
|
||||
|
||||
/** @brief Set the gathering indices of elem1 for the interior face described
|
||||
by the @a face.
|
||||
|
||||
@param[in] face The face information of the current face.
|
||||
@param[in] face_index The interior/boundary face index.
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
*/
|
||||
void SetFaceDofsGatherIndices(const Mesh::FaceInformation &face,
|
||||
const int face_index,
|
||||
const ElementDofOrdering ordering);
|
||||
};
|
||||
|
||||
/// Operator that extracts Face degrees of freedom on L2 FiniteElementSpaces.
|
||||
/// Operator that extracts Face degrees of freedom for L2 spaces.
|
||||
/** Objects of this type are typically created and owned by FiniteElementSpace
|
||||
objects, see FiniteElementSpace::GetFaceRestriction(). */
|
||||
class L2FaceRestriction : public FaceRestriction
|
||||
{
|
||||
protected:
|
||||
const FiniteElementSpace &fes;
|
||||
const int nf;
|
||||
const int ne;
|
||||
const int vdim;
|
||||
const int nf; // Number of faces of the requested type
|
||||
const int ne; // Number of elements
|
||||
const int vdim; // vdim
|
||||
const bool byvdim;
|
||||
const int ndofs;
|
||||
const int dof;
|
||||
const int elemDofs;
|
||||
const int face_dofs; // Number of dofs on each face
|
||||
const int elem_dofs; // Number of dofs in each element
|
||||
const int nfdofs; // Total number of dofs on the faces
|
||||
const int ndofs; // Total number of dofs
|
||||
const FaceType type;
|
||||
const L2FaceValues m;
|
||||
const int nfdofs;
|
||||
Array<int> scatter_indices1;
|
||||
Array<int> scatter_indices2;
|
||||
Array<int> offsets;
|
||||
Array<int> gather_indices;
|
||||
Array<int> scatter_indices1; // Scattering indices for element 1 on each face
|
||||
Array<int> scatter_indices2; // Scattering indices for element 2 on each face
|
||||
Array<int> gather_offsets; // offsets for the gathering indices of each dof
|
||||
Array<int> gather_indices; // gathering indices for each dof
|
||||
|
||||
L2FaceRestriction(const FiniteElementSpace&,
|
||||
const FaceType,
|
||||
const L2FaceValues m = L2FaceValues::DoubleValued);
|
||||
/** @brief Constructs an L2FaceRestriction.
|
||||
|
||||
@param[in] fes The FiniteElementSpace on which this operates
|
||||
@param[in] ordering Request a specific ordering
|
||||
@param[in] type Request internal or boundary faces dofs
|
||||
@param[in] m Request the face dofs for elem1, or both elem1 and
|
||||
elem2
|
||||
@param[in] build Request the NCL2FaceRestriction to compute the
|
||||
scatter/gather indices. False should only be used
|
||||
when inheriting from L2FaceRestriction.
|
||||
*/
|
||||
L2FaceRestriction(const FiniteElementSpace& fes,
|
||||
const ElementDofOrdering ordering,
|
||||
const FaceType type,
|
||||
const L2FaceValues m,
|
||||
bool build);
|
||||
|
||||
public:
|
||||
L2FaceRestriction(const FiniteElementSpace&,
|
||||
const ElementDofOrdering,
|
||||
const FaceType,
|
||||
/** @brief Constructs an L2FaceRestriction.
|
||||
|
||||
@param[in] fes The FiniteElementSpace on which this operates
|
||||
@param[in] ordering Request a specific ordering
|
||||
@param[in] type Request internal or boundary faces dofs
|
||||
@param[in] m Request the face dofs for elem1, or both elem1 and
|
||||
elem2 */
|
||||
L2FaceRestriction(const FiniteElementSpace& fes,
|
||||
const ElementDofOrdering ordering,
|
||||
const FaceType type,
|
||||
const L2FaceValues m = L2FaceValues::DoubleValued);
|
||||
|
||||
/** @brief Extract the face degrees of freedom from @a x into @a y.
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector.
|
||||
|
||||
@param[in] x The L-vector of degrees of freedom.
|
||||
@param[out] y The degrees of freedom on the face, corresponding to a face
|
||||
E-vector.
|
||||
*/
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf)
|
||||
if L2FacesValues::SingleValued (face_dofs x vdim x nf)
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
void Mult(const Vector &x, Vector &y) const override;
|
||||
|
||||
/** @brief Add the face degrees of freedom @a x to the element degrees of
|
||||
freedom @a y.
|
||||
/** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
|
||||
L-Vector.
|
||||
|
||||
@param[in] x The face degrees of freedom on the face.
|
||||
@param[in,out] y The L-vector of degrees of freedom to which we add the
|
||||
face degrees of freedom.
|
||||
*/
|
||||
@param[in] x The face E-Vector degrees of freedom with the given format:
|
||||
if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf)
|
||||
if L2FacesValues::SingleValued (face_dofs x vdim x nf)
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs should be ordered according to the given
|
||||
ElementDofOrdering
|
||||
@param[in,out] y The L-vector degrees of freedom. */
|
||||
void AddMultTranspose(const Vector &x, Vector &y) const override;
|
||||
|
||||
/** Fill the I array of SparseMatrix corresponding to the sparsity pattern
|
||||
given by this L2FaceRestriction. */
|
||||
/** @brief Fill the I array of SparseMatrix corresponding to the sparsity
|
||||
pattern given by this L2FaceRestriction.
|
||||
|
||||
@param[in,out] mat The sparse matrix for which we want to initialize the
|
||||
row offsets.
|
||||
@param[in] keep_nbr_block When set to true the SparseMatrix will
|
||||
include the rows (in addition to the columns)
|
||||
corresponding to face-neighbor dofs. The
|
||||
default behavior is to disregard those rows. */
|
||||
virtual void FillI(SparseMatrix &mat, const bool keep_nbr_block = false) const;
|
||||
|
||||
/** Fill the J and Data arrays of SparseMatrix corresponding to the sparsity
|
||||
pattern given by this L2FaceRestriction, and the values of ea_data. */
|
||||
virtual void FillJAndData(const Vector &ea_data,
|
||||
/** @brief Fill the J and Data arrays of the SparseMatrix corresponding to
|
||||
the sparsity pattern given by this L2FaceRestriction, and the values of
|
||||
fea_data.
|
||||
|
||||
@param[in] fea_data The dense matrices representing the local operators
|
||||
on each face. The format is:
|
||||
face_dofs x face_dofs x 2 x nf
|
||||
On each face the first local matrix corresponds to
|
||||
the contribution of elem1 on elem2, and the second to
|
||||
the contribution of elem2 on elem1.
|
||||
@param[in,out] mat The sparse matrix that is getting filled.
|
||||
@param[in] keep_nbr_block When set to true the SparseMatrix will
|
||||
include the rows (in addition to the columns)
|
||||
corresponding to face-neighbor dofs. The
|
||||
default behavior is to disregard those rows. */
|
||||
virtual void FillJAndData(const Vector &fea_data,
|
||||
SparseMatrix &mat,
|
||||
const bool keep_nbr_block = false) const;
|
||||
|
||||
/// This methods adds the DG face matrices to the element matrices.
|
||||
void AddFaceMatricesToElementMatrices(Vector &fea_data,
|
||||
Vector &ea_data) const;
|
||||
/** @brief This methods adds the DG face matrices to the element matrices.
|
||||
|
||||
@param[in] fea_data The dense matrices representing the local operators
|
||||
on each face. The format is:
|
||||
face_dofs x face_dofs x 2 x nf
|
||||
On each face the first and second local matrices
|
||||
correspond to the contributions of elem1 and elem2 on
|
||||
themselves respectively.
|
||||
@param[in,out] ea_data The dense matrices representing the element local
|
||||
contributions for each element to which will be
|
||||
added the face contributions.
|
||||
The format is: dofs x dofs x ne, where dofs is the
|
||||
number of dofs per element and ne the number of
|
||||
elements. */
|
||||
virtual void AddFaceMatricesToElementMatrices(const Vector &fea_data,
|
||||
Vector &ea_data) const;
|
||||
|
||||
private:
|
||||
/** @brief Compute the scatter indices: L-vector to E-vector, and the offsets
|
||||
for the gathering: E-vector to L-vector.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeScatterIndicesAndOffsets(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
/** @brief Compute the gather indices: E-vector to L-vector.
|
||||
|
||||
Note: Requires the gather offsets to be computed.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeGatherIndices(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
protected:
|
||||
mutable Array<int> face_map; // Used in the computation of GetFaceDofs
|
||||
|
||||
/** @brief Verify that L2FaceRestriction is build from an L2 FESpace.
|
||||
|
||||
@param[in] ordering The FESpace element ordering.
|
||||
*/
|
||||
void CheckFESpace(const ElementDofOrdering ordering);
|
||||
|
||||
/** @brief Set the scattering indices of elem1, and increment the offsets for
|
||||
the face described by the @a face. The ordering of the face dofs of elem1
|
||||
is lexicographic relative to elem1.
|
||||
|
||||
@param[in] face The face information of the current face.
|
||||
@param[in] face_index The interior/boundary face index.
|
||||
*/
|
||||
void SetFaceDofsScatterIndices1(const Mesh::FaceInformation &face,
|
||||
const int face_index);
|
||||
|
||||
/** @brief Permute and set the scattering indices of elem2, and increment the
|
||||
offsets for the face described by the @a face. The permutation orders the
|
||||
dofs of elem2 lexicographically as the ones of elem1.
|
||||
|
||||
@param[in] face The face information of the current face.
|
||||
@param[in] face_index The interior/boundary face index.
|
||||
*/
|
||||
void PermuteAndSetFaceDofsScatterIndices2(const Mesh::FaceInformation &face,
|
||||
const int face_index);
|
||||
|
||||
/** @brief Permute and set the scattering indices of elem2 for the shared
|
||||
face described by the @a face. The permutation orders the dofs of elem2 as
|
||||
the ones of elem1.
|
||||
|
||||
@param[in] face The face information of the current face.
|
||||
@param[in] face_index The interior/boundary face index.
|
||||
*/
|
||||
void PermuteAndSetSharedFaceDofsScatterIndices2(
|
||||
const Mesh::FaceInformation &face,
|
||||
const int face_index);
|
||||
|
||||
/** @brief Set the scattering indices of elem2 for the boundary face
|
||||
described by the @a face.
|
||||
|
||||
@param[in] face The face information of the current face.
|
||||
@param[in] face_index The interior/boundary face index.
|
||||
*/
|
||||
void SetBoundaryDofsScatterIndices2(const Mesh::FaceInformation &face,
|
||||
const int face_index);
|
||||
|
||||
/** @brief Set the gathering indices of elem1 for the interior face described
|
||||
by the @a face.
|
||||
|
||||
Note: This function modifies the offsets.
|
||||
|
||||
@param[in] face The face information of the current face.
|
||||
@param[in] face_index The interior/boundary face index.
|
||||
*/
|
||||
void SetFaceDofsGatherIndices1(const Mesh::FaceInformation &face,
|
||||
const int face_index);
|
||||
|
||||
/** @brief Permute and set the gathering indices of elem2 for the interior
|
||||
face described by the @a face. The permutation orders the dofs of elem2 as
|
||||
the ones of elem1.
|
||||
|
||||
Note: This function modifies the offsets.
|
||||
|
||||
@param[in] face The face information of the current face.
|
||||
@param[in] face_index The interior/boundary face index.
|
||||
*/
|
||||
void PermuteAndSetFaceDofsGatherIndices2(const Mesh::FaceInformation &face,
|
||||
const int face_index);
|
||||
|
||||
public:
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector. Should only be used with conforming faces and when:
|
||||
m == L2FacesValues::SingleValued
|
||||
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
face_dofs x vdim x nf
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
void SingleValuedConformingMult(const Vector& x, Vector& y) const;
|
||||
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector. Should only be used with conforming faces and when:
|
||||
m == L2FacesValues::DoubleValued
|
||||
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
face_dofs x vdim x 2 x nf
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
virtual void DoubleValuedConformingMult(const Vector& x, Vector& y) const;
|
||||
|
||||
/** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
|
||||
L-Vector. Should only be used with conforming faces and when:
|
||||
m == L2FacesValues::SingleValued
|
||||
|
||||
@param[in] x The face E-Vector degrees of freedom with the given format:
|
||||
face_dofs x vdim x nf
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs should be ordered according to the given
|
||||
ElementDofOrdering
|
||||
@param[in,out] y The L-vector degrees of freedom. */
|
||||
void SingleValuedConformingAddMultTranspose(const Vector& x, Vector& y) const;
|
||||
|
||||
/** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
|
||||
L-Vector. Should only be used with conforming faces and when:
|
||||
m == L2FacesValues::DoubleValued
|
||||
|
||||
@param[in] x The face E-Vector degrees of freedom with the given format:
|
||||
face_dofs x vdim x 2 x nf
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs should be ordered according to the given
|
||||
ElementDofOrdering
|
||||
@param[in,out] y The L-vector degrees of freedom. */
|
||||
void DoubleValuedConformingAddMultTranspose(const Vector& x, Vector& y) const;
|
||||
};
|
||||
|
||||
// Return the face degrees of freedom returned in Lexicographic order.
|
||||
void GetFaceDofs(const int dim, const int face_id,
|
||||
const int dof1d, Array<int> &faceMap);
|
||||
/** This struct stores which side is the master nonconforming side and the
|
||||
index of the interpolator, see InterpolationManager class below. */
|
||||
struct InterpConfig
|
||||
{
|
||||
uint32_t is_non_conforming : 1;
|
||||
uint32_t master_side : 1;
|
||||
uint32_t index : 30;
|
||||
|
||||
// Convert from Native ordering to lexicographic ordering
|
||||
// default constructor, create a conforming face with index 0.
|
||||
InterpConfig() = default;
|
||||
|
||||
// Non-conforming face
|
||||
InterpConfig(int master_side, int nc_index)
|
||||
: is_non_conforming(1), master_side(master_side), index(nc_index)
|
||||
{ }
|
||||
|
||||
InterpConfig(const InterpConfig&) = default;
|
||||
|
||||
InterpConfig &operator=(const InterpConfig &rhs) = default;
|
||||
};
|
||||
|
||||
/** @brief This class manages the storage and computation of the interpolations
|
||||
from master (coarse) face to slave (fine) face.
|
||||
*/
|
||||
class InterpolationManager
|
||||
{
|
||||
protected:
|
||||
const FiniteElementSpace &fes;
|
||||
const ElementDofOrdering ordering;
|
||||
Array<InterpConfig> interp_config; // interpolator index for each face
|
||||
Vector interpolators; // face_dofs x face_dofs x num_interpolators
|
||||
int nc_cpt; // Counter for interpolators, and used as index.
|
||||
|
||||
/** The interpolators are associated to a key of containing the address of
|
||||
PointMatrix and a local face identifier. */
|
||||
using Key = std::pair<const DenseMatrix*,int>;
|
||||
/// The temporary map used to store the different interpolators.
|
||||
using Map = std::map<Key, std::pair<int,const DenseMatrix*>>;
|
||||
Map interp_map; // The temporary map that stores the interpolators.
|
||||
|
||||
public:
|
||||
InterpolationManager() = delete;
|
||||
|
||||
/** @brief main constructor.
|
||||
|
||||
@param[in] fes The FiniteElementSpace on which this operates
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs
|
||||
*/
|
||||
InterpolationManager(const FiniteElementSpace &fes,
|
||||
ElementDofOrdering ordering,
|
||||
FaceType type);
|
||||
|
||||
/** @brief Register the face with @a face and index @a face_index as a
|
||||
conforming face for the interpolation of the degrees of freedom.
|
||||
|
||||
@param[in] face The face information of the current face.
|
||||
@param[in] face_index The interior/boundary face index.
|
||||
*/
|
||||
void RegisterFaceConformingInterpolation(const Mesh::FaceInformation &face,
|
||||
int face_index);
|
||||
|
||||
/** @brief Register the face with @a face and index @a face_index as a
|
||||
conforming face for the interpolation of the degrees of freedom.
|
||||
|
||||
@param[in] face The face information of the current face.
|
||||
@param[in] face_index The interior/boundary face index.
|
||||
*/
|
||||
void RegisterFaceCoarseToFineInterpolation(const Mesh::FaceInformation &face,
|
||||
int face_index);
|
||||
|
||||
/** @brief Transform the interpolation matrix map into a contiguous memory
|
||||
structure. */
|
||||
void LinearizeInterpolatorMapIntoVector();
|
||||
|
||||
/// @brief Return the total number of interpolators.
|
||||
int GetNumInterpolators() const
|
||||
{
|
||||
return nc_cpt;
|
||||
}
|
||||
|
||||
/** @brief Return an mfem::Vector containing the interpolators in the
|
||||
following format: face_dofs x face_dofs x num_interpolators. */
|
||||
const Vector& GetInterpolators() const
|
||||
{
|
||||
return interpolators;
|
||||
}
|
||||
|
||||
/** @brief Return an array containing the interpolation configuration for
|
||||
each face registered with RegisterFaceConformingInterpolation and
|
||||
RegisterFaceCoarseToFineInterpolation. */
|
||||
const Array<InterpConfig>& GetFaceInterpConfig() const
|
||||
{
|
||||
return interp_config;
|
||||
}
|
||||
|
||||
private:
|
||||
/** @brief Returns the interpolation operator from a master (coarse) face to
|
||||
a slave (fine) face.
|
||||
|
||||
@param[in] face The face information of the current face.
|
||||
@param[in] ptMat The PointMatrix describing the position and orientation
|
||||
of the fine face in the coarse face. This PointMatrix is
|
||||
usually obtained from the mesh through the method
|
||||
GetNCFacesPtMat.
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@return The dense matrix corresponding to the interpolation of the face
|
||||
degrees of freedom of the master (coarse) face to the slave
|
||||
(fine) face. */
|
||||
const DenseMatrix* GetCoarseToFineInterpolation(
|
||||
const Mesh::FaceInformation &face,
|
||||
const DenseMatrix* ptMat);
|
||||
};
|
||||
|
||||
/** @brief Operator that extracts face degrees of freedom for L2 nonconforming
|
||||
spaces.
|
||||
|
||||
In order to support face restrictions on nonconforming meshes, this
|
||||
operator interpolates master (coarse) face degrees of freedom onto the
|
||||
slave (fine) face. This allows face integrators to treat nonconforming
|
||||
faces just as regular conforming faces. */
|
||||
class NCL2FaceRestriction : virtual public L2FaceRestriction
|
||||
{
|
||||
protected:
|
||||
InterpolationManager interpolations;
|
||||
mutable Vector x_interp;
|
||||
|
||||
/** @brief Constructs an NCL2FaceRestriction, this is a specialization of a
|
||||
L2FaceRestriction for nonconforming meshes.
|
||||
|
||||
@param[in] fes The FiniteElementSpace on which this operates
|
||||
@param[in] ordering Request a specific ordering
|
||||
@param[in] type Request internal or boundary faces dofs
|
||||
@param[in] m Request the face dofs for elem1, or both elem1 and
|
||||
elem2
|
||||
@param[in] build Request the NCL2FaceRestriction to compute the
|
||||
scatter/gather indices. False should only be used
|
||||
when inheriting from NCL2FaceRestriction.
|
||||
*/
|
||||
NCL2FaceRestriction(const FiniteElementSpace& fes,
|
||||
const ElementDofOrdering ordering,
|
||||
const FaceType type,
|
||||
const L2FaceValues m,
|
||||
bool build);
|
||||
public:
|
||||
/** @brief Constructs an NCL2FaceRestriction, this is a specialization of a
|
||||
L2FaceRestriction for nonconforming meshes.
|
||||
|
||||
@param[in] fes The FiniteElementSpace on which this operates
|
||||
@param[in] ordering Request a specific ordering
|
||||
@param[in] type Request internal or boundary faces dofs
|
||||
@param[in] m Request the face dofs for elem1, or both elem1 and
|
||||
elem2
|
||||
*/
|
||||
NCL2FaceRestriction(const FiniteElementSpace& fes,
|
||||
const ElementDofOrdering ordering,
|
||||
const FaceType type,
|
||||
const L2FaceValues m = L2FaceValues::DoubleValued);
|
||||
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector.
|
||||
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf),
|
||||
if L2FacesValues::SingleValued (face_dofs x vdim x nf),
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
void Mult(const Vector &x, Vector &y) const override;
|
||||
|
||||
/** @brief Gather the degrees of freedom, i.e. goes from face E-Vector to
|
||||
L-Vector.
|
||||
|
||||
@param[in] x The face E-Vector degrees of freedom with the given format:
|
||||
if L2FacesValues::DoubleValued (face_dofs x vdim x 2 x nf),
|
||||
if L2FacesValues::SingleValued (face_dofs x vdim x nf),
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs should be ordered according to the given
|
||||
ElementDofOrdering
|
||||
@param[in,out] y The L-vector degrees of freedom. */
|
||||
void AddMultTranspose(const Vector &x, Vector &y) const override;
|
||||
|
||||
/** @brief Fill the I array of SparseMatrix corresponding to the sparsity
|
||||
pattern given by this NCL2FaceRestriction.
|
||||
|
||||
@param[in,out] mat The sparse matrix for which we want to initialize the
|
||||
row offsets.
|
||||
@param[in] keep_nbr_block When set to true the SparseMatrix will
|
||||
include the rows (in addition to the columns)
|
||||
corresponding to face-neighbor dofs. The
|
||||
default behavior is to disregard those rows.
|
||||
|
||||
@warning This method is not implemented yet. */
|
||||
void FillI(SparseMatrix &mat,
|
||||
const bool keep_nbr_block = false) const override;
|
||||
|
||||
/** @brief Fill the J and Data arrays of the SparseMatrix corresponding to
|
||||
the sparsity pattern given by this NCL2FaceRestriction, and the values of
|
||||
ea_data.
|
||||
|
||||
@param[in] fea_data The dense matrices representing the local operators
|
||||
on each face. The format is:
|
||||
face_dofs x face_dofs x 2 x nf.
|
||||
On each face the first local matrix corresponds to
|
||||
the contribution of elem1 on elem2, and the second to
|
||||
the contribution of elem2 on elem1.
|
||||
@param[in,out] mat The sparse matrix that is getting filled.
|
||||
@param[in] keep_nbr_block When set to true the SparseMatrix will
|
||||
include the rows (in addition to the columns)
|
||||
corresponding to face-neighbor dofs. The
|
||||
default behavior is to disregard those rows.
|
||||
|
||||
@warning This method is not implemented yet. */
|
||||
void FillJAndData(const Vector &fea_data,
|
||||
SparseMatrix &mat,
|
||||
const bool keep_nbr_block = false) const override;
|
||||
|
||||
/** @brief This methods adds the DG face matrices to the element matrices.
|
||||
|
||||
@param[in] fea_data The dense matrices representing the local operators
|
||||
on each face. The format is:
|
||||
face_dofs x face_dofs x 2 x nf.
|
||||
On each face the first and second local matrices
|
||||
correspond to the contributions of elem1 and elem2 on
|
||||
themselves respectively.
|
||||
@param[in,out] ea_data The dense matrices representing the element local
|
||||
contributions for each element to which will be
|
||||
added the face contributions.
|
||||
The format is: dofs x dofs x ne, where dofs is the
|
||||
number of dofs per element and ne the number of
|
||||
elements.
|
||||
|
||||
@warning This method is not implemented yet. */
|
||||
void AddFaceMatricesToElementMatrices(const Vector &fea_data,
|
||||
Vector &ea_data) const override;
|
||||
|
||||
private:
|
||||
/** @brief Compute the scatter indices: L-vector to E-vector, the offsets
|
||||
for the gathering: E-vector to L-vector, and the interpolators from
|
||||
coarse to fine face for master non-comforming faces.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeScatterIndicesAndOffsets(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
/** @brief Compute the gather indices: E-vector to L-vector.
|
||||
|
||||
Note: Requires the gather offsets to be computed.
|
||||
|
||||
@param[in] ordering Request a specific element ordering.
|
||||
@param[in] type Request internal or boundary faces dofs.
|
||||
*/
|
||||
void ComputeGatherIndices(const ElementDofOrdering ordering,
|
||||
const FaceType type);
|
||||
|
||||
public:
|
||||
/** @brief Scatter the degrees of freedom, i.e. goes from L-Vector to
|
||||
face E-Vector. Should only be used with nonconforming faces and when:
|
||||
L2FaceValues m == L2FaceValues::DoubleValued
|
||||
|
||||
@param[in] x The L-vector degrees of freedom.
|
||||
@param[out] y The face E-Vector degrees of freedom with the given format:
|
||||
(face_dofs x vdim x 2 x nf),
|
||||
where nf is the number of interior or boundary faces
|
||||
requested by @a type in the constructor.
|
||||
The face_dofs are ordered according to the given
|
||||
ElementDofOrdering. */
|
||||
virtual void DoubleValuedNonconformingMult(const Vector& x, Vector& y) const;
|
||||
|
||||
/** @brief Apply a change of basis from fine element basis to coarse element
|
||||
basis for the coarse face dofs. Should only be used when:
|
||||
L2FaceValues m == L2FaceValues::SingleValued
|
||||
|
||||
@param[in] x The dofs vector that needs coarse dofs to be express in term
|
||||
of the coarse basis, the result is stored in x_interp.
|
||||
*/
|
||||
void SingleValuedNonconformingTransposeInterpolation(const Vector& x) const;
|
||||
|
||||
/** @brief Apply a change of basis from fine element basis to coarse element
|
||||
basis for the coarse face dofs. Should only be used when:
|
||||
L2FaceValues m == L2FaceValues::DoubleValued
|
||||
|
||||
@param[in] x The dofs vector that needs coarse dofs to be express in term
|
||||
of the coarse basis, the result is stored in x_interp.
|
||||
*/
|
||||
void DoubleValuedNonconformingTransposeInterpolation(const Vector& x) const;
|
||||
};
|
||||
|
||||
/** @brief Return the face map that extracts the degrees of freedom for the
|
||||
requested local face of a quad or hex, returned in Lexicographic order.
|
||||
|
||||
@param[in] dim The dimension of the space
|
||||
@param[in] face_id The local face identifier
|
||||
@param[in] dof1d The 1D number of degrees of freedom for each dimension
|
||||
@param[out] face_map The map that maps each face dof to an element dof
|
||||
*/
|
||||
void GetFaceDofs(const int dim, const int face_id,
|
||||
const int dof1d, Array<int> &face_map);
|
||||
|
||||
/** @brief Convert a dof face index from Native ordering to lexicographic
|
||||
ordering for quads and hexes.
|
||||
|
||||
@param[in] dim The dimension of the element, 2 for quad, 3 for hex
|
||||
@param[in] face_id The local face identifier
|
||||
@param[in] size1d The 1D number of degrees of freedom for each dimension
|
||||
@param[in] index The native index on the face
|
||||
@return The lexicographic index on the face
|
||||
*/
|
||||
int ToLexOrdering(const int dim, const int face_id, const int size1d,
|
||||
const int index);
|
||||
|
||||
// Permute dofs or quads on a face for e2 to match with the ordering of e1
|
||||
/** @brief Compute the dof face index of elem2 corresponding to the given dof
|
||||
face index.
|
||||
|
||||
@param[in] dim The dimension of the element, 2 for quad, 3 for hex
|
||||
@param[in] face_id1 The local face identifier of elem1
|
||||
@param[in] face_id2 The local face identifier of elem2
|
||||
@param[in] orientation The orientation of elem2 relative to elem1 on the
|
||||
face
|
||||
@param[in] size1d The 1D number of degrees of freedom for each dimension
|
||||
@param[in] index The dof index on elem1
|
||||
@return The dof index on elem2 facing the dof on elem1
|
||||
*/
|
||||
int PermuteFaceL2(const int dim, const int face_id1,
|
||||
const int face_id2, const int orientation,
|
||||
const int size1d, const int index);
|
||||
|
||||
}
|
||||
|
||||
#endif //MFEM_RESTRICTION
|
||||
#endif // MFEM_RESTRICTION
|
||||
|
||||
+275
-267
File diff suppressed because it is too large
Load Diff
+30
-27
@@ -1133,7 +1133,7 @@ protected:
|
||||
|
||||
// Evaluation of the discrete target specification on different meshes.
|
||||
// Owned.
|
||||
AdaptivityEvaluator *adapt_eval;
|
||||
AdaptivityEvaluator *adapt_lim_eval;
|
||||
|
||||
void SetDiscreteTargetBase(const GridFunction &tspec_);
|
||||
void SetTspecAtIndex(int idx, const GridFunction &tspec_);
|
||||
@@ -1156,7 +1156,7 @@ public:
|
||||
#endif
|
||||
amr_el(-1), lim_min_size(-0.1),
|
||||
good_tspec(false), good_tspec_grad(false), good_tspec_hess(false),
|
||||
adapt_eval(NULL) { }
|
||||
adapt_lim_eval(NULL) { }
|
||||
|
||||
virtual ~DiscreteAdaptTC();
|
||||
|
||||
@@ -1232,8 +1232,8 @@ public:
|
||||
|
||||
void SetAdaptivityEvaluator(AdaptivityEvaluator *ae)
|
||||
{
|
||||
if (adapt_eval) { delete adapt_eval; }
|
||||
adapt_eval = ae;
|
||||
if (adapt_lim_eval) { delete adapt_lim_eval; }
|
||||
adapt_lim_eval = ae;
|
||||
}
|
||||
|
||||
const Vector &GetTspecPert1H() { return tspec_pert1h; }
|
||||
@@ -1315,15 +1315,15 @@ protected:
|
||||
int integ_order;
|
||||
|
||||
// Weight Coefficient multiplying the quality metric term.
|
||||
Coefficient *coeff1; // not owned, if NULL -> coeff1 is 1.
|
||||
Coefficient *metric_coeff; // not owned, if NULL -> metric_coeff is 1.
|
||||
// Normalization factor for the metric term.
|
||||
double metric_normal;
|
||||
|
||||
// Nodes and weight Coefficient used for "limiting" the TMOP_Integrator.
|
||||
// These are both NULL when there is no limiting.
|
||||
// The class doesn't own nodes0 and coeff0.
|
||||
const GridFunction *nodes0;
|
||||
Coefficient *coeff0;
|
||||
// The class doesn't own lim_nodes0 and lim_coeff.
|
||||
const GridFunction *lim_nodes0;
|
||||
Coefficient *lim_coeff;
|
||||
// Limiting reference distance. Not owned.
|
||||
const GridFunction *lim_dist;
|
||||
// Limiting function. Owned.
|
||||
@@ -1332,20 +1332,21 @@ protected:
|
||||
double lim_normal;
|
||||
|
||||
// Adaptive limiting.
|
||||
const GridFunction *zeta_0; // Not owned.
|
||||
const GridFunction *adapt_lim_gf0; // Not owned.
|
||||
#ifdef MFEM_USE_MPI
|
||||
const ParGridFunction *pzeta_0;
|
||||
const ParGridFunction *adapt_lim_pgf0;
|
||||
#endif
|
||||
GridFunction *zeta; // Owned. Updated by adapt_eval.
|
||||
Coefficient *coeff_zeta; // Not owned.
|
||||
AdaptivityEvaluator *adapt_eval; // Not owned.
|
||||
GridFunction *adapt_lim_gf; // Owned. Updated by adapt_lim_eval.
|
||||
Coefficient *adapt_lim_coeff; // Not owned.
|
||||
AdaptivityEvaluator *adapt_lim_eval; // Not owned.
|
||||
|
||||
// Surface fitting.
|
||||
GridFunction *sigma, *sigma_bar; // Owned. Updated by sigma_eval.
|
||||
const Array<bool> *sigma_marker; // Not owned.
|
||||
Coefficient *coeff_sigma; // Not owned.
|
||||
AdaptivityEvaluator *sigma_eval; // Not owned.
|
||||
double sigma_normal;
|
||||
GridFunction *surf_fit_gf,
|
||||
*surf_fit_gf_bar; // Owned, Updated by surf_fit_eval.
|
||||
const Array<bool> *surf_fit_marker; // Not owned.
|
||||
Coefficient *surf_fit_coeff; // Not owned.
|
||||
AdaptivityEvaluator *surf_fit_eval; // Not owned.
|
||||
double surf_fit_normal;
|
||||
|
||||
DiscreteAdaptTC *discr_tc;
|
||||
|
||||
@@ -1416,7 +1417,7 @@ protected:
|
||||
|
||||
void ComputeNormalizationEnergies(const GridFunction &x,
|
||||
double &metric_energy, double &lim_energy,
|
||||
double &sigma_energy);
|
||||
double &surf_fit_gf_energy);
|
||||
|
||||
void AssembleElementVectorExact(const FiniteElement &el,
|
||||
ElementTransformation &T,
|
||||
@@ -1471,7 +1472,7 @@ protected:
|
||||
|
||||
void DisableLimiting()
|
||||
{
|
||||
nodes0 = NULL; coeff0 = NULL; lim_dist = NULL;
|
||||
lim_nodes0 = NULL; lim_coeff = NULL; lim_dist = NULL;
|
||||
delete lim_func; lim_func = NULL;
|
||||
}
|
||||
|
||||
@@ -1531,12 +1532,14 @@ public:
|
||||
TMOP_Integrator(TMOP_QualityMetric *m, TargetConstructor *tc,
|
||||
TMOP_QualityMetric *hm)
|
||||
: h_metric(hm), metric(m), targetC(tc), IntegRules(NULL),
|
||||
integ_order(-1), coeff1(NULL), metric_normal(1.0),
|
||||
nodes0(NULL), coeff0(NULL),
|
||||
integ_order(-1), metric_coeff(NULL), metric_normal(1.0),
|
||||
lim_nodes0(NULL), lim_coeff(NULL),
|
||||
lim_dist(NULL), lim_func(NULL), lim_normal(1.0),
|
||||
zeta_0(NULL), zeta(NULL), coeff_zeta(NULL), adapt_eval(NULL),
|
||||
sigma(NULL), sigma_bar(NULL), sigma_marker(NULL), coeff_sigma(NULL),
|
||||
sigma_eval(NULL), sigma_normal(1.0),
|
||||
adapt_lim_gf0(NULL), adapt_lim_gf(NULL), adapt_lim_coeff(NULL),
|
||||
adapt_lim_eval(NULL),
|
||||
surf_fit_gf(NULL), surf_fit_gf_bar(NULL), surf_fit_marker(NULL),
|
||||
surf_fit_coeff(NULL),
|
||||
surf_fit_eval(NULL), surf_fit_normal(1.0),
|
||||
discr_tc(dynamic_cast<DiscreteAdaptTC *>(tc)),
|
||||
fdflag(false), dxscale(1.0e3), fd_call_flag(false), exact_action(false)
|
||||
{ PA.enabled = false; }
|
||||
@@ -1564,7 +1567,7 @@ public:
|
||||
|
||||
Note that the Coefficient is evaluated in the physical configuration and
|
||||
not in the target configuration which may be undefined. */
|
||||
void SetCoefficient(Coefficient &w1) { coeff1 = &w1; }
|
||||
void SetCoefficient(Coefficient &w1) { metric_coeff = &w1; }
|
||||
|
||||
/** @brief Limiting of the mesh displacements (general version).
|
||||
|
||||
@@ -1631,7 +1634,7 @@ public:
|
||||
void GetSurfaceFittingErrors(double &err_avg, double &err_max);
|
||||
|
||||
/// Update the original/reference nodes used for limiting.
|
||||
void SetLimitingNodes(const GridFunction &n0) { nodes0 = &n0; }
|
||||
void SetLimitingNodes(const GridFunction &n0) { lim_nodes0 = &n0; }
|
||||
|
||||
/** @brief Computes the integral of W(Jacobian(Trt)) over a target zone.
|
||||
@param[in] el Type of FiniteElement.
|
||||
|
||||
+21
-21
@@ -38,13 +38,13 @@ void TMOP_Integrator::AssembleGradPA(const Vector &xe,
|
||||
if (PA.dim == 2)
|
||||
{
|
||||
AssembleGradPA_2D(xe);
|
||||
if (coeff0) { AssembleGradPA_C0_2D(xe); }
|
||||
if (lim_coeff) { AssembleGradPA_C0_2D(xe); }
|
||||
}
|
||||
|
||||
if (PA.dim == 3)
|
||||
{
|
||||
AssembleGradPA_3D(xe);
|
||||
if (coeff0) { AssembleGradPA_C0_3D(xe); }
|
||||
if (lim_coeff) { AssembleGradPA_C0_3D(xe); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ void TMOP_Integrator::AssemblePA_Limiting()
|
||||
const MemoryType mt = (pa_mt == MemoryType::DEFAULT) ?
|
||||
Device::GetDeviceMemoryType() : pa_mt;
|
||||
// Return immediately if limiting is not enabled
|
||||
if (coeff0 == nullptr) { return; }
|
||||
MFEM_VERIFY(nodes0, "internal error");
|
||||
if (lim_coeff == nullptr) { return; }
|
||||
MFEM_VERIFY(lim_nodes0, "internal error");
|
||||
|
||||
MFEM_VERIFY(PA.enabled, "AssemblePA_Limiting but PA is not enabled!");
|
||||
MFEM_VERIFY(lim_func, "No TMOP_LimiterFunction specification!")
|
||||
@@ -68,14 +68,14 @@ void TMOP_Integrator::AssemblePA_Limiting()
|
||||
|
||||
const ElementDofOrdering ordering = ElementDofOrdering::LEXICOGRAPHIC;
|
||||
|
||||
// H0 for coeff0, (dim x dim) Q-vector
|
||||
// H0 for lim_coeff, (dim x dim) Q-vector
|
||||
PA.H0.UseDevice(true);
|
||||
PA.H0.SetSize(PA.dim * PA.dim * PA.nq * NE, mt);
|
||||
|
||||
// coeff0 -> PA.C0 (Q-vector)
|
||||
// lim_coeff -> PA.C0 (Q-vector)
|
||||
PA.C0.UseDevice(true);
|
||||
if (ConstantCoefficient* cQ =
|
||||
dynamic_cast<ConstantCoefficient*>(coeff0))
|
||||
dynamic_cast<ConstantCoefficient*>(lim_coeff))
|
||||
{
|
||||
PA.C0.SetSize(1, Device::GetMemoryType());
|
||||
PA.C0.HostWrite();
|
||||
@@ -90,17 +90,17 @@ void TMOP_Integrator::AssemblePA_Limiting()
|
||||
ElementTransformation& T = *fes->GetElementTransformation(e);
|
||||
for (int q = 0; q < ir.GetNPoints(); ++q)
|
||||
{
|
||||
C0(q,e) = coeff0->Eval(T, ir.IntPoint(q));
|
||||
C0(q,e) = lim_coeff->Eval(T, ir.IntPoint(q));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// nodes0 -> PA.X0 (E-vector)
|
||||
MFEM_VERIFY(nodes0->FESpace() == fes, "");
|
||||
// lim_nodes0 -> PA.X0 (E-vector)
|
||||
MFEM_VERIFY(lim_nodes0->FESpace() == fes, "");
|
||||
const Operator *n0_R = fes->GetElementRestriction(ordering);
|
||||
PA.X0.SetSize(n0_R->Height(), Device::GetMemoryType());
|
||||
PA.X0.UseDevice(true);
|
||||
n0_R->Mult(*nodes0, PA.X0);
|
||||
n0_R->Mult(*lim_nodes0, PA.X0);
|
||||
|
||||
// Limiting distances: lim_dist -> PA.LD (E-vector)
|
||||
// TODO: remove the hack for the case lim_dist == NULL.
|
||||
@@ -217,8 +217,8 @@ void TMOP_Integrator::AssemblePA(const FiniteElementSpace &fes)
|
||||
PA.Jtr_needs_update = true;
|
||||
PA.Jtr_debug_grad = false;
|
||||
|
||||
// Limiting: coeff0 -> PA.C0, nodes0 -> PA.X0, lim_dist -> PA.LD, PA.H0
|
||||
if (coeff0) { AssemblePA_Limiting(); }
|
||||
// Limiting: lim_coeff -> PA.C0, lim_nodes0 -> PA.X0, lim_dist -> PA.LD, PA.H0
|
||||
if (lim_coeff) { AssemblePA_Limiting(); }
|
||||
}
|
||||
|
||||
void TMOP_Integrator::AssembleGradDiagonalPA(Vector &de) const
|
||||
@@ -236,13 +236,13 @@ void TMOP_Integrator::AssembleGradDiagonalPA(Vector &de) const
|
||||
if (PA.dim == 2)
|
||||
{
|
||||
AssembleDiagonalPA_2D(de);
|
||||
if (coeff0) { AssembleDiagonalPA_C0_2D(de); }
|
||||
if (lim_coeff) { AssembleDiagonalPA_C0_2D(de); }
|
||||
}
|
||||
|
||||
if (PA.dim == 3)
|
||||
{
|
||||
AssembleDiagonalPA_3D(de);
|
||||
if (coeff0) { AssembleDiagonalPA_C0_3D(de); }
|
||||
if (lim_coeff) { AssembleDiagonalPA_C0_3D(de); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,13 +258,13 @@ void TMOP_Integrator::AddMultPA(const Vector &xe, Vector &ye) const
|
||||
if (PA.dim == 2)
|
||||
{
|
||||
AddMultPA_2D(xe,ye);
|
||||
if (coeff0) { AddMultPA_C0_2D(xe,ye); }
|
||||
if (lim_coeff) { AddMultPA_C0_2D(xe,ye); }
|
||||
}
|
||||
|
||||
if (PA.dim == 3)
|
||||
{
|
||||
AddMultPA_3D(xe,ye);
|
||||
if (coeff0) { AddMultPA_C0_3D(xe,ye); }
|
||||
if (lim_coeff) { AddMultPA_C0_3D(xe,ye); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,13 +283,13 @@ void TMOP_Integrator::AddMultGradPA(const Vector &re, Vector &ce) const
|
||||
if (PA.dim == 2)
|
||||
{
|
||||
AddMultGradPA_2D(re,ce);
|
||||
if (coeff0) { AddMultGradPA_C0_2D(re,ce); }
|
||||
if (lim_coeff) { AddMultGradPA_C0_2D(re,ce); }
|
||||
}
|
||||
|
||||
if (PA.dim == 3)
|
||||
{
|
||||
AddMultGradPA_3D(re,ce);
|
||||
if (coeff0) { AddMultGradPA_C0_3D(re,ce); }
|
||||
if (lim_coeff) { AddMultGradPA_C0_3D(re,ce); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,13 +307,13 @@ double TMOP_Integrator::GetLocalStateEnergyPA(const Vector &xe) const
|
||||
if (PA.dim == 2)
|
||||
{
|
||||
energy = GetLocalStateEnergyPA_2D(xe);
|
||||
if (coeff0) { energy += GetLocalStateEnergyPA_C0_2D(xe); }
|
||||
if (lim_coeff) { energy += GetLocalStateEnergyPA_C0_2D(xe); }
|
||||
}
|
||||
|
||||
if (PA.dim == 3)
|
||||
{
|
||||
energy = GetLocalStateEnergyPA_3D(xe);
|
||||
if (coeff0) { energy += GetLocalStateEnergyPA_C0_3D(xe); }
|
||||
if (lim_coeff) { energy += GetLocalStateEnergyPA_C0_3D(xe); }
|
||||
}
|
||||
|
||||
return energy;
|
||||
|
||||
@@ -181,9 +181,9 @@ template<int T_D1D, int T_Q1D, int T_MAX> return_t kernel(__VA_ARGS__)
|
||||
if (K##kernel.Find(id)) { return K##kernel.At(id)(__VA_ARGS__,0,0); }\
|
||||
else {\
|
||||
constexpr int T_MAX = 4;\
|
||||
const int D1D = (id>>4)&0xF, Q1D = id&0xF;\
|
||||
MFEM_VERIFY(D1D <= MAX_D1D && Q1D <= MAX_Q1D, "Max size error!");\
|
||||
return kernel<0,0,T_MAX>(__VA_ARGS__,D1D,Q1D); }
|
||||
const int d1d = (id>>4)&0xF, q1d = id&0xF;\
|
||||
MFEM_VERIFY(d1d <= MAX_D1D && q1d <= MAX_Q1D, "Max size error!");\
|
||||
return kernel<0,0,T_MAX>(__VA_ARGS__,d1d,q1d); }
|
||||
|
||||
} // namespace kernels
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ MFEM_REGISTER_TMOP_KERNELS(void, DatcSize,
|
||||
MFEM_SHARED double sm0[MDQ*MDQ*MDQ];
|
||||
MFEM_SHARED double sm1[MDQ*MDQ*MDQ];
|
||||
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,b,sB);
|
||||
|
||||
ConstDeviceMatrix B(sB, D1D, Q1D);
|
||||
DeviceCube DDD(sm0, MD1,MD1,MD1);
|
||||
DeviceCube DDQ(sm1, MD1,MD1,MQ1);
|
||||
@@ -88,7 +90,6 @@ MFEM_REGISTER_TMOP_KERNELS(void, DatcSize,
|
||||
}
|
||||
min = min_size[0];
|
||||
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,b,sB);
|
||||
kernels::internal::EvalX(D1D,Q1D,B,DDD,DDQ);
|
||||
kernels::internal::EvalY(D1D,Q1D,B,DDQ,DQQ);
|
||||
kernels::internal::EvalZ(D1D,Q1D,B,DQQ,QQQ);
|
||||
|
||||
@@ -97,9 +97,9 @@ MFEM_REGISTER_TMOP_KERNELS(void, AssembleDiagonalPA_Kernel_2D,
|
||||
const double *Jtr = &J(0,0,qx,qy,e);
|
||||
|
||||
// Jrt = Jtr^{-1}
|
||||
double j[4];
|
||||
ConstDeviceMatrix Jrt(j,2,2);
|
||||
kernels::CalcInverse<2>(Jtr, j);
|
||||
double jrt_data[4];
|
||||
ConstDeviceMatrix Jrt(jrt_data,2,2);
|
||||
kernels::CalcInverse<2>(Jtr, jrt_data);
|
||||
|
||||
const double gg = G(qy,dy) * G(qy,dy);
|
||||
const double gb = G(qy,dy) * B(qy,dy);
|
||||
|
||||
@@ -68,8 +68,8 @@ MFEM_REGISTER_TMOP_KERNELS(void, AddMultGradPA_Kernel_C0_2D,
|
||||
double Xh[2];
|
||||
kernels::internal::PullEval<MQ1,NBZ>(Q1D,qx,qy,QQ,Xh);
|
||||
|
||||
double B[4];
|
||||
DeviceMatrix H(B,2,2);
|
||||
double H_data[4];
|
||||
DeviceMatrix H(H_data,2,2);
|
||||
for (int i = 0; i < DIM; i++)
|
||||
{
|
||||
for (int j = 0; j < DIM; j++)
|
||||
@@ -78,9 +78,9 @@ MFEM_REGISTER_TMOP_KERNELS(void, AddMultGradPA_Kernel_C0_2D,
|
||||
}
|
||||
}
|
||||
|
||||
// p2 = B . Xh
|
||||
// p2 = H . Xh
|
||||
double p2[2];
|
||||
kernels::Mult(2,2,B,Xh,p2);
|
||||
kernels::Mult(2,2,H_data,Xh,p2);
|
||||
kernels::internal::PushEval<MQ1,NBZ>(Q1D,qx,qy,p2,QQ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,8 +70,8 @@ MFEM_REGISTER_TMOP_KERNELS(void, AddMultGradPA_Kernel_C0_3D,
|
||||
double Xh[3];
|
||||
kernels::internal::PullEval<MQ1>(Q1D,qx,qy,qz,QQQ,Xh);
|
||||
|
||||
double B[9];
|
||||
DeviceMatrix H(B,3,3);
|
||||
double H_data[9];
|
||||
DeviceMatrix H(H_data,3,3);
|
||||
for (int i = 0; i < DIM; i++)
|
||||
{
|
||||
for (int j = 0; j < DIM; j++)
|
||||
@@ -80,9 +80,9 @@ MFEM_REGISTER_TMOP_KERNELS(void, AddMultGradPA_Kernel_C0_3D,
|
||||
}
|
||||
}
|
||||
|
||||
// p2 = B . Xh
|
||||
// p2 = H . Xh
|
||||
double p2[3];
|
||||
kernels::Mult(3,3,B,Xh,p2);
|
||||
kernels::Mult(3,3,H_data,Xh,p2);
|
||||
kernels::internal::PushEval<MQ1>(Q1D,qx,qy,qz,p2,QQQ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ MFEM_REGISTER_TMOP_KERNELS(void, SetupGradPA_Kernel_C0_3D,
|
||||
constexpr int MDQ = (MQ1 > MD1) ? MQ1 : MD1;
|
||||
|
||||
MFEM_SHARED double sBLD[MQ1*MD1];
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,bld,sBLD);
|
||||
ConstDeviceMatrix BLD(sBLD, D1D, Q1D);
|
||||
|
||||
MFEM_SHARED double sm0[MDQ*MDQ*MDQ];
|
||||
@@ -66,8 +67,6 @@ MFEM_REGISTER_TMOP_KERNELS(void, SetupGradPA_Kernel_C0_3D,
|
||||
|
||||
kernels::internal::LoadX(e,D1D,LD,DDD);
|
||||
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,bld,sBLD);
|
||||
|
||||
kernels::internal::EvalX(D1D,Q1D,BLD,DDD,DDQ);
|
||||
kernels::internal::EvalY(D1D,Q1D,BLD,DDQ,DQQ);
|
||||
kernels::internal::EvalZ(D1D,Q1D,BLD,DQQ,QQQ);
|
||||
|
||||
@@ -62,6 +62,7 @@ MFEM_REGISTER_TMOP_KERNELS(void, AddMultPA_Kernel_C0_3D,
|
||||
|
||||
MFEM_SHARED double B[MQ1*MD1];
|
||||
MFEM_SHARED double sBLD[MQ1*MD1];
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,bld,sBLD);
|
||||
ConstDeviceMatrix BLD(sBLD, D1D, Q1D);
|
||||
|
||||
MFEM_SHARED double sm0[MDQ*MDQ*MDQ];
|
||||
@@ -86,7 +87,6 @@ MFEM_REGISTER_TMOP_KERNELS(void, AddMultPA_Kernel_C0_3D,
|
||||
kernels::internal::LoadX<MD1>(e,D1D,X1,DDD1);
|
||||
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,b,B);
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,bld,sBLD);
|
||||
|
||||
kernels::internal::EvalX(D1D,Q1D,BLD,DDD,DDQ);
|
||||
kernels::internal::EvalY(D1D,Q1D,BLD,DDQ,DQQ);
|
||||
|
||||
@@ -63,6 +63,7 @@ MFEM_REGISTER_TMOP_KERNELS(double, EnergyPA_C0_3D,
|
||||
|
||||
MFEM_SHARED double B[MQ1*MD1];
|
||||
MFEM_SHARED double sBLD[MQ1*MD1];
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,bld,sBLD);
|
||||
ConstDeviceMatrix BLD(sBLD, D1D, Q1D);
|
||||
|
||||
MFEM_SHARED double sm0[MDQ*MDQ*MDQ];
|
||||
@@ -87,7 +88,6 @@ MFEM_REGISTER_TMOP_KERNELS(double, EnergyPA_C0_3D,
|
||||
kernels::internal::LoadX<MD1>(e,D1D,X1,DDD1);
|
||||
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,b,B);
|
||||
kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,bld,sBLD);
|
||||
|
||||
kernels::internal::EvalX(D1D,Q1D,BLD,DDD,DDQ);
|
||||
kernels::internal::EvalY(D1D,Q1D,BLD,DDQ,DQQ);
|
||||
|
||||
+10
-10
@@ -837,26 +837,26 @@ void TMOPHRSolver::ParUpdate()
|
||||
}
|
||||
#endif
|
||||
|
||||
void TMOPHRSolver::UpdateNonlinearFormAndBC(Mesh *mesh, NonlinearForm *nlf)
|
||||
void TMOPHRSolver::UpdateNonlinearFormAndBC(Mesh *mesh_, NonlinearForm *nlf_)
|
||||
{
|
||||
const FiniteElementSpace &fes = *mesh->GetNodalFESpace();
|
||||
const FiniteElementSpace &fes = *mesh_->GetNodalFESpace();
|
||||
|
||||
// Update Nonlinear form and Set Essential BC
|
||||
nlf->Update();
|
||||
nlf_->Update();
|
||||
const int dim = fes.GetFE(0)->GetDim();
|
||||
if (move_bnd == false)
|
||||
{
|
||||
Array<int> ess_bdr(mesh->bdr_attributes.Max());
|
||||
Array<int> ess_bdr(mesh_->bdr_attributes.Max());
|
||||
ess_bdr = 1;
|
||||
nlf->SetEssentialBC(ess_bdr);
|
||||
nlf_->SetEssentialBC(ess_bdr);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int nd = fes.GetBE(0)->GetDof();
|
||||
int n = 0;
|
||||
for (int i = 0; i < mesh->GetNBE(); i++)
|
||||
for (int i = 0; i < mesh_->GetNBE(); i++)
|
||||
{
|
||||
const int attr = mesh->GetBdrElement(i)->GetAttribute();
|
||||
const int attr = mesh_->GetBdrElement(i)->GetAttribute();
|
||||
MFEM_VERIFY(!(dim == 2 && attr == 3),
|
||||
"Boundary attribute 3 must be used only for 3D meshes. "
|
||||
"Adjust the attributes (1/2/3/4 for fixed x/y/z/all "
|
||||
@@ -866,9 +866,9 @@ void TMOPHRSolver::UpdateNonlinearFormAndBC(Mesh *mesh, NonlinearForm *nlf)
|
||||
}
|
||||
Array<int> ess_vdofs(n), vdofs;
|
||||
n = 0;
|
||||
for (int i = 0; i < mesh->GetNBE(); i++)
|
||||
for (int i = 0; i < mesh_->GetNBE(); i++)
|
||||
{
|
||||
const int attr = mesh->GetBdrElement(i)->GetAttribute();
|
||||
const int attr = mesh_->GetBdrElement(i)->GetAttribute();
|
||||
fes.GetBdrElementVDofs(i, vdofs);
|
||||
if (attr == 1) // Fix x components.
|
||||
{
|
||||
@@ -891,7 +891,7 @@ void TMOPHRSolver::UpdateNonlinearFormAndBC(Mesh *mesh, NonlinearForm *nlf)
|
||||
{ ess_vdofs[n++] = vdofs[j]; }
|
||||
}
|
||||
}
|
||||
nlf->SetEssentialVDofs(ess_vdofs);
|
||||
nlf_->SetEssentialVDofs(ess_vdofs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-10
@@ -444,15 +444,19 @@ double TMOPNewtonSolver::ComputeScalingFactor(const Vector &x,
|
||||
if (untangling == false && min_detT_out < 0.0)
|
||||
{
|
||||
// No untangling, and detJ got negative -- no good.
|
||||
if (print_level >= 0)
|
||||
{ mfem::out << "Scale = " << scale << " Neg det(J) found.\n"; }
|
||||
if (print_options.iterations)
|
||||
{
|
||||
mfem::out << "Scale = " << scale << " Neg det(J) found.\n";
|
||||
}
|
||||
scale *= detJ_factor; continue;
|
||||
}
|
||||
if (untangling == true && min_detT_out < *min_det_ptr)
|
||||
{
|
||||
// Untangling, and detJ got even more negative -- no good.
|
||||
if (print_level >= 0)
|
||||
{ mfem::out << "Scale = " << scale << " Neg det(J) decreased.\n"; }
|
||||
if (print_options.iterations)
|
||||
{
|
||||
mfem::out << "Scale = " << scale << " Neg det(J) decreased.\n";
|
||||
}
|
||||
scale *= detJ_factor; continue;
|
||||
}
|
||||
|
||||
@@ -477,7 +481,7 @@ double TMOPNewtonSolver::ComputeScalingFactor(const Vector &x,
|
||||
if (energy_out > energy_in + 0.2*fabs(energy_in) ||
|
||||
std::isnan(energy_out) != 0)
|
||||
{
|
||||
if (print_level >= 0)
|
||||
if (print_options.iterations)
|
||||
{
|
||||
mfem::out << "Scale = " << scale << " Increasing energy: "
|
||||
<< energy_in << " --> " << energy_out << '\n';
|
||||
@@ -492,7 +496,7 @@ double TMOPNewtonSolver::ComputeScalingFactor(const Vector &x,
|
||||
|
||||
if (norm_out > 1.2*norm_in)
|
||||
{
|
||||
if (print_level >= 0)
|
||||
if (print_options.iterations)
|
||||
{
|
||||
mfem::out << "Scale = " << scale << " Norm increased: "
|
||||
<< norm_in << " --> " << norm_out << '\n';
|
||||
@@ -508,13 +512,15 @@ double TMOPNewtonSolver::ComputeScalingFactor(const Vector &x,
|
||||
if (min_detT_out > 0.0)
|
||||
{
|
||||
*min_det_ptr = 0.0;
|
||||
if (print_level >= 0)
|
||||
if (print_options.summary || print_options.iterations ||
|
||||
print_options.first_and_last)
|
||||
{ mfem::out << "The mesh has been untangled at the used points!\n"; }
|
||||
}
|
||||
else { *min_det_ptr = untangle_factor * min_detT_out; }
|
||||
}
|
||||
|
||||
if (print_level >= 0)
|
||||
if (print_options.summary || print_options.iterations ||
|
||||
print_options.first_and_last)
|
||||
{
|
||||
if (untangling)
|
||||
{
|
||||
@@ -568,9 +574,9 @@ void TMOPNewtonSolver::ProcessNewState(const Vector &x) const
|
||||
if (parallel)
|
||||
{
|
||||
#ifdef MFEM_USE_MPI
|
||||
const ParNonlinearForm *nlf =
|
||||
const ParNonlinearForm *pnlf =
|
||||
dynamic_cast<const ParNonlinearForm *>(oper);
|
||||
const ParFiniteElementSpace *pfesc = nlf->ParFESpace();
|
||||
const ParFiniteElementSpace *pfesc = pnlf->ParFESpace();
|
||||
Vector x_loc(pfesc->GetVSize());
|
||||
pfesc->GetProlongationMatrix()->Mult(x, x_loc);
|
||||
for (int i = 0; i < integs.Size(); i++)
|
||||
|
||||
+61
-17
@@ -903,7 +903,8 @@ TransferOperator::TransferOperator(const FiniteElementSpace& lFESpace_,
|
||||
const FiniteElementSpace& hFESpace_)
|
||||
: Operator(hFESpace_.GetVSize(), lFESpace_.GetVSize())
|
||||
{
|
||||
if (lFESpace_.FEColl() == hFESpace_.FEColl())
|
||||
bool isvar_order = lFESpace_.IsVariableOrder() || hFESpace_.IsVariableOrder();
|
||||
if (lFESpace_.FEColl() == hFESpace_.FEColl() && !isvar_order)
|
||||
{
|
||||
OperatorPtr P(Operator::ANY_TYPE);
|
||||
hFESpace_.GetTransferOperator(lFESpace_, P);
|
||||
@@ -912,8 +913,11 @@ TransferOperator::TransferOperator(const FiniteElementSpace& lFESpace_,
|
||||
}
|
||||
else if (lFESpace_.GetMesh()->GetNE() > 0
|
||||
&& hFESpace_.GetMesh()->GetNE() > 0
|
||||
&& lFESpace_.GetVDim() == 1
|
||||
&& hFESpace_.GetVDim() == 1
|
||||
&& dynamic_cast<const TensorBasisElement*>(lFESpace_.GetFE(0))
|
||||
&& dynamic_cast<const TensorBasisElement*>(hFESpace_.GetFE(0))
|
||||
&& !isvar_order
|
||||
&& (hFESpace_.FEColl()->GetContType() ==
|
||||
mfem::FiniteElementCollection::CONTINUOUS ||
|
||||
hFESpace_.FEColl()->GetContType() ==
|
||||
@@ -945,6 +949,7 @@ PRefinementTransferOperator::PRefinementTransferOperator(
|
||||
: Operator(hFESpace_.GetVSize(), lFESpace_.GetVSize()), lFESpace(lFESpace_),
|
||||
hFESpace(hFESpace_)
|
||||
{
|
||||
isvar_order = lFESpace_.IsVariableOrder() || hFESpace_.IsVariableOrder();
|
||||
}
|
||||
|
||||
PRefinementTransferOperator::~PRefinementTransferOperator() {}
|
||||
@@ -969,7 +974,7 @@ void PRefinementTransferOperator::Mult(const Vector& x, Vector& y) const
|
||||
DofTransformation * doftrans_l = lFESpace.GetElementDofs(i, l_dofs);
|
||||
|
||||
const Geometry::Type geom = mesh->GetElementBaseGeometry(i);
|
||||
if (geom != cached_geom)
|
||||
if (geom != cached_geom || isvar_order)
|
||||
{
|
||||
h_fe = hFESpace.GetFE(i);
|
||||
l_fe = lFESpace.GetFE(i);
|
||||
@@ -1026,7 +1031,7 @@ void PRefinementTransferOperator::MultTranspose(const Vector& x,
|
||||
DofTransformation * doftrans_l = lFESpace.GetElementDofs(i, l_dofs);
|
||||
|
||||
const Geometry::Type geom = mesh->GetElementBaseGeometry(i);
|
||||
if (geom != cached_geom)
|
||||
if (geom != cached_geom || isvar_order)
|
||||
{
|
||||
h_fe = hFESpace.GetFE(i);
|
||||
l_fe = lFESpace.GetFE(i);
|
||||
@@ -1424,20 +1429,36 @@ void TensorProductPRefinementTransferOperator::MultTranspose(const Vector& x,
|
||||
elem_restrict_lex_l->MultTranspose(localL, y);
|
||||
}
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
TrueTransferOperator::TrueTransferOperator(const
|
||||
ParFiniteElementSpace& lFESpace_,
|
||||
const ParFiniteElementSpace& hFESpace_)
|
||||
|
||||
TrueTransferOperator::TrueTransferOperator(const FiniteElementSpace& lFESpace_,
|
||||
const FiniteElementSpace& hFESpace_)
|
||||
: Operator(hFESpace_.GetTrueVSize(), lFESpace_.GetTrueVSize()),
|
||||
lFESpace(lFESpace_),
|
||||
hFESpace(hFESpace_)
|
||||
{
|
||||
localTransferOperator = new TransferOperator(lFESpace_, hFESpace_);
|
||||
|
||||
tmpL.SetSize(lFESpace_.GetVSize());
|
||||
tmpH.SetSize(hFESpace_.GetVSize());
|
||||
P = lFESpace.GetProlongationMatrix();
|
||||
R = hFESpace.IsVariableOrder() ? hFESpace.GetHpRestrictionMatrix() :
|
||||
hFESpace.GetRestrictionMatrix();
|
||||
|
||||
hFESpace.GetRestrictionMatrix()->BuildTranspose();
|
||||
// P and R can be both null
|
||||
// P can be null and R not null
|
||||
// If P is not null it is assumed that R is not null as well
|
||||
if (P) { MFEM_VERIFY(R, "Both P and R have to be not NULL") }
|
||||
|
||||
if (P)
|
||||
{
|
||||
tmpL.SetSize(lFESpace_.GetVSize());
|
||||
tmpH.SetSize(hFESpace_.GetVSize());
|
||||
R->EnsureMultTranspose();
|
||||
}
|
||||
// P can be null and R not null
|
||||
else if (R)
|
||||
{
|
||||
tmpH.SetSize(hFESpace_.GetVSize());
|
||||
R->EnsureMultTranspose();
|
||||
}
|
||||
}
|
||||
|
||||
TrueTransferOperator::~TrueTransferOperator()
|
||||
@@ -1447,17 +1468,40 @@ TrueTransferOperator::~TrueTransferOperator()
|
||||
|
||||
void TrueTransferOperator::Mult(const Vector& x, Vector& y) const
|
||||
{
|
||||
lFESpace.GetProlongationMatrix()->Mult(x, tmpL);
|
||||
localTransferOperator->Mult(tmpL, tmpH);
|
||||
hFESpace.GetRestrictionMatrix()->Mult(tmpH, y);
|
||||
if (P)
|
||||
{
|
||||
P->Mult(x, tmpL);
|
||||
localTransferOperator->Mult(tmpL, tmpH);
|
||||
R->Mult(tmpH, y);
|
||||
}
|
||||
else if (R)
|
||||
{
|
||||
localTransferOperator->Mult(x, tmpH);
|
||||
R->Mult(tmpH, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
localTransferOperator->Mult(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void TrueTransferOperator::MultTranspose(const Vector& x, Vector& y) const
|
||||
{
|
||||
hFESpace.GetRestrictionMatrix()->MultTranspose(x, tmpH);
|
||||
localTransferOperator->MultTranspose(tmpH, tmpL);
|
||||
lFESpace.GetProlongationMatrix()->MultTranspose(tmpL, y);
|
||||
if (P)
|
||||
{
|
||||
R->MultTranspose(x, tmpH);
|
||||
localTransferOperator->MultTranspose(tmpH, tmpL);
|
||||
P->MultTranspose(tmpL, y);
|
||||
}
|
||||
else if (R)
|
||||
{
|
||||
R->MultTranspose(x, tmpH);
|
||||
localTransferOperator->MultTranspose(tmpH, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
localTransferOperator->MultTranspose(x, y);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
+7
-6
@@ -387,6 +387,7 @@ class PRefinementTransferOperator : public Operator
|
||||
private:
|
||||
const FiniteElementSpace& lFESpace;
|
||||
const FiniteElementSpace& hFESpace;
|
||||
bool isvar_order;
|
||||
|
||||
public:
|
||||
/// @brief Constructs a transfer operator from \p lFESpace to \p hFESpace
|
||||
@@ -452,14 +453,15 @@ public:
|
||||
virtual void MultTranspose(const Vector& x, Vector& y) const override;
|
||||
};
|
||||
|
||||
#ifdef MFEM_USE_MPI
|
||||
/// @brief Matrix-free transfer operator between finite element spaces working
|
||||
/// on true degrees of freedom
|
||||
class TrueTransferOperator : public Operator
|
||||
{
|
||||
private:
|
||||
const ParFiniteElementSpace& lFESpace;
|
||||
const ParFiniteElementSpace& hFESpace;
|
||||
const FiniteElementSpace& lFESpace;
|
||||
const FiniteElementSpace& hFESpace;
|
||||
const Operator * P = nullptr;
|
||||
const SparseMatrix * R = nullptr;
|
||||
TransferOperator* localTransferOperator;
|
||||
mutable Vector tmpL;
|
||||
mutable Vector tmpH;
|
||||
@@ -467,8 +469,8 @@ private:
|
||||
public:
|
||||
/// @brief Constructs a transfer operator working on true degrees of freedom
|
||||
/// from \p lFESpace to \p hFESpace
|
||||
TrueTransferOperator(const ParFiniteElementSpace& lFESpace_,
|
||||
const ParFiniteElementSpace& hFESpace_);
|
||||
TrueTransferOperator(const FiniteElementSpace& lFESpace_,
|
||||
const FiniteElementSpace& hFESpace_);
|
||||
|
||||
/// Destructor
|
||||
~TrueTransferOperator();
|
||||
@@ -484,7 +486,6 @@ public:
|
||||
the true dof vector \p y corresponding to the coarse space. */
|
||||
virtual void MultTranspose(const Vector& x, Vector& y) const override;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace mfem
|
||||
|
||||
|
||||
@@ -58,16 +58,19 @@ void AppendBytes(std::vector<char> &vec, const T &val)
|
||||
vec.insert(vec.end(), ptr, ptr + sizeof(T));
|
||||
}
|
||||
|
||||
/// Given a buffer @a buf of length @a nbytes, encode the data in base-64
|
||||
/// format, and write the encoded data to the output stream @a out.
|
||||
/// @brief Given a buffer @a bytes of length @a nbytes, encode the data in
|
||||
/// base-64 format, and write the encoded data to the output stream @a out.
|
||||
void WriteBase64(std::ostream &out, const void *bytes, size_t nbytes);
|
||||
|
||||
/// Decode @a len base-64 encoded characters in the buffer @a src, and store the
|
||||
/// resulting decoded data in @a buf. @a buf will be resized as needed.
|
||||
/// @brief Decode @a len base-64 encoded characters in the buffer @a src, and
|
||||
/// store the resulting decoded data in @a buf. @a buf will be resized as
|
||||
/// needed.
|
||||
void DecodeBase64(const char *src, size_t len, std::vector<char> &buf);
|
||||
|
||||
/// Return the number of characters needed to encode @a nbytes in base-64. This
|
||||
/// is equal to 4*nbytes/3, rounded up to the nearest multiple of 4.
|
||||
/// @brief Return the number of characters needed to encode @a nbytes in
|
||||
/// base-64.
|
||||
///
|
||||
/// This is equal to 4*nbytes/3, rounded up to the nearest multiple of 4.
|
||||
size_t NumBase64Chars(size_t nbytes);
|
||||
|
||||
} // namespace mfem::bin_io
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define MFEM_CUDA_BLOCKS 256
|
||||
|
||||
#ifdef MFEM_USE_CUDA
|
||||
#define MFEM_USE_CUDA_OR_HIP
|
||||
#define MFEM_DEVICE __device__
|
||||
#define MFEM_LAMBDA __host__
|
||||
#define MFEM_HOST_DEVICE __host__ __device__
|
||||
|
||||
+14
-14
@@ -177,7 +177,7 @@ Device::~Device()
|
||||
Get().device_mem_class = MemoryClass::HOST;
|
||||
}
|
||||
|
||||
void Device::Configure(const std::string &device, const int dev)
|
||||
void Device::Configure(const std::string &device, const int device_id)
|
||||
{
|
||||
// If a device was configured via the environment, skip the configuration,
|
||||
// and avoid the 'singleton_device' to destroy the mm.
|
||||
@@ -240,7 +240,7 @@ void Device::Configure(const std::string &device, const int dev)
|
||||
#endif
|
||||
|
||||
// Perform setup.
|
||||
Get().Setup(dev);
|
||||
Get().Setup(device_id);
|
||||
|
||||
// Enable the device
|
||||
Enable();
|
||||
@@ -276,35 +276,35 @@ void Device::SetMemoryTypes(MemoryType h_mt, MemoryType d_mt)
|
||||
// the call mm.Configure(...) in UpdateMemoryTypeAndClass()
|
||||
}
|
||||
|
||||
void Device::Print(std::ostream &out)
|
||||
void Device::Print(std::ostream &os)
|
||||
{
|
||||
out << "Device configuration: ";
|
||||
os << "Device configuration: ";
|
||||
bool add_comma = false;
|
||||
for (int i = 0; i < Backend::NUM_BACKENDS; i++)
|
||||
{
|
||||
if (backends & internal::backend_list[i])
|
||||
{
|
||||
if (add_comma) { out << ','; }
|
||||
if (add_comma) { os << ','; }
|
||||
add_comma = true;
|
||||
out << internal::backend_name[i];
|
||||
os << internal::backend_name[i];
|
||||
}
|
||||
}
|
||||
out << '\n';
|
||||
os << '\n';
|
||||
#ifdef MFEM_USE_CEED
|
||||
if (Allows(Backend::CEED_MASK))
|
||||
{
|
||||
const char *ceed_backend;
|
||||
CeedGetResource(internal::ceed, &ceed_backend);
|
||||
out << "libCEED backend: " << ceed_backend << '\n';
|
||||
os << "libCEED backend: " << ceed_backend << '\n';
|
||||
}
|
||||
#endif
|
||||
out << "Memory configuration: "
|
||||
<< MemoryTypeName[static_cast<int>(host_mem_type)];
|
||||
os << "Memory configuration: "
|
||||
<< MemoryTypeName[static_cast<int>(host_mem_type)];
|
||||
if (Device::Allows(Backend::DEVICE_MASK))
|
||||
{
|
||||
out << ',' << MemoryTypeName[static_cast<int>(device_mem_type)];
|
||||
os << ',' << MemoryTypeName[static_cast<int>(device_mem_type)];
|
||||
}
|
||||
out << std::endl;
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
void Device::UpdateMemoryTypeAndClass()
|
||||
@@ -502,12 +502,12 @@ static void CeedDeviceSetup(const char* ceed_spec)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Device::Setup(const int device)
|
||||
void Device::Setup(const int device_id)
|
||||
{
|
||||
MFEM_VERIFY(ngpu == -1, "the mfem::Device is already configured!");
|
||||
|
||||
ngpu = 0;
|
||||
dev = device;
|
||||
dev = device_id;
|
||||
#ifndef MFEM_USE_CUDA
|
||||
MFEM_VERIFY(!Allows(Backend::CUDA_MASK),
|
||||
"the CUDA backends require MFEM built with MFEM_USE_CUDA=YES");
|
||||
|
||||
+1
-1
@@ -150,7 +150,7 @@ private:
|
||||
static Device& Get() { return device_singleton; }
|
||||
|
||||
/// Setup switcher based on configuration settings
|
||||
void Setup(const int dev = 0);
|
||||
void Setup(const int device_id = 0);
|
||||
|
||||
void MarkBackend(Backend::Id b) { backends |= b; }
|
||||
|
||||
|
||||
@@ -42,6 +42,19 @@ const int MAX_Q1D = 14;
|
||||
#define MFEM_UNROLL(N)
|
||||
#endif
|
||||
|
||||
// MFEM_GPU_FORALL: "parallel for" executed with CUDA or HIP based on the MFEM
|
||||
// build-time configuration (MFEM_USE_CUDA or MFEM_USE_HIP). If neither CUDA nor
|
||||
// HIP is enabled, this macro is a no-op.
|
||||
#if defined(MFEM_USE_CUDA)
|
||||
#define MFEM_GPU_FORALL(i, N,...) CuWrap1D(N, [=] MFEM_DEVICE \
|
||||
(int i) {__VA_ARGS__})
|
||||
#elif defined(MFEM_USE_HIP)
|
||||
#define MFEM_GPU_FORALL(i, N,...) HipWrap1D(N, [=] MFEM_DEVICE \
|
||||
(int i) {__VA_ARGS__})
|
||||
#else
|
||||
#define MFEM_GPU_FORALL(i, N,...) do { } while (false)
|
||||
#endif
|
||||
|
||||
// Implementation of MFEM's "parallel for" (forall) device/host kernel
|
||||
// interfaces supporting RAJA, CUDA, OpenMP, and sequential backends.
|
||||
|
||||
|
||||
+4
-4
@@ -1228,12 +1228,12 @@ Graph::reweight(uint k)
|
||||
|
||||
// Linearly order graph.
|
||||
void
|
||||
Graph::order(Functional* functional, uint iterations, uint window, uint period,
|
||||
uint seed, Progress* progress)
|
||||
Graph::order(Functional* functional_, uint iterations, uint window, uint period,
|
||||
uint seed, Progress* progress_)
|
||||
{
|
||||
// Initialize graph.
|
||||
this->functional = functional;
|
||||
progress = this->progress = progress ? progress : new Progress;
|
||||
this->functional = functional_;
|
||||
progress_ = this->progress = progress_ ? progress_ : new Progress;
|
||||
for (level = 0; (1u << level) < nodes(); level++);
|
||||
place();
|
||||
Float mincost = cost();
|
||||
|
||||
+302
-24
@@ -66,6 +66,16 @@ struct Hashed4
|
||||
*
|
||||
* All items in the container can also be accessed sequentially using the
|
||||
* provided iterator.
|
||||
*
|
||||
* Notes:
|
||||
* The data structure and implementation is based on a BlockArray<T> which
|
||||
* provides an efficient item storage that avoids heap fragmentation, and
|
||||
* index-based item access. The hash table implemented on top of the
|
||||
* BlockArray provides fast associative (key -> value) access by grouping
|
||||
* items into bins (buckets) of O(1) size.
|
||||
* - "id" denotes the index of an item in the underlying BlockArray<T>,
|
||||
* - "idx" denotes the index of a bin, determined by hashing a key with
|
||||
* the function `Hash`.
|
||||
*/
|
||||
template<typename T>
|
||||
class HashTable : public BlockArray<T>
|
||||
@@ -74,68 +84,212 @@ protected:
|
||||
typedef BlockArray<T> Base;
|
||||
|
||||
public:
|
||||
/** @brief Main constructor of the HashTable class.
|
||||
|
||||
@param[in] block_size The size of the storage blocks of the underlying
|
||||
BlockArray<T>.
|
||||
@param[in] init_hash_size The initial size of the hash table. Must be
|
||||
a power of 2. */
|
||||
HashTable(int block_size = 16*1024, int init_hash_size = 32*1024);
|
||||
HashTable(const HashTable& other); // deep copy
|
||||
/// @brief Deep copy
|
||||
HashTable(const HashTable& other);
|
||||
~HashTable();
|
||||
|
||||
/// Get item whose parents are 'p1', 'p2'... Create it if it doesn't exist.
|
||||
/** @brief Item accessor with key (or parents) the pair 'p1', 'p2'. Default
|
||||
construct an item of type T if no value correspond to the requested key.
|
||||
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@return The index "id" of the key in the BlockArray<T>.
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed2. */
|
||||
T* Get(int p1, int p2);
|
||||
|
||||
/** @brief Item accessor with key (or parents) the quadruplet 'p1', 'p2',
|
||||
'p3', 'p4'. The key 'p4' is optional. Default construct an item of type T
|
||||
if no value corresponds to the requested key.
|
||||
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@param[in] p3 Third part of the key.
|
||||
@param[in] p4 Fourth part of the key (optional).
|
||||
@return The index "id" of the key in the BlockArray<T>.
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed4. */
|
||||
T* Get(int p1, int p2, int p3, int p4 = -1 /* p4 optional */);
|
||||
|
||||
/// Get id of item whose parents are p1, p2... Create it if it doesn't exist.
|
||||
/** @brief Get the "id" of an item, this "id" corresponding to the index of the
|
||||
item in the underlying BlockArray<T> object. Default construct an item
|
||||
and id if no value corresponds to the requested key.
|
||||
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@return The index "id" of the key in the BlockArray<T>.
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed2. */
|
||||
int GetId(int p1, int p2);
|
||||
|
||||
/** @brief Get the "id" of an item, this "id" corresponding to the index of the
|
||||
item in the underlying BlockArray<T> object. Default construct an item
|
||||
and id if no value correspond to the requested key.
|
||||
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@param[in] p3 Third part of the key.
|
||||
@param[in] p4 Fourth part of the key (optional).
|
||||
@return The index "id" of the key in the BlockArray<T>.
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed4. */
|
||||
int GetId(int p1, int p2, int p3, int p4 = -1);
|
||||
|
||||
/// Find item whose parents are p1, p2... Return NULL if it doesn't exist.
|
||||
/** @brief Item accessor with key (or parents) the pair 'p1', 'p2'. Return
|
||||
nullptr if no value correspond to the requested key.
|
||||
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@return The item associated to the key (p1,p2).
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed2. */
|
||||
T* Find(int p1, int p2);
|
||||
|
||||
/** @brief Item accessor with key (or parents) the quadruplet 'p1', 'p2',
|
||||
'p3', 'p4'. The key 'p4' is optional. Return nullptr if no value
|
||||
correspond to the requested key.
|
||||
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@param[in] p3 Third part of the key.
|
||||
@param[in] p4 Fourth part of the key (optional).
|
||||
@return The item associated to the key (p1,p2,p3,p4).
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed4. */
|
||||
T* Find(int p1, int p2, int p3, int p4 = -1);
|
||||
|
||||
/** @brief Item const accessor with key (or parents) the pair 'p1', 'p2'.
|
||||
Return nullptr if no value correspond to the requested key.
|
||||
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@return The item associated to the key (p1,p2).
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed2. */
|
||||
const T* Find(int p1, int p2) const;
|
||||
|
||||
/** @brief Item const accessor with key (or parents) the quadruplet 'p1',
|
||||
'p2', 'p3', 'p4'. The key 'p4' is optional. Return nullptr if no value
|
||||
correspond to the requested key.
|
||||
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@param[in] p3 Third part of the key.
|
||||
@param[in] p4 Fourth part of the key (optional).
|
||||
@return The item associated to the key (p1,p2,p3,p4).
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed4. */
|
||||
const T* Find(int p1, int p2, int p3, int p4 = -1) const;
|
||||
|
||||
/// Find id of item whose parents are p1, p2... Return -1 if it doesn't exist.
|
||||
/** @brief Find the "id" of an item, this "id" corresponding to the index of
|
||||
the item in the underlying BlockArray<T> object. Default construct an
|
||||
item and id if no value correspond to the requested key.
|
||||
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@return The index "id" of the key in the BlockArray<T>.
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed2. */
|
||||
int FindId(int p1, int p2) const;
|
||||
|
||||
/** @brief Find the "id" of an item, this "id" corresponding to the index of
|
||||
the item in the underlying BlockArray<T> object. Default construct an
|
||||
item and id if no value correspond to the requested key.
|
||||
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@param[in] p3 Third part of the key.
|
||||
@param[in] p4 Fourth part of the key (optional).
|
||||
@return The index "id" of the key in the BlockArray<T>.
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed4. */
|
||||
int FindId(int p1, int p2, int p3, int p4 = -1) const;
|
||||
|
||||
/// Return the number of elements currently stored in the HashTable.
|
||||
/// @brief Return the number of elements currently stored in the HashTable.
|
||||
int Size() const { return Base::Size() - unused.Size(); }
|
||||
|
||||
/// Return the total number of ids (used and unused) in the HashTable.
|
||||
/// @brief Return the total number of ids (used and unused) in the HashTable.
|
||||
int NumIds() const { return Base::Size(); }
|
||||
|
||||
/// Return the number of free/unused ids in the HashTable.
|
||||
/// @brief Return the number of free/unused ids in the HashTable.
|
||||
int NumFreeIds() const { return unused.Size(); }
|
||||
|
||||
/// Return true if item 'id' exists in (is used by) the container.
|
||||
/** It is assumed that 0 <= id < NumIds(). */
|
||||
/** @brief Return true if item 'id' exists in (is used by) the container.
|
||||
|
||||
@param[in] id Index of the item in the underlying BlockArray<T>.
|
||||
|
||||
@warning It is assumed that 0 <= id < NumIds(). */
|
||||
bool IdExists(int id) const { return (Base::At(id).next != -2); }
|
||||
|
||||
/// Remove an item from the hash table.
|
||||
/** Its id will be reused by newly added items. */
|
||||
/** @brief Remove an item from the hash table.
|
||||
|
||||
@param[in] id Index of the item in the underlying BlockArray<T>.
|
||||
|
||||
@warning Its id will be reused by newly added items. */
|
||||
void Delete(int id);
|
||||
|
||||
/// Remove all items.
|
||||
/// @brief Remove all items.
|
||||
void DeleteAll();
|
||||
|
||||
/// Allocate an item at 'id'. Enlarge the underlying BlockArray if necessary.
|
||||
/** This is a special purpose method used when loading data from a file.
|
||||
Does nothing if the slot 'id' has already been allocated. */
|
||||
/** @brief Allocate an item at 'id'. Enlarge the underlying BlockArray if
|
||||
necessary.
|
||||
|
||||
@param[in] id Index of the item in the underlying BlockArray<T>.
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
|
||||
@warning This is a special purpose method used when loading data from a
|
||||
file. Does nothing if the slot 'id' has already been allocated. */
|
||||
void Alloc(int id, int p1, int p2);
|
||||
|
||||
/// Reinitialize the internal list of unallocated items.
|
||||
/** This is a special purpose method used when loading data from a file. */
|
||||
/** @brief Reinitialize the internal list of unallocated items.
|
||||
|
||||
@warning This is a special purpose method used when loading data from a file. */
|
||||
void UpdateUnused();
|
||||
|
||||
/// Make an item hashed under different parent IDs.
|
||||
/** @brief Change the key associated with an item.
|
||||
|
||||
In other words, makes an item hashed under different parent IDs.
|
||||
|
||||
@param[in] id Index of the item in the underlying BlockArray<T>.
|
||||
@param[in] new_p1 First part of the new key.
|
||||
@param[in] new_p2 Second part of the new key.
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed2. */
|
||||
void Reparent(int id, int new_p1, int new_p2);
|
||||
|
||||
/** @brief Change the key associated with an item.
|
||||
|
||||
In other words, makes an item hashed under different parent IDs.
|
||||
|
||||
@param[in] id Index of the item in the underlying BlockArray<T>.
|
||||
@param[in] new_p1 First part of the new key.
|
||||
@param[in] new_p2 Second part of the new key.
|
||||
@param[in] new_p3 Third part of the new key.
|
||||
@param[in] new_p4 Fourth part of the new key (optional).
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed4. */
|
||||
void Reparent(int id, int new_p1, int new_p2, int new_p3, int new_p4 = -1);
|
||||
|
||||
/// Return total size of allocated memory (tables plus items), in bytes.
|
||||
/// @brief Return total size of allocated memory (tables plus items), in bytes.
|
||||
long MemoryUsage() const;
|
||||
|
||||
/// Write details of the memory usage to the mfem output stream.
|
||||
/// @brief Write details of the memory usage to the mfem output stream.
|
||||
void PrintMemoryDetail() const;
|
||||
|
||||
/// @brief Print a histogram of bin sizes for debugging purposes.
|
||||
void PrintStats() const;
|
||||
|
||||
class iterator : public Base::iterator
|
||||
{
|
||||
protected:
|
||||
@@ -183,33 +337,114 @@ public:
|
||||
const_iterator cend() const { return const_iterator(); }
|
||||
|
||||
protected:
|
||||
/** The hash table: each bin is a linked list of items. For each non-empty
|
||||
bin, this arrays stores the 'id' of the first item in the list, or -1
|
||||
if the bin is empty. */
|
||||
int* table;
|
||||
|
||||
/** mask = table_size-1. Used for fast modulo operation in Hash(), to wrap
|
||||
the raw hashed index around the current table size (which must be a power
|
||||
of two). */
|
||||
int mask;
|
||||
|
||||
/** List of deleted items in the BlockArray<T>. New items are created with
|
||||
these ids first, before they are appended to the block array. */
|
||||
Array<int> unused;
|
||||
|
||||
// hash functions (NOTE: the constants are arbitrary)
|
||||
inline int Hash(int p1, int p2) const
|
||||
{ return (984120265*p1 + 125965121*p2) & mask; }
|
||||
/** @brief hash function for Hashed2 items.
|
||||
|
||||
inline int Hash(int p1, int p2, int p3) const
|
||||
{ return (984120265*p1 + 125965121*p2 + 495698413*p3) & mask; }
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@return The hash key "idx" identifying a bin/bucket.
|
||||
|
||||
NOTE: the constants are arbitrary
|
||||
@warning This method should only be called if T inherits from Hashed2. */
|
||||
inline int Hash(size_t p1, size_t p2) const
|
||||
{ return (984120265ul*p1 + 125965121ul*p2) & mask; }
|
||||
|
||||
/** @brief hash function for Hashed4 items.
|
||||
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@param[in] p3 Third part of the key.
|
||||
@return The hash key "idx" identifying a bin/bucket.
|
||||
|
||||
NOTE: The constants are arbitrary.
|
||||
NOTE: p4 is not hashed nor stored as p1, p2, p3 identify a face uniquely.
|
||||
@warning This method should only be called if T inherits from Hashed4. */
|
||||
inline int Hash(size_t p1, size_t p2, size_t p3) const
|
||||
{ return (984120265ul*p1 + 125965121ul*p2 + 495698413ul*p3) & mask; }
|
||||
|
||||
// Delete() and Reparent() use one of these:
|
||||
/// @brief Hash function for items of type T that inherit from Hashed2.
|
||||
inline int Hash(const Hashed2& item) const
|
||||
{ return Hash(item.p1, item.p2); }
|
||||
|
||||
/// @brief Hash function for items of type T that inherit from Hashed4.
|
||||
inline int Hash(const Hashed4& item) const
|
||||
{ return Hash(item.p1, item.p2, item.p3); }
|
||||
|
||||
/** @brief Search the index of the item associated to the key (p1,p2)
|
||||
starting from the item with index @a id.
|
||||
|
||||
@param[in] id Index of the item in the underlying BlockArray<T>.
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@return The index "id" of the key in the BlockArray<T>.
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed2. */
|
||||
int SearchList(int id, int p1, int p2) const;
|
||||
|
||||
/** @brief Search the index of the item associated to the key (p1,p2,p3,(p4))
|
||||
starting from the item with index @a id.
|
||||
|
||||
@param[in] id Index of the item in the underlying BlockArray<T>.
|
||||
@param[in] p1 First part of the key.
|
||||
@param[in] p2 Second part of the key.
|
||||
@param[in] p3 Third part of the key.
|
||||
@return The index "id" of the key in the BlockArray<T>.
|
||||
|
||||
@warning This method should only be called if T inherits from Hashed4. */
|
||||
int SearchList(int id, int p1, int p2, int p3) const;
|
||||
|
||||
/** @brief Insert the item 'id' into bin 'idx'.
|
||||
|
||||
@param[in] idx The bin/bucket index.
|
||||
@param[in] id The index of the item in the BlockArray<T>.
|
||||
@param[in] item The item to insert at the begining of the linked list.
|
||||
|
||||
@warning The method only works with bin 'idx' and does not check the
|
||||
overall fill factor of the hash table. If appropriate,
|
||||
use CheckRehash() for that. */
|
||||
inline void Insert(int idx, int id, T &item);
|
||||
|
||||
/** @brief Unlink an item @a id from the linked list of bin @a idx.
|
||||
|
||||
@param[in] idx The bin/bucket index.
|
||||
@param[in] id The index of the item in the BlockArray<T>.
|
||||
|
||||
@warning The method aborts if the item is not found. */
|
||||
void Unlink(int idx, int id);
|
||||
|
||||
/// Check table load factor and resize if necessary
|
||||
/** @brief Check table fill factor and resize if necessary.
|
||||
|
||||
The method checks the average size of the bins (i.e., the fill factor).
|
||||
If the fill factor is > 2, the table is enlarged (see DoRehash()). */
|
||||
inline void CheckRehash();
|
||||
|
||||
/** @brief Double the size of the hash table (i.e., double the number of bins)
|
||||
and reinsert all items into the new bins.
|
||||
|
||||
NOTE: Rehashing is computationally expensive (O(N) in the number of items),
|
||||
but since it is only done rarely (when the number of items doubles),
|
||||
the amortized complexity of inserting an item is still O(1). */
|
||||
void DoRehash();
|
||||
|
||||
/** @brief Return the size of the bin "idx".
|
||||
|
||||
@param[in] idx The index of the bin.
|
||||
@return The size of the bin. */
|
||||
int BinSize(int idx) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -591,6 +826,7 @@ void HashTable<T>::Alloc(int id, int p1, int p2)
|
||||
item.p2 = p2;
|
||||
|
||||
Insert(Hash(p1, p2), id, item);
|
||||
CheckRehash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,6 +885,48 @@ void HashTable<T>::PrintMemoryDetail() const
|
||||
<< " + " << unused.MemoryUsage();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int HashTable<T>::BinSize(int idx) const
|
||||
{
|
||||
int count = 0;
|
||||
int id = table[idx];
|
||||
while (id >= 0)
|
||||
{
|
||||
const T& item = Base::At(id);
|
||||
id = item.next;
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void HashTable<T>::PrintStats() const
|
||||
{
|
||||
int table_size = mask+1;
|
||||
mfem::out << "Hash table size: " << table_size << "\n";
|
||||
mfem::out << "Item count: " << Size() << "\n";
|
||||
mfem::out << "BlockArray size: " << Base::Size() << "\n";
|
||||
|
||||
const int H = 16;
|
||||
int hist[H];
|
||||
|
||||
for (int i = 0; i < H; i++) { hist[i] = 0; }
|
||||
|
||||
for (int i = 0; i < table_size; i++)
|
||||
{
|
||||
int bs = BinSize(i);
|
||||
if (bs >= H) { bs = H-1; }
|
||||
hist[bs]++;
|
||||
}
|
||||
|
||||
mfem::out << "Bin size histogram:\n";
|
||||
for (int i = 0; i < H; i++)
|
||||
{
|
||||
mfem::out << " size " << i << ": "
|
||||
<< hist[i] << " bins" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename int_type_const_iter>
|
||||
HashFunction &HashFunction::EncodeAndHashInts(int_type_const_iter begin,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define MFEM_HIP_BLOCKS 256
|
||||
|
||||
#ifdef MFEM_USE_HIP
|
||||
#define MFEM_USE_CUDA_OR_HIP
|
||||
#define MFEM_DEVICE __device__
|
||||
#define MFEM_LAMBDA __host__ __device__
|
||||
#define MFEM_HOST_DEVICE __host__ __device__
|
||||
|
||||
@@ -470,7 +470,10 @@ public:
|
||||
void *HtoD(void *dst, const void *src, size_t bytes)
|
||||
{ return HipMemcpyHtoD(dst, src, bytes); }
|
||||
void *DtoD(void* dst, const void* src, size_t bytes)
|
||||
{ return HipMemcpyDtoD(dst, src, bytes); }
|
||||
// Unlike cudaMemcpy(DtoD), hipMemcpy(DtoD) causes a host-side synchronization so
|
||||
// instead we use hipMemcpyAsync to get similar behavior.
|
||||
// for more info see: https://github.com/mfem/mfem/pull/2780
|
||||
{ return HipMemcpyDtoDAsync(dst, src, bytes); }
|
||||
void *DtoH(void *dst, const void *src, size_t bytes)
|
||||
{ return HipMemcpyDtoH(dst, src, bytes); }
|
||||
};
|
||||
@@ -593,7 +596,10 @@ public:
|
||||
return CuMemcpyDtoD(dst, src, bytes);
|
||||
#endif
|
||||
#ifdef MFEM_USE_HIP
|
||||
return HipMemcpyDtoD(dst, src, bytes);
|
||||
// Unlike cudaMemcpy(DtoD), hipMemcpy(DtoD) causes a host-side synchronization so
|
||||
// instead we use hipMemcpyAsync to get similar behavior.
|
||||
// for more info see: https://github.com/mfem/mfem/pull/2780
|
||||
return HipMemcpyDtoDAsync(dst, src, bytes);
|
||||
#endif
|
||||
// rm.copy(dst, const_cast<void*>(src), bytes); return dst;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <type_traits> // std::is_const
|
||||
#include <cstddef> // std::max_align_t
|
||||
#ifdef MFEM_USE_MPI
|
||||
#include <HYPRE_config.h> // HYPRE_USING_CUDA
|
||||
#include <HYPRE_config.h> // HYPRE_USING_GPU
|
||||
#endif
|
||||
|
||||
namespace mfem
|
||||
@@ -849,13 +849,14 @@ inline void Memory<T>::New(int size, MemoryType mt)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void Memory<T>::New(int size, MemoryType h_mt, MemoryType d_mt)
|
||||
inline void Memory<T>::New(int size, MemoryType host_mt, MemoryType device_mt)
|
||||
{
|
||||
capacity = size;
|
||||
const size_t bytes = size*sizeof(T);
|
||||
this->h_mt = h_mt;
|
||||
T *h_tmp = (h_mt == MemoryType::HOST) ? NewHOST(size) : nullptr;
|
||||
h_ptr = (T*)MemoryManager::New_(h_tmp, bytes, h_mt, d_mt, VALID_HOST, flags);
|
||||
this->h_mt = host_mt;
|
||||
T *h_tmp = (host_mt == MemoryType::HOST) ? NewHOST(size) : nullptr;
|
||||
h_ptr = (T*)MemoryManager::New_(h_tmp, bytes, host_mt, device_mt,
|
||||
VALID_HOST, flags);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -933,12 +934,12 @@ inline void Memory<T>::MakeAlias(const Memory &base, int offset, int size)
|
||||
if (!(base.flags & REGISTERED))
|
||||
{
|
||||
if (
|
||||
#ifndef HYPRE_USING_CUDA
|
||||
#if !defined(HYPRE_USING_GPU)
|
||||
// If the following condition is true then MemoryManager::Exists()
|
||||
// should also be true:
|
||||
IsDeviceMemory(MemoryManager::GetDeviceMemoryType())
|
||||
#else
|
||||
// When HYPRE_USING_CUDA is defined we always register the 'base' if
|
||||
// When HYPRE_USING_GPU is defined we always register the 'base' if
|
||||
// the MemoryManager::Exists():
|
||||
MemoryManager::Exists()
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public:
|
||||
/// Clear the elapsed time on the stopwatch and restart it if it's running.
|
||||
void Clear();
|
||||
|
||||
/// Clear the elapsed time and start the stopwatch.
|
||||
/// Start the stopwatch. The elapsed time is @b not cleared.
|
||||
void Start();
|
||||
|
||||
/// Stop the stopwatch.
|
||||
|
||||
@@ -327,7 +327,7 @@ void EliminationSolver::Mult(const Vector& rhs, Vector& sol) const
|
||||
krylov->SetMaxIter(max_iter);
|
||||
krylov->SetRelTol(rel_tol);
|
||||
krylov->SetAbsTol(abs_tol);
|
||||
krylov->SetPrintLevel(print_level);
|
||||
krylov->SetPrintLevel(print_options);
|
||||
|
||||
Vector rtilde(rhs.Size());
|
||||
if (constraint_rhs.Size() > 0)
|
||||
@@ -447,7 +447,7 @@ void PenaltyConstrainedSolver::Mult(const Vector& b, Vector& x) const
|
||||
krylov->SetRelTol(rel_tol);
|
||||
krylov->SetAbsTol(abs_tol);
|
||||
krylov->SetMaxIter(max_iter);
|
||||
krylov->SetPrintLevel(print_level);
|
||||
krylov->SetPrintLevel(print_options);
|
||||
krylov->Mult(penalized_rhs, x);
|
||||
final_iter = krylov->GetNumIterations();
|
||||
final_norm = krylov->GetFinalNorm();
|
||||
@@ -574,7 +574,7 @@ void SchurConstrainedSolver::LagrangeSystemMult(const Vector& x,
|
||||
gmres->SetRelTol(rel_tol);
|
||||
gmres->SetAbsTol(abs_tol);
|
||||
gmres->SetMaxIter(max_iter);
|
||||
gmres->SetPrintLevel(print_level);
|
||||
gmres->SetPrintLevel(print_options);
|
||||
gmres->SetPreconditioner(
|
||||
const_cast<BlockDiagonalPreconditioner&>(*block_pc));
|
||||
|
||||
|
||||
+485
-1
@@ -513,6 +513,119 @@ double DenseMatrix::Weight() const
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void DenseMatrix::DetRevDiff(DenseMatrix &A_bar) const
|
||||
{
|
||||
MFEM_ASSERT(Height() == Width() && Height() > 0,
|
||||
"The matrix must be square and "
|
||||
<< "sized larger than zero to compute the determinant."
|
||||
<< " Height() = " << Height()
|
||||
<< ", Width() = " << Width());
|
||||
|
||||
switch (Height())
|
||||
{
|
||||
case 1:
|
||||
// return data[0];
|
||||
A_bar(0,0) = 1.0;
|
||||
return;
|
||||
|
||||
case 2:
|
||||
// return data[0] * data[3] - data[1] * data[2];
|
||||
A_bar(0,0) = data[3]; // data[0]
|
||||
A_bar(1,1) = data[0]; // data[3]
|
||||
A_bar(1,0) = -data[2]; // data[1]
|
||||
A_bar(0,1) = -data[1]; // data[2]
|
||||
return;
|
||||
|
||||
case 3:
|
||||
{
|
||||
const double *d = data;
|
||||
// return
|
||||
// d[0] * (d[4] * d[8] - d[5] * d[7]) +
|
||||
// d[3] * (d[2] * d[7] - d[1] * d[8]) +
|
||||
// d[6] * (d[1] * d[5] - d[2] * d[4]);
|
||||
A_bar(0,0) = d[4]*d[8] - d[5]*d[7]; // d[0]
|
||||
A_bar(1,0) = d[6]*d[5] - d[3]*d[8]; // d[1]
|
||||
A_bar(2,0) = d[3]*d[7] - d[6]*d[4]; // d[2]
|
||||
A_bar(0,1) = d[2]*d[7] - d[1]*d[8]; // d[3]
|
||||
A_bar(1,1) = d[0]*d[8] - d[6]*d[2]; // d[4]
|
||||
A_bar(2,1) = d[6]*d[1] - d[0]*d[7]; // d[5]
|
||||
A_bar(0,2) = d[1]*d[5] - d[2]*d[4]; // d[6]
|
||||
A_bar(1,2) = d[3]*d[2] - d[0]*d[5]; // d[7]
|
||||
A_bar(2,2) = d[0]*d[4] - d[3]*d[1]; // d[8]
|
||||
return;
|
||||
|
||||
}
|
||||
default:
|
||||
{
|
||||
// In the general case we compute the gradient of the determinant
|
||||
// using the relation from Mike Giles document:
|
||||
// "An extended collection of matrix derivative results for forward
|
||||
// and reverse mode algorithmic differentiation"
|
||||
DenseMatrixInverse lu_factors(*this);
|
||||
lu_factors.GetInverseMatrix(A_bar);
|
||||
A_bar.Transpose();
|
||||
A_bar *= lu_factors.Det();
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
// not reachable
|
||||
}
|
||||
|
||||
void DenseMatrix::WeightRevDiff(DenseMatrix &A_bar) const
|
||||
{
|
||||
#ifdef MFEM_DEBUG
|
||||
if (Height() != A_bar.Height() || Width() != A_bar.Width())
|
||||
{
|
||||
mfem_error("DenseMatrix::WeightRevDiff()");
|
||||
}
|
||||
#endif
|
||||
if (Height() == Width())
|
||||
{
|
||||
// return Det();
|
||||
DetRevDiff(A_bar);
|
||||
return;
|
||||
}
|
||||
else if ((Height() == 2) && (Width() == 1))
|
||||
{
|
||||
// return sqrt(data[0] * data[0] + data[1] * data[1]);
|
||||
double wgt = sqrt(data[0] * data[0] + data[1] * data[1]);
|
||||
A_bar(0,0) = data[0]/wgt;
|
||||
A_bar(1,0) = data[1]/wgt;
|
||||
return;
|
||||
}
|
||||
else if ((Height() == 3) && (Width() == 1))
|
||||
{
|
||||
// return sqrt(data[0] * data[0] + data[1] * data[1] + data[2] * data[2]);
|
||||
double wgt = sqrt(data[0] * data[0] + data[1] * data[1] + data[2] * data[2]);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
A_bar(i,0) = data[i]/wgt;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if ((Height() == 3) && (Width() == 2))
|
||||
{
|
||||
const double *d = data;
|
||||
double E = d[0] * d[0] + d[1] * d[1] + d[2] * d[2];
|
||||
double G = d[3] * d[3] + d[4] * d[4] + d[5] * d[5];
|
||||
double F = d[0] * d[3] + d[1] * d[4] + d[2] * d[5];
|
||||
double wgt = sqrt(E * G - F * F);
|
||||
// start reverse sweep
|
||||
double E_bar = 0.5*G/wgt;
|
||||
double G_bar = 0.5*E/wgt;
|
||||
double F_bar = -F/wgt;
|
||||
A_bar(0,0) = F_bar*d[3] + 2.0*E_bar*d[0]; // d[0]
|
||||
A_bar(1,0) = F_bar*d[4] + 2.0*E_bar*d[1]; // d[1]
|
||||
A_bar(2,0) = F_bar*d[5] + 2.0*E_bar*d[2]; // d[2]
|
||||
A_bar(0,1) = F_bar*d[0] + 2.0*G_bar*d[3]; // d[3]
|
||||
A_bar(1,1) = F_bar*d[1] + 2.0*G_bar*d[4]; // d[4]
|
||||
A_bar(2,1) = F_bar*d[2] + 2.0*G_bar*d[5]; // d[5]
|
||||
return;
|
||||
}
|
||||
mfem_error("DenseMatrix::WeightRevDiff()");
|
||||
}
|
||||
|
||||
void DenseMatrix::Set(double alpha, const double *A)
|
||||
{
|
||||
const int s = Width()*Height();
|
||||
@@ -2175,6 +2288,143 @@ void CalcAdjugateTranspose(const DenseMatrix &a, DenseMatrix &adjat)
|
||||
}
|
||||
}
|
||||
|
||||
void CalcAdjugateRevDiff(const DenseMatrix &a, const DenseMatrix &adja_bar,
|
||||
DenseMatrix &a_bar)
|
||||
{
|
||||
#ifdef MFEM_DEBUG
|
||||
if (a.Width() > a.Height() || a.Width() < 1 || a.Height() > 3)
|
||||
{
|
||||
mfem_error("CalcAdjugateRevDiff(...)");
|
||||
}
|
||||
if (a.Width() != a_bar.Width() ||
|
||||
a.Height() != a_bar.Height() ||
|
||||
a_bar.Width() != adja_bar.Height() ||
|
||||
a_bar.Height() != adja_bar.Width())
|
||||
{
|
||||
mfem_error("CalcAdjugateRefDiff(...)");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (a.Width() < a.Height())
|
||||
{
|
||||
const double *d = a.Data();
|
||||
const double *ad_bar = adja_bar.Data();
|
||||
double *d_bar = a_bar.Data();
|
||||
if (a.Width() == 1)
|
||||
{
|
||||
// N x 1, N = 2,3
|
||||
// ad[0] = d[0];
|
||||
d_bar[0] = ad_bar[0];
|
||||
// ad[1] = d[1];
|
||||
d_bar[1] = ad_bar[1];
|
||||
if (a.Height() == 3)
|
||||
{
|
||||
// ad[2] = d[2];
|
||||
d_bar[2] = ad_bar[2];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 3 x 2
|
||||
// e, g, and f are needed during the reverse sweep
|
||||
double e, g, f;
|
||||
e = d[0]*d[0] + d[1]*d[1] + d[2]*d[2];
|
||||
g = d[3]*d[3] + d[4]*d[4] + d[5]*d[5];
|
||||
f = d[0]*d[3] + d[1]*d[4] + d[2]*d[5];
|
||||
|
||||
// start reverse sweep
|
||||
a_bar = 0.0; // this zeros out d_bar[]
|
||||
double e_bar = 0.0;
|
||||
double g_bar = 0.0;
|
||||
double f_bar = 0.0;
|
||||
// ad[0] = d[0]*g - d[3]*f;
|
||||
d_bar[0] += g*ad_bar[0];
|
||||
d_bar[3] -= f*ad_bar[0];
|
||||
g_bar += d[0]*ad_bar[0];
|
||||
f_bar -= d[3]*ad_bar[0];
|
||||
// ad[1] = d[3]*e - d[0]*f;
|
||||
d_bar[3] += e*ad_bar[1];
|
||||
d_bar[0] -= f*ad_bar[1];
|
||||
e_bar += d[3]*ad_bar[1];
|
||||
f_bar -= d[0]*ad_bar[1];
|
||||
// ad[2] = d[1]*g - d[4]*f;
|
||||
d_bar[1] += g*ad_bar[2];
|
||||
d_bar[4] -= f*ad_bar[2];
|
||||
g_bar += d[1]*ad_bar[2];
|
||||
f_bar -= d[4]*ad_bar[2];
|
||||
// ad[3] = d[4]*e - d[1]*f;
|
||||
d_bar[4] += e*ad_bar[3];
|
||||
d_bar[1] -= f*ad_bar[3];
|
||||
e_bar += d[4]*ad_bar[3];
|
||||
f_bar -= d[1]*ad_bar[3];
|
||||
// ad[4] = d[2]*g - d[5]*f;
|
||||
d_bar[2] += g*ad_bar[4];
|
||||
d_bar[5] -= f*ad_bar[4];
|
||||
g_bar += d[2]*ad_bar[4];
|
||||
f_bar -= d[5]*ad_bar[4];
|
||||
// ad[5] = d[5]*e - d[2]*f;
|
||||
d_bar[5] += e*ad_bar[5];
|
||||
d_bar[2] -= f*ad_bar[5];
|
||||
e_bar += d[5]*ad_bar[5];
|
||||
f_bar -= d[2]*ad_bar[5];
|
||||
|
||||
// e = d[0]*d[0] + d[1]*d[1] + d[2]*d[2];
|
||||
d_bar[0] += 2.0*d[0]*e_bar;
|
||||
d_bar[1] += 2.0*d[1]*e_bar;
|
||||
d_bar[2] += 2.0*d[2]*e_bar;
|
||||
// g = d[3]*d[3] + d[4]*d[4] + d[5]*d[5];
|
||||
d_bar[3] += 2.0*d[3]*g_bar;
|
||||
d_bar[4] += 2.0*d[4]*g_bar;
|
||||
d_bar[5] += 2.0*d[5]*g_bar;
|
||||
// f = d[0]*d[3] + d[1]*d[4] + d[2]*d[5];
|
||||
d_bar[0] += d[3]*f_bar;
|
||||
d_bar[3] += d[0]*f_bar;
|
||||
d_bar[1] += d[4]*f_bar;
|
||||
d_bar[4] += d[1]*f_bar;
|
||||
d_bar[2] += d[5]*f_bar;
|
||||
d_bar[5] += d[2]*f_bar;
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (a.Width() == 1)
|
||||
{
|
||||
// adja(0,0) = 1.0;
|
||||
a_bar(0,0) = 0.0;
|
||||
}
|
||||
else if (a.Width() == 2)
|
||||
{
|
||||
// adja(0,0) = a(1,1);
|
||||
a_bar(1,1) = adja_bar(0,0);
|
||||
// adja(0,1) = -a(0,1);
|
||||
a_bar(0,1) = -adja_bar(0,1);
|
||||
// adja(1,0) = -a(1,0);
|
||||
a_bar(1,0) = -adja_bar(1,0);
|
||||
// adja(1,1) = a(0,0);
|
||||
a_bar(0,0) = adja_bar(1,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
a_bar = 0.0;
|
||||
for (int di1 = 0; di1 < 3; ++di1)
|
||||
{
|
||||
int it11 = (di1 + 1) % 3;
|
||||
int it12 = (di1 + 2) % 3;
|
||||
for (int di2 = 0; di2 < 3; ++di2)
|
||||
{
|
||||
int it21 = (di2 + 1) % 3;
|
||||
int it22 = (di2 + 2) % 3;
|
||||
// adja(di2,di1) = a(it11,it21)*a(it12,it22) - a(it11,it22)*a(it12,it21);
|
||||
a_bar(it11,it21) += a(it12,it22)*adja_bar(di2,di1);
|
||||
a_bar(it12,it22) += a(it11,it21)*adja_bar(di2,di1);
|
||||
a_bar(it11,it22) -= a(it12,it21)*adja_bar(di2,di1);
|
||||
a_bar(it12,it21) -= a(it11,it22)*adja_bar(di2,di1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
|
||||
{
|
||||
MFEM_ASSERT(a.Width() <= a.Height() && a.Width() >= 1 && a.Height() <= 3, "");
|
||||
@@ -2209,7 +2459,9 @@ void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
|
||||
g = d[3]*d[3] + d[4]*d[4] + d[5]*d[5];
|
||||
f = d[0]*d[3] + d[1]*d[4] + d[2]*d[5];
|
||||
t = 1.0 / (e*g - f*f);
|
||||
e *= t; g *= t; f *= t;
|
||||
e *= t;
|
||||
g *= t;
|
||||
f *= t;
|
||||
|
||||
id[0] = d[0]*g - d[3]*f;
|
||||
id[1] = d[3]*e - d[0]*f;
|
||||
@@ -2281,6 +2533,194 @@ void CalcInverseTranspose(const DenseMatrix &a, DenseMatrix &inva)
|
||||
}
|
||||
}
|
||||
|
||||
void CalcInverseRevDiff(const DenseMatrix &a, const DenseMatrix &inva_bar,
|
||||
DenseMatrix &a_bar)
|
||||
{
|
||||
#ifdef MFEM_DEBUG
|
||||
if (a.Width() > a.Height() || a.Width() < 1 || a.Height() > 3)
|
||||
{
|
||||
mfem_error("CalcInverseRevDiff(...)");
|
||||
}
|
||||
if (a.Width() != a_bar.Width() ||
|
||||
a.Height() != a_bar.Height() ||
|
||||
a_bar.Width() != inva_bar.Height() ||
|
||||
a_bar.Height() != inva_bar.Width())
|
||||
{
|
||||
mfem_error("CalcInverseRevDiff(...)");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (a.Width() < a.Height())
|
||||
{
|
||||
const double *d = a.Data();
|
||||
const double *id_bar = inva_bar.Data();
|
||||
double *d_bar = a_bar.Data();
|
||||
if (a.Height() == 2)
|
||||
{
|
||||
double t = 1.0 / (d[0]*d[0] + d[1]*d[1]);
|
||||
|
||||
/// id[0] = d[0] * t;
|
||||
d_bar[0] += id_bar[0] * t;
|
||||
double t_bar = id_bar[0] * d[0];
|
||||
|
||||
/// id[1] = d[1] * t;
|
||||
d_bar[1] += id_bar[1] * t;
|
||||
t_bar += id_bar[1] * d[1];
|
||||
|
||||
/// t = 1.0 / (d[0]*d[0] + d[1]*d[1]);
|
||||
d_bar[0] -= t_bar * 2 * d[0] / pow(d[0]*d[0] + d[1]*d[1], 2);
|
||||
d_bar[1] -= t_bar * 2 * d[1] / pow(d[0]*d[0] + d[1]*d[1], 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a.Width() == 1)
|
||||
{
|
||||
double t = 1.0 / (d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
|
||||
|
||||
/// id[0] = d[0] * t;
|
||||
d_bar[0] += id_bar[0] * t;
|
||||
double t_bar = id_bar[0] * d[0];
|
||||
|
||||
/// id[1] = d[1] * t;
|
||||
d_bar[1] += id_bar[1] * t;
|
||||
t_bar += id_bar[1] * d[1];
|
||||
|
||||
/// id[2] = d[2] * t;
|
||||
d_bar[2] += id_bar[2] * t;
|
||||
t_bar += id_bar[2] * d[2];
|
||||
|
||||
/// t = 1.0 / (d[0]*d[0] + d[1]*d[1] + d[2]*d[2]);
|
||||
d_bar[0] -= t_bar * 2 * d[0] / pow(d[0]*d[0] + d[1]*d[1] + d[2]*d[2], 2);
|
||||
d_bar[1] -= t_bar * 2 * d[1] / pow(d[0]*d[0] + d[1]*d[1] + d[2]*d[2], 2);
|
||||
d_bar[2] -= t_bar * 2 * d[2] / pow(d[0]*d[0] + d[1]*d[1] + d[2]*d[2], 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
double e = d[0]*d[0] + d[1]*d[1] + d[2]*d[2];
|
||||
double g = d[3]*d[3] + d[4]*d[4] + d[5]*d[5];
|
||||
double f = d[0]*d[3] + d[1]*d[4] + d[2]*d[5];
|
||||
double t = 1.0 / (e*g - f*f);
|
||||
|
||||
double ee = e * t;
|
||||
double gg = g * t;
|
||||
double ff = f * t;
|
||||
|
||||
/// id[0] = d[0]*g - d[3]*f;
|
||||
d_bar[0] += id_bar[0]*gg;
|
||||
double gg_bar = id_bar[0] * d[0];
|
||||
d_bar[3] += -id_bar[0] * ff;
|
||||
double ff_bar = -id_bar[0] * d[3];
|
||||
|
||||
/// id[1] = d[3]*e - d[0]*f;
|
||||
d_bar[3] += id_bar[1] * ee;
|
||||
double ee_bar = id_bar[1] * d[3];
|
||||
d_bar[0] += -id_bar[1] * ff;
|
||||
ff_bar -= id_bar[1] * d[0];
|
||||
|
||||
/// id[2] = d[1]*g - d[4]*f;
|
||||
d_bar[1] += id_bar[2] * gg;
|
||||
gg_bar += id_bar[2] * d[1];
|
||||
d_bar[4] += -id_bar[2] * ff;
|
||||
ff_bar -= id_bar[2] * d[4];
|
||||
|
||||
/// id[3] = d[4]*e - d[1]*f;
|
||||
d_bar[4] += id_bar[3] * ee;
|
||||
ee_bar += id_bar[3] * d[4];
|
||||
d_bar[1] += -id_bar[3] * ff;
|
||||
ff_bar -= id_bar[3] * d[1];
|
||||
|
||||
/// id[4] = d[2]*g - d[5]*f;
|
||||
d_bar[2] += id_bar[4] * gg;
|
||||
gg_bar += id_bar[4] * d[2];
|
||||
d_bar[5] += -id_bar[4] * ff;
|
||||
ff_bar -= id_bar[4] * d[5];
|
||||
|
||||
/// id[5] = d[5]*e - d[2]*f;
|
||||
d_bar[5] += id_bar[5] * ee;
|
||||
ee_bar += id_bar[5] * d[5];
|
||||
d_bar[2] += -id_bar[5] * ff;
|
||||
ff_bar -= id_bar[5] * d[2];
|
||||
|
||||
|
||||
/// double ff = f * t;
|
||||
double t_bar = ff_bar * f;
|
||||
double f_bar = ff_bar * t;
|
||||
|
||||
/// double gg = g * t;
|
||||
t_bar += gg_bar * g;
|
||||
double g_bar = gg_bar * t;
|
||||
|
||||
/// double ee = e * t;
|
||||
t_bar += ee_bar * e;
|
||||
double e_bar = ee_bar * t;
|
||||
|
||||
// /// f *= t;
|
||||
// double t_bar = f_bar * f / t;
|
||||
// f_bar *= t;
|
||||
|
||||
// /// g *= t;
|
||||
// t_bar += g_bar * g / t;
|
||||
// g_bar *= t;
|
||||
|
||||
// /// e *= t;
|
||||
// t_bar += e_bar * e / t;
|
||||
// e_bar *= t;
|
||||
|
||||
/// double t = 1.0 / (e*g - f*f);
|
||||
e_bar -= t_bar * g / pow(e*g - f*f, 2);
|
||||
g_bar -= t_bar * e / pow(e*g - f*f, 2);
|
||||
f_bar += t_bar * 2*f / pow(e*g - f*f, 2);
|
||||
|
||||
/// double f = d[0]*d[3] + d[1]*d[4] + d[2]*d[5];
|
||||
d_bar[0] += f_bar * d[3];
|
||||
d_bar[3] += f_bar * d[0];
|
||||
d_bar[1] += f_bar * d[4];
|
||||
d_bar[4] += f_bar * d[1];
|
||||
d_bar[2] += f_bar * d[5];
|
||||
d_bar[5] += f_bar * d[2];
|
||||
|
||||
/// double g = d[3]*d[3] + d[4]*d[4] + d[5]*d[5];
|
||||
d_bar[3] += g_bar * 2 * d[3];
|
||||
d_bar[4] += g_bar * 2 * d[4];
|
||||
d_bar[5] += g_bar * 2 * d[5];
|
||||
|
||||
/// double e = d[0]*d[0] + d[1]*d[1] + d[2]*d[2];
|
||||
d_bar[0] += e_bar * 2 * d[0];
|
||||
d_bar[1] += e_bar * 2 * d[1];
|
||||
d_bar[2] += e_bar * 2 * d[2];
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef MFEM_DEBUG
|
||||
double t = a.Det();
|
||||
MFEM_ASSERT(std::abs(t) > 1.0e-14 * pow(a.FNorm()/a.Width(), a.Width()),
|
||||
"singular matrix!");
|
||||
#endif
|
||||
|
||||
double inva_buffer[9] = {};
|
||||
DenseMatrix inva(inva_buffer, a.Height(), a.Width());
|
||||
|
||||
switch (a.Height())
|
||||
{
|
||||
case 1:
|
||||
inva(0,0) = 1.0 / a.Det();
|
||||
break;
|
||||
case 2:
|
||||
kernels::CalcInverse<2>(a.Data(), inva.Data());
|
||||
break;
|
||||
case 3:
|
||||
kernels::CalcInverse<3>(a.Data(), inva.Data());
|
||||
break;
|
||||
}
|
||||
|
||||
double tmp_buffer[9] = {};
|
||||
DenseMatrix tmp(tmp_buffer, a.Height(), a.Width());
|
||||
MultAtB(inva, inva_bar, tmp);
|
||||
AddMult_a_ABt(-1, tmp, inva, a_bar);
|
||||
}
|
||||
|
||||
void CalcOrtho(const DenseMatrix &J, Vector &n)
|
||||
{
|
||||
MFEM_ASSERT( ((J.Height() == 2 && J.Width() == 1)
|
||||
@@ -2307,6 +2747,50 @@ void CalcOrtho(const DenseMatrix &J, Vector &n)
|
||||
}
|
||||
}
|
||||
|
||||
void CalcOrthoRevDiff(const DenseMatrix &J, const Vector &n_bar,
|
||||
DenseMatrix &J_bar)
|
||||
{
|
||||
MFEM_ASSERT(((J.Height() == 2 && J.Width() == 1) ||
|
||||
(J.Height() == 3 && J.Width() == 2)) &&
|
||||
(J.Height() == n_bar.Size()),
|
||||
"Matrix must be 3x2 or 2x1, "
|
||||
<< "and the Vector must be sized with the rows. "
|
||||
<< " J.Height() = " << J.Height()
|
||||
<< ", J.Width() = " << J.Width()
|
||||
<< ", n_bar.Size() = " << n_bar.Size());
|
||||
MFEM_ASSERT((J.Height() == J_bar.Height() && J.Width() == J_bar.Width()),
|
||||
"Input matrix and derivative matrix must be the same size.");
|
||||
|
||||
const double *d = J.Data();
|
||||
double *d_bar = J_bar.Data();
|
||||
if (J.Height() == 2)
|
||||
{
|
||||
// n(0) = d[1];
|
||||
d_bar[1] = n_bar(0);
|
||||
// n(1) = -d[0];
|
||||
d_bar[0] = -n_bar(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
J_bar = 0.0;
|
||||
// n(0) = d[1]*d[5] - d[2]*d[4];
|
||||
d_bar[1] += d[5]*n_bar(0);
|
||||
d_bar[5] += d[1]*n_bar(0);
|
||||
d_bar[2] -= d[4]*n_bar(0);
|
||||
d_bar[4] -= d[2]*n_bar(0);
|
||||
// n(1) = d[2]*d[3] - d[0]*d[5];
|
||||
d_bar[2] += d[3]*n_bar(1);
|
||||
d_bar[3] += d[2]*n_bar(1);
|
||||
d_bar[0] -= d[5]*n_bar(1);
|
||||
d_bar[5] -= d[0]*n_bar(1);
|
||||
// n(2) = d[0]*d[4] - d[1]*d[3];
|
||||
d_bar[0] += d[4]*n_bar(2);
|
||||
d_bar[4] += d[0]*n_bar(2);
|
||||
d_bar[1] -= d[3]*n_bar(2);
|
||||
d_bar[3] -= d[1]*n_bar(2);
|
||||
}
|
||||
}
|
||||
|
||||
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
|
||||
{
|
||||
const int height = a.Height();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user